babylon.module.d.ts 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923
  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/Misc/andOrNotEvaluator" {
  1646. /**
  1647. * Class used to evalaute queries containing `and` and `or` operators
  1648. */
  1649. export class AndOrNotEvaluator {
  1650. /**
  1651. * Evaluate a query
  1652. * @param query defines the query to evaluate
  1653. * @param evaluateCallback defines the callback used to filter result
  1654. * @returns true if the query matches
  1655. */
  1656. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1657. private static _HandleParenthesisContent;
  1658. private static _SimplifyNegation;
  1659. }
  1660. }
  1661. declare module "babylonjs/Misc/tags" {
  1662. /**
  1663. * Class used to store custom tags
  1664. */
  1665. export class Tags {
  1666. /**
  1667. * Adds support for tags on the given object
  1668. * @param obj defines the object to use
  1669. */
  1670. static EnableFor(obj: any): void;
  1671. /**
  1672. * Removes tags support
  1673. * @param obj defines the object to use
  1674. */
  1675. static DisableFor(obj: any): void;
  1676. /**
  1677. * Gets a boolean indicating if the given object has tags
  1678. * @param obj defines the object to use
  1679. * @returns a boolean
  1680. */
  1681. static HasTags(obj: any): boolean;
  1682. /**
  1683. * Gets the tags available on a given object
  1684. * @param obj defines the object to use
  1685. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1686. * @returns the tags
  1687. */
  1688. static GetTags(obj: any, asString?: boolean): any;
  1689. /**
  1690. * Adds tags to an object
  1691. * @param obj defines the object to use
  1692. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1693. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1694. */
  1695. static AddTagsTo(obj: any, tagsString: string): void;
  1696. /**
  1697. * @hidden
  1698. */
  1699. static _AddTagTo(obj: any, tag: string): void;
  1700. /**
  1701. * Removes specific tags from a specific object
  1702. * @param obj defines the object to use
  1703. * @param tagsString defines the tags to remove
  1704. */
  1705. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1706. /**
  1707. * @hidden
  1708. */
  1709. static _RemoveTagFrom(obj: any, tag: string): void;
  1710. /**
  1711. * Defines if tags hosted on an object match a given query
  1712. * @param obj defines the object to use
  1713. * @param tagsQuery defines the tag query
  1714. * @returns a boolean
  1715. */
  1716. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1717. }
  1718. }
  1719. declare module "babylonjs/Maths/math.scalar" {
  1720. /**
  1721. * Scalar computation library
  1722. */
  1723. export class Scalar {
  1724. /**
  1725. * Two pi constants convenient for computation.
  1726. */
  1727. static TwoPi: number;
  1728. /**
  1729. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1730. * @param a number
  1731. * @param b number
  1732. * @param epsilon (default = 1.401298E-45)
  1733. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1734. */
  1735. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1736. /**
  1737. * Returns a string : the upper case translation of the number i to hexadecimal.
  1738. * @param i number
  1739. * @returns the upper case translation of the number i to hexadecimal.
  1740. */
  1741. static ToHex(i: number): string;
  1742. /**
  1743. * Returns -1 if value is negative and +1 is value is positive.
  1744. * @param value the value
  1745. * @returns the value itself if it's equal to zero.
  1746. */
  1747. static Sign(value: number): number;
  1748. /**
  1749. * Returns the value itself if it's between min and max.
  1750. * Returns min if the value is lower than min.
  1751. * Returns max if the value is greater than max.
  1752. * @param value the value to clmap
  1753. * @param min the min value to clamp to (default: 0)
  1754. * @param max the max value to clamp to (default: 1)
  1755. * @returns the clamped value
  1756. */
  1757. static Clamp(value: number, min?: number, max?: number): number;
  1758. /**
  1759. * the log2 of value.
  1760. * @param value the value to compute log2 of
  1761. * @returns the log2 of value.
  1762. */
  1763. static Log2(value: number): number;
  1764. /**
  1765. * Loops the value, so that it is never larger than length and never smaller than 0.
  1766. *
  1767. * This is similar to the modulo operator but it works with floating point numbers.
  1768. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1769. * With t = 5 and length = 2.5, the result would be 0.0.
  1770. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1771. * @param value the value
  1772. * @param length the length
  1773. * @returns the looped value
  1774. */
  1775. static Repeat(value: number, length: number): number;
  1776. /**
  1777. * Normalize the value between 0.0 and 1.0 using min and max values
  1778. * @param value value to normalize
  1779. * @param min max to normalize between
  1780. * @param max min to normalize between
  1781. * @returns the normalized value
  1782. */
  1783. static Normalize(value: number, min: number, max: number): number;
  1784. /**
  1785. * Denormalize the value from 0.0 and 1.0 using min and max values
  1786. * @param normalized value to denormalize
  1787. * @param min max to denormalize between
  1788. * @param max min to denormalize between
  1789. * @returns the denormalized value
  1790. */
  1791. static Denormalize(normalized: number, min: number, max: number): number;
  1792. /**
  1793. * Calculates the shortest difference between two given angles given in degrees.
  1794. * @param current current angle in degrees
  1795. * @param target target angle in degrees
  1796. * @returns the delta
  1797. */
  1798. static DeltaAngle(current: number, target: number): number;
  1799. /**
  1800. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1801. * @param tx value
  1802. * @param length length
  1803. * @returns The returned value will move back and forth between 0 and length
  1804. */
  1805. static PingPong(tx: number, length: number): number;
  1806. /**
  1807. * Interpolates between min and max with smoothing at the limits.
  1808. *
  1809. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1810. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1811. * @param from from
  1812. * @param to to
  1813. * @param tx value
  1814. * @returns the smooth stepped value
  1815. */
  1816. static SmoothStep(from: number, to: number, tx: number): number;
  1817. /**
  1818. * Moves a value current towards target.
  1819. *
  1820. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1821. * Negative values of maxDelta pushes the value away from target.
  1822. * @param current current value
  1823. * @param target target value
  1824. * @param maxDelta max distance to move
  1825. * @returns resulting value
  1826. */
  1827. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1828. /**
  1829. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1830. *
  1831. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1832. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1833. * @param current current value
  1834. * @param target target value
  1835. * @param maxDelta max distance to move
  1836. * @returns resulting angle
  1837. */
  1838. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1839. /**
  1840. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1841. * @param start start value
  1842. * @param end target value
  1843. * @param amount amount to lerp between
  1844. * @returns the lerped value
  1845. */
  1846. static Lerp(start: number, end: number, amount: number): number;
  1847. /**
  1848. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1849. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1850. * @param start start value
  1851. * @param end target value
  1852. * @param amount amount to lerp between
  1853. * @returns the lerped value
  1854. */
  1855. static LerpAngle(start: number, end: number, amount: number): number;
  1856. /**
  1857. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1858. * @param a start value
  1859. * @param b target value
  1860. * @param value value between a and b
  1861. * @returns the inverseLerp value
  1862. */
  1863. static InverseLerp(a: number, b: number, value: number): number;
  1864. /**
  1865. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1866. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1867. * @param value1 spline value
  1868. * @param tangent1 spline value
  1869. * @param value2 spline value
  1870. * @param tangent2 spline value
  1871. * @param amount input value
  1872. * @returns hermite result
  1873. */
  1874. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1875. /**
  1876. * Returns a random float number between and min and max values
  1877. * @param min min value of random
  1878. * @param max max value of random
  1879. * @returns random value
  1880. */
  1881. static RandomRange(min: number, max: number): number;
  1882. /**
  1883. * This function returns percentage of a number in a given range.
  1884. *
  1885. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1886. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1887. * @param number to convert to percentage
  1888. * @param min min range
  1889. * @param max max range
  1890. * @returns the percentage
  1891. */
  1892. static RangeToPercent(number: number, min: number, max: number): number;
  1893. /**
  1894. * This function returns number that corresponds to the percentage in a given range.
  1895. *
  1896. * PercentToRange(0.34,0,100) will return 34.
  1897. * @param percent to convert to number
  1898. * @param min min range
  1899. * @param max max range
  1900. * @returns the number
  1901. */
  1902. static PercentToRange(percent: number, min: number, max: number): number;
  1903. /**
  1904. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1905. * @param angle The angle to normalize in radian.
  1906. * @return The converted angle.
  1907. */
  1908. static NormalizeRadians(angle: number): number;
  1909. }
  1910. }
  1911. declare module "babylonjs/Maths/math.constants" {
  1912. /**
  1913. * Constant used to convert a value to gamma space
  1914. * @ignorenaming
  1915. */
  1916. export const ToGammaSpace: number;
  1917. /**
  1918. * Constant used to convert a value to linear space
  1919. * @ignorenaming
  1920. */
  1921. export const ToLinearSpace = 2.2;
  1922. /**
  1923. * Constant used to define the minimal number value in Babylon.js
  1924. * @ignorenaming
  1925. */
  1926. let Epsilon: number;
  1927. export { Epsilon };
  1928. }
  1929. declare module "babylonjs/Maths/math.viewport" {
  1930. /**
  1931. * Class used to represent a viewport on screen
  1932. */
  1933. export class Viewport {
  1934. /** viewport left coordinate */
  1935. x: number;
  1936. /** viewport top coordinate */
  1937. y: number;
  1938. /**viewport width */
  1939. width: number;
  1940. /** viewport height */
  1941. height: number;
  1942. /**
  1943. * Creates a Viewport object located at (x, y) and sized (width, height)
  1944. * @param x defines viewport left coordinate
  1945. * @param y defines viewport top coordinate
  1946. * @param width defines the viewport width
  1947. * @param height defines the viewport height
  1948. */
  1949. constructor(
  1950. /** viewport left coordinate */
  1951. x: number,
  1952. /** viewport top coordinate */
  1953. y: number,
  1954. /**viewport width */
  1955. width: number,
  1956. /** viewport height */
  1957. height: number);
  1958. /**
  1959. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1960. * @param renderWidth defines the rendering width
  1961. * @param renderHeight defines the rendering height
  1962. * @returns a new Viewport
  1963. */
  1964. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1965. /**
  1966. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1967. * @param renderWidth defines the rendering width
  1968. * @param renderHeight defines the rendering height
  1969. * @param ref defines the target viewport
  1970. * @returns the current viewport
  1971. */
  1972. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1973. /**
  1974. * Returns a new Viewport copied from the current one
  1975. * @returns a new Viewport
  1976. */
  1977. clone(): Viewport;
  1978. }
  1979. }
  1980. declare module "babylonjs/Misc/arrayTools" {
  1981. /**
  1982. * Class containing a set of static utilities functions for arrays.
  1983. */
  1984. export class ArrayTools {
  1985. /**
  1986. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1987. * @param size the number of element to construct and put in the array
  1988. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1989. * @returns a new array filled with new objects
  1990. */
  1991. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1992. }
  1993. }
  1994. declare module "babylonjs/Maths/math.plane" {
  1995. import { DeepImmutable } from "babylonjs/types";
  1996. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1997. /**
  1998. * Represents a plane by the equation ax + by + cz + d = 0
  1999. */
  2000. export class Plane {
  2001. private static _TmpMatrix;
  2002. /**
  2003. * Normal of the plane (a,b,c)
  2004. */
  2005. normal: Vector3;
  2006. /**
  2007. * d component of the plane
  2008. */
  2009. d: number;
  2010. /**
  2011. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2012. * @param a a component of the plane
  2013. * @param b b component of the plane
  2014. * @param c c component of the plane
  2015. * @param d d component of the plane
  2016. */
  2017. constructor(a: number, b: number, c: number, d: number);
  2018. /**
  2019. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2020. */
  2021. asArray(): number[];
  2022. /**
  2023. * @returns a new plane copied from the current Plane.
  2024. */
  2025. clone(): Plane;
  2026. /**
  2027. * @returns the string "Plane".
  2028. */
  2029. getClassName(): string;
  2030. /**
  2031. * @returns the Plane hash code.
  2032. */
  2033. getHashCode(): number;
  2034. /**
  2035. * Normalize the current Plane in place.
  2036. * @returns the updated Plane.
  2037. */
  2038. normalize(): Plane;
  2039. /**
  2040. * Applies a transformation the plane and returns the result
  2041. * @param transformation the transformation matrix to be applied to the plane
  2042. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2043. */
  2044. transform(transformation: DeepImmutable<Matrix>): Plane;
  2045. /**
  2046. * Compute the dot product between the point and the plane normal
  2047. * @param point point to calculate the dot product with
  2048. * @returns the dot product (float) of the point coordinates and the plane normal.
  2049. */
  2050. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2051. /**
  2052. * Updates the current Plane from the plane defined by the three given points.
  2053. * @param point1 one of the points used to contruct the plane
  2054. * @param point2 one of the points used to contruct the plane
  2055. * @param point3 one of the points used to contruct the plane
  2056. * @returns the updated Plane.
  2057. */
  2058. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2059. /**
  2060. * Checks if the plane is facing a given direction
  2061. * @param direction the direction to check if the plane is facing
  2062. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2063. * @returns True is the vector "direction" is the same side than the plane normal.
  2064. */
  2065. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2066. /**
  2067. * Calculates the distance to a point
  2068. * @param point point to calculate distance to
  2069. * @returns the signed distance (float) from the given point to the Plane.
  2070. */
  2071. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2072. /**
  2073. * Creates a plane from an array
  2074. * @param array the array to create a plane from
  2075. * @returns a new Plane from the given array.
  2076. */
  2077. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2078. /**
  2079. * Creates a plane from three points
  2080. * @param point1 point used to create the plane
  2081. * @param point2 point used to create the plane
  2082. * @param point3 point used to create the plane
  2083. * @returns a new Plane defined by the three given points.
  2084. */
  2085. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2086. /**
  2087. * Creates a plane from an origin point and a normal
  2088. * @param origin origin of the plane to be constructed
  2089. * @param normal normal of the plane to be constructed
  2090. * @returns a new Plane the normal vector to this plane at the given origin point.
  2091. * Note : the vector "normal" is updated because normalized.
  2092. */
  2093. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2094. /**
  2095. * Calculates the distance from a plane and a point
  2096. * @param origin origin of the plane to be constructed
  2097. * @param normal normal of the plane to be constructed
  2098. * @param point point to calculate distance to
  2099. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2100. */
  2101. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2102. }
  2103. }
  2104. declare module "babylonjs/Engines/performanceConfigurator" {
  2105. /** @hidden */
  2106. export class PerformanceConfigurator {
  2107. /** @hidden */
  2108. static MatrixUse64Bits: boolean;
  2109. /** @hidden */
  2110. static MatrixTrackPrecisionChange: boolean;
  2111. /** @hidden */
  2112. static MatrixCurrentType: any;
  2113. /** @hidden */
  2114. static MatrixTrackedMatrices: Array<any> | null;
  2115. /** @hidden */
  2116. static SetMatrixPrecision(use64bits: boolean): void;
  2117. }
  2118. }
  2119. declare module "babylonjs/Maths/math.vector" {
  2120. import { Viewport } from "babylonjs/Maths/math.viewport";
  2121. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2122. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2123. import { Plane } from "babylonjs/Maths/math.plane";
  2124. /**
  2125. * Class representing a vector containing 2 coordinates
  2126. */
  2127. export class Vector2 {
  2128. /** defines the first coordinate */
  2129. x: number;
  2130. /** defines the second coordinate */
  2131. y: number;
  2132. /**
  2133. * Creates a new Vector2 from the given x and y coordinates
  2134. * @param x defines the first coordinate
  2135. * @param y defines the second coordinate
  2136. */
  2137. constructor(
  2138. /** defines the first coordinate */
  2139. x?: number,
  2140. /** defines the second coordinate */
  2141. y?: number);
  2142. /**
  2143. * Gets a string with the Vector2 coordinates
  2144. * @returns a string with the Vector2 coordinates
  2145. */
  2146. toString(): string;
  2147. /**
  2148. * Gets class name
  2149. * @returns the string "Vector2"
  2150. */
  2151. getClassName(): string;
  2152. /**
  2153. * Gets current vector hash code
  2154. * @returns the Vector2 hash code as a number
  2155. */
  2156. getHashCode(): number;
  2157. /**
  2158. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2159. * @param array defines the source array
  2160. * @param index defines the offset in source array
  2161. * @returns the current Vector2
  2162. */
  2163. toArray(array: FloatArray, index?: number): Vector2;
  2164. /**
  2165. * Update the current vector from an array
  2166. * @param array defines the destination array
  2167. * @param index defines the offset in the destination array
  2168. * @returns the current Vector3
  2169. */
  2170. fromArray(array: FloatArray, index?: number): Vector2;
  2171. /**
  2172. * Copy the current vector to an array
  2173. * @returns a new array with 2 elements: the Vector2 coordinates.
  2174. */
  2175. asArray(): number[];
  2176. /**
  2177. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2178. * @param source defines the source Vector2
  2179. * @returns the current updated Vector2
  2180. */
  2181. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Sets the Vector2 coordinates with the given floats
  2184. * @param x defines the first coordinate
  2185. * @param y defines the second coordinate
  2186. * @returns the current updated Vector2
  2187. */
  2188. copyFromFloats(x: number, y: number): Vector2;
  2189. /**
  2190. * Sets the Vector2 coordinates with the given floats
  2191. * @param x defines the first coordinate
  2192. * @param y defines the second coordinate
  2193. * @returns the current updated Vector2
  2194. */
  2195. set(x: number, y: number): Vector2;
  2196. /**
  2197. * Add another vector with the current one
  2198. * @param otherVector defines the other vector
  2199. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2200. */
  2201. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2204. * @param otherVector defines the other vector
  2205. * @param result defines the target vector
  2206. * @returns the unmodified current Vector2
  2207. */
  2208. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2209. /**
  2210. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2211. * @param otherVector defines the other vector
  2212. * @returns the current updated Vector2
  2213. */
  2214. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2215. /**
  2216. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2217. * @param otherVector defines the other vector
  2218. * @returns a new Vector2
  2219. */
  2220. addVector3(otherVector: Vector3): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2223. * @param otherVector defines the other vector
  2224. * @returns a new Vector2
  2225. */
  2226. subtract(otherVector: Vector2): Vector2;
  2227. /**
  2228. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2229. * @param otherVector defines the other vector
  2230. * @param result defines the target vector
  2231. * @returns the unmodified current Vector2
  2232. */
  2233. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2234. /**
  2235. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2236. * @param otherVector defines the other vector
  2237. * @returns the current updated Vector2
  2238. */
  2239. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2240. /**
  2241. * Multiplies in place the current Vector2 coordinates by the given ones
  2242. * @param otherVector defines the other vector
  2243. * @returns the current updated Vector2
  2244. */
  2245. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2246. /**
  2247. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2248. * @param otherVector defines the other vector
  2249. * @returns a new Vector2
  2250. */
  2251. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2254. * @param otherVector defines the other vector
  2255. * @param result defines the target vector
  2256. * @returns the unmodified current Vector2
  2257. */
  2258. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2259. /**
  2260. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2261. * @param x defines the first coordinate
  2262. * @param y defines the second coordinate
  2263. * @returns a new Vector2
  2264. */
  2265. multiplyByFloats(x: number, y: number): Vector2;
  2266. /**
  2267. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2268. * @param otherVector defines the other vector
  2269. * @returns a new Vector2
  2270. */
  2271. divide(otherVector: Vector2): Vector2;
  2272. /**
  2273. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2274. * @param otherVector defines the other vector
  2275. * @param result defines the target vector
  2276. * @returns the unmodified current Vector2
  2277. */
  2278. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2279. /**
  2280. * Divides the current Vector2 coordinates by the given ones
  2281. * @param otherVector defines the other vector
  2282. * @returns the current updated Vector2
  2283. */
  2284. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2285. /**
  2286. * Gets a new Vector2 with current Vector2 negated coordinates
  2287. * @returns a new Vector2
  2288. */
  2289. negate(): Vector2;
  2290. /**
  2291. * Negate this vector in place
  2292. * @returns this
  2293. */
  2294. negateInPlace(): Vector2;
  2295. /**
  2296. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2297. * @param result defines the Vector3 object where to store the result
  2298. * @returns the current Vector2
  2299. */
  2300. negateToRef(result: Vector2): Vector2;
  2301. /**
  2302. * Multiply the Vector2 coordinates by scale
  2303. * @param scale defines the scaling factor
  2304. * @returns the current updated Vector2
  2305. */
  2306. scaleInPlace(scale: number): Vector2;
  2307. /**
  2308. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2309. * @param scale defines the scaling factor
  2310. * @returns a new Vector2
  2311. */
  2312. scale(scale: number): Vector2;
  2313. /**
  2314. * Scale the current Vector2 values by a factor to a given Vector2
  2315. * @param scale defines the scale factor
  2316. * @param result defines the Vector2 object where to store the result
  2317. * @returns the unmodified current Vector2
  2318. */
  2319. scaleToRef(scale: number, result: Vector2): Vector2;
  2320. /**
  2321. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2322. * @param scale defines the scale factor
  2323. * @param result defines the Vector2 object where to store the result
  2324. * @returns the unmodified current Vector2
  2325. */
  2326. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2327. /**
  2328. * Gets a boolean if two vectors are equals
  2329. * @param otherVector defines the other vector
  2330. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2331. */
  2332. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2333. /**
  2334. * Gets a boolean if two vectors are equals (using an epsilon value)
  2335. * @param otherVector defines the other vector
  2336. * @param epsilon defines the minimal distance to consider equality
  2337. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2338. */
  2339. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2340. /**
  2341. * Gets a new Vector2 from current Vector2 floored values
  2342. * @returns a new Vector2
  2343. */
  2344. floor(): Vector2;
  2345. /**
  2346. * Gets a new Vector2 from current Vector2 floored values
  2347. * @returns a new Vector2
  2348. */
  2349. fract(): Vector2;
  2350. /**
  2351. * Gets the length of the vector
  2352. * @returns the vector length (float)
  2353. */
  2354. length(): number;
  2355. /**
  2356. * Gets the vector squared length
  2357. * @returns the vector squared length (float)
  2358. */
  2359. lengthSquared(): number;
  2360. /**
  2361. * Normalize the vector
  2362. * @returns the current updated Vector2
  2363. */
  2364. normalize(): Vector2;
  2365. /**
  2366. * Gets a new Vector2 copied from the Vector2
  2367. * @returns a new Vector2
  2368. */
  2369. clone(): Vector2;
  2370. /**
  2371. * Gets a new Vector2(0, 0)
  2372. * @returns a new Vector2
  2373. */
  2374. static Zero(): Vector2;
  2375. /**
  2376. * Gets a new Vector2(1, 1)
  2377. * @returns a new Vector2
  2378. */
  2379. static One(): Vector2;
  2380. /**
  2381. * Gets a new Vector2 set from the given index element of the given array
  2382. * @param array defines the data source
  2383. * @param offset defines the offset in the data source
  2384. * @returns a new Vector2
  2385. */
  2386. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2387. /**
  2388. * Sets "result" from the given index element of the given array
  2389. * @param array defines the data source
  2390. * @param offset defines the offset in the data source
  2391. * @param result defines the target vector
  2392. */
  2393. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2394. /**
  2395. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2396. * @param value1 defines 1st point of control
  2397. * @param value2 defines 2nd point of control
  2398. * @param value3 defines 3rd point of control
  2399. * @param value4 defines 4th point of control
  2400. * @param amount defines the interpolation factor
  2401. * @returns a new Vector2
  2402. */
  2403. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2404. /**
  2405. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2406. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2407. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2408. * @param value defines the value to clamp
  2409. * @param min defines the lower limit
  2410. * @param max defines the upper limit
  2411. * @returns a new Vector2
  2412. */
  2413. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2414. /**
  2415. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2416. * @param value1 defines the 1st control point
  2417. * @param tangent1 defines the outgoing tangent
  2418. * @param value2 defines the 2nd control point
  2419. * @param tangent2 defines the incoming tangent
  2420. * @param amount defines the interpolation factor
  2421. * @returns a new Vector2
  2422. */
  2423. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2424. /**
  2425. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2426. * @param start defines the start vector
  2427. * @param end defines the end vector
  2428. * @param amount defines the interpolation factor
  2429. * @returns a new Vector2
  2430. */
  2431. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2432. /**
  2433. * Gets the dot product of the vector "left" and the vector "right"
  2434. * @param left defines first vector
  2435. * @param right defines second vector
  2436. * @returns the dot product (float)
  2437. */
  2438. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2439. /**
  2440. * Returns a new Vector2 equal to the normalized given vector
  2441. * @param vector defines the vector to normalize
  2442. * @returns a new Vector2
  2443. */
  2444. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2445. /**
  2446. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2447. * @param left defines 1st vector
  2448. * @param right defines 2nd vector
  2449. * @returns a new Vector2
  2450. */
  2451. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2452. /**
  2453. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2454. * @param left defines 1st vector
  2455. * @param right defines 2nd vector
  2456. * @returns a new Vector2
  2457. */
  2458. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2459. /**
  2460. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2461. * @param vector defines the vector to transform
  2462. * @param transformation defines the matrix to apply
  2463. * @returns a new Vector2
  2464. */
  2465. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2466. /**
  2467. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2468. * @param vector defines the vector to transform
  2469. * @param transformation defines the matrix to apply
  2470. * @param result defines the target vector
  2471. */
  2472. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2473. /**
  2474. * Determines if a given vector is included in a triangle
  2475. * @param p defines the vector to test
  2476. * @param p0 defines 1st triangle point
  2477. * @param p1 defines 2nd triangle point
  2478. * @param p2 defines 3rd triangle point
  2479. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2480. */
  2481. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2482. /**
  2483. * Gets the distance between the vectors "value1" and "value2"
  2484. * @param value1 defines first vector
  2485. * @param value2 defines second vector
  2486. * @returns the distance between vectors
  2487. */
  2488. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2489. /**
  2490. * Returns the squared distance between the vectors "value1" and "value2"
  2491. * @param value1 defines first vector
  2492. * @param value2 defines second vector
  2493. * @returns the squared distance between vectors
  2494. */
  2495. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2496. /**
  2497. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2498. * @param value1 defines first vector
  2499. * @param value2 defines second vector
  2500. * @returns a new Vector2
  2501. */
  2502. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2503. /**
  2504. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2505. * @param p defines the middle point
  2506. * @param segA defines one point of the segment
  2507. * @param segB defines the other point of the segment
  2508. * @returns the shortest distance
  2509. */
  2510. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2511. }
  2512. /**
  2513. * Class used to store (x,y,z) vector representation
  2514. * A Vector3 is the main object used in 3D geometry
  2515. * It can represent etiher the coordinates of a point the space, either a direction
  2516. * Reminder: js uses a left handed forward facing system
  2517. */
  2518. export class Vector3 {
  2519. private static _UpReadOnly;
  2520. private static _ZeroReadOnly;
  2521. /** @hidden */
  2522. _x: number;
  2523. /** @hidden */
  2524. _y: number;
  2525. /** @hidden */
  2526. _z: number;
  2527. /** @hidden */
  2528. _isDirty: boolean;
  2529. /** Gets or sets the x coordinate */
  2530. get x(): number;
  2531. set x(value: number);
  2532. /** Gets or sets the y coordinate */
  2533. get y(): number;
  2534. set y(value: number);
  2535. /** Gets or sets the z coordinate */
  2536. get z(): number;
  2537. set z(value: number);
  2538. /**
  2539. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2540. * @param x defines the first coordinates (on X axis)
  2541. * @param y defines the second coordinates (on Y axis)
  2542. * @param z defines the third coordinates (on Z axis)
  2543. */
  2544. constructor(x?: number, y?: number, z?: number);
  2545. /**
  2546. * Creates a string representation of the Vector3
  2547. * @returns a string with the Vector3 coordinates.
  2548. */
  2549. toString(): string;
  2550. /**
  2551. * Gets the class name
  2552. * @returns the string "Vector3"
  2553. */
  2554. getClassName(): string;
  2555. /**
  2556. * Creates the Vector3 hash code
  2557. * @returns a number which tends to be unique between Vector3 instances
  2558. */
  2559. getHashCode(): number;
  2560. /**
  2561. * Creates an array containing three elements : the coordinates of the Vector3
  2562. * @returns a new array of numbers
  2563. */
  2564. asArray(): number[];
  2565. /**
  2566. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2567. * @param array defines the destination array
  2568. * @param index defines the offset in the destination array
  2569. * @returns the current Vector3
  2570. */
  2571. toArray(array: FloatArray, index?: number): Vector3;
  2572. /**
  2573. * Update the current vector from an array
  2574. * @param array defines the destination array
  2575. * @param index defines the offset in the destination array
  2576. * @returns the current Vector3
  2577. */
  2578. fromArray(array: FloatArray, index?: number): Vector3;
  2579. /**
  2580. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2581. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2582. */
  2583. toQuaternion(): Quaternion;
  2584. /**
  2585. * Adds the given vector to the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the current updated Vector3
  2588. */
  2589. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Adds the given coordinates to the current Vector3
  2592. * @param x defines the x coordinate of the operand
  2593. * @param y defines the y coordinate of the operand
  2594. * @param z defines the z coordinate of the operand
  2595. * @returns the current updated Vector3
  2596. */
  2597. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2598. /**
  2599. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2600. * @param otherVector defines the second operand
  2601. * @returns the resulting Vector3
  2602. */
  2603. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2604. /**
  2605. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2606. * @param otherVector defines the second operand
  2607. * @param result defines the Vector3 object where to store the result
  2608. * @returns the current Vector3
  2609. */
  2610. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2611. /**
  2612. * Subtract the given vector from the current Vector3
  2613. * @param otherVector defines the second operand
  2614. * @returns the current updated Vector3
  2615. */
  2616. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2617. /**
  2618. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2619. * @param otherVector defines the second operand
  2620. * @returns the resulting Vector3
  2621. */
  2622. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2623. /**
  2624. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2625. * @param otherVector defines the second operand
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2630. /**
  2631. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2632. * @param x defines the x coordinate of the operand
  2633. * @param y defines the y coordinate of the operand
  2634. * @param z defines the z coordinate of the operand
  2635. * @returns the resulting Vector3
  2636. */
  2637. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2638. /**
  2639. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2640. * @param x defines the x coordinate of the operand
  2641. * @param y defines the y coordinate of the operand
  2642. * @param z defines the z coordinate of the operand
  2643. * @param result defines the Vector3 object where to store the result
  2644. * @returns the current Vector3
  2645. */
  2646. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2647. /**
  2648. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2649. * @returns a new Vector3
  2650. */
  2651. negate(): Vector3;
  2652. /**
  2653. * Negate this vector in place
  2654. * @returns this
  2655. */
  2656. negateInPlace(): Vector3;
  2657. /**
  2658. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2659. * @param result defines the Vector3 object where to store the result
  2660. * @returns the current Vector3
  2661. */
  2662. negateToRef(result: Vector3): Vector3;
  2663. /**
  2664. * Multiplies the Vector3 coordinates by the float "scale"
  2665. * @param scale defines the multiplier factor
  2666. * @returns the current updated Vector3
  2667. */
  2668. scaleInPlace(scale: number): Vector3;
  2669. /**
  2670. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2671. * @param scale defines the multiplier factor
  2672. * @returns a new Vector3
  2673. */
  2674. scale(scale: number): Vector3;
  2675. /**
  2676. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2677. * @param scale defines the multiplier factor
  2678. * @param result defines the Vector3 object where to store the result
  2679. * @returns the current Vector3
  2680. */
  2681. scaleToRef(scale: number, result: Vector3): Vector3;
  2682. /**
  2683. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2684. * @param scale defines the scale factor
  2685. * @param result defines the Vector3 object where to store the result
  2686. * @returns the unmodified current Vector3
  2687. */
  2688. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2689. /**
  2690. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2691. * @param origin defines the origin of the projection ray
  2692. * @param plane defines the plane to project to
  2693. * @returns the projected vector3
  2694. */
  2695. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2696. /**
  2697. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2698. * @param origin defines the origin of the projection ray
  2699. * @param plane defines the plane to project to
  2700. * @param result defines the Vector3 where to store the result
  2701. */
  2702. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2703. /**
  2704. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2705. * @param otherVector defines the second operand
  2706. * @returns true if both vectors are equals
  2707. */
  2708. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2709. /**
  2710. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2711. * @param otherVector defines the second operand
  2712. * @param epsilon defines the minimal distance to define values as equals
  2713. * @returns true if both vectors are distant less than epsilon
  2714. */
  2715. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2716. /**
  2717. * Returns true if the current Vector3 coordinates equals the given floats
  2718. * @param x defines the x coordinate of the operand
  2719. * @param y defines the y coordinate of the operand
  2720. * @param z defines the z coordinate of the operand
  2721. * @returns true if both vectors are equals
  2722. */
  2723. equalsToFloats(x: number, y: number, z: number): boolean;
  2724. /**
  2725. * Multiplies the current Vector3 coordinates by the given ones
  2726. * @param otherVector defines the second operand
  2727. * @returns the current updated Vector3
  2728. */
  2729. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2730. /**
  2731. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2732. * @param otherVector defines the second operand
  2733. * @returns the new Vector3
  2734. */
  2735. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2736. /**
  2737. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2738. * @param otherVector defines the second operand
  2739. * @param result defines the Vector3 object where to store the result
  2740. * @returns the current Vector3
  2741. */
  2742. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2743. /**
  2744. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2745. * @param x defines the x coordinate of the operand
  2746. * @param y defines the y coordinate of the operand
  2747. * @param z defines the z coordinate of the operand
  2748. * @returns the new Vector3
  2749. */
  2750. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2751. /**
  2752. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2753. * @param otherVector defines the second operand
  2754. * @returns the new Vector3
  2755. */
  2756. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2757. /**
  2758. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2759. * @param otherVector defines the second operand
  2760. * @param result defines the Vector3 object where to store the result
  2761. * @returns the current Vector3
  2762. */
  2763. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2764. /**
  2765. * Divides the current Vector3 coordinates by the given ones.
  2766. * @param otherVector defines the second operand
  2767. * @returns the current updated Vector3
  2768. */
  2769. divideInPlace(otherVector: Vector3): Vector3;
  2770. /**
  2771. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2772. * @param other defines the second operand
  2773. * @returns the current updated Vector3
  2774. */
  2775. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2776. /**
  2777. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2778. * @param other defines the second operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2782. /**
  2783. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2784. * @param x defines the x coordinate of the operand
  2785. * @param y defines the y coordinate of the operand
  2786. * @param z defines the z coordinate of the operand
  2787. * @returns the current updated Vector3
  2788. */
  2789. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2790. /**
  2791. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2792. * @param x defines the x coordinate of the operand
  2793. * @param y defines the y coordinate of the operand
  2794. * @param z defines the z coordinate of the operand
  2795. * @returns the current updated Vector3
  2796. */
  2797. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2798. /**
  2799. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2800. * Check if is non uniform within a certain amount of decimal places to account for this
  2801. * @param epsilon the amount the values can differ
  2802. * @returns if the the vector is non uniform to a certain number of decimal places
  2803. */
  2804. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2805. /**
  2806. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2807. */
  2808. get isNonUniform(): boolean;
  2809. /**
  2810. * Gets a new Vector3 from current Vector3 floored values
  2811. * @returns a new Vector3
  2812. */
  2813. floor(): Vector3;
  2814. /**
  2815. * Gets a new Vector3 from current Vector3 floored values
  2816. * @returns a new Vector3
  2817. */
  2818. fract(): Vector3;
  2819. /**
  2820. * Gets the length of the Vector3
  2821. * @returns the length of the Vector3
  2822. */
  2823. length(): number;
  2824. /**
  2825. * Gets the squared length of the Vector3
  2826. * @returns squared length of the Vector3
  2827. */
  2828. lengthSquared(): number;
  2829. /**
  2830. * Normalize the current Vector3.
  2831. * Please note that this is an in place operation.
  2832. * @returns the current updated Vector3
  2833. */
  2834. normalize(): Vector3;
  2835. /**
  2836. * Reorders the x y z properties of the vector in place
  2837. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2838. * @returns the current updated vector
  2839. */
  2840. reorderInPlace(order: string): this;
  2841. /**
  2842. * Rotates the vector around 0,0,0 by a quaternion
  2843. * @param quaternion the rotation quaternion
  2844. * @param result vector to store the result
  2845. * @returns the resulting vector
  2846. */
  2847. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2848. /**
  2849. * Rotates a vector around a given point
  2850. * @param quaternion the rotation quaternion
  2851. * @param point the point to rotate around
  2852. * @param result vector to store the result
  2853. * @returns the resulting vector
  2854. */
  2855. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2856. /**
  2857. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2858. * The cross product is then orthogonal to both current and "other"
  2859. * @param other defines the right operand
  2860. * @returns the cross product
  2861. */
  2862. cross(other: Vector3): Vector3;
  2863. /**
  2864. * Normalize the current Vector3 with the given input length.
  2865. * Please note that this is an in place operation.
  2866. * @param len the length of the vector
  2867. * @returns the current updated Vector3
  2868. */
  2869. normalizeFromLength(len: number): Vector3;
  2870. /**
  2871. * Normalize the current Vector3 to a new vector
  2872. * @returns the new Vector3
  2873. */
  2874. normalizeToNew(): Vector3;
  2875. /**
  2876. * Normalize the current Vector3 to the reference
  2877. * @param reference define the Vector3 to update
  2878. * @returns the updated Vector3
  2879. */
  2880. normalizeToRef(reference: Vector3): Vector3;
  2881. /**
  2882. * Creates a new Vector3 copied from the current Vector3
  2883. * @returns the new Vector3
  2884. */
  2885. clone(): Vector3;
  2886. /**
  2887. * Copies the given vector coordinates to the current Vector3 ones
  2888. * @param source defines the source Vector3
  2889. * @returns the current updated Vector3
  2890. */
  2891. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2892. /**
  2893. * Copies the given floats to the current Vector3 coordinates
  2894. * @param x defines the x coordinate of the operand
  2895. * @param y defines the y coordinate of the operand
  2896. * @param z defines the z coordinate of the operand
  2897. * @returns the current updated Vector3
  2898. */
  2899. copyFromFloats(x: number, y: number, z: number): Vector3;
  2900. /**
  2901. * Copies the given floats to the current Vector3 coordinates
  2902. * @param x defines the x coordinate of the operand
  2903. * @param y defines the y coordinate of the operand
  2904. * @param z defines the z coordinate of the operand
  2905. * @returns the current updated Vector3
  2906. */
  2907. set(x: number, y: number, z: number): Vector3;
  2908. /**
  2909. * Copies the given float to the current Vector3 coordinates
  2910. * @param v defines the x, y and z coordinates of the operand
  2911. * @returns the current updated Vector3
  2912. */
  2913. setAll(v: number): Vector3;
  2914. /**
  2915. * Get the clip factor between two vectors
  2916. * @param vector0 defines the first operand
  2917. * @param vector1 defines the second operand
  2918. * @param axis defines the axis to use
  2919. * @param size defines the size along the axis
  2920. * @returns the clip factor
  2921. */
  2922. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2923. /**
  2924. * Get angle between two vectors
  2925. * @param vector0 angle between vector0 and vector1
  2926. * @param vector1 angle between vector0 and vector1
  2927. * @param normal direction of the normal
  2928. * @return the angle between vector0 and vector1
  2929. */
  2930. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2931. /**
  2932. * Returns a new Vector3 set from the index "offset" of the given array
  2933. * @param array defines the source array
  2934. * @param offset defines the offset in the source array
  2935. * @returns the new Vector3
  2936. */
  2937. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2938. /**
  2939. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2940. * @param array defines the source array
  2941. * @param offset defines the offset in the source array
  2942. * @returns the new Vector3
  2943. * @deprecated Please use FromArray instead.
  2944. */
  2945. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2946. /**
  2947. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2948. * @param array defines the source array
  2949. * @param offset defines the offset in the source array
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2953. /**
  2954. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2955. * @param array defines the source array
  2956. * @param offset defines the offset in the source array
  2957. * @param result defines the Vector3 where to store the result
  2958. * @deprecated Please use FromArrayToRef instead.
  2959. */
  2960. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2961. /**
  2962. * Sets the given vector "result" with the given floats.
  2963. * @param x defines the x coordinate of the source
  2964. * @param y defines the y coordinate of the source
  2965. * @param z defines the z coordinate of the source
  2966. * @param result defines the Vector3 where to store the result
  2967. */
  2968. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2969. /**
  2970. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2971. * @returns a new empty Vector3
  2972. */
  2973. static Zero(): Vector3;
  2974. /**
  2975. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2976. * @returns a new unit Vector3
  2977. */
  2978. static One(): Vector3;
  2979. /**
  2980. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2981. * @returns a new up Vector3
  2982. */
  2983. static Up(): Vector3;
  2984. /**
  2985. * Gets a up Vector3 that must not be updated
  2986. */
  2987. static get UpReadOnly(): DeepImmutable<Vector3>;
  2988. /**
  2989. * Gets a zero Vector3 that must not be updated
  2990. */
  2991. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2992. /**
  2993. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2994. * @returns a new down Vector3
  2995. */
  2996. static Down(): Vector3;
  2997. /**
  2998. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2999. * @param rightHandedSystem is the scene right-handed (negative z)
  3000. * @returns a new forward Vector3
  3001. */
  3002. static Forward(rightHandedSystem?: boolean): Vector3;
  3003. /**
  3004. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3005. * @param rightHandedSystem is the scene right-handed (negative-z)
  3006. * @returns a new forward Vector3
  3007. */
  3008. static Backward(rightHandedSystem?: boolean): Vector3;
  3009. /**
  3010. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3011. * @returns a new right Vector3
  3012. */
  3013. static Right(): Vector3;
  3014. /**
  3015. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3016. * @returns a new left Vector3
  3017. */
  3018. static Left(): Vector3;
  3019. /**
  3020. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3021. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3022. * @param vector defines the Vector3 to transform
  3023. * @param transformation defines the transformation matrix
  3024. * @returns the transformed Vector3
  3025. */
  3026. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3027. /**
  3028. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3029. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3030. * @param vector defines the Vector3 to transform
  3031. * @param transformation defines the transformation matrix
  3032. * @param result defines the Vector3 where to store the result
  3033. */
  3034. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3035. /**
  3036. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3037. * This method computes tranformed coordinates only, not transformed direction vectors
  3038. * @param x define the x coordinate of the source vector
  3039. * @param y define the y coordinate of the source vector
  3040. * @param z define the z coordinate of the source vector
  3041. * @param transformation defines the transformation matrix
  3042. * @param result defines the Vector3 where to store the result
  3043. */
  3044. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3045. /**
  3046. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3047. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3048. * @param vector defines the Vector3 to transform
  3049. * @param transformation defines the transformation matrix
  3050. * @returns the new Vector3
  3051. */
  3052. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3053. /**
  3054. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3055. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3056. * @param vector defines the Vector3 to transform
  3057. * @param transformation defines the transformation matrix
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3061. /**
  3062. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3063. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3064. * @param x define the x coordinate of the source vector
  3065. * @param y define the y coordinate of the source vector
  3066. * @param z define the z coordinate of the source vector
  3067. * @param transformation defines the transformation matrix
  3068. * @param result defines the Vector3 where to store the result
  3069. */
  3070. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3071. /**
  3072. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3073. * @param value1 defines the first control point
  3074. * @param value2 defines the second control point
  3075. * @param value3 defines the third control point
  3076. * @param value4 defines the fourth control point
  3077. * @param amount defines the amount on the spline to use
  3078. * @returns the new Vector3
  3079. */
  3080. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3081. /**
  3082. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3083. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3084. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3085. * @param value defines the current value
  3086. * @param min defines the lower range value
  3087. * @param max defines the upper range value
  3088. * @returns the new Vector3
  3089. */
  3090. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3091. /**
  3092. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3093. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3094. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3095. * @param value defines the current value
  3096. * @param min defines the lower range value
  3097. * @param max defines the upper range value
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3101. /**
  3102. * Checks if a given vector is inside a specific range
  3103. * @param v defines the vector to test
  3104. * @param min defines the minimum range
  3105. * @param max defines the maximum range
  3106. */
  3107. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3108. /**
  3109. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3110. * @param value1 defines the first control point
  3111. * @param tangent1 defines the first tangent vector
  3112. * @param value2 defines the second control point
  3113. * @param tangent2 defines the second tangent vector
  3114. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3115. * @returns the new Vector3
  3116. */
  3117. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3118. /**
  3119. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3120. * @param start defines the start value
  3121. * @param end defines the end value
  3122. * @param amount max defines amount between both (between 0 and 1)
  3123. * @returns the new Vector3
  3124. */
  3125. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3126. /**
  3127. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3128. * @param start defines the start value
  3129. * @param end defines the end value
  3130. * @param amount max defines amount between both (between 0 and 1)
  3131. * @param result defines the Vector3 where to store the result
  3132. */
  3133. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3134. /**
  3135. * Returns the dot product (float) between the vectors "left" and "right"
  3136. * @param left defines the left operand
  3137. * @param right defines the right operand
  3138. * @returns the dot product
  3139. */
  3140. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3141. /**
  3142. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3143. * The cross product is then orthogonal to both "left" and "right"
  3144. * @param left defines the left operand
  3145. * @param right defines the right operand
  3146. * @returns the cross product
  3147. */
  3148. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3149. /**
  3150. * Sets the given vector "result" with the cross product of "left" and "right"
  3151. * The cross product is then orthogonal to both "left" and "right"
  3152. * @param left defines the left operand
  3153. * @param right defines the right operand
  3154. * @param result defines the Vector3 where to store the result
  3155. */
  3156. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3157. /**
  3158. * Returns a new Vector3 as the normalization of the given vector
  3159. * @param vector defines the Vector3 to normalize
  3160. * @returns the new Vector3
  3161. */
  3162. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Sets the given vector "result" with the normalization of the given first vector
  3165. * @param vector defines the Vector3 to normalize
  3166. * @param result defines the Vector3 where to store the result
  3167. */
  3168. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3169. /**
  3170. * Project a Vector3 onto screen space
  3171. * @param vector defines the Vector3 to project
  3172. * @param world defines the world matrix to use
  3173. * @param transform defines the transform (view x projection) matrix to use
  3174. * @param viewport defines the screen viewport to use
  3175. * @returns the new Vector3
  3176. */
  3177. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3178. /**
  3179. * Project a Vector3 onto screen space to reference
  3180. * @param vector defines the Vector3 to project
  3181. * @param world defines the world matrix to use
  3182. * @param transform defines the transform (view x projection) matrix to use
  3183. * @param viewport defines the screen viewport to use
  3184. * @param result the vector in which the screen space will be stored
  3185. * @returns the new Vector3
  3186. */
  3187. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3188. /** @hidden */
  3189. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3190. /**
  3191. * Unproject from screen space to object space
  3192. * @param source defines the screen space Vector3 to use
  3193. * @param viewportWidth defines the current width of the viewport
  3194. * @param viewportHeight defines the current height of the viewport
  3195. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3196. * @param transform defines the transform (view x projection) matrix to use
  3197. * @returns the new Vector3
  3198. */
  3199. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3200. /**
  3201. * Unproject from screen space to object space
  3202. * @param source defines the screen space Vector3 to use
  3203. * @param viewportWidth defines the current width of the viewport
  3204. * @param viewportHeight defines the current height of the viewport
  3205. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3206. * @param view defines the view matrix to use
  3207. * @param projection defines the projection matrix to use
  3208. * @returns the new Vector3
  3209. */
  3210. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3211. /**
  3212. * Unproject from screen space to object space
  3213. * @param source defines the screen space Vector3 to use
  3214. * @param viewportWidth defines the current width of the viewport
  3215. * @param viewportHeight defines the current height of the viewport
  3216. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3217. * @param view defines the view matrix to use
  3218. * @param projection defines the projection matrix to use
  3219. * @param result defines the Vector3 where to store the result
  3220. */
  3221. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3222. /**
  3223. * Unproject from screen space to object space
  3224. * @param sourceX defines the screen space x coordinate to use
  3225. * @param sourceY defines the screen space y coordinate to use
  3226. * @param sourceZ defines the screen space z coordinate to use
  3227. * @param viewportWidth defines the current width of the viewport
  3228. * @param viewportHeight defines the current height of the viewport
  3229. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3230. * @param view defines the view matrix to use
  3231. * @param projection defines the projection matrix to use
  3232. * @param result defines the Vector3 where to store the result
  3233. */
  3234. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3235. /**
  3236. * Gets the minimal coordinate values between two Vector3
  3237. * @param left defines the first operand
  3238. * @param right defines the second operand
  3239. * @returns the new Vector3
  3240. */
  3241. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3242. /**
  3243. * Gets the maximal coordinate values between two Vector3
  3244. * @param left defines the first operand
  3245. * @param right defines the second operand
  3246. * @returns the new Vector3
  3247. */
  3248. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3249. /**
  3250. * Returns the distance between the vectors "value1" and "value2"
  3251. * @param value1 defines the first operand
  3252. * @param value2 defines the second operand
  3253. * @returns the distance
  3254. */
  3255. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3256. /**
  3257. * Returns the squared distance between the vectors "value1" and "value2"
  3258. * @param value1 defines the first operand
  3259. * @param value2 defines the second operand
  3260. * @returns the squared distance
  3261. */
  3262. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3263. /**
  3264. * Returns a new Vector3 located at the center between "value1" and "value2"
  3265. * @param value1 defines the first operand
  3266. * @param value2 defines the second operand
  3267. * @returns the new Vector3
  3268. */
  3269. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3270. /**
  3271. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3272. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3273. * to something in order to rotate it from its local system to the given target system
  3274. * Note: axis1, axis2 and axis3 are normalized during this operation
  3275. * @param axis1 defines the first axis
  3276. * @param axis2 defines the second axis
  3277. * @param axis3 defines the third axis
  3278. * @returns a new Vector3
  3279. */
  3280. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3281. /**
  3282. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3283. * @param axis1 defines the first axis
  3284. * @param axis2 defines the second axis
  3285. * @param axis3 defines the third axis
  3286. * @param ref defines the Vector3 where to store the result
  3287. */
  3288. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3289. }
  3290. /**
  3291. * Vector4 class created for EulerAngle class conversion to Quaternion
  3292. */
  3293. export class Vector4 {
  3294. /** x value of the vector */
  3295. x: number;
  3296. /** y value of the vector */
  3297. y: number;
  3298. /** z value of the vector */
  3299. z: number;
  3300. /** w value of the vector */
  3301. w: number;
  3302. /**
  3303. * Creates a Vector4 object from the given floats.
  3304. * @param x x value of the vector
  3305. * @param y y value of the vector
  3306. * @param z z value of the vector
  3307. * @param w w value of the vector
  3308. */
  3309. constructor(
  3310. /** x value of the vector */
  3311. x: number,
  3312. /** y value of the vector */
  3313. y: number,
  3314. /** z value of the vector */
  3315. z: number,
  3316. /** w value of the vector */
  3317. w: number);
  3318. /**
  3319. * Returns the string with the Vector4 coordinates.
  3320. * @returns a string containing all the vector values
  3321. */
  3322. toString(): string;
  3323. /**
  3324. * Returns the string "Vector4".
  3325. * @returns "Vector4"
  3326. */
  3327. getClassName(): string;
  3328. /**
  3329. * Returns the Vector4 hash code.
  3330. * @returns a unique hash code
  3331. */
  3332. getHashCode(): number;
  3333. /**
  3334. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3335. * @returns the resulting array
  3336. */
  3337. asArray(): number[];
  3338. /**
  3339. * Populates the given array from the given index with the Vector4 coordinates.
  3340. * @param array array to populate
  3341. * @param index index of the array to start at (default: 0)
  3342. * @returns the Vector4.
  3343. */
  3344. toArray(array: FloatArray, index?: number): Vector4;
  3345. /**
  3346. * Update the current vector from an array
  3347. * @param array defines the destination array
  3348. * @param index defines the offset in the destination array
  3349. * @returns the current Vector3
  3350. */
  3351. fromArray(array: FloatArray, index?: number): Vector4;
  3352. /**
  3353. * Adds the given vector to the current Vector4.
  3354. * @param otherVector the vector to add
  3355. * @returns the updated Vector4.
  3356. */
  3357. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3358. /**
  3359. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3360. * @param otherVector the vector to add
  3361. * @returns the resulting vector
  3362. */
  3363. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3364. /**
  3365. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3366. * @param otherVector the vector to add
  3367. * @param result the vector to store the result
  3368. * @returns the current Vector4.
  3369. */
  3370. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3371. /**
  3372. * Subtract in place the given vector from the current Vector4.
  3373. * @param otherVector the vector to subtract
  3374. * @returns the updated Vector4.
  3375. */
  3376. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3377. /**
  3378. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3379. * @param otherVector the vector to add
  3380. * @returns the new vector with the result
  3381. */
  3382. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3383. /**
  3384. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3385. * @param otherVector the vector to subtract
  3386. * @param result the vector to store the result
  3387. * @returns the current Vector4.
  3388. */
  3389. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3390. /**
  3391. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3392. */
  3393. /**
  3394. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3395. * @param x value to subtract
  3396. * @param y value to subtract
  3397. * @param z value to subtract
  3398. * @param w value to subtract
  3399. * @returns new vector containing the result
  3400. */
  3401. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3402. /**
  3403. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3404. * @param x value to subtract
  3405. * @param y value to subtract
  3406. * @param z value to subtract
  3407. * @param w value to subtract
  3408. * @param result the vector to store the result in
  3409. * @returns the current Vector4.
  3410. */
  3411. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3412. /**
  3413. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3414. * @returns a new vector with the negated values
  3415. */
  3416. negate(): Vector4;
  3417. /**
  3418. * Negate this vector in place
  3419. * @returns this
  3420. */
  3421. negateInPlace(): Vector4;
  3422. /**
  3423. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3424. * @param result defines the Vector3 object where to store the result
  3425. * @returns the current Vector4
  3426. */
  3427. negateToRef(result: Vector4): Vector4;
  3428. /**
  3429. * Multiplies the current Vector4 coordinates by scale (float).
  3430. * @param scale the number to scale with
  3431. * @returns the updated Vector4.
  3432. */
  3433. scaleInPlace(scale: number): Vector4;
  3434. /**
  3435. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3436. * @param scale the number to scale with
  3437. * @returns a new vector with the result
  3438. */
  3439. scale(scale: number): Vector4;
  3440. /**
  3441. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3442. * @param scale the number to scale with
  3443. * @param result a vector to store the result in
  3444. * @returns the current Vector4.
  3445. */
  3446. scaleToRef(scale: number, result: Vector4): Vector4;
  3447. /**
  3448. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3449. * @param scale defines the scale factor
  3450. * @param result defines the Vector4 object where to store the result
  3451. * @returns the unmodified current Vector4
  3452. */
  3453. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3454. /**
  3455. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3456. * @param otherVector the vector to compare against
  3457. * @returns true if they are equal
  3458. */
  3459. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3460. /**
  3461. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3462. * @param otherVector vector to compare against
  3463. * @param epsilon (Default: very small number)
  3464. * @returns true if they are equal
  3465. */
  3466. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3467. /**
  3468. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3469. * @param x x value to compare against
  3470. * @param y y value to compare against
  3471. * @param z z value to compare against
  3472. * @param w w value to compare against
  3473. * @returns true if equal
  3474. */
  3475. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3476. /**
  3477. * Multiplies in place the current Vector4 by the given one.
  3478. * @param otherVector vector to multiple with
  3479. * @returns the updated Vector4.
  3480. */
  3481. multiplyInPlace(otherVector: Vector4): Vector4;
  3482. /**
  3483. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3484. * @param otherVector vector to multiple with
  3485. * @returns resulting new vector
  3486. */
  3487. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3488. /**
  3489. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3490. * @param otherVector vector to multiple with
  3491. * @param result vector to store the result
  3492. * @returns the current Vector4.
  3493. */
  3494. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3495. /**
  3496. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3497. * @param x x value multiply with
  3498. * @param y y value multiply with
  3499. * @param z z value multiply with
  3500. * @param w w value multiply with
  3501. * @returns resulting new vector
  3502. */
  3503. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3504. /**
  3505. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3506. * @param otherVector vector to devide with
  3507. * @returns resulting new vector
  3508. */
  3509. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3510. /**
  3511. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3512. * @param otherVector vector to devide with
  3513. * @param result vector to store the result
  3514. * @returns the current Vector4.
  3515. */
  3516. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3517. /**
  3518. * Divides the current Vector3 coordinates by the given ones.
  3519. * @param otherVector vector to devide with
  3520. * @returns the updated Vector3.
  3521. */
  3522. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3523. /**
  3524. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3525. * @param other defines the second operand
  3526. * @returns the current updated Vector4
  3527. */
  3528. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3529. /**
  3530. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3531. * @param other defines the second operand
  3532. * @returns the current updated Vector4
  3533. */
  3534. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3535. /**
  3536. * Gets a new Vector4 from current Vector4 floored values
  3537. * @returns a new Vector4
  3538. */
  3539. floor(): Vector4;
  3540. /**
  3541. * Gets a new Vector4 from current Vector3 floored values
  3542. * @returns a new Vector4
  3543. */
  3544. fract(): Vector4;
  3545. /**
  3546. * Returns the Vector4 length (float).
  3547. * @returns the length
  3548. */
  3549. length(): number;
  3550. /**
  3551. * Returns the Vector4 squared length (float).
  3552. * @returns the length squared
  3553. */
  3554. lengthSquared(): number;
  3555. /**
  3556. * Normalizes in place the Vector4.
  3557. * @returns the updated Vector4.
  3558. */
  3559. normalize(): Vector4;
  3560. /**
  3561. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3562. * @returns this converted to a new vector3
  3563. */
  3564. toVector3(): Vector3;
  3565. /**
  3566. * Returns a new Vector4 copied from the current one.
  3567. * @returns the new cloned vector
  3568. */
  3569. clone(): Vector4;
  3570. /**
  3571. * Updates the current Vector4 with the given one coordinates.
  3572. * @param source the source vector to copy from
  3573. * @returns the updated Vector4.
  3574. */
  3575. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3576. /**
  3577. * Updates the current Vector4 coordinates with the given floats.
  3578. * @param x float to copy from
  3579. * @param y float to copy from
  3580. * @param z float to copy from
  3581. * @param w float to copy from
  3582. * @returns the updated Vector4.
  3583. */
  3584. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3585. /**
  3586. * Updates the current Vector4 coordinates with the given floats.
  3587. * @param x float to set from
  3588. * @param y float to set from
  3589. * @param z float to set from
  3590. * @param w float to set from
  3591. * @returns the updated Vector4.
  3592. */
  3593. set(x: number, y: number, z: number, w: number): Vector4;
  3594. /**
  3595. * Copies the given float to the current Vector3 coordinates
  3596. * @param v defines the x, y, z and w coordinates of the operand
  3597. * @returns the current updated Vector3
  3598. */
  3599. setAll(v: number): Vector4;
  3600. /**
  3601. * Returns a new Vector4 set from the starting index of the given array.
  3602. * @param array the array to pull values from
  3603. * @param offset the offset into the array to start at
  3604. * @returns the new vector
  3605. */
  3606. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3607. /**
  3608. * Updates the given vector "result" from the starting index of the given array.
  3609. * @param array the array to pull values from
  3610. * @param offset the offset into the array to start at
  3611. * @param result the vector to store the result in
  3612. */
  3613. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3614. /**
  3615. * Updates the given vector "result" from the starting index of the given Float32Array.
  3616. * @param array the array to pull values from
  3617. * @param offset the offset into the array to start at
  3618. * @param result the vector to store the result in
  3619. */
  3620. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3621. /**
  3622. * Updates the given vector "result" coordinates from the given floats.
  3623. * @param x float to set from
  3624. * @param y float to set from
  3625. * @param z float to set from
  3626. * @param w float to set from
  3627. * @param result the vector to the floats in
  3628. */
  3629. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3630. /**
  3631. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3632. * @returns the new vector
  3633. */
  3634. static Zero(): Vector4;
  3635. /**
  3636. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3637. * @returns the new vector
  3638. */
  3639. static One(): Vector4;
  3640. /**
  3641. * Returns a new normalized Vector4 from the given one.
  3642. * @param vector the vector to normalize
  3643. * @returns the vector
  3644. */
  3645. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3646. /**
  3647. * Updates the given vector "result" from the normalization of the given one.
  3648. * @param vector the vector to normalize
  3649. * @param result the vector to store the result in
  3650. */
  3651. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3652. /**
  3653. * Returns a vector with the minimum values from the left and right vectors
  3654. * @param left left vector to minimize
  3655. * @param right right vector to minimize
  3656. * @returns a new vector with the minimum of the left and right vector values
  3657. */
  3658. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3659. /**
  3660. * Returns a vector with the maximum values from the left and right vectors
  3661. * @param left left vector to maximize
  3662. * @param right right vector to maximize
  3663. * @returns a new vector with the maximum of the left and right vector values
  3664. */
  3665. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3666. /**
  3667. * Returns the distance (float) between the vectors "value1" and "value2".
  3668. * @param value1 value to calulate the distance between
  3669. * @param value2 value to calulate the distance between
  3670. * @return the distance between the two vectors
  3671. */
  3672. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3673. /**
  3674. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3675. * @param value1 value to calulate the distance between
  3676. * @param value2 value to calulate the distance between
  3677. * @return the distance between the two vectors squared
  3678. */
  3679. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3680. /**
  3681. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3682. * @param value1 value to calulate the center between
  3683. * @param value2 value to calulate the center between
  3684. * @return the center between the two vectors
  3685. */
  3686. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3687. /**
  3688. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3689. * This methods computes transformed normalized direction vectors only.
  3690. * @param vector the vector to transform
  3691. * @param transformation the transformation matrix to apply
  3692. * @returns the new vector
  3693. */
  3694. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3695. /**
  3696. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3697. * This methods computes transformed normalized direction vectors only.
  3698. * @param vector the vector to transform
  3699. * @param transformation the transformation matrix to apply
  3700. * @param result the vector to store the result in
  3701. */
  3702. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3703. /**
  3704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3705. * This methods computes transformed normalized direction vectors only.
  3706. * @param x value to transform
  3707. * @param y value to transform
  3708. * @param z value to transform
  3709. * @param w value to transform
  3710. * @param transformation the transformation matrix to apply
  3711. * @param result the vector to store the results in
  3712. */
  3713. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3714. /**
  3715. * Creates a new Vector4 from a Vector3
  3716. * @param source defines the source data
  3717. * @param w defines the 4th component (default is 0)
  3718. * @returns a new Vector4
  3719. */
  3720. static FromVector3(source: Vector3, w?: number): Vector4;
  3721. }
  3722. /**
  3723. * Class used to store quaternion data
  3724. * @see https://en.wikipedia.org/wiki/Quaternion
  3725. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3726. */
  3727. export class Quaternion {
  3728. /** @hidden */
  3729. _x: number;
  3730. /** @hidden */
  3731. _y: number;
  3732. /** @hidden */
  3733. _z: number;
  3734. /** @hidden */
  3735. _w: number;
  3736. /** @hidden */
  3737. _isDirty: boolean;
  3738. /** Gets or sets the x coordinate */
  3739. get x(): number;
  3740. set x(value: number);
  3741. /** Gets or sets the y coordinate */
  3742. get y(): number;
  3743. set y(value: number);
  3744. /** Gets or sets the z coordinate */
  3745. get z(): number;
  3746. set z(value: number);
  3747. /** Gets or sets the w coordinate */
  3748. get w(): number;
  3749. set w(value: number);
  3750. /**
  3751. * Creates a new Quaternion from the given floats
  3752. * @param x defines the first component (0 by default)
  3753. * @param y defines the second component (0 by default)
  3754. * @param z defines the third component (0 by default)
  3755. * @param w defines the fourth component (1.0 by default)
  3756. */
  3757. constructor(x?: number, y?: number, z?: number, w?: number);
  3758. /**
  3759. * Gets a string representation for the current quaternion
  3760. * @returns a string with the Quaternion coordinates
  3761. */
  3762. toString(): string;
  3763. /**
  3764. * Gets the class name of the quaternion
  3765. * @returns the string "Quaternion"
  3766. */
  3767. getClassName(): string;
  3768. /**
  3769. * Gets a hash code for this quaternion
  3770. * @returns the quaternion hash code
  3771. */
  3772. getHashCode(): number;
  3773. /**
  3774. * Copy the quaternion to an array
  3775. * @returns a new array populated with 4 elements from the quaternion coordinates
  3776. */
  3777. asArray(): number[];
  3778. /**
  3779. * Check if two quaternions are equals
  3780. * @param otherQuaternion defines the second operand
  3781. * @return true if the current quaternion and the given one coordinates are strictly equals
  3782. */
  3783. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3784. /**
  3785. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3786. * @param otherQuaternion defines the other quaternion
  3787. * @param epsilon defines the minimal distance to consider equality
  3788. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3789. */
  3790. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3791. /**
  3792. * Clone the current quaternion
  3793. * @returns a new quaternion copied from the current one
  3794. */
  3795. clone(): Quaternion;
  3796. /**
  3797. * Copy a quaternion to the current one
  3798. * @param other defines the other quaternion
  3799. * @returns the updated current quaternion
  3800. */
  3801. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3802. /**
  3803. * Updates the current quaternion with the given float coordinates
  3804. * @param x defines the x coordinate
  3805. * @param y defines the y coordinate
  3806. * @param z defines the z coordinate
  3807. * @param w defines the w coordinate
  3808. * @returns the updated current quaternion
  3809. */
  3810. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3811. /**
  3812. * Updates the current quaternion from the given float coordinates
  3813. * @param x defines the x coordinate
  3814. * @param y defines the y coordinate
  3815. * @param z defines the z coordinate
  3816. * @param w defines the w coordinate
  3817. * @returns the updated current quaternion
  3818. */
  3819. set(x: number, y: number, z: number, w: number): Quaternion;
  3820. /**
  3821. * Adds two quaternions
  3822. * @param other defines the second operand
  3823. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3824. */
  3825. add(other: DeepImmutable<Quaternion>): Quaternion;
  3826. /**
  3827. * Add a quaternion to the current one
  3828. * @param other defines the quaternion to add
  3829. * @returns the current quaternion
  3830. */
  3831. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Subtract two quaternions
  3834. * @param other defines the second operand
  3835. * @returns a new quaternion as the subtraction result of the given one from the current one
  3836. */
  3837. subtract(other: Quaternion): Quaternion;
  3838. /**
  3839. * Multiplies the current quaternion by a scale factor
  3840. * @param value defines the scale factor
  3841. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3842. */
  3843. scale(value: number): Quaternion;
  3844. /**
  3845. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3846. * @param scale defines the scale factor
  3847. * @param result defines the Quaternion object where to store the result
  3848. * @returns the unmodified current quaternion
  3849. */
  3850. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3851. /**
  3852. * Multiplies in place the current quaternion by a scale factor
  3853. * @param value defines the scale factor
  3854. * @returns the current modified quaternion
  3855. */
  3856. scaleInPlace(value: number): Quaternion;
  3857. /**
  3858. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3859. * @param scale defines the scale factor
  3860. * @param result defines the Quaternion object where to store the result
  3861. * @returns the unmodified current quaternion
  3862. */
  3863. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3864. /**
  3865. * Multiplies two quaternions
  3866. * @param q1 defines the second operand
  3867. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3868. */
  3869. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3870. /**
  3871. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3872. * @param q1 defines the second operand
  3873. * @param result defines the target quaternion
  3874. * @returns the current quaternion
  3875. */
  3876. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3877. /**
  3878. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3879. * @param q1 defines the second operand
  3880. * @returns the currentupdated quaternion
  3881. */
  3882. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3883. /**
  3884. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3885. * @param ref defines the target quaternion
  3886. * @returns the current quaternion
  3887. */
  3888. conjugateToRef(ref: Quaternion): Quaternion;
  3889. /**
  3890. * Conjugates in place (1-q) the current quaternion
  3891. * @returns the current updated quaternion
  3892. */
  3893. conjugateInPlace(): Quaternion;
  3894. /**
  3895. * Conjugates in place (1-q) the current quaternion
  3896. * @returns a new quaternion
  3897. */
  3898. conjugate(): Quaternion;
  3899. /**
  3900. * Gets length of current quaternion
  3901. * @returns the quaternion length (float)
  3902. */
  3903. length(): number;
  3904. /**
  3905. * Normalize in place the current quaternion
  3906. * @returns the current updated quaternion
  3907. */
  3908. normalize(): Quaternion;
  3909. /**
  3910. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3911. * @param order is a reserved parameter and is ignored for now
  3912. * @returns a new Vector3 containing the Euler angles
  3913. */
  3914. toEulerAngles(order?: string): Vector3;
  3915. /**
  3916. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3917. * @param result defines the vector which will be filled with the Euler angles
  3918. * @returns the current unchanged quaternion
  3919. */
  3920. toEulerAnglesToRef(result: Vector3): Quaternion;
  3921. /**
  3922. * Updates the given rotation matrix with the current quaternion values
  3923. * @param result defines the target matrix
  3924. * @returns the current unchanged quaternion
  3925. */
  3926. toRotationMatrix(result: Matrix): Quaternion;
  3927. /**
  3928. * Updates the current quaternion from the given rotation matrix values
  3929. * @param matrix defines the source matrix
  3930. * @returns the current updated quaternion
  3931. */
  3932. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3933. /**
  3934. * Creates a new quaternion from a rotation matrix
  3935. * @param matrix defines the source matrix
  3936. * @returns a new quaternion created from the given rotation matrix values
  3937. */
  3938. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3939. /**
  3940. * Updates the given quaternion with the given rotation matrix values
  3941. * @param matrix defines the source matrix
  3942. * @param result defines the target quaternion
  3943. */
  3944. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3945. /**
  3946. * Returns the dot product (float) between the quaternions "left" and "right"
  3947. * @param left defines the left operand
  3948. * @param right defines the right operand
  3949. * @returns the dot product
  3950. */
  3951. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3952. /**
  3953. * Checks if the two quaternions are close to each other
  3954. * @param quat0 defines the first quaternion to check
  3955. * @param quat1 defines the second quaternion to check
  3956. * @returns true if the two quaternions are close to each other
  3957. */
  3958. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3959. /**
  3960. * Creates an empty quaternion
  3961. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3962. */
  3963. static Zero(): Quaternion;
  3964. /**
  3965. * Inverse a given quaternion
  3966. * @param q defines the source quaternion
  3967. * @returns a new quaternion as the inverted current quaternion
  3968. */
  3969. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3970. /**
  3971. * Inverse a given quaternion
  3972. * @param q defines the source quaternion
  3973. * @param result the quaternion the result will be stored in
  3974. * @returns the result quaternion
  3975. */
  3976. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3977. /**
  3978. * Creates an identity quaternion
  3979. * @returns the identity quaternion
  3980. */
  3981. static Identity(): Quaternion;
  3982. /**
  3983. * Gets a boolean indicating if the given quaternion is identity
  3984. * @param quaternion defines the quaternion to check
  3985. * @returns true if the quaternion is identity
  3986. */
  3987. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3988. /**
  3989. * Creates a quaternion from a rotation around an axis
  3990. * @param axis defines the axis to use
  3991. * @param angle defines the angle to use
  3992. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3993. */
  3994. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3995. /**
  3996. * Creates a rotation around an axis and stores it into the given quaternion
  3997. * @param axis defines the axis to use
  3998. * @param angle defines the angle to use
  3999. * @param result defines the target quaternion
  4000. * @returns the target quaternion
  4001. */
  4002. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4003. /**
  4004. * Creates a new quaternion from data stored into an array
  4005. * @param array defines the data source
  4006. * @param offset defines the offset in the source array where the data starts
  4007. * @returns a new quaternion
  4008. */
  4009. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4010. /**
  4011. * Updates the given quaternion "result" from the starting index of the given array.
  4012. * @param array the array to pull values from
  4013. * @param offset the offset into the array to start at
  4014. * @param result the quaternion to store the result in
  4015. */
  4016. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4017. /**
  4018. * Create a quaternion from Euler rotation angles
  4019. * @param x Pitch
  4020. * @param y Yaw
  4021. * @param z Roll
  4022. * @returns the new Quaternion
  4023. */
  4024. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4025. /**
  4026. * Updates a quaternion from Euler rotation angles
  4027. * @param x Pitch
  4028. * @param y Yaw
  4029. * @param z Roll
  4030. * @param result the quaternion to store the result
  4031. * @returns the updated quaternion
  4032. */
  4033. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4034. /**
  4035. * Create a quaternion from Euler rotation vector
  4036. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4037. * @returns the new Quaternion
  4038. */
  4039. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4040. /**
  4041. * Updates a quaternion from Euler rotation vector
  4042. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4043. * @param result the quaternion to store the result
  4044. * @returns the updated quaternion
  4045. */
  4046. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4047. /**
  4048. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4049. * @param yaw defines the rotation around Y axis
  4050. * @param pitch defines the rotation around X axis
  4051. * @param roll defines the rotation around Z axis
  4052. * @returns the new quaternion
  4053. */
  4054. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4055. /**
  4056. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4057. * @param yaw defines the rotation around Y axis
  4058. * @param pitch defines the rotation around X axis
  4059. * @param roll defines the rotation around Z axis
  4060. * @param result defines the target quaternion
  4061. */
  4062. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4063. /**
  4064. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4065. * @param alpha defines the rotation around first axis
  4066. * @param beta defines the rotation around second axis
  4067. * @param gamma defines the rotation around third axis
  4068. * @returns the new quaternion
  4069. */
  4070. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4071. /**
  4072. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4073. * @param alpha defines the rotation around first axis
  4074. * @param beta defines the rotation around second axis
  4075. * @param gamma defines the rotation around third axis
  4076. * @param result defines the target quaternion
  4077. */
  4078. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4079. /**
  4080. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4081. * @param axis1 defines the first axis
  4082. * @param axis2 defines the second axis
  4083. * @param axis3 defines the third axis
  4084. * @returns the new quaternion
  4085. */
  4086. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4087. /**
  4088. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4089. * @param axis1 defines the first axis
  4090. * @param axis2 defines the second axis
  4091. * @param axis3 defines the third axis
  4092. * @param ref defines the target quaternion
  4093. */
  4094. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4095. /**
  4096. * Interpolates between two quaternions
  4097. * @param left defines first quaternion
  4098. * @param right defines second quaternion
  4099. * @param amount defines the gradient to use
  4100. * @returns the new interpolated quaternion
  4101. */
  4102. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4103. /**
  4104. * Interpolates between two quaternions and stores it into a target quaternion
  4105. * @param left defines first quaternion
  4106. * @param right defines second quaternion
  4107. * @param amount defines the gradient to use
  4108. * @param result defines the target quaternion
  4109. */
  4110. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4111. /**
  4112. * Interpolate between two quaternions using Hermite interpolation
  4113. * @param value1 defines first quaternion
  4114. * @param tangent1 defines the incoming tangent
  4115. * @param value2 defines second quaternion
  4116. * @param tangent2 defines the outgoing tangent
  4117. * @param amount defines the target quaternion
  4118. * @returns the new interpolated quaternion
  4119. */
  4120. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4121. }
  4122. /**
  4123. * Class used to store matrix data (4x4)
  4124. */
  4125. export class Matrix {
  4126. /**
  4127. * Gets the precision of matrix computations
  4128. */
  4129. static get Use64Bits(): boolean;
  4130. private static _updateFlagSeed;
  4131. private static _identityReadOnly;
  4132. private _isIdentity;
  4133. private _isIdentityDirty;
  4134. private _isIdentity3x2;
  4135. private _isIdentity3x2Dirty;
  4136. /**
  4137. * Gets the update flag of the matrix which is an unique number for the matrix.
  4138. * It will be incremented every time the matrix data change.
  4139. * You can use it to speed the comparison between two versions of the same matrix.
  4140. */
  4141. updateFlag: number;
  4142. private readonly _m;
  4143. /**
  4144. * Gets the internal data of the matrix
  4145. */
  4146. get m(): DeepImmutable<Float32Array | Array<number>>;
  4147. /** @hidden */
  4148. _markAsUpdated(): void;
  4149. /** @hidden */
  4150. private _updateIdentityStatus;
  4151. /**
  4152. * Creates an empty matrix (filled with zeros)
  4153. */
  4154. constructor();
  4155. /**
  4156. * Check if the current matrix is identity
  4157. * @returns true is the matrix is the identity matrix
  4158. */
  4159. isIdentity(): boolean;
  4160. /**
  4161. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4162. * @returns true is the matrix is the identity matrix
  4163. */
  4164. isIdentityAs3x2(): boolean;
  4165. /**
  4166. * Gets the determinant of the matrix
  4167. * @returns the matrix determinant
  4168. */
  4169. determinant(): number;
  4170. /**
  4171. * Returns the matrix as a Float32Array or Array<number>
  4172. * @returns the matrix underlying array
  4173. */
  4174. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4175. /**
  4176. * Returns the matrix as a Float32Array or Array<number>
  4177. * @returns the matrix underlying array.
  4178. */
  4179. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4180. /**
  4181. * Inverts the current matrix in place
  4182. * @returns the current inverted matrix
  4183. */
  4184. invert(): Matrix;
  4185. /**
  4186. * Sets all the matrix elements to zero
  4187. * @returns the current matrix
  4188. */
  4189. reset(): Matrix;
  4190. /**
  4191. * Adds the current matrix with a second one
  4192. * @param other defines the matrix to add
  4193. * @returns a new matrix as the addition of the current matrix and the given one
  4194. */
  4195. add(other: DeepImmutable<Matrix>): Matrix;
  4196. /**
  4197. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4198. * @param other defines the matrix to add
  4199. * @param result defines the target matrix
  4200. * @returns the current matrix
  4201. */
  4202. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4203. /**
  4204. * Adds in place the given matrix to the current matrix
  4205. * @param other defines the second operand
  4206. * @returns the current updated matrix
  4207. */
  4208. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4209. /**
  4210. * Sets the given matrix to the current inverted Matrix
  4211. * @param other defines the target matrix
  4212. * @returns the unmodified current matrix
  4213. */
  4214. invertToRef(other: Matrix): Matrix;
  4215. /**
  4216. * add a value at the specified position in the current Matrix
  4217. * @param index the index of the value within the matrix. between 0 and 15.
  4218. * @param value the value to be added
  4219. * @returns the current updated matrix
  4220. */
  4221. addAtIndex(index: number, value: number): Matrix;
  4222. /**
  4223. * mutiply the specified position in the current Matrix by a value
  4224. * @param index the index of the value within the matrix. between 0 and 15.
  4225. * @param value the value to be added
  4226. * @returns the current updated matrix
  4227. */
  4228. multiplyAtIndex(index: number, value: number): Matrix;
  4229. /**
  4230. * Inserts the translation vector (using 3 floats) in the current matrix
  4231. * @param x defines the 1st component of the translation
  4232. * @param y defines the 2nd component of the translation
  4233. * @param z defines the 3rd component of the translation
  4234. * @returns the current updated matrix
  4235. */
  4236. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4237. /**
  4238. * Adds the translation vector (using 3 floats) in the current matrix
  4239. * @param x defines the 1st component of the translation
  4240. * @param y defines the 2nd component of the translation
  4241. * @param z defines the 3rd component of the translation
  4242. * @returns the current updated matrix
  4243. */
  4244. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4245. /**
  4246. * Inserts the translation vector in the current matrix
  4247. * @param vector3 defines the translation to insert
  4248. * @returns the current updated matrix
  4249. */
  4250. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4251. /**
  4252. * Gets the translation value of the current matrix
  4253. * @returns a new Vector3 as the extracted translation from the matrix
  4254. */
  4255. getTranslation(): Vector3;
  4256. /**
  4257. * Fill a Vector3 with the extracted translation from the matrix
  4258. * @param result defines the Vector3 where to store the translation
  4259. * @returns the current matrix
  4260. */
  4261. getTranslationToRef(result: Vector3): Matrix;
  4262. /**
  4263. * Remove rotation and scaling part from the matrix
  4264. * @returns the updated matrix
  4265. */
  4266. removeRotationAndScaling(): Matrix;
  4267. /**
  4268. * Multiply two matrices
  4269. * @param other defines the second operand
  4270. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4271. */
  4272. multiply(other: DeepImmutable<Matrix>): Matrix;
  4273. /**
  4274. * Copy the current matrix from the given one
  4275. * @param other defines the source matrix
  4276. * @returns the current updated matrix
  4277. */
  4278. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4279. /**
  4280. * Populates the given array from the starting index with the current matrix values
  4281. * @param array defines the target array
  4282. * @param offset defines the offset in the target array where to start storing values
  4283. * @returns the current matrix
  4284. */
  4285. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4286. /**
  4287. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4288. * @param other defines the second operand
  4289. * @param result defines the matrix where to store the multiplication
  4290. * @returns the current matrix
  4291. */
  4292. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4293. /**
  4294. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4295. * @param other defines the second operand
  4296. * @param result defines the array where to store the multiplication
  4297. * @param offset defines the offset in the target array where to start storing values
  4298. * @returns the current matrix
  4299. */
  4300. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4301. /**
  4302. * Check equality between this matrix and a second one
  4303. * @param value defines the second matrix to compare
  4304. * @returns true is the current matrix and the given one values are strictly equal
  4305. */
  4306. equals(value: DeepImmutable<Matrix>): boolean;
  4307. /**
  4308. * Clone the current matrix
  4309. * @returns a new matrix from the current matrix
  4310. */
  4311. clone(): Matrix;
  4312. /**
  4313. * Returns the name of the current matrix class
  4314. * @returns the string "Matrix"
  4315. */
  4316. getClassName(): string;
  4317. /**
  4318. * Gets the hash code of the current matrix
  4319. * @returns the hash code
  4320. */
  4321. getHashCode(): number;
  4322. /**
  4323. * Decomposes the current Matrix into a translation, rotation and scaling components
  4324. * @param scale defines the scale vector3 given as a reference to update
  4325. * @param rotation defines the rotation quaternion given as a reference to update
  4326. * @param translation defines the translation vector3 given as a reference to update
  4327. * @returns true if operation was successful
  4328. */
  4329. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4330. /**
  4331. * Gets specific row of the matrix
  4332. * @param index defines the number of the row to get
  4333. * @returns the index-th row of the current matrix as a new Vector4
  4334. */
  4335. getRow(index: number): Nullable<Vector4>;
  4336. /**
  4337. * Sets the index-th row of the current matrix to the vector4 values
  4338. * @param index defines the number of the row to set
  4339. * @param row defines the target vector4
  4340. * @returns the updated current matrix
  4341. */
  4342. setRow(index: number, row: Vector4): Matrix;
  4343. /**
  4344. * Compute the transpose of the matrix
  4345. * @returns the new transposed matrix
  4346. */
  4347. transpose(): Matrix;
  4348. /**
  4349. * Compute the transpose of the matrix and store it in a given matrix
  4350. * @param result defines the target matrix
  4351. * @returns the current matrix
  4352. */
  4353. transposeToRef(result: Matrix): Matrix;
  4354. /**
  4355. * Sets the index-th row of the current matrix with the given 4 x float values
  4356. * @param index defines the row index
  4357. * @param x defines the x component to set
  4358. * @param y defines the y component to set
  4359. * @param z defines the z component to set
  4360. * @param w defines the w component to set
  4361. * @returns the updated current matrix
  4362. */
  4363. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4364. /**
  4365. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4366. * @param scale defines the scale factor
  4367. * @returns a new matrix
  4368. */
  4369. scale(scale: number): Matrix;
  4370. /**
  4371. * Scale the current matrix values by a factor to a given result matrix
  4372. * @param scale defines the scale factor
  4373. * @param result defines the matrix to store the result
  4374. * @returns the current matrix
  4375. */
  4376. scaleToRef(scale: number, result: Matrix): Matrix;
  4377. /**
  4378. * Scale the current matrix values by a factor and add the result to a given matrix
  4379. * @param scale defines the scale factor
  4380. * @param result defines the Matrix to store the result
  4381. * @returns the current matrix
  4382. */
  4383. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4384. /**
  4385. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4386. * @param ref matrix to store the result
  4387. */
  4388. toNormalMatrix(ref: Matrix): void;
  4389. /**
  4390. * Gets only rotation part of the current matrix
  4391. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4392. */
  4393. getRotationMatrix(): Matrix;
  4394. /**
  4395. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4396. * @param result defines the target matrix to store data to
  4397. * @returns the current matrix
  4398. */
  4399. getRotationMatrixToRef(result: Matrix): Matrix;
  4400. /**
  4401. * Toggles model matrix from being right handed to left handed in place and vice versa
  4402. */
  4403. toggleModelMatrixHandInPlace(): void;
  4404. /**
  4405. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4406. */
  4407. toggleProjectionMatrixHandInPlace(): void;
  4408. /**
  4409. * Creates a matrix from an array
  4410. * @param array defines the source array
  4411. * @param offset defines an offset in the source array
  4412. * @returns a new Matrix set from the starting index of the given array
  4413. */
  4414. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4415. /**
  4416. * Copy the content of an array into a given matrix
  4417. * @param array defines the source array
  4418. * @param offset defines an offset in the source array
  4419. * @param result defines the target matrix
  4420. */
  4421. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4422. /**
  4423. * Stores an array into a matrix after having multiplied each component by a given factor
  4424. * @param array defines the source array
  4425. * @param offset defines the offset in the source array
  4426. * @param scale defines the scaling factor
  4427. * @param result defines the target matrix
  4428. */
  4429. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4430. /**
  4431. * Gets an identity matrix that must not be updated
  4432. */
  4433. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4434. /**
  4435. * Stores a list of values (16) inside a given matrix
  4436. * @param initialM11 defines 1st value of 1st row
  4437. * @param initialM12 defines 2nd value of 1st row
  4438. * @param initialM13 defines 3rd value of 1st row
  4439. * @param initialM14 defines 4th value of 1st row
  4440. * @param initialM21 defines 1st value of 2nd row
  4441. * @param initialM22 defines 2nd value of 2nd row
  4442. * @param initialM23 defines 3rd value of 2nd row
  4443. * @param initialM24 defines 4th value of 2nd row
  4444. * @param initialM31 defines 1st value of 3rd row
  4445. * @param initialM32 defines 2nd value of 3rd row
  4446. * @param initialM33 defines 3rd value of 3rd row
  4447. * @param initialM34 defines 4th value of 3rd row
  4448. * @param initialM41 defines 1st value of 4th row
  4449. * @param initialM42 defines 2nd value of 4th row
  4450. * @param initialM43 defines 3rd value of 4th row
  4451. * @param initialM44 defines 4th value of 4th row
  4452. * @param result defines the target matrix
  4453. */
  4454. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4455. /**
  4456. * Creates new matrix from a list of values (16)
  4457. * @param initialM11 defines 1st value of 1st row
  4458. * @param initialM12 defines 2nd value of 1st row
  4459. * @param initialM13 defines 3rd value of 1st row
  4460. * @param initialM14 defines 4th value of 1st row
  4461. * @param initialM21 defines 1st value of 2nd row
  4462. * @param initialM22 defines 2nd value of 2nd row
  4463. * @param initialM23 defines 3rd value of 2nd row
  4464. * @param initialM24 defines 4th value of 2nd row
  4465. * @param initialM31 defines 1st value of 3rd row
  4466. * @param initialM32 defines 2nd value of 3rd row
  4467. * @param initialM33 defines 3rd value of 3rd row
  4468. * @param initialM34 defines 4th value of 3rd row
  4469. * @param initialM41 defines 1st value of 4th row
  4470. * @param initialM42 defines 2nd value of 4th row
  4471. * @param initialM43 defines 3rd value of 4th row
  4472. * @param initialM44 defines 4th value of 4th row
  4473. * @returns the new matrix
  4474. */
  4475. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4476. /**
  4477. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4478. * @param scale defines the scale vector3
  4479. * @param rotation defines the rotation quaternion
  4480. * @param translation defines the translation vector3
  4481. * @returns a new matrix
  4482. */
  4483. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4484. /**
  4485. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4486. * @param scale defines the scale vector3
  4487. * @param rotation defines the rotation quaternion
  4488. * @param translation defines the translation vector3
  4489. * @param result defines the target matrix
  4490. */
  4491. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4492. /**
  4493. * Creates a new identity matrix
  4494. * @returns a new identity matrix
  4495. */
  4496. static Identity(): Matrix;
  4497. /**
  4498. * Creates a new identity matrix and stores the result in a given matrix
  4499. * @param result defines the target matrix
  4500. */
  4501. static IdentityToRef(result: Matrix): void;
  4502. /**
  4503. * Creates a new zero matrix
  4504. * @returns a new zero matrix
  4505. */
  4506. static Zero(): Matrix;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the X axis
  4509. * @param angle defines the angle (in radians) to use
  4510. * @return the new matrix
  4511. */
  4512. static RotationX(angle: number): Matrix;
  4513. /**
  4514. * Creates a new matrix as the invert of a given matrix
  4515. * @param source defines the source matrix
  4516. * @returns the new matrix
  4517. */
  4518. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4519. /**
  4520. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationXToRef(angle: number, result: Matrix): void;
  4525. /**
  4526. * Creates a new rotation matrix for "angle" radians around the Y axis
  4527. * @param angle defines the angle (in radians) to use
  4528. * @return the new matrix
  4529. */
  4530. static RotationY(angle: number): Matrix;
  4531. /**
  4532. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4533. * @param angle defines the angle (in radians) to use
  4534. * @param result defines the target matrix
  4535. */
  4536. static RotationYToRef(angle: number, result: Matrix): void;
  4537. /**
  4538. * Creates a new rotation matrix for "angle" radians around the Z axis
  4539. * @param angle defines the angle (in radians) to use
  4540. * @return the new matrix
  4541. */
  4542. static RotationZ(angle: number): Matrix;
  4543. /**
  4544. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4545. * @param angle defines the angle (in radians) to use
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationZToRef(angle: number, result: Matrix): void;
  4549. /**
  4550. * Creates a new rotation matrix for "angle" radians around the given axis
  4551. * @param axis defines the axis to use
  4552. * @param angle defines the angle (in radians) to use
  4553. * @return the new matrix
  4554. */
  4555. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4556. /**
  4557. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4558. * @param axis defines the axis to use
  4559. * @param angle defines the angle (in radians) to use
  4560. * @param result defines the target matrix
  4561. */
  4562. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4563. /**
  4564. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4565. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4566. * @param from defines the vector to align
  4567. * @param to defines the vector to align to
  4568. * @param result defines the target matrix
  4569. */
  4570. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4571. /**
  4572. * Creates a rotation matrix
  4573. * @param yaw defines the yaw angle in radians (Y axis)
  4574. * @param pitch defines the pitch angle in radians (X axis)
  4575. * @param roll defines the roll angle in radians (Z axis)
  4576. * @returns the new rotation matrix
  4577. */
  4578. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4579. /**
  4580. * Creates a rotation matrix and stores it in a given matrix
  4581. * @param yaw defines the yaw angle in radians (Y axis)
  4582. * @param pitch defines the pitch angle in radians (X axis)
  4583. * @param roll defines the roll angle in radians (Z axis)
  4584. * @param result defines the target matrix
  4585. */
  4586. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4587. /**
  4588. * Creates a scaling matrix
  4589. * @param x defines the scale factor on X axis
  4590. * @param y defines the scale factor on Y axis
  4591. * @param z defines the scale factor on Z axis
  4592. * @returns the new matrix
  4593. */
  4594. static Scaling(x: number, y: number, z: number): Matrix;
  4595. /**
  4596. * Creates a scaling matrix and stores it in a given matrix
  4597. * @param x defines the scale factor on X axis
  4598. * @param y defines the scale factor on Y axis
  4599. * @param z defines the scale factor on Z axis
  4600. * @param result defines the target matrix
  4601. */
  4602. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4603. /**
  4604. * Creates a translation matrix
  4605. * @param x defines the translation on X axis
  4606. * @param y defines the translation on Y axis
  4607. * @param z defines the translationon Z axis
  4608. * @returns the new matrix
  4609. */
  4610. static Translation(x: number, y: number, z: number): Matrix;
  4611. /**
  4612. * Creates a translation matrix and stores it in a given matrix
  4613. * @param x defines the translation on X axis
  4614. * @param y defines the translation on Y axis
  4615. * @param z defines the translationon Z axis
  4616. * @param result defines the target matrix
  4617. */
  4618. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4619. /**
  4620. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4621. * @param startValue defines the start value
  4622. * @param endValue defines the end value
  4623. * @param gradient defines the gradient factor
  4624. * @returns the new matrix
  4625. */
  4626. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4627. /**
  4628. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4629. * @param startValue defines the start value
  4630. * @param endValue defines the end value
  4631. * @param gradient defines the gradient factor
  4632. * @param result defines the Matrix object where to store data
  4633. */
  4634. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4635. /**
  4636. * Builds a new matrix whose values are computed by:
  4637. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4638. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4639. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4640. * @param startValue defines the first matrix
  4641. * @param endValue defines the second matrix
  4642. * @param gradient defines the gradient between the two matrices
  4643. * @returns the new matrix
  4644. */
  4645. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4646. /**
  4647. * Update a matrix to values which are computed by:
  4648. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4649. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4650. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4651. * @param startValue defines the first matrix
  4652. * @param endValue defines the second matrix
  4653. * @param gradient defines the gradient between the two matrices
  4654. * @param result defines the target matrix
  4655. */
  4656. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4657. /**
  4658. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4659. * This function works in left handed mode
  4660. * @param eye defines the final position of the entity
  4661. * @param target defines where the entity should look at
  4662. * @param up defines the up vector for the entity
  4663. * @returns the new matrix
  4664. */
  4665. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4666. /**
  4667. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4668. * This function works in left handed mode
  4669. * @param eye defines the final position of the entity
  4670. * @param target defines where the entity should look at
  4671. * @param up defines the up vector for the entity
  4672. * @param result defines the target matrix
  4673. */
  4674. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4675. /**
  4676. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4677. * This function works in right handed mode
  4678. * @param eye defines the final position of the entity
  4679. * @param target defines where the entity should look at
  4680. * @param up defines the up vector for the entity
  4681. * @returns the new matrix
  4682. */
  4683. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4684. /**
  4685. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4686. * This function works in right handed mode
  4687. * @param eye defines the final position of the entity
  4688. * @param target defines where the entity should look at
  4689. * @param up defines the up vector for the entity
  4690. * @param result defines the target matrix
  4691. */
  4692. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4693. /**
  4694. * Create a left-handed orthographic projection matrix
  4695. * @param width defines the viewport width
  4696. * @param height defines the viewport height
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a left-handed orthographic projection matrix
  4700. */
  4701. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Store a left-handed orthographic projection to a given matrix
  4704. * @param width defines the viewport width
  4705. * @param height defines the viewport height
  4706. * @param znear defines the near clip plane
  4707. * @param zfar defines the far clip plane
  4708. * @param result defines the target matrix
  4709. */
  4710. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4711. /**
  4712. * Create a left-handed orthographic projection matrix
  4713. * @param left defines the viewport left coordinate
  4714. * @param right defines the viewport right coordinate
  4715. * @param bottom defines the viewport bottom coordinate
  4716. * @param top defines the viewport top coordinate
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @returns a new matrix as a left-handed orthographic projection matrix
  4720. */
  4721. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Stores a left-handed orthographic projection into a given matrix
  4724. * @param left defines the viewport left coordinate
  4725. * @param right defines the viewport right coordinate
  4726. * @param bottom defines the viewport bottom coordinate
  4727. * @param top defines the viewport top coordinate
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. */
  4732. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4733. /**
  4734. * Creates a right-handed orthographic projection matrix
  4735. * @param left defines the viewport left coordinate
  4736. * @param right defines the viewport right coordinate
  4737. * @param bottom defines the viewport bottom coordinate
  4738. * @param top defines the viewport top coordinate
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @returns a new matrix as a right-handed orthographic projection matrix
  4742. */
  4743. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4744. /**
  4745. * Stores a right-handed orthographic projection into a given matrix
  4746. * @param left defines the viewport left coordinate
  4747. * @param right defines the viewport right coordinate
  4748. * @param bottom defines the viewport bottom coordinate
  4749. * @param top defines the viewport top coordinate
  4750. * @param znear defines the near clip plane
  4751. * @param zfar defines the far clip plane
  4752. * @param result defines the target matrix
  4753. */
  4754. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4755. /**
  4756. * Creates a left-handed perspective projection matrix
  4757. * @param width defines the viewport width
  4758. * @param height defines the viewport height
  4759. * @param znear defines the near clip plane
  4760. * @param zfar defines the far clip plane
  4761. * @returns a new matrix as a left-handed perspective projection matrix
  4762. */
  4763. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4764. /**
  4765. * Creates a left-handed perspective projection matrix
  4766. * @param fov defines the horizontal field of view
  4767. * @param aspect defines the aspect ratio
  4768. * @param znear defines the near clip plane
  4769. * @param zfar defines the far clip plane
  4770. * @returns a new matrix as a left-handed perspective projection matrix
  4771. */
  4772. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4773. /**
  4774. * Stores a left-handed perspective projection into a given matrix
  4775. * @param fov defines the horizontal field of view
  4776. * @param aspect defines the aspect ratio
  4777. * @param znear defines the near clip plane
  4778. * @param zfar defines the far clip plane
  4779. * @param result defines the target matrix
  4780. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4781. */
  4782. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4783. /**
  4784. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4785. * @param fov defines the horizontal field of view
  4786. * @param aspect defines the aspect ratio
  4787. * @param znear defines the near clip plane
  4788. * @param zfar not used as infinity is used as far clip
  4789. * @param result defines the target matrix
  4790. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4791. */
  4792. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4793. /**
  4794. * Creates a right-handed perspective projection matrix
  4795. * @param fov defines the horizontal field of view
  4796. * @param aspect defines the aspect ratio
  4797. * @param znear defines the near clip plane
  4798. * @param zfar defines the far clip plane
  4799. * @returns a new matrix as a right-handed perspective projection matrix
  4800. */
  4801. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4802. /**
  4803. * Stores a right-handed perspective projection into a given matrix
  4804. * @param fov defines the horizontal field of view
  4805. * @param aspect defines the aspect ratio
  4806. * @param znear defines the near clip plane
  4807. * @param zfar defines the far clip plane
  4808. * @param result defines the target matrix
  4809. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4810. */
  4811. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4812. /**
  4813. * Stores a right-handed perspective projection into a given matrix
  4814. * @param fov defines the horizontal field of view
  4815. * @param aspect defines the aspect ratio
  4816. * @param znear defines the near clip plane
  4817. * @param zfar not used as infinity is used as far clip
  4818. * @param result defines the target matrix
  4819. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4820. */
  4821. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4822. /**
  4823. * Stores a perspective projection for WebVR info a given matrix
  4824. * @param fov defines the field of view
  4825. * @param znear defines the near clip plane
  4826. * @param zfar defines the far clip plane
  4827. * @param result defines the target matrix
  4828. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4829. */
  4830. static PerspectiveFovWebVRToRef(fov: {
  4831. upDegrees: number;
  4832. downDegrees: number;
  4833. leftDegrees: number;
  4834. rightDegrees: number;
  4835. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4836. /**
  4837. * Computes a complete transformation matrix
  4838. * @param viewport defines the viewport to use
  4839. * @param world defines the world matrix
  4840. * @param view defines the view matrix
  4841. * @param projection defines the projection matrix
  4842. * @param zmin defines the near clip plane
  4843. * @param zmax defines the far clip plane
  4844. * @returns the transformation matrix
  4845. */
  4846. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4847. /**
  4848. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4849. * @param matrix defines the matrix to use
  4850. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4851. */
  4852. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4853. /**
  4854. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4855. * @param matrix defines the matrix to use
  4856. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4857. */
  4858. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4859. /**
  4860. * Compute the transpose of a given matrix
  4861. * @param matrix defines the matrix to transpose
  4862. * @returns the new matrix
  4863. */
  4864. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4865. /**
  4866. * Compute the transpose of a matrix and store it in a target matrix
  4867. * @param matrix defines the matrix to transpose
  4868. * @param result defines the target matrix
  4869. */
  4870. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4871. /**
  4872. * Computes a reflection matrix from a plane
  4873. * @param plane defines the reflection plane
  4874. * @returns a new matrix
  4875. */
  4876. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4877. /**
  4878. * Computes a reflection matrix from a plane
  4879. * @param plane defines the reflection plane
  4880. * @param result defines the target matrix
  4881. */
  4882. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4883. /**
  4884. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4885. * @param xaxis defines the value of the 1st axis
  4886. * @param yaxis defines the value of the 2nd axis
  4887. * @param zaxis defines the value of the 3rd axis
  4888. * @param result defines the target matrix
  4889. */
  4890. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4891. /**
  4892. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4893. * @param quat defines the quaternion to use
  4894. * @param result defines the target matrix
  4895. */
  4896. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4897. }
  4898. /**
  4899. * @hidden
  4900. */
  4901. export class TmpVectors {
  4902. static Vector2: Vector2[];
  4903. static Vector3: Vector3[];
  4904. static Vector4: Vector4[];
  4905. static Quaternion: Quaternion[];
  4906. static Matrix: Matrix[];
  4907. }
  4908. }
  4909. declare module "babylonjs/Maths/math.path" {
  4910. import { DeepImmutable, Nullable } from "babylonjs/types";
  4911. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4912. /**
  4913. * Defines potential orientation for back face culling
  4914. */
  4915. export enum Orientation {
  4916. /**
  4917. * Clockwise
  4918. */
  4919. CW = 0,
  4920. /** Counter clockwise */
  4921. CCW = 1
  4922. }
  4923. /** Class used to represent a Bezier curve */
  4924. export class BezierCurve {
  4925. /**
  4926. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4927. * @param t defines the time
  4928. * @param x1 defines the left coordinate on X axis
  4929. * @param y1 defines the left coordinate on Y axis
  4930. * @param x2 defines the right coordinate on X axis
  4931. * @param y2 defines the right coordinate on Y axis
  4932. * @returns the interpolated value
  4933. */
  4934. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4935. }
  4936. /**
  4937. * Defines angle representation
  4938. */
  4939. export class Angle {
  4940. private _radians;
  4941. /**
  4942. * Creates an Angle object of "radians" radians (float).
  4943. * @param radians the angle in radians
  4944. */
  4945. constructor(radians: number);
  4946. /**
  4947. * Get value in degrees
  4948. * @returns the Angle value in degrees (float)
  4949. */
  4950. degrees(): number;
  4951. /**
  4952. * Get value in radians
  4953. * @returns the Angle value in radians (float)
  4954. */
  4955. radians(): number;
  4956. /**
  4957. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4958. * @param a defines first point as the origin
  4959. * @param b defines point
  4960. * @returns a new Angle
  4961. */
  4962. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4963. /**
  4964. * Gets a new Angle object from the given float in radians
  4965. * @param radians defines the angle value in radians
  4966. * @returns a new Angle
  4967. */
  4968. static FromRadians(radians: number): Angle;
  4969. /**
  4970. * Gets a new Angle object from the given float in degrees
  4971. * @param degrees defines the angle value in degrees
  4972. * @returns a new Angle
  4973. */
  4974. static FromDegrees(degrees: number): Angle;
  4975. }
  4976. /**
  4977. * This represents an arc in a 2d space.
  4978. */
  4979. export class Arc2 {
  4980. /** Defines the start point of the arc */
  4981. startPoint: Vector2;
  4982. /** Defines the mid point of the arc */
  4983. midPoint: Vector2;
  4984. /** Defines the end point of the arc */
  4985. endPoint: Vector2;
  4986. /**
  4987. * Defines the center point of the arc.
  4988. */
  4989. centerPoint: Vector2;
  4990. /**
  4991. * Defines the radius of the arc.
  4992. */
  4993. radius: number;
  4994. /**
  4995. * Defines the angle of the arc (from mid point to end point).
  4996. */
  4997. angle: Angle;
  4998. /**
  4999. * Defines the start angle of the arc (from start point to middle point).
  5000. */
  5001. startAngle: Angle;
  5002. /**
  5003. * Defines the orientation of the arc (clock wise/counter clock wise).
  5004. */
  5005. orientation: Orientation;
  5006. /**
  5007. * Creates an Arc object from the three given points : start, middle and end.
  5008. * @param startPoint Defines the start point of the arc
  5009. * @param midPoint Defines the midlle point of the arc
  5010. * @param endPoint Defines the end point of the arc
  5011. */
  5012. constructor(
  5013. /** Defines the start point of the arc */
  5014. startPoint: Vector2,
  5015. /** Defines the mid point of the arc */
  5016. midPoint: Vector2,
  5017. /** Defines the end point of the arc */
  5018. endPoint: Vector2);
  5019. }
  5020. /**
  5021. * Represents a 2D path made up of multiple 2D points
  5022. */
  5023. export class Path2 {
  5024. private _points;
  5025. private _length;
  5026. /**
  5027. * If the path start and end point are the same
  5028. */
  5029. closed: boolean;
  5030. /**
  5031. * Creates a Path2 object from the starting 2D coordinates x and y.
  5032. * @param x the starting points x value
  5033. * @param y the starting points y value
  5034. */
  5035. constructor(x: number, y: number);
  5036. /**
  5037. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5038. * @param x the added points x value
  5039. * @param y the added points y value
  5040. * @returns the updated Path2.
  5041. */
  5042. addLineTo(x: number, y: number): Path2;
  5043. /**
  5044. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5045. * @param midX middle point x value
  5046. * @param midY middle point y value
  5047. * @param endX end point x value
  5048. * @param endY end point y value
  5049. * @param numberOfSegments (default: 36)
  5050. * @returns the updated Path2.
  5051. */
  5052. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5053. /**
  5054. * Closes the Path2.
  5055. * @returns the Path2.
  5056. */
  5057. close(): Path2;
  5058. /**
  5059. * Gets the sum of the distance between each sequential point in the path
  5060. * @returns the Path2 total length (float).
  5061. */
  5062. length(): number;
  5063. /**
  5064. * Gets the points which construct the path
  5065. * @returns the Path2 internal array of points.
  5066. */
  5067. getPoints(): Vector2[];
  5068. /**
  5069. * Retreives the point at the distance aways from the starting point
  5070. * @param normalizedLengthPosition the length along the path to retreive the point from
  5071. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5072. */
  5073. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5074. /**
  5075. * Creates a new path starting from an x and y position
  5076. * @param x starting x value
  5077. * @param y starting y value
  5078. * @returns a new Path2 starting at the coordinates (x, y).
  5079. */
  5080. static StartingAt(x: number, y: number): Path2;
  5081. }
  5082. /**
  5083. * Represents a 3D path made up of multiple 3D points
  5084. */
  5085. export class Path3D {
  5086. /**
  5087. * an array of Vector3, the curve axis of the Path3D
  5088. */
  5089. path: Vector3[];
  5090. private _curve;
  5091. private _distances;
  5092. private _tangents;
  5093. private _normals;
  5094. private _binormals;
  5095. private _raw;
  5096. private _alignTangentsWithPath;
  5097. private readonly _pointAtData;
  5098. /**
  5099. * new Path3D(path, normal, raw)
  5100. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5101. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5102. * @param path an array of Vector3, the curve axis of the Path3D
  5103. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5104. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5105. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5106. */
  5107. constructor(
  5108. /**
  5109. * an array of Vector3, the curve axis of the Path3D
  5110. */
  5111. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5112. /**
  5113. * Returns the Path3D array of successive Vector3 designing its curve.
  5114. * @returns the Path3D array of successive Vector3 designing its curve.
  5115. */
  5116. getCurve(): Vector3[];
  5117. /**
  5118. * Returns the Path3D array of successive Vector3 designing its curve.
  5119. * @returns the Path3D array of successive Vector3 designing its curve.
  5120. */
  5121. getPoints(): Vector3[];
  5122. /**
  5123. * @returns the computed length (float) of the path.
  5124. */
  5125. length(): number;
  5126. /**
  5127. * Returns an array populated with tangent vectors on each Path3D curve point.
  5128. * @returns an array populated with tangent vectors on each Path3D curve point.
  5129. */
  5130. getTangents(): Vector3[];
  5131. /**
  5132. * Returns an array populated with normal vectors on each Path3D curve point.
  5133. * @returns an array populated with normal vectors on each Path3D curve point.
  5134. */
  5135. getNormals(): Vector3[];
  5136. /**
  5137. * Returns an array populated with binormal vectors on each Path3D curve point.
  5138. * @returns an array populated with binormal vectors on each Path3D curve point.
  5139. */
  5140. getBinormals(): Vector3[];
  5141. /**
  5142. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5143. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5144. */
  5145. getDistances(): number[];
  5146. /**
  5147. * Returns an interpolated point along this path
  5148. * @param position the position of the point along this path, from 0.0 to 1.0
  5149. * @returns a new Vector3 as the point
  5150. */
  5151. getPointAt(position: number): Vector3;
  5152. /**
  5153. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5154. * @param position the position of the point along this path, from 0.0 to 1.0
  5155. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5156. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5157. */
  5158. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5159. /**
  5160. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5161. * @param position the position of the point along this path, from 0.0 to 1.0
  5162. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5163. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5164. */
  5165. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5166. /**
  5167. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5168. * @param position the position of the point along this path, from 0.0 to 1.0
  5169. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5170. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5171. */
  5172. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5173. /**
  5174. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5175. * @param position the position of the point along this path, from 0.0 to 1.0
  5176. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5177. */
  5178. getDistanceAt(position: number): number;
  5179. /**
  5180. * Returns the array index of the previous point of an interpolated point along this path
  5181. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5182. * @returns the array index
  5183. */
  5184. getPreviousPointIndexAt(position: number): number;
  5185. /**
  5186. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5187. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5188. * @returns the sub position
  5189. */
  5190. getSubPositionAt(position: number): number;
  5191. /**
  5192. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5193. * @param target the vector of which to get the closest position to
  5194. * @returns the position of the closest virtual point on this path to the target vector
  5195. */
  5196. getClosestPositionTo(target: Vector3): number;
  5197. /**
  5198. * Returns a sub path (slice) of this path
  5199. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5200. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5201. * @returns a sub path (slice) of this path
  5202. */
  5203. slice(start?: number, end?: number): Path3D;
  5204. /**
  5205. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5206. * @param path path which all values are copied into the curves points
  5207. * @param firstNormal which should be projected onto the curve
  5208. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5209. * @returns the same object updated.
  5210. */
  5211. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5212. private _compute;
  5213. private _getFirstNonNullVector;
  5214. private _getLastNonNullVector;
  5215. private _normalVector;
  5216. /**
  5217. * Updates the point at data for an interpolated point along this curve
  5218. * @param position the position of the point along this curve, from 0.0 to 1.0
  5219. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5220. * @returns the (updated) point at data
  5221. */
  5222. private _updatePointAtData;
  5223. /**
  5224. * Updates the point at data from the specified parameters
  5225. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5226. * @param point the interpolated point
  5227. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5228. */
  5229. private _setPointAtData;
  5230. /**
  5231. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5232. */
  5233. private _updateInterpolationMatrix;
  5234. }
  5235. /**
  5236. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5237. * A Curve3 is designed from a series of successive Vector3.
  5238. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5239. */
  5240. export class Curve3 {
  5241. private _points;
  5242. private _length;
  5243. /**
  5244. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5245. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5246. * @param v1 (Vector3) the control point
  5247. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5248. * @param nbPoints (integer) the wanted number of points in the curve
  5249. * @returns the created Curve3
  5250. */
  5251. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5252. /**
  5253. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5254. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5255. * @param v1 (Vector3) the first control point
  5256. * @param v2 (Vector3) the second control point
  5257. * @param v3 (Vector3) the end point of the Cubic Bezier
  5258. * @param nbPoints (integer) the wanted number of points in the curve
  5259. * @returns the created Curve3
  5260. */
  5261. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5262. /**
  5263. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5264. * @param p1 (Vector3) the origin point of the Hermite Spline
  5265. * @param t1 (Vector3) the tangent vector at the origin point
  5266. * @param p2 (Vector3) the end point of the Hermite Spline
  5267. * @param t2 (Vector3) the tangent vector at the end point
  5268. * @param nbPoints (integer) the wanted number of points in the curve
  5269. * @returns the created Curve3
  5270. */
  5271. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5272. /**
  5273. * Returns a Curve3 object along a CatmullRom Spline curve :
  5274. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5275. * @param nbPoints (integer) the wanted number of points between each curve control points
  5276. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5277. * @returns the created Curve3
  5278. */
  5279. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5280. /**
  5281. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5282. * A Curve3 is designed from a series of successive Vector3.
  5283. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5284. * @param points points which make up the curve
  5285. */
  5286. constructor(points: Vector3[]);
  5287. /**
  5288. * @returns the Curve3 stored array of successive Vector3
  5289. */
  5290. getPoints(): Vector3[];
  5291. /**
  5292. * @returns the computed length (float) of the curve.
  5293. */
  5294. length(): number;
  5295. /**
  5296. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5297. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5298. * curveA and curveB keep unchanged.
  5299. * @param curve the curve to continue from this curve
  5300. * @returns the newly constructed curve
  5301. */
  5302. continue(curve: DeepImmutable<Curve3>): Curve3;
  5303. private _computeLength;
  5304. }
  5305. }
  5306. declare module "babylonjs/Animations/easing" {
  5307. /**
  5308. * This represents the main contract an easing function should follow.
  5309. * Easing functions are used throughout the animation system.
  5310. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5311. */
  5312. export interface IEasingFunction {
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5315. * of the easing function.
  5316. * The link below provides some of the most common examples of easing functions.
  5317. * @see https://easings.net/
  5318. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5319. * @returns the corresponding value on the curve defined by the easing function
  5320. */
  5321. ease(gradient: number): number;
  5322. }
  5323. /**
  5324. * Base class used for every default easing function.
  5325. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5326. */
  5327. export class EasingFunction implements IEasingFunction {
  5328. /**
  5329. * Interpolation follows the mathematical formula associated with the easing function.
  5330. */
  5331. static readonly EASINGMODE_EASEIN: number;
  5332. /**
  5333. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5334. */
  5335. static readonly EASINGMODE_EASEOUT: number;
  5336. /**
  5337. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5338. */
  5339. static readonly EASINGMODE_EASEINOUT: number;
  5340. private _easingMode;
  5341. /**
  5342. * Sets the easing mode of the current function.
  5343. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5344. */
  5345. setEasingMode(easingMode: number): void;
  5346. /**
  5347. * Gets the current easing mode.
  5348. * @returns the easing mode
  5349. */
  5350. getEasingMode(): number;
  5351. /**
  5352. * @hidden
  5353. */
  5354. easeInCore(gradient: number): number;
  5355. /**
  5356. * Given an input gradient between 0 and 1, this returns the corresponding value
  5357. * of the easing function.
  5358. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5359. * @returns the corresponding value on the curve defined by the easing function
  5360. */
  5361. ease(gradient: number): number;
  5362. }
  5363. /**
  5364. * Easing function with a circle shape (see link below).
  5365. * @see https://easings.net/#easeInCirc
  5366. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5367. */
  5368. export class CircleEase extends EasingFunction implements IEasingFunction {
  5369. /** @hidden */
  5370. easeInCore(gradient: number): number;
  5371. }
  5372. /**
  5373. * Easing function with a ease back shape (see link below).
  5374. * @see https://easings.net/#easeInBack
  5375. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5376. */
  5377. export class BackEase extends EasingFunction implements IEasingFunction {
  5378. /** Defines the amplitude of the function */
  5379. amplitude: number;
  5380. /**
  5381. * Instantiates a back ease easing
  5382. * @see https://easings.net/#easeInBack
  5383. * @param amplitude Defines the amplitude of the function
  5384. */
  5385. constructor(
  5386. /** Defines the amplitude of the function */
  5387. amplitude?: number);
  5388. /** @hidden */
  5389. easeInCore(gradient: number): number;
  5390. }
  5391. /**
  5392. * Easing function with a bouncing shape (see link below).
  5393. * @see https://easings.net/#easeInBounce
  5394. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5395. */
  5396. export class BounceEase extends EasingFunction implements IEasingFunction {
  5397. /** Defines the number of bounces */
  5398. bounces: number;
  5399. /** Defines the amplitude of the bounce */
  5400. bounciness: number;
  5401. /**
  5402. * Instantiates a bounce easing
  5403. * @see https://easings.net/#easeInBounce
  5404. * @param bounces Defines the number of bounces
  5405. * @param bounciness Defines the amplitude of the bounce
  5406. */
  5407. constructor(
  5408. /** Defines the number of bounces */
  5409. bounces?: number,
  5410. /** Defines the amplitude of the bounce */
  5411. bounciness?: number);
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 3 shape (see link below).
  5417. * @see https://easings.net/#easeInCubic
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class CubicEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with an elastic shape (see link below).
  5426. * @see https://easings.net/#easeInElastic
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the number of oscillations*/
  5431. oscillations: number;
  5432. /** Defines the amplitude of the oscillations*/
  5433. springiness: number;
  5434. /**
  5435. * Instantiates an elastic easing function
  5436. * @see https://easings.net/#easeInElastic
  5437. * @param oscillations Defines the number of oscillations
  5438. * @param springiness Defines the amplitude of the oscillations
  5439. */
  5440. constructor(
  5441. /** Defines the number of oscillations*/
  5442. oscillations?: number,
  5443. /** Defines the amplitude of the oscillations*/
  5444. springiness?: number);
  5445. /** @hidden */
  5446. easeInCore(gradient: number): number;
  5447. }
  5448. /**
  5449. * Easing function with an exponential shape (see link below).
  5450. * @see https://easings.net/#easeInExpo
  5451. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5452. */
  5453. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5454. /** Defines the exponent of the function */
  5455. exponent: number;
  5456. /**
  5457. * Instantiates an exponential easing function
  5458. * @see https://easings.net/#easeInExpo
  5459. * @param exponent Defines the exponent of the function
  5460. */
  5461. constructor(
  5462. /** Defines the exponent of the function */
  5463. exponent?: number);
  5464. /** @hidden */
  5465. easeInCore(gradient: number): number;
  5466. }
  5467. /**
  5468. * Easing function with a power shape (see link below).
  5469. * @see https://easings.net/#easeInQuad
  5470. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5471. */
  5472. export class PowerEase extends EasingFunction implements IEasingFunction {
  5473. /** Defines the power of the function */
  5474. power: number;
  5475. /**
  5476. * Instantiates an power base easing function
  5477. * @see https://easings.net/#easeInQuad
  5478. * @param power Defines the power of the function
  5479. */
  5480. constructor(
  5481. /** Defines the power of the function */
  5482. power?: number);
  5483. /** @hidden */
  5484. easeInCore(gradient: number): number;
  5485. }
  5486. /**
  5487. * Easing function with a power of 2 shape (see link below).
  5488. * @see https://easings.net/#easeInQuad
  5489. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5490. */
  5491. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5492. /** @hidden */
  5493. easeInCore(gradient: number): number;
  5494. }
  5495. /**
  5496. * Easing function with a power of 4 shape (see link below).
  5497. * @see https://easings.net/#easeInQuart
  5498. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5499. */
  5500. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5501. /** @hidden */
  5502. easeInCore(gradient: number): number;
  5503. }
  5504. /**
  5505. * Easing function with a power of 5 shape (see link below).
  5506. * @see https://easings.net/#easeInQuint
  5507. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5508. */
  5509. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5510. /** @hidden */
  5511. easeInCore(gradient: number): number;
  5512. }
  5513. /**
  5514. * Easing function with a sin shape (see link below).
  5515. * @see https://easings.net/#easeInSine
  5516. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5517. */
  5518. export class SineEase extends EasingFunction implements IEasingFunction {
  5519. /** @hidden */
  5520. easeInCore(gradient: number): number;
  5521. }
  5522. /**
  5523. * Easing function with a bezier shape (see link below).
  5524. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5525. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5526. */
  5527. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5528. /** Defines the x component of the start tangent in the bezier curve */
  5529. x1: number;
  5530. /** Defines the y component of the start tangent in the bezier curve */
  5531. y1: number;
  5532. /** Defines the x component of the end tangent in the bezier curve */
  5533. x2: number;
  5534. /** Defines the y component of the end tangent in the bezier curve */
  5535. y2: number;
  5536. /**
  5537. * Instantiates a bezier function
  5538. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5539. * @param x1 Defines the x component of the start tangent in the bezier curve
  5540. * @param y1 Defines the y component of the start tangent in the bezier curve
  5541. * @param x2 Defines the x component of the end tangent in the bezier curve
  5542. * @param y2 Defines the y component of the end tangent in the bezier curve
  5543. */
  5544. constructor(
  5545. /** Defines the x component of the start tangent in the bezier curve */
  5546. x1?: number,
  5547. /** Defines the y component of the start tangent in the bezier curve */
  5548. y1?: number,
  5549. /** Defines the x component of the end tangent in the bezier curve */
  5550. x2?: number,
  5551. /** Defines the y component of the end tangent in the bezier curve */
  5552. y2?: number);
  5553. /** @hidden */
  5554. easeInCore(gradient: number): number;
  5555. }
  5556. }
  5557. declare module "babylonjs/Maths/math.color" {
  5558. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5559. /**
  5560. * Class used to hold a RBG color
  5561. */
  5562. export class Color3 {
  5563. /**
  5564. * Defines the red component (between 0 and 1, default is 0)
  5565. */
  5566. r: number;
  5567. /**
  5568. * Defines the green component (between 0 and 1, default is 0)
  5569. */
  5570. g: number;
  5571. /**
  5572. * Defines the blue component (between 0 and 1, default is 0)
  5573. */
  5574. b: number;
  5575. /**
  5576. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5577. * @param r defines the red component (between 0 and 1, default is 0)
  5578. * @param g defines the green component (between 0 and 1, default is 0)
  5579. * @param b defines the blue component (between 0 and 1, default is 0)
  5580. */
  5581. constructor(
  5582. /**
  5583. * Defines the red component (between 0 and 1, default is 0)
  5584. */
  5585. r?: number,
  5586. /**
  5587. * Defines the green component (between 0 and 1, default is 0)
  5588. */
  5589. g?: number,
  5590. /**
  5591. * Defines the blue component (between 0 and 1, default is 0)
  5592. */
  5593. b?: number);
  5594. /**
  5595. * Creates a string with the Color3 current values
  5596. * @returns the string representation of the Color3 object
  5597. */
  5598. toString(): string;
  5599. /**
  5600. * Returns the string "Color3"
  5601. * @returns "Color3"
  5602. */
  5603. getClassName(): string;
  5604. /**
  5605. * Compute the Color3 hash code
  5606. * @returns an unique number that can be used to hash Color3 objects
  5607. */
  5608. getHashCode(): number;
  5609. /**
  5610. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5611. * @param array defines the array where to store the r,g,b components
  5612. * @param index defines an optional index in the target array to define where to start storing values
  5613. * @returns the current Color3 object
  5614. */
  5615. toArray(array: FloatArray, index?: number): Color3;
  5616. /**
  5617. * Update the current color with values stored in an array from the starting index of the given array
  5618. * @param array defines the source array
  5619. * @param offset defines an offset in the source array
  5620. * @returns the current Color3 object
  5621. */
  5622. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5623. /**
  5624. * Returns a new Color4 object from the current Color3 and the given alpha
  5625. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5626. * @returns a new Color4 object
  5627. */
  5628. toColor4(alpha?: number): Color4;
  5629. /**
  5630. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5631. * @returns the new array
  5632. */
  5633. asArray(): number[];
  5634. /**
  5635. * Returns the luminance value
  5636. * @returns a float value
  5637. */
  5638. toLuminance(): number;
  5639. /**
  5640. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5641. * @param otherColor defines the second operand
  5642. * @returns the new Color3 object
  5643. */
  5644. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5645. /**
  5646. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5647. * @param otherColor defines the second operand
  5648. * @param result defines the Color3 object where to store the result
  5649. * @returns the current Color3
  5650. */
  5651. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5652. /**
  5653. * Determines equality between Color3 objects
  5654. * @param otherColor defines the second operand
  5655. * @returns true if the rgb values are equal to the given ones
  5656. */
  5657. equals(otherColor: DeepImmutable<Color3>): boolean;
  5658. /**
  5659. * Determines equality between the current Color3 object and a set of r,b,g values
  5660. * @param r defines the red component to check
  5661. * @param g defines the green component to check
  5662. * @param b defines the blue component to check
  5663. * @returns true if the rgb values are equal to the given ones
  5664. */
  5665. equalsFloats(r: number, g: number, b: number): boolean;
  5666. /**
  5667. * Multiplies in place each rgb value by scale
  5668. * @param scale defines the scaling factor
  5669. * @returns the updated Color3
  5670. */
  5671. scale(scale: number): Color3;
  5672. /**
  5673. * Multiplies the rgb values by scale and stores the result into "result"
  5674. * @param scale defines the scaling factor
  5675. * @param result defines the Color3 object where to store the result
  5676. * @returns the unmodified current Color3
  5677. */
  5678. scaleToRef(scale: number, result: Color3): Color3;
  5679. /**
  5680. * Scale the current Color3 values by a factor and add the result to a given Color3
  5681. * @param scale defines the scale factor
  5682. * @param result defines color to store the result into
  5683. * @returns the unmodified current Color3
  5684. */
  5685. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5686. /**
  5687. * Clamps the rgb values by the min and max values and stores the result into "result"
  5688. * @param min defines minimum clamping value (default is 0)
  5689. * @param max defines maximum clamping value (default is 1)
  5690. * @param result defines color to store the result into
  5691. * @returns the original Color3
  5692. */
  5693. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5694. /**
  5695. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5696. * @param otherColor defines the second operand
  5697. * @returns the new Color3
  5698. */
  5699. add(otherColor: DeepImmutable<Color3>): Color3;
  5700. /**
  5701. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5702. * @param otherColor defines the second operand
  5703. * @param result defines Color3 object to store the result into
  5704. * @returns the unmodified current Color3
  5705. */
  5706. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5707. /**
  5708. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5709. * @param otherColor defines the second operand
  5710. * @returns the new Color3
  5711. */
  5712. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5713. /**
  5714. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5715. * @param otherColor defines the second operand
  5716. * @param result defines Color3 object to store the result into
  5717. * @returns the unmodified current Color3
  5718. */
  5719. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5720. /**
  5721. * Copy the current object
  5722. * @returns a new Color3 copied the current one
  5723. */
  5724. clone(): Color3;
  5725. /**
  5726. * Copies the rgb values from the source in the current Color3
  5727. * @param source defines the source Color3 object
  5728. * @returns the updated Color3 object
  5729. */
  5730. copyFrom(source: DeepImmutable<Color3>): Color3;
  5731. /**
  5732. * Updates the Color3 rgb values from the given floats
  5733. * @param r defines the red component to read from
  5734. * @param g defines the green component to read from
  5735. * @param b defines the blue component to read from
  5736. * @returns the current Color3 object
  5737. */
  5738. copyFromFloats(r: number, g: number, b: number): Color3;
  5739. /**
  5740. * Updates the Color3 rgb values from the given floats
  5741. * @param r defines the red component to read from
  5742. * @param g defines the green component to read from
  5743. * @param b defines the blue component to read from
  5744. * @returns the current Color3 object
  5745. */
  5746. set(r: number, g: number, b: number): Color3;
  5747. /**
  5748. * Compute the Color3 hexadecimal code as a string
  5749. * @returns a string containing the hexadecimal representation of the Color3 object
  5750. */
  5751. toHexString(): string;
  5752. /**
  5753. * Computes a new Color3 converted from the current one to linear space
  5754. * @returns a new Color3 object
  5755. */
  5756. toLinearSpace(): Color3;
  5757. /**
  5758. * Converts current color in rgb space to HSV values
  5759. * @returns a new color3 representing the HSV values
  5760. */
  5761. toHSV(): Color3;
  5762. /**
  5763. * Converts current color in rgb space to HSV values
  5764. * @param result defines the Color3 where to store the HSV values
  5765. */
  5766. toHSVToRef(result: Color3): void;
  5767. /**
  5768. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5769. * @param convertedColor defines the Color3 object where to store the linear space version
  5770. * @returns the unmodified Color3
  5771. */
  5772. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5773. /**
  5774. * Computes a new Color3 converted from the current one to gamma space
  5775. * @returns a new Color3 object
  5776. */
  5777. toGammaSpace(): Color3;
  5778. /**
  5779. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5780. * @param convertedColor defines the Color3 object where to store the gamma space version
  5781. * @returns the unmodified Color3
  5782. */
  5783. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5784. private static _BlackReadOnly;
  5785. /**
  5786. * Convert Hue, saturation and value to a Color3 (RGB)
  5787. * @param hue defines the hue
  5788. * @param saturation defines the saturation
  5789. * @param value defines the value
  5790. * @param result defines the Color3 where to store the RGB values
  5791. */
  5792. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5793. /**
  5794. * Creates a new Color3 from the string containing valid hexadecimal values
  5795. * @param hex defines a string containing valid hexadecimal values
  5796. * @returns a new Color3 object
  5797. */
  5798. static FromHexString(hex: string): Color3;
  5799. /**
  5800. * Creates a new Color3 from the starting index of the given array
  5801. * @param array defines the source array
  5802. * @param offset defines an offset in the source array
  5803. * @returns a new Color3 object
  5804. */
  5805. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5806. /**
  5807. * Creates a new Color3 from the starting index element of the given array
  5808. * @param array defines the source array to read from
  5809. * @param offset defines the offset in the source array
  5810. * @param result defines the target Color3 object
  5811. */
  5812. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5813. /**
  5814. * Creates a new Color3 from integer values (< 256)
  5815. * @param r defines the red component to read from (value between 0 and 255)
  5816. * @param g defines the green component to read from (value between 0 and 255)
  5817. * @param b defines the blue component to read from (value between 0 and 255)
  5818. * @returns a new Color3 object
  5819. */
  5820. static FromInts(r: number, g: number, b: number): Color3;
  5821. /**
  5822. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5823. * @param start defines the start Color3 value
  5824. * @param end defines the end Color3 value
  5825. * @param amount defines the gradient value between start and end
  5826. * @returns a new Color3 object
  5827. */
  5828. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5829. /**
  5830. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5831. * @param left defines the start value
  5832. * @param right defines the end value
  5833. * @param amount defines the gradient factor
  5834. * @param result defines the Color3 object where to store the result
  5835. */
  5836. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5837. /**
  5838. * Returns a Color3 value containing a red color
  5839. * @returns a new Color3 object
  5840. */
  5841. static Red(): Color3;
  5842. /**
  5843. * Returns a Color3 value containing a green color
  5844. * @returns a new Color3 object
  5845. */
  5846. static Green(): Color3;
  5847. /**
  5848. * Returns a Color3 value containing a blue color
  5849. * @returns a new Color3 object
  5850. */
  5851. static Blue(): Color3;
  5852. /**
  5853. * Returns a Color3 value containing a black color
  5854. * @returns a new Color3 object
  5855. */
  5856. static Black(): Color3;
  5857. /**
  5858. * Gets a Color3 value containing a black color that must not be updated
  5859. */
  5860. static get BlackReadOnly(): DeepImmutable<Color3>;
  5861. /**
  5862. * Returns a Color3 value containing a white color
  5863. * @returns a new Color3 object
  5864. */
  5865. static White(): Color3;
  5866. /**
  5867. * Returns a Color3 value containing a purple color
  5868. * @returns a new Color3 object
  5869. */
  5870. static Purple(): Color3;
  5871. /**
  5872. * Returns a Color3 value containing a magenta color
  5873. * @returns a new Color3 object
  5874. */
  5875. static Magenta(): Color3;
  5876. /**
  5877. * Returns a Color3 value containing a yellow color
  5878. * @returns a new Color3 object
  5879. */
  5880. static Yellow(): Color3;
  5881. /**
  5882. * Returns a Color3 value containing a gray color
  5883. * @returns a new Color3 object
  5884. */
  5885. static Gray(): Color3;
  5886. /**
  5887. * Returns a Color3 value containing a teal color
  5888. * @returns a new Color3 object
  5889. */
  5890. static Teal(): Color3;
  5891. /**
  5892. * Returns a Color3 value containing a random color
  5893. * @returns a new Color3 object
  5894. */
  5895. static Random(): Color3;
  5896. }
  5897. /**
  5898. * Class used to hold a RBGA color
  5899. */
  5900. export class Color4 {
  5901. /**
  5902. * Defines the red component (between 0 and 1, default is 0)
  5903. */
  5904. r: number;
  5905. /**
  5906. * Defines the green component (between 0 and 1, default is 0)
  5907. */
  5908. g: number;
  5909. /**
  5910. * Defines the blue component (between 0 and 1, default is 0)
  5911. */
  5912. b: number;
  5913. /**
  5914. * Defines the alpha component (between 0 and 1, default is 1)
  5915. */
  5916. a: number;
  5917. /**
  5918. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5919. * @param r defines the red component (between 0 and 1, default is 0)
  5920. * @param g defines the green component (between 0 and 1, default is 0)
  5921. * @param b defines the blue component (between 0 and 1, default is 0)
  5922. * @param a defines the alpha component (between 0 and 1, default is 1)
  5923. */
  5924. constructor(
  5925. /**
  5926. * Defines the red component (between 0 and 1, default is 0)
  5927. */
  5928. r?: number,
  5929. /**
  5930. * Defines the green component (between 0 and 1, default is 0)
  5931. */
  5932. g?: number,
  5933. /**
  5934. * Defines the blue component (between 0 and 1, default is 0)
  5935. */
  5936. b?: number,
  5937. /**
  5938. * Defines the alpha component (between 0 and 1, default is 1)
  5939. */
  5940. a?: number);
  5941. /**
  5942. * Adds in place the given Color4 values to the current Color4 object
  5943. * @param right defines the second operand
  5944. * @returns the current updated Color4 object
  5945. */
  5946. addInPlace(right: DeepImmutable<Color4>): Color4;
  5947. /**
  5948. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5949. * @returns the new array
  5950. */
  5951. asArray(): number[];
  5952. /**
  5953. * Stores from the starting index in the given array the Color4 successive values
  5954. * @param array defines the array where to store the r,g,b components
  5955. * @param index defines an optional index in the target array to define where to start storing values
  5956. * @returns the current Color4 object
  5957. */
  5958. toArray(array: number[], index?: number): Color4;
  5959. /**
  5960. * Update the current color with values stored in an array from the starting index of the given array
  5961. * @param array defines the source array
  5962. * @param offset defines an offset in the source array
  5963. * @returns the current Color4 object
  5964. */
  5965. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5966. /**
  5967. * Determines equality between Color4 objects
  5968. * @param otherColor defines the second operand
  5969. * @returns true if the rgba values are equal to the given ones
  5970. */
  5971. equals(otherColor: DeepImmutable<Color4>): boolean;
  5972. /**
  5973. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5974. * @param right defines the second operand
  5975. * @returns a new Color4 object
  5976. */
  5977. add(right: DeepImmutable<Color4>): Color4;
  5978. /**
  5979. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5980. * @param right defines the second operand
  5981. * @returns a new Color4 object
  5982. */
  5983. subtract(right: DeepImmutable<Color4>): Color4;
  5984. /**
  5985. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5986. * @param right defines the second operand
  5987. * @param result defines the Color4 object where to store the result
  5988. * @returns the current Color4 object
  5989. */
  5990. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5991. /**
  5992. * Creates a new Color4 with the current Color4 values multiplied by scale
  5993. * @param scale defines the scaling factor to apply
  5994. * @returns a new Color4 object
  5995. */
  5996. scale(scale: number): Color4;
  5997. /**
  5998. * Multiplies the current Color4 values by scale and stores the result in "result"
  5999. * @param scale defines the scaling factor to apply
  6000. * @param result defines the Color4 object where to store the result
  6001. * @returns the current unmodified Color4
  6002. */
  6003. scaleToRef(scale: number, result: Color4): Color4;
  6004. /**
  6005. * Scale the current Color4 values by a factor and add the result to a given Color4
  6006. * @param scale defines the scale factor
  6007. * @param result defines the Color4 object where to store the result
  6008. * @returns the unmodified current Color4
  6009. */
  6010. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6011. /**
  6012. * Clamps the rgb values by the min and max values and stores the result into "result"
  6013. * @param min defines minimum clamping value (default is 0)
  6014. * @param max defines maximum clamping value (default is 1)
  6015. * @param result defines color to store the result into.
  6016. * @returns the cuurent Color4
  6017. */
  6018. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6019. /**
  6020. * Multipy an Color4 value by another and return a new Color4 object
  6021. * @param color defines the Color4 value to multiply by
  6022. * @returns a new Color4 object
  6023. */
  6024. multiply(color: Color4): Color4;
  6025. /**
  6026. * Multipy a Color4 value by another and push the result in a reference value
  6027. * @param color defines the Color4 value to multiply by
  6028. * @param result defines the Color4 to fill the result in
  6029. * @returns the result Color4
  6030. */
  6031. multiplyToRef(color: Color4, result: Color4): Color4;
  6032. /**
  6033. * Creates a string with the Color4 current values
  6034. * @returns the string representation of the Color4 object
  6035. */
  6036. toString(): string;
  6037. /**
  6038. * Returns the string "Color4"
  6039. * @returns "Color4"
  6040. */
  6041. getClassName(): string;
  6042. /**
  6043. * Compute the Color4 hash code
  6044. * @returns an unique number that can be used to hash Color4 objects
  6045. */
  6046. getHashCode(): number;
  6047. /**
  6048. * Creates a new Color4 copied from the current one
  6049. * @returns a new Color4 object
  6050. */
  6051. clone(): Color4;
  6052. /**
  6053. * Copies the given Color4 values into the current one
  6054. * @param source defines the source Color4 object
  6055. * @returns the current updated Color4 object
  6056. */
  6057. copyFrom(source: Color4): Color4;
  6058. /**
  6059. * Copies the given float values into the current one
  6060. * @param r defines the red component to read from
  6061. * @param g defines the green component to read from
  6062. * @param b defines the blue component to read from
  6063. * @param a defines the alpha component to read from
  6064. * @returns the current updated Color4 object
  6065. */
  6066. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6067. /**
  6068. * Copies the given float values into the current one
  6069. * @param r defines the red component to read from
  6070. * @param g defines the green component to read from
  6071. * @param b defines the blue component to read from
  6072. * @param a defines the alpha component to read from
  6073. * @returns the current updated Color4 object
  6074. */
  6075. set(r: number, g: number, b: number, a: number): Color4;
  6076. /**
  6077. * Compute the Color4 hexadecimal code as a string
  6078. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6079. * @returns a string containing the hexadecimal representation of the Color4 object
  6080. */
  6081. toHexString(returnAsColor3?: boolean): string;
  6082. /**
  6083. * Computes a new Color4 converted from the current one to linear space
  6084. * @returns a new Color4 object
  6085. */
  6086. toLinearSpace(): Color4;
  6087. /**
  6088. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6089. * @param convertedColor defines the Color4 object where to store the linear space version
  6090. * @returns the unmodified Color4
  6091. */
  6092. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6093. /**
  6094. * Computes a new Color4 converted from the current one to gamma space
  6095. * @returns a new Color4 object
  6096. */
  6097. toGammaSpace(): Color4;
  6098. /**
  6099. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6100. * @param convertedColor defines the Color4 object where to store the gamma space version
  6101. * @returns the unmodified Color4
  6102. */
  6103. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6104. /**
  6105. * Creates a new Color4 from the string containing valid hexadecimal values
  6106. * @param hex defines a string containing valid hexadecimal values
  6107. * @returns a new Color4 object
  6108. */
  6109. static FromHexString(hex: string): Color4;
  6110. /**
  6111. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6112. * @param left defines the start value
  6113. * @param right defines the end value
  6114. * @param amount defines the gradient factor
  6115. * @returns a new Color4 object
  6116. */
  6117. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6118. /**
  6119. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6120. * @param left defines the start value
  6121. * @param right defines the end value
  6122. * @param amount defines the gradient factor
  6123. * @param result defines the Color4 object where to store data
  6124. */
  6125. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6126. /**
  6127. * Creates a new Color4 from a Color3 and an alpha value
  6128. * @param color3 defines the source Color3 to read from
  6129. * @param alpha defines the alpha component (1.0 by default)
  6130. * @returns a new Color4 object
  6131. */
  6132. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6133. /**
  6134. * Creates a new Color4 from the starting index element of the given array
  6135. * @param array defines the source array to read from
  6136. * @param offset defines the offset in the source array
  6137. * @returns a new Color4 object
  6138. */
  6139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6140. /**
  6141. * Creates a new Color4 from the starting index element of the given array
  6142. * @param array defines the source array to read from
  6143. * @param offset defines the offset in the source array
  6144. * @param result defines the target Color4 object
  6145. */
  6146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6147. /**
  6148. * Creates a new Color3 from integer values (< 256)
  6149. * @param r defines the red component to read from (value between 0 and 255)
  6150. * @param g defines the green component to read from (value between 0 and 255)
  6151. * @param b defines the blue component to read from (value between 0 and 255)
  6152. * @param a defines the alpha component to read from (value between 0 and 255)
  6153. * @returns a new Color3 object
  6154. */
  6155. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6156. /**
  6157. * Check the content of a given array and convert it to an array containing RGBA data
  6158. * If the original array was already containing count * 4 values then it is returned directly
  6159. * @param colors defines the array to check
  6160. * @param count defines the number of RGBA data to expect
  6161. * @returns an array containing count * 4 values (RGBA)
  6162. */
  6163. static CheckColors4(colors: number[], count: number): number[];
  6164. }
  6165. /**
  6166. * @hidden
  6167. */
  6168. export class TmpColors {
  6169. static Color3: Color3[];
  6170. static Color4: Color4[];
  6171. }
  6172. }
  6173. declare module "babylonjs/Animations/animationKey" {
  6174. /**
  6175. * Defines an interface which represents an animation key frame
  6176. */
  6177. export interface IAnimationKey {
  6178. /**
  6179. * Frame of the key frame
  6180. */
  6181. frame: number;
  6182. /**
  6183. * Value at the specifies key frame
  6184. */
  6185. value: any;
  6186. /**
  6187. * The input tangent for the cubic hermite spline
  6188. */
  6189. inTangent?: any;
  6190. /**
  6191. * The output tangent for the cubic hermite spline
  6192. */
  6193. outTangent?: any;
  6194. /**
  6195. * The animation interpolation type
  6196. */
  6197. interpolation?: AnimationKeyInterpolation;
  6198. }
  6199. /**
  6200. * Enum for the animation key frame interpolation type
  6201. */
  6202. export enum AnimationKeyInterpolation {
  6203. /**
  6204. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6205. */
  6206. STEP = 1
  6207. }
  6208. }
  6209. declare module "babylonjs/Animations/animationRange" {
  6210. /**
  6211. * Represents the range of an animation
  6212. */
  6213. export class AnimationRange {
  6214. /**The name of the animation range**/
  6215. name: string;
  6216. /**The starting frame of the animation */
  6217. from: number;
  6218. /**The ending frame of the animation*/
  6219. to: number;
  6220. /**
  6221. * Initializes the range of an animation
  6222. * @param name The name of the animation range
  6223. * @param from The starting frame of the animation
  6224. * @param to The ending frame of the animation
  6225. */
  6226. constructor(
  6227. /**The name of the animation range**/
  6228. name: string,
  6229. /**The starting frame of the animation */
  6230. from: number,
  6231. /**The ending frame of the animation*/
  6232. to: number);
  6233. /**
  6234. * Makes a copy of the animation range
  6235. * @returns A copy of the animation range
  6236. */
  6237. clone(): AnimationRange;
  6238. }
  6239. }
  6240. declare module "babylonjs/Animations/animationEvent" {
  6241. /**
  6242. * Composed of a frame, and an action function
  6243. */
  6244. export class AnimationEvent {
  6245. /** The frame for which the event is triggered **/
  6246. frame: number;
  6247. /** The event to perform when triggered **/
  6248. action: (currentFrame: number) => void;
  6249. /** Specifies if the event should be triggered only once**/
  6250. onlyOnce?: boolean | undefined;
  6251. /**
  6252. * Specifies if the animation event is done
  6253. */
  6254. isDone: boolean;
  6255. /**
  6256. * Initializes the animation event
  6257. * @param frame The frame for which the event is triggered
  6258. * @param action The event to perform when triggered
  6259. * @param onlyOnce Specifies if the event should be triggered only once
  6260. */
  6261. constructor(
  6262. /** The frame for which the event is triggered **/
  6263. frame: number,
  6264. /** The event to perform when triggered **/
  6265. action: (currentFrame: number) => void,
  6266. /** Specifies if the event should be triggered only once**/
  6267. onlyOnce?: boolean | undefined);
  6268. /** @hidden */
  6269. _clone(): AnimationEvent;
  6270. }
  6271. }
  6272. declare module "babylonjs/Behaviors/behavior" {
  6273. import { Nullable } from "babylonjs/types";
  6274. /**
  6275. * Interface used to define a behavior
  6276. */
  6277. export interface Behavior<T> {
  6278. /** gets or sets behavior's name */
  6279. name: string;
  6280. /**
  6281. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6282. */
  6283. init(): void;
  6284. /**
  6285. * Called when the behavior is attached to a target
  6286. * @param target defines the target where the behavior is attached to
  6287. */
  6288. attach(target: T): void;
  6289. /**
  6290. * Called when the behavior is detached from its target
  6291. */
  6292. detach(): void;
  6293. }
  6294. /**
  6295. * Interface implemented by classes supporting behaviors
  6296. */
  6297. export interface IBehaviorAware<T> {
  6298. /**
  6299. * Attach a behavior
  6300. * @param behavior defines the behavior to attach
  6301. * @returns the current host
  6302. */
  6303. addBehavior(behavior: Behavior<T>): T;
  6304. /**
  6305. * Remove a behavior from the current object
  6306. * @param behavior defines the behavior to detach
  6307. * @returns the current host
  6308. */
  6309. removeBehavior(behavior: Behavior<T>): T;
  6310. /**
  6311. * Gets a behavior using its name to search
  6312. * @param name defines the name to search
  6313. * @returns the behavior or null if not found
  6314. */
  6315. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6316. }
  6317. }
  6318. declare module "babylonjs/Misc/smartArray" {
  6319. /**
  6320. * Defines an array and its length.
  6321. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6322. */
  6323. export interface ISmartArrayLike<T> {
  6324. /**
  6325. * The data of the array.
  6326. */
  6327. data: Array<T>;
  6328. /**
  6329. * The active length of the array.
  6330. */
  6331. length: number;
  6332. }
  6333. /**
  6334. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6335. */
  6336. export class SmartArray<T> implements ISmartArrayLike<T> {
  6337. /**
  6338. * The full set of data from the array.
  6339. */
  6340. data: Array<T>;
  6341. /**
  6342. * The active length of the array.
  6343. */
  6344. length: number;
  6345. protected _id: number;
  6346. /**
  6347. * Instantiates a Smart Array.
  6348. * @param capacity defines the default capacity of the array.
  6349. */
  6350. constructor(capacity: number);
  6351. /**
  6352. * Pushes a value at the end of the active data.
  6353. * @param value defines the object to push in the array.
  6354. */
  6355. push(value: T): void;
  6356. /**
  6357. * Iterates over the active data and apply the lambda to them.
  6358. * @param func defines the action to apply on each value.
  6359. */
  6360. forEach(func: (content: T) => void): void;
  6361. /**
  6362. * Sorts the full sets of data.
  6363. * @param compareFn defines the comparison function to apply.
  6364. */
  6365. sort(compareFn: (a: T, b: T) => number): void;
  6366. /**
  6367. * Resets the active data to an empty array.
  6368. */
  6369. reset(): void;
  6370. /**
  6371. * Releases all the data from the array as well as the array.
  6372. */
  6373. dispose(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * @param array defines the data to concatenate with.
  6377. */
  6378. concat(array: any): void;
  6379. /**
  6380. * Returns the position of a value in the active data.
  6381. * @param value defines the value to find the index for
  6382. * @returns the index if found in the active data otherwise -1
  6383. */
  6384. indexOf(value: T): number;
  6385. /**
  6386. * Returns whether an element is part of the active data.
  6387. * @param value defines the value to look for
  6388. * @returns true if found in the active data otherwise false
  6389. */
  6390. contains(value: T): boolean;
  6391. private static _GlobalId;
  6392. }
  6393. /**
  6394. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6395. * The data in this array can only be present once
  6396. */
  6397. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6398. private _duplicateId;
  6399. /**
  6400. * Pushes a value at the end of the active data.
  6401. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6402. * @param value defines the object to push in the array.
  6403. */
  6404. push(value: T): void;
  6405. /**
  6406. * Pushes a value at the end of the active data.
  6407. * If the data is already present, it won t be added again
  6408. * @param value defines the object to push in the array.
  6409. * @returns true if added false if it was already present
  6410. */
  6411. pushNoDuplicate(value: T): boolean;
  6412. /**
  6413. * Resets the active data to an empty array.
  6414. */
  6415. reset(): void;
  6416. /**
  6417. * Concats the active data with a given array.
  6418. * This ensures no dupplicate will be present in the result.
  6419. * @param array defines the data to concatenate with.
  6420. */
  6421. concatWithNoDuplicate(array: any): void;
  6422. }
  6423. }
  6424. declare module "babylonjs/Cameras/cameraInputsManager" {
  6425. import { Nullable } from "babylonjs/types";
  6426. import { Camera } from "babylonjs/Cameras/camera";
  6427. /**
  6428. * @ignore
  6429. * This is a list of all the different input types that are available in the application.
  6430. * Fo instance: ArcRotateCameraGamepadInput...
  6431. */
  6432. export var CameraInputTypes: {};
  6433. /**
  6434. * This is the contract to implement in order to create a new input class.
  6435. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6436. */
  6437. export interface ICameraInput<TCamera extends Camera> {
  6438. /**
  6439. * Defines the camera the input is attached to.
  6440. */
  6441. camera: Nullable<TCamera>;
  6442. /**
  6443. * Gets the class name of the current intput.
  6444. * @returns the class name
  6445. */
  6446. getClassName(): string;
  6447. /**
  6448. * Get the friendly name associated with the input class.
  6449. * @returns the input friendly name
  6450. */
  6451. getSimpleName(): string;
  6452. /**
  6453. * Attach the input controls to a specific dom element to get the input from.
  6454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6455. */
  6456. attachControl(noPreventDefault?: boolean): void;
  6457. /**
  6458. * Detach the current controls from the specified dom element.
  6459. */
  6460. detachControl(): void;
  6461. /**
  6462. * Update the current camera state depending on the inputs that have been used this frame.
  6463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6464. */
  6465. checkInputs?: () => void;
  6466. }
  6467. /**
  6468. * Represents a map of input types to input instance or input index to input instance.
  6469. */
  6470. export interface CameraInputsMap<TCamera extends Camera> {
  6471. /**
  6472. * Accessor to the input by input type.
  6473. */
  6474. [name: string]: ICameraInput<TCamera>;
  6475. /**
  6476. * Accessor to the input by input index.
  6477. */
  6478. [idx: number]: ICameraInput<TCamera>;
  6479. }
  6480. /**
  6481. * This represents the input manager used within a camera.
  6482. * It helps dealing with all the different kind of input attached to a camera.
  6483. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6484. */
  6485. export class CameraInputsManager<TCamera extends Camera> {
  6486. /**
  6487. * Defines the list of inputs attahed to the camera.
  6488. */
  6489. attached: CameraInputsMap<TCamera>;
  6490. /**
  6491. * Defines the dom element the camera is collecting inputs from.
  6492. * This is null if the controls have not been attached.
  6493. */
  6494. attachedToElement: boolean;
  6495. /**
  6496. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6497. */
  6498. noPreventDefault: boolean;
  6499. /**
  6500. * Defined the camera the input manager belongs to.
  6501. */
  6502. camera: TCamera;
  6503. /**
  6504. * Update the current camera state depending on the inputs that have been used this frame.
  6505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6506. */
  6507. checkInputs: () => void;
  6508. /**
  6509. * Instantiate a new Camera Input Manager.
  6510. * @param camera Defines the camera the input manager blongs to
  6511. */
  6512. constructor(camera: TCamera);
  6513. /**
  6514. * Add an input method to a camera
  6515. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6516. * @param input camera input method
  6517. */
  6518. add(input: ICameraInput<TCamera>): void;
  6519. /**
  6520. * Remove a specific input method from a camera
  6521. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6522. * @param inputToRemove camera input method
  6523. */
  6524. remove(inputToRemove: ICameraInput<TCamera>): void;
  6525. /**
  6526. * Remove a specific input type from a camera
  6527. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6528. * @param inputType the type of the input to remove
  6529. */
  6530. removeByType(inputType: string): void;
  6531. private _addCheckInputs;
  6532. /**
  6533. * Attach the input controls to the currently attached dom element to listen the events from.
  6534. * @param input Defines the input to attach
  6535. */
  6536. attachInput(input: ICameraInput<TCamera>): void;
  6537. /**
  6538. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6539. * @param element Defines the dom element to collect the events from
  6540. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6541. */
  6542. attachElement(noPreventDefault?: boolean): void;
  6543. /**
  6544. * Detach the current manager inputs controls from a specific dom element.
  6545. * @param element Defines the dom element to collect the events from
  6546. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6547. */
  6548. detachElement(disconnect?: boolean): void;
  6549. /**
  6550. * Rebuild the dynamic inputCheck function from the current list of
  6551. * defined inputs in the manager.
  6552. */
  6553. rebuildInputCheck(): void;
  6554. /**
  6555. * Remove all attached input methods from a camera
  6556. */
  6557. clear(): void;
  6558. /**
  6559. * Serialize the current input manager attached to a camera.
  6560. * This ensures than once parsed,
  6561. * the input associated to the camera will be identical to the current ones
  6562. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6563. */
  6564. serialize(serializedCamera: any): void;
  6565. /**
  6566. * Parses an input manager serialized JSON to restore the previous list of inputs
  6567. * and states associated to a camera.
  6568. * @param parsedCamera Defines the JSON to parse
  6569. */
  6570. parse(parsedCamera: any): void;
  6571. }
  6572. }
  6573. declare module "babylonjs/Meshes/buffer" {
  6574. import { Nullable, DataArray } from "babylonjs/types";
  6575. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6576. /**
  6577. * Class used to store data that will be store in GPU memory
  6578. */
  6579. export class Buffer {
  6580. private _engine;
  6581. private _buffer;
  6582. /** @hidden */
  6583. _data: Nullable<DataArray>;
  6584. private _updatable;
  6585. private _instanced;
  6586. private _divisor;
  6587. /**
  6588. * Gets the byte stride.
  6589. */
  6590. readonly byteStride: number;
  6591. /**
  6592. * Constructor
  6593. * @param engine the engine
  6594. * @param data the data to use for this buffer
  6595. * @param updatable whether the data is updatable
  6596. * @param stride the stride (optional)
  6597. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6598. * @param instanced whether the buffer is instanced (optional)
  6599. * @param useBytes set to true if the stride in in bytes (optional)
  6600. * @param divisor sets an optional divisor for instances (1 by default)
  6601. */
  6602. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6603. /**
  6604. * Create a new VertexBuffer based on the current buffer
  6605. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6606. * @param offset defines offset in the buffer (0 by default)
  6607. * @param size defines the size in floats of attributes (position is 3 for instance)
  6608. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6609. * @param instanced defines if the vertex buffer contains indexed data
  6610. * @param useBytes defines if the offset and stride are in bytes *
  6611. * @param divisor sets an optional divisor for instances (1 by default)
  6612. * @returns the new vertex buffer
  6613. */
  6614. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6615. /**
  6616. * Gets a boolean indicating if the Buffer is updatable?
  6617. * @returns true if the buffer is updatable
  6618. */
  6619. isUpdatable(): boolean;
  6620. /**
  6621. * Gets current buffer's data
  6622. * @returns a DataArray or null
  6623. */
  6624. getData(): Nullable<DataArray>;
  6625. /**
  6626. * Gets underlying native buffer
  6627. * @returns underlying native buffer
  6628. */
  6629. getBuffer(): Nullable<DataBuffer>;
  6630. /**
  6631. * Gets the stride in float32 units (i.e. byte stride / 4).
  6632. * May not be an integer if the byte stride is not divisible by 4.
  6633. * @returns the stride in float32 units
  6634. * @deprecated Please use byteStride instead.
  6635. */
  6636. getStrideSize(): number;
  6637. /**
  6638. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6639. * @param data defines the data to store
  6640. */
  6641. create(data?: Nullable<DataArray>): void;
  6642. /** @hidden */
  6643. _rebuild(): void;
  6644. /**
  6645. * Update current buffer data
  6646. * @param data defines the data to store
  6647. */
  6648. update(data: DataArray): void;
  6649. /**
  6650. * Updates the data directly.
  6651. * @param data the new data
  6652. * @param offset the new offset
  6653. * @param vertexCount the vertex count (optional)
  6654. * @param useBytes set to true if the offset is in bytes
  6655. */
  6656. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6657. /**
  6658. * Release all resources
  6659. */
  6660. dispose(): void;
  6661. }
  6662. /**
  6663. * Specialized buffer used to store vertex data
  6664. */
  6665. export class VertexBuffer {
  6666. /** @hidden */
  6667. _buffer: Buffer;
  6668. private _kind;
  6669. private _size;
  6670. private _ownsBuffer;
  6671. private _instanced;
  6672. private _instanceDivisor;
  6673. /**
  6674. * The byte type.
  6675. */
  6676. static readonly BYTE: number;
  6677. /**
  6678. * The unsigned byte type.
  6679. */
  6680. static readonly UNSIGNED_BYTE: number;
  6681. /**
  6682. * The short type.
  6683. */
  6684. static readonly SHORT: number;
  6685. /**
  6686. * The unsigned short type.
  6687. */
  6688. static readonly UNSIGNED_SHORT: number;
  6689. /**
  6690. * The integer type.
  6691. */
  6692. static readonly INT: number;
  6693. /**
  6694. * The unsigned integer type.
  6695. */
  6696. static readonly UNSIGNED_INT: number;
  6697. /**
  6698. * The float type.
  6699. */
  6700. static readonly FLOAT: number;
  6701. /**
  6702. * Gets or sets the instance divisor when in instanced mode
  6703. */
  6704. get instanceDivisor(): number;
  6705. set instanceDivisor(value: number);
  6706. /**
  6707. * Gets the byte stride.
  6708. */
  6709. readonly byteStride: number;
  6710. /**
  6711. * Gets the byte offset.
  6712. */
  6713. readonly byteOffset: number;
  6714. /**
  6715. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6716. */
  6717. readonly normalized: boolean;
  6718. /**
  6719. * Gets the data type of each component in the array.
  6720. */
  6721. readonly type: number;
  6722. /**
  6723. * Constructor
  6724. * @param engine the engine
  6725. * @param data the data to use for this vertex buffer
  6726. * @param kind the vertex buffer kind
  6727. * @param updatable whether the data is updatable
  6728. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6729. * @param stride the stride (optional)
  6730. * @param instanced whether the buffer is instanced (optional)
  6731. * @param offset the offset of the data (optional)
  6732. * @param size the number of components (optional)
  6733. * @param type the type of the component (optional)
  6734. * @param normalized whether the data contains normalized data (optional)
  6735. * @param useBytes set to true if stride and offset are in bytes (optional)
  6736. * @param divisor defines the instance divisor to use (1 by default)
  6737. */
  6738. 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);
  6739. /** @hidden */
  6740. _rebuild(): void;
  6741. /**
  6742. * Returns the kind of the VertexBuffer (string)
  6743. * @returns a string
  6744. */
  6745. getKind(): string;
  6746. /**
  6747. * Gets a boolean indicating if the VertexBuffer is updatable?
  6748. * @returns true if the buffer is updatable
  6749. */
  6750. isUpdatable(): boolean;
  6751. /**
  6752. * Gets current buffer's data
  6753. * @returns a DataArray or null
  6754. */
  6755. getData(): Nullable<DataArray>;
  6756. /**
  6757. * Gets underlying native buffer
  6758. * @returns underlying native buffer
  6759. */
  6760. getBuffer(): Nullable<DataBuffer>;
  6761. /**
  6762. * Gets the stride in float32 units (i.e. byte stride / 4).
  6763. * May not be an integer if the byte stride is not divisible by 4.
  6764. * @returns the stride in float32 units
  6765. * @deprecated Please use byteStride instead.
  6766. */
  6767. getStrideSize(): number;
  6768. /**
  6769. * Returns the offset as a multiple of the type byte length.
  6770. * @returns the offset in bytes
  6771. * @deprecated Please use byteOffset instead.
  6772. */
  6773. getOffset(): number;
  6774. /**
  6775. * Returns the number of components per vertex attribute (integer)
  6776. * @returns the size in float
  6777. */
  6778. getSize(): number;
  6779. /**
  6780. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6781. * @returns true if this buffer is instanced
  6782. */
  6783. getIsInstanced(): boolean;
  6784. /**
  6785. * Returns the instancing divisor, zero for non-instanced (integer).
  6786. * @returns a number
  6787. */
  6788. getInstanceDivisor(): number;
  6789. /**
  6790. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6791. * @param data defines the data to store
  6792. */
  6793. create(data?: DataArray): void;
  6794. /**
  6795. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6796. * This function will create a new buffer if the current one is not updatable
  6797. * @param data defines the data to store
  6798. */
  6799. update(data: DataArray): void;
  6800. /**
  6801. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6802. * Returns the directly updated WebGLBuffer.
  6803. * @param data the new data
  6804. * @param offset the new offset
  6805. * @param useBytes set to true if the offset is in bytes
  6806. */
  6807. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6808. /**
  6809. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6810. */
  6811. dispose(): void;
  6812. /**
  6813. * Enumerates each value of this vertex buffer as numbers.
  6814. * @param count the number of values to enumerate
  6815. * @param callback the callback function called for each value
  6816. */
  6817. forEach(count: number, callback: (value: number, index: number) => void): void;
  6818. /**
  6819. * Positions
  6820. */
  6821. static readonly PositionKind: string;
  6822. /**
  6823. * Normals
  6824. */
  6825. static readonly NormalKind: string;
  6826. /**
  6827. * Tangents
  6828. */
  6829. static readonly TangentKind: string;
  6830. /**
  6831. * Texture coordinates
  6832. */
  6833. static readonly UVKind: string;
  6834. /**
  6835. * Texture coordinates 2
  6836. */
  6837. static readonly UV2Kind: string;
  6838. /**
  6839. * Texture coordinates 3
  6840. */
  6841. static readonly UV3Kind: string;
  6842. /**
  6843. * Texture coordinates 4
  6844. */
  6845. static readonly UV4Kind: string;
  6846. /**
  6847. * Texture coordinates 5
  6848. */
  6849. static readonly UV5Kind: string;
  6850. /**
  6851. * Texture coordinates 6
  6852. */
  6853. static readonly UV6Kind: string;
  6854. /**
  6855. * Colors
  6856. */
  6857. static readonly ColorKind: string;
  6858. /**
  6859. * Matrix indices (for bones)
  6860. */
  6861. static readonly MatricesIndicesKind: string;
  6862. /**
  6863. * Matrix weights (for bones)
  6864. */
  6865. static readonly MatricesWeightsKind: string;
  6866. /**
  6867. * Additional matrix indices (for bones)
  6868. */
  6869. static readonly MatricesIndicesExtraKind: string;
  6870. /**
  6871. * Additional matrix weights (for bones)
  6872. */
  6873. static readonly MatricesWeightsExtraKind: string;
  6874. /**
  6875. * Deduces the stride given a kind.
  6876. * @param kind The kind string to deduce
  6877. * @returns The deduced stride
  6878. */
  6879. static DeduceStride(kind: string): number;
  6880. /**
  6881. * Gets the byte length of the given type.
  6882. * @param type the type
  6883. * @returns the number of bytes
  6884. */
  6885. static GetTypeByteLength(type: number): number;
  6886. /**
  6887. * Enumerates each value of the given parameters as numbers.
  6888. * @param data the data to enumerate
  6889. * @param byteOffset the byte offset of the data
  6890. * @param byteStride the byte stride of the data
  6891. * @param componentCount the number of components per element
  6892. * @param componentType the type of the component
  6893. * @param count the number of values to enumerate
  6894. * @param normalized whether the data is normalized
  6895. * @param callback the callback function called for each value
  6896. */
  6897. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6898. private static _GetFloatValue;
  6899. }
  6900. }
  6901. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6902. import { Vector3 } from "babylonjs/Maths/math.vector";
  6903. import { Mesh } from "babylonjs/Meshes/mesh";
  6904. /**
  6905. * The options Interface for creating a Capsule Mesh
  6906. */
  6907. export interface ICreateCapsuleOptions {
  6908. /** The Orientation of the capsule. Default : Vector3.Up() */
  6909. orientation?: Vector3;
  6910. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6911. subdivisions: number;
  6912. /** Number of cylindrical segments on the capsule. */
  6913. tessellation: number;
  6914. /** Height or Length of the capsule. */
  6915. height: number;
  6916. /** Radius of the capsule. */
  6917. radius: number;
  6918. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6919. capSubdivisions: number;
  6920. /** Overwrite for the top radius. */
  6921. radiusTop?: number;
  6922. /** Overwrite for the bottom radius. */
  6923. radiusBottom?: number;
  6924. /** Overwrite for the top capSubdivisions. */
  6925. topCapSubdivisions?: number;
  6926. /** Overwrite for the bottom capSubdivisions. */
  6927. bottomCapSubdivisions?: number;
  6928. }
  6929. /**
  6930. * Class containing static functions to help procedurally build meshes
  6931. */
  6932. export class CapsuleBuilder {
  6933. /**
  6934. * Creates a capsule or a pill mesh
  6935. * @param name defines the name of the mesh
  6936. * @param options The constructors options.
  6937. * @param scene The scene the mesh is scoped to.
  6938. * @returns Capsule Mesh
  6939. */
  6940. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6941. }
  6942. }
  6943. declare module "babylonjs/Collisions/intersectionInfo" {
  6944. import { Nullable } from "babylonjs/types";
  6945. /**
  6946. * @hidden
  6947. */
  6948. export class IntersectionInfo {
  6949. bu: Nullable<number>;
  6950. bv: Nullable<number>;
  6951. distance: number;
  6952. faceId: number;
  6953. subMeshId: number;
  6954. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6955. }
  6956. }
  6957. declare module "babylonjs/Culling/boundingSphere" {
  6958. import { DeepImmutable } from "babylonjs/types";
  6959. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6960. import { Plane } from "babylonjs/Maths/math.plane";
  6961. /**
  6962. * Class used to store bounding sphere information
  6963. */
  6964. export class BoundingSphere {
  6965. /**
  6966. * Gets the center of the bounding sphere in local space
  6967. */
  6968. readonly center: Vector3;
  6969. /**
  6970. * Radius of the bounding sphere in local space
  6971. */
  6972. radius: number;
  6973. /**
  6974. * Gets the center of the bounding sphere in world space
  6975. */
  6976. readonly centerWorld: Vector3;
  6977. /**
  6978. * Radius of the bounding sphere in world space
  6979. */
  6980. radiusWorld: number;
  6981. /**
  6982. * Gets the minimum vector in local space
  6983. */
  6984. readonly minimum: Vector3;
  6985. /**
  6986. * Gets the maximum vector in local space
  6987. */
  6988. readonly maximum: Vector3;
  6989. private _worldMatrix;
  6990. private static readonly TmpVector3;
  6991. /**
  6992. * Creates a new bounding sphere
  6993. * @param min defines the minimum vector (in local space)
  6994. * @param max defines the maximum vector (in local space)
  6995. * @param worldMatrix defines the new world matrix
  6996. */
  6997. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6998. /**
  6999. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7000. * @param min defines the new minimum vector (in local space)
  7001. * @param max defines the new maximum vector (in local space)
  7002. * @param worldMatrix defines the new world matrix
  7003. */
  7004. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7005. /**
  7006. * Scale the current bounding sphere by applying a scale factor
  7007. * @param factor defines the scale factor to apply
  7008. * @returns the current bounding box
  7009. */
  7010. scale(factor: number): BoundingSphere;
  7011. /**
  7012. * Gets the world matrix of the bounding box
  7013. * @returns a matrix
  7014. */
  7015. getWorldMatrix(): DeepImmutable<Matrix>;
  7016. /** @hidden */
  7017. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7018. /**
  7019. * Tests if the bounding sphere is intersecting the frustum planes
  7020. * @param frustumPlanes defines the frustum planes to test
  7021. * @returns true if there is an intersection
  7022. */
  7023. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7024. /**
  7025. * Tests if the bounding sphere center is in between the frustum planes.
  7026. * Used for optimistic fast inclusion.
  7027. * @param frustumPlanes defines the frustum planes to test
  7028. * @returns true if the sphere center is in between the frustum planes
  7029. */
  7030. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7031. /**
  7032. * Tests if a point is inside the bounding sphere
  7033. * @param point defines the point to test
  7034. * @returns true if the point is inside the bounding sphere
  7035. */
  7036. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7037. /**
  7038. * Checks if two sphere intersct
  7039. * @param sphere0 sphere 0
  7040. * @param sphere1 sphere 1
  7041. * @returns true if the speres intersect
  7042. */
  7043. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7044. }
  7045. }
  7046. declare module "babylonjs/Culling/boundingBox" {
  7047. import { DeepImmutable } from "babylonjs/types";
  7048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7049. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7050. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7051. import { Plane } from "babylonjs/Maths/math.plane";
  7052. /**
  7053. * Class used to store bounding box information
  7054. */
  7055. export class BoundingBox implements ICullable {
  7056. /**
  7057. * Gets the 8 vectors representing the bounding box in local space
  7058. */
  7059. readonly vectors: Vector3[];
  7060. /**
  7061. * Gets the center of the bounding box in local space
  7062. */
  7063. readonly center: Vector3;
  7064. /**
  7065. * Gets the center of the bounding box in world space
  7066. */
  7067. readonly centerWorld: Vector3;
  7068. /**
  7069. * Gets the extend size in local space
  7070. */
  7071. readonly extendSize: Vector3;
  7072. /**
  7073. * Gets the extend size in world space
  7074. */
  7075. readonly extendSizeWorld: Vector3;
  7076. /**
  7077. * Gets the OBB (object bounding box) directions
  7078. */
  7079. readonly directions: Vector3[];
  7080. /**
  7081. * Gets the 8 vectors representing the bounding box in world space
  7082. */
  7083. readonly vectorsWorld: Vector3[];
  7084. /**
  7085. * Gets the minimum vector in world space
  7086. */
  7087. readonly minimumWorld: Vector3;
  7088. /**
  7089. * Gets the maximum vector in world space
  7090. */
  7091. readonly maximumWorld: Vector3;
  7092. /**
  7093. * Gets the minimum vector in local space
  7094. */
  7095. readonly minimum: Vector3;
  7096. /**
  7097. * Gets the maximum vector in local space
  7098. */
  7099. readonly maximum: Vector3;
  7100. private _worldMatrix;
  7101. private static readonly TmpVector3;
  7102. /**
  7103. * @hidden
  7104. */
  7105. _tag: number;
  7106. /**
  7107. * Creates a new bounding box
  7108. * @param min defines the minimum vector (in local space)
  7109. * @param max defines the maximum vector (in local space)
  7110. * @param worldMatrix defines the new world matrix
  7111. */
  7112. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7113. /**
  7114. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7115. * @param min defines the new minimum vector (in local space)
  7116. * @param max defines the new maximum vector (in local space)
  7117. * @param worldMatrix defines the new world matrix
  7118. */
  7119. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7120. /**
  7121. * Scale the current bounding box by applying a scale factor
  7122. * @param factor defines the scale factor to apply
  7123. * @returns the current bounding box
  7124. */
  7125. scale(factor: number): BoundingBox;
  7126. /**
  7127. * Gets the world matrix of the bounding box
  7128. * @returns a matrix
  7129. */
  7130. getWorldMatrix(): DeepImmutable<Matrix>;
  7131. /** @hidden */
  7132. _update(world: DeepImmutable<Matrix>): void;
  7133. /**
  7134. * Tests if the bounding box is intersecting the frustum planes
  7135. * @param frustumPlanes defines the frustum planes to test
  7136. * @returns true if there is an intersection
  7137. */
  7138. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7139. /**
  7140. * Tests if the bounding box is entirely inside the frustum planes
  7141. * @param frustumPlanes defines the frustum planes to test
  7142. * @returns true if there is an inclusion
  7143. */
  7144. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7145. /**
  7146. * Tests if a point is inside the bounding box
  7147. * @param point defines the point to test
  7148. * @returns true if the point is inside the bounding box
  7149. */
  7150. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7151. /**
  7152. * Tests if the bounding box intersects with a bounding sphere
  7153. * @param sphere defines the sphere to test
  7154. * @returns true if there is an intersection
  7155. */
  7156. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7157. /**
  7158. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7159. * @param min defines the min vector to use
  7160. * @param max defines the max vector to use
  7161. * @returns true if there is an intersection
  7162. */
  7163. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7164. /**
  7165. * Tests if two bounding boxes are intersections
  7166. * @param box0 defines the first box to test
  7167. * @param box1 defines the second box to test
  7168. * @returns true if there is an intersection
  7169. */
  7170. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7171. /**
  7172. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7173. * @param minPoint defines the minimum vector of the bounding box
  7174. * @param maxPoint defines the maximum vector of the bounding box
  7175. * @param sphereCenter defines the sphere center
  7176. * @param sphereRadius defines the sphere radius
  7177. * @returns true if there is an intersection
  7178. */
  7179. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7180. /**
  7181. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7182. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7183. * @param frustumPlanes defines the frustum planes to test
  7184. * @return true if there is an inclusion
  7185. */
  7186. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7187. /**
  7188. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7189. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7190. * @param frustumPlanes defines the frustum planes to test
  7191. * @return true if there is an intersection
  7192. */
  7193. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7194. }
  7195. }
  7196. declare module "babylonjs/Collisions/collider" {
  7197. import { Nullable, IndicesArray } from "babylonjs/types";
  7198. import { Vector3 } from "babylonjs/Maths/math.vector";
  7199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7200. import { Plane } from "babylonjs/Maths/math.plane";
  7201. /** @hidden */
  7202. export class Collider {
  7203. /** Define if a collision was found */
  7204. collisionFound: boolean;
  7205. /**
  7206. * Define last intersection point in local space
  7207. */
  7208. intersectionPoint: Vector3;
  7209. /**
  7210. * Define last collided mesh
  7211. */
  7212. collidedMesh: Nullable<AbstractMesh>;
  7213. private _collisionPoint;
  7214. private _planeIntersectionPoint;
  7215. private _tempVector;
  7216. private _tempVector2;
  7217. private _tempVector3;
  7218. private _tempVector4;
  7219. private _edge;
  7220. private _baseToVertex;
  7221. private _destinationPoint;
  7222. private _slidePlaneNormal;
  7223. private _displacementVector;
  7224. /** @hidden */
  7225. _radius: Vector3;
  7226. /** @hidden */
  7227. _retry: number;
  7228. private _velocity;
  7229. private _basePoint;
  7230. private _epsilon;
  7231. /** @hidden */
  7232. _velocityWorldLength: number;
  7233. /** @hidden */
  7234. _basePointWorld: Vector3;
  7235. private _velocityWorld;
  7236. private _normalizedVelocity;
  7237. /** @hidden */
  7238. _initialVelocity: Vector3;
  7239. /** @hidden */
  7240. _initialPosition: Vector3;
  7241. private _nearestDistance;
  7242. private _collisionMask;
  7243. get collisionMask(): number;
  7244. set collisionMask(mask: number);
  7245. /**
  7246. * Gets the plane normal used to compute the sliding response (in local space)
  7247. */
  7248. get slidePlaneNormal(): Vector3;
  7249. /** @hidden */
  7250. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7251. /** @hidden */
  7252. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7253. /** @hidden */
  7254. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7255. /** @hidden */
  7256. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7257. /** @hidden */
  7258. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7259. /** @hidden */
  7260. _getResponse(pos: Vector3, vel: Vector3): void;
  7261. }
  7262. }
  7263. declare module "babylonjs/Culling/boundingInfo" {
  7264. import { DeepImmutable } from "babylonjs/types";
  7265. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7266. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7267. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7268. import { Plane } from "babylonjs/Maths/math.plane";
  7269. import { Collider } from "babylonjs/Collisions/collider";
  7270. /**
  7271. * Interface for cullable objects
  7272. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7273. */
  7274. export interface ICullable {
  7275. /**
  7276. * Checks if the object or part of the object is in the frustum
  7277. * @param frustumPlanes Camera near/planes
  7278. * @returns true if the object is in frustum otherwise false
  7279. */
  7280. isInFrustum(frustumPlanes: Plane[]): boolean;
  7281. /**
  7282. * Checks if a cullable object (mesh...) is in the camera frustum
  7283. * Unlike isInFrustum this cheks the full bounding box
  7284. * @param frustumPlanes Camera near/planes
  7285. * @returns true if the object is in frustum otherwise false
  7286. */
  7287. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7288. }
  7289. /**
  7290. * Info for a bounding data of a mesh
  7291. */
  7292. export class BoundingInfo implements ICullable {
  7293. /**
  7294. * Bounding box for the mesh
  7295. */
  7296. readonly boundingBox: BoundingBox;
  7297. /**
  7298. * Bounding sphere for the mesh
  7299. */
  7300. readonly boundingSphere: BoundingSphere;
  7301. private _isLocked;
  7302. private static readonly TmpVector3;
  7303. /**
  7304. * Constructs bounding info
  7305. * @param minimum min vector of the bounding box/sphere
  7306. * @param maximum max vector of the bounding box/sphere
  7307. * @param worldMatrix defines the new world matrix
  7308. */
  7309. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7310. /**
  7311. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7312. * @param min defines the new minimum vector (in local space)
  7313. * @param max defines the new maximum vector (in local space)
  7314. * @param worldMatrix defines the new world matrix
  7315. */
  7316. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7317. /**
  7318. * min vector of the bounding box/sphere
  7319. */
  7320. get minimum(): Vector3;
  7321. /**
  7322. * max vector of the bounding box/sphere
  7323. */
  7324. get maximum(): Vector3;
  7325. /**
  7326. * If the info is locked and won't be updated to avoid perf overhead
  7327. */
  7328. get isLocked(): boolean;
  7329. set isLocked(value: boolean);
  7330. /**
  7331. * Updates the bounding sphere and box
  7332. * @param world world matrix to be used to update
  7333. */
  7334. update(world: DeepImmutable<Matrix>): void;
  7335. /**
  7336. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7337. * @param center New center of the bounding info
  7338. * @param extend New extend of the bounding info
  7339. * @returns the current bounding info
  7340. */
  7341. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7342. /**
  7343. * Scale the current bounding info by applying a scale factor
  7344. * @param factor defines the scale factor to apply
  7345. * @returns the current bounding info
  7346. */
  7347. scale(factor: number): BoundingInfo;
  7348. /**
  7349. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7350. * @param frustumPlanes defines the frustum to test
  7351. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7352. * @returns true if the bounding info is in the frustum planes
  7353. */
  7354. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7355. /**
  7356. * Gets the world distance between the min and max points of the bounding box
  7357. */
  7358. get diagonalLength(): number;
  7359. /**
  7360. * Checks if a cullable object (mesh...) is in the camera frustum
  7361. * Unlike isInFrustum this cheks the full bounding box
  7362. * @param frustumPlanes Camera near/planes
  7363. * @returns true if the object is in frustum otherwise false
  7364. */
  7365. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7366. /** @hidden */
  7367. _checkCollision(collider: Collider): boolean;
  7368. /**
  7369. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7370. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7371. * @param point the point to check intersection with
  7372. * @returns if the point intersects
  7373. */
  7374. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7375. /**
  7376. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7377. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7378. * @param boundingInfo the bounding info to check intersection with
  7379. * @param precise if the intersection should be done using OBB
  7380. * @returns if the bounding info intersects
  7381. */
  7382. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7383. }
  7384. }
  7385. declare module "babylonjs/Maths/math.functions" {
  7386. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7387. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7388. /**
  7389. * Extracts minimum and maximum values from a list of indexed positions
  7390. * @param positions defines the positions to use
  7391. * @param indices defines the indices to the positions
  7392. * @param indexStart defines the start index
  7393. * @param indexCount defines the end index
  7394. * @param bias defines bias value to add to the result
  7395. * @return minimum and maximum values
  7396. */
  7397. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7398. minimum: Vector3;
  7399. maximum: Vector3;
  7400. };
  7401. /**
  7402. * Extracts minimum and maximum values from a list of positions
  7403. * @param positions defines the positions to use
  7404. * @param start defines the start index in the positions array
  7405. * @param count defines the number of positions to handle
  7406. * @param bias defines bias value to add to the result
  7407. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7408. * @return minimum and maximum values
  7409. */
  7410. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7411. minimum: Vector3;
  7412. maximum: Vector3;
  7413. };
  7414. }
  7415. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7416. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7417. /** @hidden */
  7418. export class WebGLDataBuffer extends DataBuffer {
  7419. private _buffer;
  7420. constructor(resource: WebGLBuffer);
  7421. get underlyingResource(): any;
  7422. }
  7423. }
  7424. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7425. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7426. import { Nullable } from "babylonjs/types";
  7427. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7428. /** @hidden */
  7429. export class WebGLPipelineContext implements IPipelineContext {
  7430. engine: ThinEngine;
  7431. program: Nullable<WebGLProgram>;
  7432. context?: WebGLRenderingContext;
  7433. vertexShader?: WebGLShader;
  7434. fragmentShader?: WebGLShader;
  7435. isParallelCompiled: boolean;
  7436. onCompiled?: () => void;
  7437. transformFeedback?: WebGLTransformFeedback | null;
  7438. vertexCompilationError: Nullable<string>;
  7439. fragmentCompilationError: Nullable<string>;
  7440. programLinkError: Nullable<string>;
  7441. programValidationError: Nullable<string>;
  7442. get isAsync(): boolean;
  7443. get isReady(): boolean;
  7444. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7445. _getVertexShaderCode(): string | null;
  7446. _getFragmentShaderCode(): string | null;
  7447. }
  7448. }
  7449. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7450. import { FloatArray, Nullable } from "babylonjs/types";
  7451. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7452. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7453. module "babylonjs/Engines/thinEngine" {
  7454. interface ThinEngine {
  7455. /**
  7456. * Create an uniform buffer
  7457. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7458. * @param elements defines the content of the uniform buffer
  7459. * @returns the webGL uniform buffer
  7460. */
  7461. createUniformBuffer(elements: FloatArray): DataBuffer;
  7462. /**
  7463. * Create a dynamic uniform buffer
  7464. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7465. * @param elements defines the content of the uniform buffer
  7466. * @returns the webGL uniform buffer
  7467. */
  7468. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7469. /**
  7470. * Update an existing uniform buffer
  7471. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7472. * @param uniformBuffer defines the target uniform buffer
  7473. * @param elements defines the content to update
  7474. * @param offset defines the offset in the uniform buffer where update should start
  7475. * @param count defines the size of the data to update
  7476. */
  7477. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7478. /**
  7479. * Bind an uniform buffer to the current webGL context
  7480. * @param buffer defines the buffer to bind
  7481. */
  7482. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7483. /**
  7484. * Bind a buffer to the current webGL context at a given location
  7485. * @param buffer defines the buffer to bind
  7486. * @param location defines the index where to bind the buffer
  7487. */
  7488. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7489. /**
  7490. * Bind a specific block at a given index in a specific shader program
  7491. * @param pipelineContext defines the pipeline context to use
  7492. * @param blockName defines the block name
  7493. * @param index defines the index where to bind the block
  7494. */
  7495. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7496. }
  7497. }
  7498. }
  7499. declare module "babylonjs/Materials/uniformBuffer" {
  7500. import { Nullable, FloatArray } from "babylonjs/types";
  7501. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7502. import { Engine } from "babylonjs/Engines/engine";
  7503. import { Effect } from "babylonjs/Materials/effect";
  7504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7505. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7506. import { Color3 } from "babylonjs/Maths/math.color";
  7507. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7508. /**
  7509. * Uniform buffer objects.
  7510. *
  7511. * Handles blocks of uniform on the GPU.
  7512. *
  7513. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7514. *
  7515. * For more information, please refer to :
  7516. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7517. */
  7518. export class UniformBuffer {
  7519. private _engine;
  7520. private _buffer;
  7521. private _data;
  7522. private _bufferData;
  7523. private _dynamic?;
  7524. private _uniformLocations;
  7525. private _uniformSizes;
  7526. private _uniformLocationPointer;
  7527. private _needSync;
  7528. private _noUBO;
  7529. private _currentEffect;
  7530. /** @hidden */
  7531. _alreadyBound: boolean;
  7532. private static _MAX_UNIFORM_SIZE;
  7533. private static _tempBuffer;
  7534. /**
  7535. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7536. * This is dynamic to allow compat with webgl 1 and 2.
  7537. * You will need to pass the name of the uniform as well as the value.
  7538. */
  7539. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7540. /**
  7541. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7542. * This is dynamic to allow compat with webgl 1 and 2.
  7543. * You will need to pass the name of the uniform as well as the value.
  7544. */
  7545. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7546. /**
  7547. * Lambda to Update a single float in a uniform buffer.
  7548. * This is dynamic to allow compat with webgl 1 and 2.
  7549. * You will need to pass the name of the uniform as well as the value.
  7550. */
  7551. updateFloat: (name: string, x: number) => void;
  7552. /**
  7553. * Lambda to Update a vec2 of float in a uniform buffer.
  7554. * This is dynamic to allow compat with webgl 1 and 2.
  7555. * You will need to pass the name of the uniform as well as the value.
  7556. */
  7557. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7558. /**
  7559. * Lambda to Update a vec3 of float in a uniform buffer.
  7560. * This is dynamic to allow compat with webgl 1 and 2.
  7561. * You will need to pass the name of the uniform as well as the value.
  7562. */
  7563. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7564. /**
  7565. * Lambda to Update a vec4 of float in a uniform buffer.
  7566. * This is dynamic to allow compat with webgl 1 and 2.
  7567. * You will need to pass the name of the uniform as well as the value.
  7568. */
  7569. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7570. /**
  7571. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7572. * This is dynamic to allow compat with webgl 1 and 2.
  7573. * You will need to pass the name of the uniform as well as the value.
  7574. */
  7575. updateMatrix: (name: string, mat: Matrix) => void;
  7576. /**
  7577. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7578. * This is dynamic to allow compat with webgl 1 and 2.
  7579. * You will need to pass the name of the uniform as well as the value.
  7580. */
  7581. updateVector3: (name: string, vector: Vector3) => void;
  7582. /**
  7583. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7584. * This is dynamic to allow compat with webgl 1 and 2.
  7585. * You will need to pass the name of the uniform as well as the value.
  7586. */
  7587. updateVector4: (name: string, vector: Vector4) => void;
  7588. /**
  7589. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7590. * This is dynamic to allow compat with webgl 1 and 2.
  7591. * You will need to pass the name of the uniform as well as the value.
  7592. */
  7593. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7594. /**
  7595. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7596. * This is dynamic to allow compat with webgl 1 and 2.
  7597. * You will need to pass the name of the uniform as well as the value.
  7598. */
  7599. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7600. /**
  7601. * Instantiates a new Uniform buffer objects.
  7602. *
  7603. * Handles blocks of uniform on the GPU.
  7604. *
  7605. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7606. *
  7607. * For more information, please refer to :
  7608. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7609. * @param engine Define the engine the buffer is associated with
  7610. * @param data Define the data contained in the buffer
  7611. * @param dynamic Define if the buffer is updatable
  7612. */
  7613. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7614. /**
  7615. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7616. * or just falling back on setUniformXXX calls.
  7617. */
  7618. get useUbo(): boolean;
  7619. /**
  7620. * Indicates if the WebGL underlying uniform buffer is in sync
  7621. * with the javascript cache data.
  7622. */
  7623. get isSync(): boolean;
  7624. /**
  7625. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7626. * Also, a dynamic UniformBuffer will disable cache verification and always
  7627. * update the underlying WebGL uniform buffer to the GPU.
  7628. * @returns if Dynamic, otherwise false
  7629. */
  7630. isDynamic(): boolean;
  7631. /**
  7632. * The data cache on JS side.
  7633. * @returns the underlying data as a float array
  7634. */
  7635. getData(): Float32Array;
  7636. /**
  7637. * The underlying WebGL Uniform buffer.
  7638. * @returns the webgl buffer
  7639. */
  7640. getBuffer(): Nullable<DataBuffer>;
  7641. /**
  7642. * std140 layout specifies how to align data within an UBO structure.
  7643. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7644. * for specs.
  7645. */
  7646. private _fillAlignment;
  7647. /**
  7648. * Adds an uniform in the buffer.
  7649. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7650. * for the layout to be correct !
  7651. * @param name Name of the uniform, as used in the uniform block in the shader.
  7652. * @param size Data size, or data directly.
  7653. */
  7654. addUniform(name: string, size: number | number[]): void;
  7655. /**
  7656. * Adds a Matrix 4x4 to the uniform buffer.
  7657. * @param name Name of the uniform, as used in the uniform block in the shader.
  7658. * @param mat A 4x4 matrix.
  7659. */
  7660. addMatrix(name: string, mat: Matrix): void;
  7661. /**
  7662. * Adds a vec2 to the uniform buffer.
  7663. * @param name Name of the uniform, as used in the uniform block in the shader.
  7664. * @param x Define the x component value of the vec2
  7665. * @param y Define the y component value of the vec2
  7666. */
  7667. addFloat2(name: string, x: number, y: number): void;
  7668. /**
  7669. * Adds a vec3 to the uniform buffer.
  7670. * @param name Name of the uniform, as used in the uniform block in the shader.
  7671. * @param x Define the x component value of the vec3
  7672. * @param y Define the y component value of the vec3
  7673. * @param z Define the z component value of the vec3
  7674. */
  7675. addFloat3(name: string, x: number, y: number, z: number): void;
  7676. /**
  7677. * Adds a vec3 to the uniform buffer.
  7678. * @param name Name of the uniform, as used in the uniform block in the shader.
  7679. * @param color Define the vec3 from a Color
  7680. */
  7681. addColor3(name: string, color: Color3): void;
  7682. /**
  7683. * Adds a vec4 to the uniform buffer.
  7684. * @param name Name of the uniform, as used in the uniform block in the shader.
  7685. * @param color Define the rgb components from a Color
  7686. * @param alpha Define the a component of the vec4
  7687. */
  7688. addColor4(name: string, color: Color3, alpha: number): void;
  7689. /**
  7690. * Adds a vec3 to the uniform buffer.
  7691. * @param name Name of the uniform, as used in the uniform block in the shader.
  7692. * @param vector Define the vec3 components from a Vector
  7693. */
  7694. addVector3(name: string, vector: Vector3): void;
  7695. /**
  7696. * Adds a Matrix 3x3 to the uniform buffer.
  7697. * @param name Name of the uniform, as used in the uniform block in the shader.
  7698. */
  7699. addMatrix3x3(name: string): void;
  7700. /**
  7701. * Adds a Matrix 2x2 to the uniform buffer.
  7702. * @param name Name of the uniform, as used in the uniform block in the shader.
  7703. */
  7704. addMatrix2x2(name: string): void;
  7705. /**
  7706. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7707. */
  7708. create(): void;
  7709. /** @hidden */
  7710. _rebuild(): void;
  7711. /**
  7712. * Updates the WebGL Uniform Buffer on the GPU.
  7713. * If the `dynamic` flag is set to true, no cache comparison is done.
  7714. * Otherwise, the buffer will be updated only if the cache differs.
  7715. */
  7716. update(): void;
  7717. /**
  7718. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7719. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7720. * @param data Define the flattened data
  7721. * @param size Define the size of the data.
  7722. */
  7723. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7724. private _valueCache;
  7725. private _cacheMatrix;
  7726. private _updateMatrix3x3ForUniform;
  7727. private _updateMatrix3x3ForEffect;
  7728. private _updateMatrix2x2ForEffect;
  7729. private _updateMatrix2x2ForUniform;
  7730. private _updateFloatForEffect;
  7731. private _updateFloatForUniform;
  7732. private _updateFloat2ForEffect;
  7733. private _updateFloat2ForUniform;
  7734. private _updateFloat3ForEffect;
  7735. private _updateFloat3ForUniform;
  7736. private _updateFloat4ForEffect;
  7737. private _updateFloat4ForUniform;
  7738. private _updateMatrixForEffect;
  7739. private _updateMatrixForUniform;
  7740. private _updateVector3ForEffect;
  7741. private _updateVector3ForUniform;
  7742. private _updateVector4ForEffect;
  7743. private _updateVector4ForUniform;
  7744. private _updateColor3ForEffect;
  7745. private _updateColor3ForUniform;
  7746. private _updateColor4ForEffect;
  7747. private _updateColor4ForUniform;
  7748. /**
  7749. * Sets a sampler uniform on the effect.
  7750. * @param name Define the name of the sampler.
  7751. * @param texture Define the texture to set in the sampler
  7752. */
  7753. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7754. /**
  7755. * Directly updates the value of the uniform in the cache AND on the GPU.
  7756. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7757. * @param data Define the flattened data
  7758. */
  7759. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7760. /**
  7761. * Binds this uniform buffer to an effect.
  7762. * @param effect Define the effect to bind the buffer to
  7763. * @param name Name of the uniform block in the shader.
  7764. */
  7765. bindToEffect(effect: Effect, name: string): void;
  7766. /**
  7767. * Disposes the uniform buffer.
  7768. */
  7769. dispose(): void;
  7770. }
  7771. }
  7772. declare module "babylonjs/Misc/iInspectable" {
  7773. /**
  7774. * Enum that determines the text-wrapping mode to use.
  7775. */
  7776. export enum InspectableType {
  7777. /**
  7778. * Checkbox for booleans
  7779. */
  7780. Checkbox = 0,
  7781. /**
  7782. * Sliders for numbers
  7783. */
  7784. Slider = 1,
  7785. /**
  7786. * Vector3
  7787. */
  7788. Vector3 = 2,
  7789. /**
  7790. * Quaternions
  7791. */
  7792. Quaternion = 3,
  7793. /**
  7794. * Color3
  7795. */
  7796. Color3 = 4,
  7797. /**
  7798. * String
  7799. */
  7800. String = 5
  7801. }
  7802. /**
  7803. * Interface used to define custom inspectable properties.
  7804. * This interface is used by the inspector to display custom property grids
  7805. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7806. */
  7807. export interface IInspectable {
  7808. /**
  7809. * Gets the label to display
  7810. */
  7811. label: string;
  7812. /**
  7813. * Gets the name of the property to edit
  7814. */
  7815. propertyName: string;
  7816. /**
  7817. * Gets the type of the editor to use
  7818. */
  7819. type: InspectableType;
  7820. /**
  7821. * Gets the minimum value of the property when using in "slider" mode
  7822. */
  7823. min?: number;
  7824. /**
  7825. * Gets the maximum value of the property when using in "slider" mode
  7826. */
  7827. max?: number;
  7828. /**
  7829. * Gets the setp to use when using in "slider" mode
  7830. */
  7831. step?: number;
  7832. }
  7833. }
  7834. declare module "babylonjs/Misc/timingTools" {
  7835. /**
  7836. * Class used to provide helper for timing
  7837. */
  7838. export class TimingTools {
  7839. /**
  7840. * Polyfill for setImmediate
  7841. * @param action defines the action to execute after the current execution block
  7842. */
  7843. static SetImmediate(action: () => void): void;
  7844. }
  7845. }
  7846. declare module "babylonjs/Misc/instantiationTools" {
  7847. /**
  7848. * Class used to enable instatition of objects by class name
  7849. */
  7850. export class InstantiationTools {
  7851. /**
  7852. * Use this object to register external classes like custom textures or material
  7853. * to allow the laoders to instantiate them
  7854. */
  7855. static RegisteredExternalClasses: {
  7856. [key: string]: Object;
  7857. };
  7858. /**
  7859. * Tries to instantiate a new object from a given class name
  7860. * @param className defines the class name to instantiate
  7861. * @returns the new object or null if the system was not able to do the instantiation
  7862. */
  7863. static Instantiate(className: string): any;
  7864. }
  7865. }
  7866. declare module "babylonjs/Misc/copyTools" {
  7867. import { Nullable } from "babylonjs/types";
  7868. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7869. /**
  7870. * Class used to host copy specific utilities
  7871. */
  7872. export class CopyTools {
  7873. /**
  7874. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  7875. * @param texture defines the texture to read pixels from
  7876. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7877. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7878. * @returns The base64 encoded string or null
  7879. */
  7880. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  7881. }
  7882. }
  7883. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7884. /**
  7885. * Define options used to create a depth texture
  7886. */
  7887. export class DepthTextureCreationOptions {
  7888. /** Specifies whether or not a stencil should be allocated in the texture */
  7889. generateStencil?: boolean;
  7890. /** Specifies whether or not bilinear filtering is enable on the texture */
  7891. bilinearFiltering?: boolean;
  7892. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7893. comparisonFunction?: number;
  7894. /** Specifies if the created texture is a cube texture */
  7895. isCube?: boolean;
  7896. }
  7897. }
  7898. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7899. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7900. import { Nullable } from "babylonjs/types";
  7901. import { Scene } from "babylonjs/scene";
  7902. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7903. module "babylonjs/Engines/thinEngine" {
  7904. interface ThinEngine {
  7905. /**
  7906. * Creates a depth stencil cube texture.
  7907. * This is only available in WebGL 2.
  7908. * @param size The size of face edge in the cube texture.
  7909. * @param options The options defining the cube texture.
  7910. * @returns The cube texture
  7911. */
  7912. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7913. /**
  7914. * Creates a cube texture
  7915. * @param rootUrl defines the url where the files to load is located
  7916. * @param scene defines the current scene
  7917. * @param files defines the list of files to load (1 per face)
  7918. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7919. * @param onLoad defines an optional callback raised when the texture is loaded
  7920. * @param onError defines an optional callback raised if there is an issue to load the texture
  7921. * @param format defines the format of the data
  7922. * @param forcedExtension defines the extension to use to pick the right loader
  7923. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7924. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7925. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7926. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7927. * @param loaderOptions options to be passed to the loader
  7928. * @returns the cube texture as an InternalTexture
  7929. */
  7930. 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;
  7931. /**
  7932. * Creates a cube texture
  7933. * @param rootUrl defines the url where the files to load is located
  7934. * @param scene defines the current scene
  7935. * @param files defines the list of files to load (1 per face)
  7936. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7937. * @param onLoad defines an optional callback raised when the texture is loaded
  7938. * @param onError defines an optional callback raised if there is an issue to load the texture
  7939. * @param format defines the format of the data
  7940. * @param forcedExtension defines the extension to use to pick the right loader
  7941. * @returns the cube texture as an InternalTexture
  7942. */
  7943. 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;
  7944. /**
  7945. * Creates a cube texture
  7946. * @param rootUrl defines the url where the files to load is located
  7947. * @param scene defines the current scene
  7948. * @param files defines the list of files to load (1 per face)
  7949. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7950. * @param onLoad defines an optional callback raised when the texture is loaded
  7951. * @param onError defines an optional callback raised if there is an issue to load the texture
  7952. * @param format defines the format of the data
  7953. * @param forcedExtension defines the extension to use to pick the right loader
  7954. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7955. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7956. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7957. * @returns the cube texture as an InternalTexture
  7958. */
  7959. 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;
  7960. /** @hidden */
  7961. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7962. /** @hidden */
  7963. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7964. /** @hidden */
  7965. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7966. /** @hidden */
  7967. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7968. /**
  7969. * @hidden
  7970. */
  7971. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7972. }
  7973. }
  7974. }
  7975. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7976. import { Nullable } from "babylonjs/types";
  7977. import { Scene } from "babylonjs/scene";
  7978. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7979. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7980. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7981. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7982. import { Observable } from "babylonjs/Misc/observable";
  7983. /**
  7984. * Class for creating a cube texture
  7985. */
  7986. export class CubeTexture extends BaseTexture {
  7987. private _delayedOnLoad;
  7988. /**
  7989. * Observable triggered once the texture has been loaded.
  7990. */
  7991. onLoadObservable: Observable<CubeTexture>;
  7992. /**
  7993. * The url of the texture
  7994. */
  7995. url: string;
  7996. /**
  7997. * Gets or sets the center of the bounding box associated with the cube texture.
  7998. * It must define where the camera used to render the texture was set
  7999. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8000. */
  8001. boundingBoxPosition: Vector3;
  8002. private _boundingBoxSize;
  8003. /**
  8004. * Gets or sets the size of the bounding box associated with the cube texture
  8005. * When defined, the cubemap will switch to local mode
  8006. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8007. * @example https://www.babylonjs-playground.com/#RNASML
  8008. */
  8009. set boundingBoxSize(value: Vector3);
  8010. /**
  8011. * Returns the bounding box size
  8012. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8013. */
  8014. get boundingBoxSize(): Vector3;
  8015. protected _rotationY: number;
  8016. /**
  8017. * Sets texture matrix rotation angle around Y axis in radians.
  8018. */
  8019. set rotationY(value: number);
  8020. /**
  8021. * Gets texture matrix rotation angle around Y axis radians.
  8022. */
  8023. get rotationY(): number;
  8024. /**
  8025. * Are mip maps generated for this texture or not.
  8026. */
  8027. get noMipmap(): boolean;
  8028. private _noMipmap;
  8029. private _files;
  8030. protected _forcedExtension: Nullable<string>;
  8031. private _extensions;
  8032. private _textureMatrix;
  8033. private _format;
  8034. private _createPolynomials;
  8035. private _loaderOptions;
  8036. /**
  8037. * Creates a cube texture from an array of image urls
  8038. * @param files defines an array of image urls
  8039. * @param scene defines the hosting scene
  8040. * @param noMipmap specifies if mip maps are not used
  8041. * @returns a cube texture
  8042. */
  8043. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8044. /**
  8045. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8046. * @param url defines the url of the prefiltered texture
  8047. * @param scene defines the scene the texture is attached to
  8048. * @param forcedExtension defines the extension of the file if different from the url
  8049. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8050. * @return the prefiltered texture
  8051. */
  8052. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8053. /**
  8054. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8055. * as prefiltered data.
  8056. * @param rootUrl defines the url of the texture or the root name of the six images
  8057. * @param null defines the scene or engine the texture is attached to
  8058. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8059. * @param noMipmap defines if mipmaps should be created or not
  8060. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8061. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8062. * @param onError defines a callback triggered in case of error during load
  8063. * @param format defines the internal format to use for the texture once loaded
  8064. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8065. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8066. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8067. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8068. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8069. * @param loaderOptions options to be passed to the loader
  8070. * @return the cube texture
  8071. */
  8072. 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);
  8073. /**
  8074. * Get the current class name of the texture useful for serialization or dynamic coding.
  8075. * @returns "CubeTexture"
  8076. */
  8077. getClassName(): string;
  8078. /**
  8079. * Update the url (and optional buffer) of this texture if url was null during construction.
  8080. * @param url the url of the texture
  8081. * @param forcedExtension defines the extension to use
  8082. * @param onLoad callback called when the texture is loaded (defaults to null)
  8083. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8084. */
  8085. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8086. /**
  8087. * Delays loading of the cube texture
  8088. * @param forcedExtension defines the extension to use
  8089. */
  8090. delayLoad(forcedExtension?: string): void;
  8091. /**
  8092. * Returns the reflection texture matrix
  8093. * @returns the reflection texture matrix
  8094. */
  8095. getReflectionTextureMatrix(): Matrix;
  8096. /**
  8097. * Sets the reflection texture matrix
  8098. * @param value Reflection texture matrix
  8099. */
  8100. setReflectionTextureMatrix(value: Matrix): void;
  8101. /**
  8102. * Parses text to create a cube texture
  8103. * @param parsedTexture define the serialized text to read from
  8104. * @param scene defines the hosting scene
  8105. * @param rootUrl defines the root url of the cube texture
  8106. * @returns a cube texture
  8107. */
  8108. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8109. /**
  8110. * Makes a clone, or deep copy, of the cube texture
  8111. * @returns a new cube texture
  8112. */
  8113. clone(): CubeTexture;
  8114. }
  8115. }
  8116. declare module "babylonjs/Materials/materialDefines" {
  8117. /**
  8118. * Manages the defines for the Material
  8119. */
  8120. export class MaterialDefines {
  8121. /** @hidden */
  8122. protected _keys: string[];
  8123. private _isDirty;
  8124. /** @hidden */
  8125. _renderId: number;
  8126. /** @hidden */
  8127. _areLightsDirty: boolean;
  8128. /** @hidden */
  8129. _areLightsDisposed: boolean;
  8130. /** @hidden */
  8131. _areAttributesDirty: boolean;
  8132. /** @hidden */
  8133. _areTexturesDirty: boolean;
  8134. /** @hidden */
  8135. _areFresnelDirty: boolean;
  8136. /** @hidden */
  8137. _areMiscDirty: boolean;
  8138. /** @hidden */
  8139. _arePrePassDirty: boolean;
  8140. /** @hidden */
  8141. _areImageProcessingDirty: boolean;
  8142. /** @hidden */
  8143. _normals: boolean;
  8144. /** @hidden */
  8145. _uvs: boolean;
  8146. /** @hidden */
  8147. _needNormals: boolean;
  8148. /** @hidden */
  8149. _needUVs: boolean;
  8150. [id: string]: any;
  8151. /**
  8152. * Specifies if the material needs to be re-calculated
  8153. */
  8154. get isDirty(): boolean;
  8155. /**
  8156. * Marks the material to indicate that it has been re-calculated
  8157. */
  8158. markAsProcessed(): void;
  8159. /**
  8160. * Marks the material to indicate that it needs to be re-calculated
  8161. */
  8162. markAsUnprocessed(): void;
  8163. /**
  8164. * Marks the material to indicate all of its defines need to be re-calculated
  8165. */
  8166. markAllAsDirty(): void;
  8167. /**
  8168. * Marks the material to indicate that image processing needs to be re-calculated
  8169. */
  8170. markAsImageProcessingDirty(): void;
  8171. /**
  8172. * Marks the material to indicate the lights need to be re-calculated
  8173. * @param disposed Defines whether the light is dirty due to dispose or not
  8174. */
  8175. markAsLightDirty(disposed?: boolean): void;
  8176. /**
  8177. * Marks the attribute state as changed
  8178. */
  8179. markAsAttributesDirty(): void;
  8180. /**
  8181. * Marks the texture state as changed
  8182. */
  8183. markAsTexturesDirty(): void;
  8184. /**
  8185. * Marks the fresnel state as changed
  8186. */
  8187. markAsFresnelDirty(): void;
  8188. /**
  8189. * Marks the misc state as changed
  8190. */
  8191. markAsMiscDirty(): void;
  8192. /**
  8193. * Marks the prepass state as changed
  8194. */
  8195. markAsPrePassDirty(): void;
  8196. /**
  8197. * Rebuilds the material defines
  8198. */
  8199. rebuild(): void;
  8200. /**
  8201. * Specifies if two material defines are equal
  8202. * @param other - A material define instance to compare to
  8203. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8204. */
  8205. isEqual(other: MaterialDefines): boolean;
  8206. /**
  8207. * Clones this instance's defines to another instance
  8208. * @param other - material defines to clone values to
  8209. */
  8210. cloneTo(other: MaterialDefines): void;
  8211. /**
  8212. * Resets the material define values
  8213. */
  8214. reset(): void;
  8215. /**
  8216. * Converts the material define values to a string
  8217. * @returns - String of material define information
  8218. */
  8219. toString(): string;
  8220. }
  8221. }
  8222. declare module "babylonjs/Materials/colorCurves" {
  8223. import { Effect } from "babylonjs/Materials/effect";
  8224. /**
  8225. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8226. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8227. * 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;
  8228. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8229. */
  8230. export class ColorCurves {
  8231. private _dirty;
  8232. private _tempColor;
  8233. private _globalCurve;
  8234. private _highlightsCurve;
  8235. private _midtonesCurve;
  8236. private _shadowsCurve;
  8237. private _positiveCurve;
  8238. private _negativeCurve;
  8239. private _globalHue;
  8240. private _globalDensity;
  8241. private _globalSaturation;
  8242. private _globalExposure;
  8243. /**
  8244. * Gets the global Hue value.
  8245. * 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).
  8246. */
  8247. get globalHue(): number;
  8248. /**
  8249. * Sets the global Hue value.
  8250. * 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).
  8251. */
  8252. set globalHue(value: number);
  8253. /**
  8254. * Gets the global Density value.
  8255. * 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.
  8256. * Values less than zero provide a filter of opposite hue.
  8257. */
  8258. get globalDensity(): number;
  8259. /**
  8260. * Sets the global Density value.
  8261. * 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.
  8262. * Values less than zero provide a filter of opposite hue.
  8263. */
  8264. set globalDensity(value: number);
  8265. /**
  8266. * Gets the global Saturation value.
  8267. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8268. */
  8269. get globalSaturation(): number;
  8270. /**
  8271. * Sets the global Saturation value.
  8272. * 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.
  8273. */
  8274. set globalSaturation(value: number);
  8275. /**
  8276. * Gets the global Exposure value.
  8277. * 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.
  8278. */
  8279. get globalExposure(): number;
  8280. /**
  8281. * Sets the global Exposure value.
  8282. * 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.
  8283. */
  8284. set globalExposure(value: number);
  8285. private _highlightsHue;
  8286. private _highlightsDensity;
  8287. private _highlightsSaturation;
  8288. private _highlightsExposure;
  8289. /**
  8290. * Gets the highlights Hue value.
  8291. * 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).
  8292. */
  8293. get highlightsHue(): number;
  8294. /**
  8295. * Sets the highlights Hue value.
  8296. * 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).
  8297. */
  8298. set highlightsHue(value: number);
  8299. /**
  8300. * Gets the highlights Density value.
  8301. * 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.
  8302. * Values less than zero provide a filter of opposite hue.
  8303. */
  8304. get highlightsDensity(): number;
  8305. /**
  8306. * Sets the highlights Density value.
  8307. * 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.
  8308. * Values less than zero provide a filter of opposite hue.
  8309. */
  8310. set highlightsDensity(value: number);
  8311. /**
  8312. * Gets the highlights Saturation value.
  8313. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8314. */
  8315. get highlightsSaturation(): number;
  8316. /**
  8317. * Sets the highlights Saturation value.
  8318. * 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.
  8319. */
  8320. set highlightsSaturation(value: number);
  8321. /**
  8322. * Gets the highlights Exposure value.
  8323. * 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.
  8324. */
  8325. get highlightsExposure(): number;
  8326. /**
  8327. * Sets the highlights Exposure value.
  8328. * 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.
  8329. */
  8330. set highlightsExposure(value: number);
  8331. private _midtonesHue;
  8332. private _midtonesDensity;
  8333. private _midtonesSaturation;
  8334. private _midtonesExposure;
  8335. /**
  8336. * Gets the midtones Hue value.
  8337. * 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).
  8338. */
  8339. get midtonesHue(): number;
  8340. /**
  8341. * Sets the midtones Hue value.
  8342. * 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).
  8343. */
  8344. set midtonesHue(value: number);
  8345. /**
  8346. * Gets the midtones Density value.
  8347. * 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.
  8348. * Values less than zero provide a filter of opposite hue.
  8349. */
  8350. get midtonesDensity(): number;
  8351. /**
  8352. * Sets the midtones Density value.
  8353. * 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.
  8354. * Values less than zero provide a filter of opposite hue.
  8355. */
  8356. set midtonesDensity(value: number);
  8357. /**
  8358. * Gets the midtones Saturation value.
  8359. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8360. */
  8361. get midtonesSaturation(): number;
  8362. /**
  8363. * Sets the midtones Saturation value.
  8364. * 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.
  8365. */
  8366. set midtonesSaturation(value: number);
  8367. /**
  8368. * Gets the midtones Exposure value.
  8369. * 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.
  8370. */
  8371. get midtonesExposure(): number;
  8372. /**
  8373. * Sets the midtones Exposure value.
  8374. * 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.
  8375. */
  8376. set midtonesExposure(value: number);
  8377. private _shadowsHue;
  8378. private _shadowsDensity;
  8379. private _shadowsSaturation;
  8380. private _shadowsExposure;
  8381. /**
  8382. * Gets the shadows Hue value.
  8383. * 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).
  8384. */
  8385. get shadowsHue(): number;
  8386. /**
  8387. * Sets the shadows Hue value.
  8388. * 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).
  8389. */
  8390. set shadowsHue(value: number);
  8391. /**
  8392. * Gets the shadows Density value.
  8393. * 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.
  8394. * Values less than zero provide a filter of opposite hue.
  8395. */
  8396. get shadowsDensity(): number;
  8397. /**
  8398. * Sets the shadows Density value.
  8399. * 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.
  8400. * Values less than zero provide a filter of opposite hue.
  8401. */
  8402. set shadowsDensity(value: number);
  8403. /**
  8404. * Gets the shadows Saturation value.
  8405. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8406. */
  8407. get shadowsSaturation(): number;
  8408. /**
  8409. * Sets the shadows Saturation value.
  8410. * 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.
  8411. */
  8412. set shadowsSaturation(value: number);
  8413. /**
  8414. * Gets the shadows Exposure value.
  8415. * 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.
  8416. */
  8417. get shadowsExposure(): number;
  8418. /**
  8419. * Sets the shadows Exposure value.
  8420. * 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.
  8421. */
  8422. set shadowsExposure(value: number);
  8423. /**
  8424. * Returns the class name
  8425. * @returns The class name
  8426. */
  8427. getClassName(): string;
  8428. /**
  8429. * Binds the color curves to the shader.
  8430. * @param colorCurves The color curve to bind
  8431. * @param effect The effect to bind to
  8432. * @param positiveUniform The positive uniform shader parameter
  8433. * @param neutralUniform The neutral uniform shader parameter
  8434. * @param negativeUniform The negative uniform shader parameter
  8435. */
  8436. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8437. /**
  8438. * Prepare the list of uniforms associated with the ColorCurves effects.
  8439. * @param uniformsList The list of uniforms used in the effect
  8440. */
  8441. static PrepareUniforms(uniformsList: string[]): void;
  8442. /**
  8443. * Returns color grading data based on a hue, density, saturation and exposure value.
  8444. * @param filterHue The hue of the color filter.
  8445. * @param filterDensity The density of the color filter.
  8446. * @param saturation The saturation.
  8447. * @param exposure The exposure.
  8448. * @param result The result data container.
  8449. */
  8450. private getColorGradingDataToRef;
  8451. /**
  8452. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8453. * @param value The input slider value in range [-100,100].
  8454. * @returns Adjusted value.
  8455. */
  8456. private static applyColorGradingSliderNonlinear;
  8457. /**
  8458. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8459. * @param hue The hue (H) input.
  8460. * @param saturation The saturation (S) input.
  8461. * @param brightness The brightness (B) input.
  8462. * @result An RGBA color represented as Vector4.
  8463. */
  8464. private static fromHSBToRef;
  8465. /**
  8466. * Returns a value clamped between min and max
  8467. * @param value The value to clamp
  8468. * @param min The minimum of value
  8469. * @param max The maximum of value
  8470. * @returns The clamped value.
  8471. */
  8472. private static clamp;
  8473. /**
  8474. * Clones the current color curve instance.
  8475. * @return The cloned curves
  8476. */
  8477. clone(): ColorCurves;
  8478. /**
  8479. * Serializes the current color curve instance to a json representation.
  8480. * @return a JSON representation
  8481. */
  8482. serialize(): any;
  8483. /**
  8484. * Parses the color curve from a json representation.
  8485. * @param source the JSON source to parse
  8486. * @return The parsed curves
  8487. */
  8488. static Parse(source: any): ColorCurves;
  8489. }
  8490. }
  8491. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8492. import { Observable } from "babylonjs/Misc/observable";
  8493. import { Nullable } from "babylonjs/types";
  8494. import { Color4 } from "babylonjs/Maths/math.color";
  8495. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8496. import { Effect } from "babylonjs/Materials/effect";
  8497. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8498. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8499. /**
  8500. * Interface to follow in your material defines to integrate easily the
  8501. * Image proccessing functions.
  8502. * @hidden
  8503. */
  8504. export interface IImageProcessingConfigurationDefines {
  8505. IMAGEPROCESSING: boolean;
  8506. VIGNETTE: boolean;
  8507. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8508. VIGNETTEBLENDMODEOPAQUE: boolean;
  8509. TONEMAPPING: boolean;
  8510. TONEMAPPING_ACES: boolean;
  8511. CONTRAST: boolean;
  8512. EXPOSURE: boolean;
  8513. COLORCURVES: boolean;
  8514. COLORGRADING: boolean;
  8515. COLORGRADING3D: boolean;
  8516. SAMPLER3DGREENDEPTH: boolean;
  8517. SAMPLER3DBGRMAP: boolean;
  8518. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8519. }
  8520. /**
  8521. * @hidden
  8522. */
  8523. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8524. IMAGEPROCESSING: boolean;
  8525. VIGNETTE: boolean;
  8526. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8527. VIGNETTEBLENDMODEOPAQUE: boolean;
  8528. TONEMAPPING: boolean;
  8529. TONEMAPPING_ACES: boolean;
  8530. CONTRAST: boolean;
  8531. COLORCURVES: boolean;
  8532. COLORGRADING: boolean;
  8533. COLORGRADING3D: boolean;
  8534. SAMPLER3DGREENDEPTH: boolean;
  8535. SAMPLER3DBGRMAP: boolean;
  8536. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8537. EXPOSURE: boolean;
  8538. constructor();
  8539. }
  8540. /**
  8541. * This groups together the common properties used for image processing either in direct forward pass
  8542. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8543. * or not.
  8544. */
  8545. export class ImageProcessingConfiguration {
  8546. /**
  8547. * Default tone mapping applied in BabylonJS.
  8548. */
  8549. static readonly TONEMAPPING_STANDARD: number;
  8550. /**
  8551. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8552. * to other engines rendering to increase portability.
  8553. */
  8554. static readonly TONEMAPPING_ACES: number;
  8555. /**
  8556. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8557. */
  8558. colorCurves: Nullable<ColorCurves>;
  8559. private _colorCurvesEnabled;
  8560. /**
  8561. * Gets wether the color curves effect is enabled.
  8562. */
  8563. get colorCurvesEnabled(): boolean;
  8564. /**
  8565. * Sets wether the color curves effect is enabled.
  8566. */
  8567. set colorCurvesEnabled(value: boolean);
  8568. private _colorGradingTexture;
  8569. /**
  8570. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8571. */
  8572. get colorGradingTexture(): Nullable<BaseTexture>;
  8573. /**
  8574. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8575. */
  8576. set colorGradingTexture(value: Nullable<BaseTexture>);
  8577. private _colorGradingEnabled;
  8578. /**
  8579. * Gets wether the color grading effect is enabled.
  8580. */
  8581. get colorGradingEnabled(): boolean;
  8582. /**
  8583. * Sets wether the color grading effect is enabled.
  8584. */
  8585. set colorGradingEnabled(value: boolean);
  8586. private _colorGradingWithGreenDepth;
  8587. /**
  8588. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8589. */
  8590. get colorGradingWithGreenDepth(): boolean;
  8591. /**
  8592. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8593. */
  8594. set colorGradingWithGreenDepth(value: boolean);
  8595. private _colorGradingBGR;
  8596. /**
  8597. * Gets wether the color grading texture contains BGR values.
  8598. */
  8599. get colorGradingBGR(): boolean;
  8600. /**
  8601. * Sets wether the color grading texture contains BGR values.
  8602. */
  8603. set colorGradingBGR(value: boolean);
  8604. /** @hidden */
  8605. _exposure: number;
  8606. /**
  8607. * Gets the Exposure used in the effect.
  8608. */
  8609. get exposure(): number;
  8610. /**
  8611. * Sets the Exposure used in the effect.
  8612. */
  8613. set exposure(value: number);
  8614. private _toneMappingEnabled;
  8615. /**
  8616. * Gets wether the tone mapping effect is enabled.
  8617. */
  8618. get toneMappingEnabled(): boolean;
  8619. /**
  8620. * Sets wether the tone mapping effect is enabled.
  8621. */
  8622. set toneMappingEnabled(value: boolean);
  8623. private _toneMappingType;
  8624. /**
  8625. * Gets the type of tone mapping effect.
  8626. */
  8627. get toneMappingType(): number;
  8628. /**
  8629. * Sets the type of tone mapping effect used in BabylonJS.
  8630. */
  8631. set toneMappingType(value: number);
  8632. protected _contrast: number;
  8633. /**
  8634. * Gets the contrast used in the effect.
  8635. */
  8636. get contrast(): number;
  8637. /**
  8638. * Sets the contrast used in the effect.
  8639. */
  8640. set contrast(value: number);
  8641. /**
  8642. * Vignette stretch size.
  8643. */
  8644. vignetteStretch: number;
  8645. /**
  8646. * Vignette centre X Offset.
  8647. */
  8648. vignetteCentreX: number;
  8649. /**
  8650. * Vignette centre Y Offset.
  8651. */
  8652. vignetteCentreY: number;
  8653. /**
  8654. * Vignette weight or intensity of the vignette effect.
  8655. */
  8656. vignetteWeight: number;
  8657. /**
  8658. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8659. * if vignetteEnabled is set to true.
  8660. */
  8661. vignetteColor: Color4;
  8662. /**
  8663. * Camera field of view used by the Vignette effect.
  8664. */
  8665. vignetteCameraFov: number;
  8666. private _vignetteBlendMode;
  8667. /**
  8668. * Gets the vignette blend mode allowing different kind of effect.
  8669. */
  8670. get vignetteBlendMode(): number;
  8671. /**
  8672. * Sets the vignette blend mode allowing different kind of effect.
  8673. */
  8674. set vignetteBlendMode(value: number);
  8675. private _vignetteEnabled;
  8676. /**
  8677. * Gets wether the vignette effect is enabled.
  8678. */
  8679. get vignetteEnabled(): boolean;
  8680. /**
  8681. * Sets wether the vignette effect is enabled.
  8682. */
  8683. set vignetteEnabled(value: boolean);
  8684. private _applyByPostProcess;
  8685. /**
  8686. * Gets wether the image processing is applied through a post process or not.
  8687. */
  8688. get applyByPostProcess(): boolean;
  8689. /**
  8690. * Sets wether the image processing is applied through a post process or not.
  8691. */
  8692. set applyByPostProcess(value: boolean);
  8693. private _isEnabled;
  8694. /**
  8695. * Gets wether the image processing is enabled or not.
  8696. */
  8697. get isEnabled(): boolean;
  8698. /**
  8699. * Sets wether the image processing is enabled or not.
  8700. */
  8701. set isEnabled(value: boolean);
  8702. /**
  8703. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8704. */
  8705. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8706. /**
  8707. * Method called each time the image processing information changes requires to recompile the effect.
  8708. */
  8709. protected _updateParameters(): void;
  8710. /**
  8711. * Gets the current class name.
  8712. * @return "ImageProcessingConfiguration"
  8713. */
  8714. getClassName(): string;
  8715. /**
  8716. * Prepare the list of uniforms associated with the Image Processing effects.
  8717. * @param uniforms The list of uniforms used in the effect
  8718. * @param defines the list of defines currently in use
  8719. */
  8720. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8721. /**
  8722. * Prepare the list of samplers associated with the Image Processing effects.
  8723. * @param samplersList The list of uniforms used in the effect
  8724. * @param defines the list of defines currently in use
  8725. */
  8726. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8727. /**
  8728. * Prepare the list of defines associated to the shader.
  8729. * @param defines the list of defines to complete
  8730. * @param forPostProcess Define if we are currently in post process mode or not
  8731. */
  8732. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8733. /**
  8734. * Returns true if all the image processing information are ready.
  8735. * @returns True if ready, otherwise, false
  8736. */
  8737. isReady(): boolean;
  8738. /**
  8739. * Binds the image processing to the shader.
  8740. * @param effect The effect to bind to
  8741. * @param overrideAspectRatio Override the aspect ratio of the effect
  8742. */
  8743. bind(effect: Effect, overrideAspectRatio?: number): void;
  8744. /**
  8745. * Clones the current image processing instance.
  8746. * @return The cloned image processing
  8747. */
  8748. clone(): ImageProcessingConfiguration;
  8749. /**
  8750. * Serializes the current image processing instance to a json representation.
  8751. * @return a JSON representation
  8752. */
  8753. serialize(): any;
  8754. /**
  8755. * Parses the image processing from a json representation.
  8756. * @param source the JSON source to parse
  8757. * @return The parsed image processing
  8758. */
  8759. static Parse(source: any): ImageProcessingConfiguration;
  8760. private static _VIGNETTEMODE_MULTIPLY;
  8761. private static _VIGNETTEMODE_OPAQUE;
  8762. /**
  8763. * Used to apply the vignette as a mix with the pixel color.
  8764. */
  8765. static get VIGNETTEMODE_MULTIPLY(): number;
  8766. /**
  8767. * Used to apply the vignette as a replacement of the pixel color.
  8768. */
  8769. static get VIGNETTEMODE_OPAQUE(): number;
  8770. }
  8771. }
  8772. declare module "babylonjs/Shaders/postprocess.vertex" {
  8773. /** @hidden */
  8774. export var postprocessVertexShader: {
  8775. name: string;
  8776. shader: string;
  8777. };
  8778. }
  8779. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8780. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8781. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8782. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8783. /**
  8784. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8785. */
  8786. export type RenderTargetTextureSize = number | {
  8787. width: number;
  8788. height: number;
  8789. layers?: number;
  8790. };
  8791. module "babylonjs/Engines/thinEngine" {
  8792. interface ThinEngine {
  8793. /**
  8794. * Creates a new render target texture
  8795. * @param size defines the size of the texture
  8796. * @param options defines the options used to create the texture
  8797. * @returns a new render target texture stored in an InternalTexture
  8798. */
  8799. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8800. /**
  8801. * Creates a depth stencil texture.
  8802. * This is only available in WebGL 2 or with the depth texture extension available.
  8803. * @param size The size of face edge in the texture.
  8804. * @param options The options defining the texture.
  8805. * @returns The texture
  8806. */
  8807. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8808. /** @hidden */
  8809. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8810. }
  8811. }
  8812. }
  8813. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8814. /**
  8815. * Defines the kind of connection point for node based material
  8816. */
  8817. export enum NodeMaterialBlockConnectionPointTypes {
  8818. /** Float */
  8819. Float = 1,
  8820. /** Int */
  8821. Int = 2,
  8822. /** Vector2 */
  8823. Vector2 = 4,
  8824. /** Vector3 */
  8825. Vector3 = 8,
  8826. /** Vector4 */
  8827. Vector4 = 16,
  8828. /** Color3 */
  8829. Color3 = 32,
  8830. /** Color4 */
  8831. Color4 = 64,
  8832. /** Matrix */
  8833. Matrix = 128,
  8834. /** Custom object */
  8835. Object = 256,
  8836. /** Detect type based on connection */
  8837. AutoDetect = 1024,
  8838. /** Output type that will be defined by input type */
  8839. BasedOnInput = 2048
  8840. }
  8841. }
  8842. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8843. /**
  8844. * Enum used to define the target of a block
  8845. */
  8846. export enum NodeMaterialBlockTargets {
  8847. /** Vertex shader */
  8848. Vertex = 1,
  8849. /** Fragment shader */
  8850. Fragment = 2,
  8851. /** Neutral */
  8852. Neutral = 4,
  8853. /** Vertex and Fragment */
  8854. VertexAndFragment = 3
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8858. /**
  8859. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8860. */
  8861. export enum NodeMaterialBlockConnectionPointMode {
  8862. /** Value is an uniform */
  8863. Uniform = 0,
  8864. /** Value is a mesh attribute */
  8865. Attribute = 1,
  8866. /** Value is a varying between vertex and fragment shaders */
  8867. Varying = 2,
  8868. /** Mode is undefined */
  8869. Undefined = 3
  8870. }
  8871. }
  8872. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8873. /**
  8874. * Enum used to define system values e.g. values automatically provided by the system
  8875. */
  8876. export enum NodeMaterialSystemValues {
  8877. /** World */
  8878. World = 1,
  8879. /** View */
  8880. View = 2,
  8881. /** Projection */
  8882. Projection = 3,
  8883. /** ViewProjection */
  8884. ViewProjection = 4,
  8885. /** WorldView */
  8886. WorldView = 5,
  8887. /** WorldViewProjection */
  8888. WorldViewProjection = 6,
  8889. /** CameraPosition */
  8890. CameraPosition = 7,
  8891. /** Fog Color */
  8892. FogColor = 8,
  8893. /** Delta time */
  8894. DeltaTime = 9
  8895. }
  8896. }
  8897. declare module "babylonjs/Maths/math.axis" {
  8898. import { Vector3 } from "babylonjs/Maths/math.vector";
  8899. /** Defines supported spaces */
  8900. export enum Space {
  8901. /** Local (object) space */
  8902. LOCAL = 0,
  8903. /** World space */
  8904. WORLD = 1,
  8905. /** Bone space */
  8906. BONE = 2
  8907. }
  8908. /** Defines the 3 main axes */
  8909. export class Axis {
  8910. /** X axis */
  8911. static X: Vector3;
  8912. /** Y axis */
  8913. static Y: Vector3;
  8914. /** Z axis */
  8915. static Z: Vector3;
  8916. }
  8917. /**
  8918. * Defines cartesian components.
  8919. */
  8920. export enum Coordinate {
  8921. /** X axis */
  8922. X = 0,
  8923. /** Y axis */
  8924. Y = 1,
  8925. /** Z axis */
  8926. Z = 2
  8927. }
  8928. }
  8929. declare module "babylonjs/Maths/math.frustum" {
  8930. import { Matrix } from "babylonjs/Maths/math.vector";
  8931. import { DeepImmutable } from "babylonjs/types";
  8932. import { Plane } from "babylonjs/Maths/math.plane";
  8933. /**
  8934. * Represents a camera frustum
  8935. */
  8936. export class Frustum {
  8937. /**
  8938. * Gets the planes representing the frustum
  8939. * @param transform matrix to be applied to the returned planes
  8940. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8941. */
  8942. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8943. /**
  8944. * Gets the near frustum plane transformed by the transform matrix
  8945. * @param transform transformation matrix to be applied to the resulting frustum plane
  8946. * @param frustumPlane the resuling frustum plane
  8947. */
  8948. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8949. /**
  8950. * Gets the far frustum plane transformed by the transform matrix
  8951. * @param transform transformation matrix to be applied to the resulting frustum plane
  8952. * @param frustumPlane the resuling frustum plane
  8953. */
  8954. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8955. /**
  8956. * Gets the left frustum plane transformed by the transform matrix
  8957. * @param transform transformation matrix to be applied to the resulting frustum plane
  8958. * @param frustumPlane the resuling frustum plane
  8959. */
  8960. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8961. /**
  8962. * Gets the right frustum plane transformed by the transform matrix
  8963. * @param transform transformation matrix to be applied to the resulting frustum plane
  8964. * @param frustumPlane the resuling frustum plane
  8965. */
  8966. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8967. /**
  8968. * Gets the top frustum plane transformed by the transform matrix
  8969. * @param transform transformation matrix to be applied to the resulting frustum plane
  8970. * @param frustumPlane the resuling frustum plane
  8971. */
  8972. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8973. /**
  8974. * Gets the bottom frustum plane transformed by the transform matrix
  8975. * @param transform transformation matrix to be applied to the resulting frustum plane
  8976. * @param frustumPlane the resuling frustum plane
  8977. */
  8978. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8979. /**
  8980. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8981. * @param transform transformation matrix to be applied to the resulting frustum planes
  8982. * @param frustumPlanes the resuling frustum planes
  8983. */
  8984. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8985. }
  8986. }
  8987. declare module "babylonjs/Maths/math.size" {
  8988. /**
  8989. * Interface for the size containing width and height
  8990. */
  8991. export interface ISize {
  8992. /**
  8993. * Width
  8994. */
  8995. width: number;
  8996. /**
  8997. * Heighht
  8998. */
  8999. height: number;
  9000. }
  9001. /**
  9002. * Size containing widht and height
  9003. */
  9004. export class Size implements ISize {
  9005. /**
  9006. * Width
  9007. */
  9008. width: number;
  9009. /**
  9010. * Height
  9011. */
  9012. height: number;
  9013. /**
  9014. * Creates a Size object from the given width and height (floats).
  9015. * @param width width of the new size
  9016. * @param height height of the new size
  9017. */
  9018. constructor(width: number, height: number);
  9019. /**
  9020. * Returns a string with the Size width and height
  9021. * @returns a string with the Size width and height
  9022. */
  9023. toString(): string;
  9024. /**
  9025. * "Size"
  9026. * @returns the string "Size"
  9027. */
  9028. getClassName(): string;
  9029. /**
  9030. * Returns the Size hash code.
  9031. * @returns a hash code for a unique width and height
  9032. */
  9033. getHashCode(): number;
  9034. /**
  9035. * Updates the current size from the given one.
  9036. * @param src the given size
  9037. */
  9038. copyFrom(src: Size): void;
  9039. /**
  9040. * Updates in place the current Size from the given floats.
  9041. * @param width width of the new size
  9042. * @param height height of the new size
  9043. * @returns the updated Size.
  9044. */
  9045. copyFromFloats(width: number, height: number): Size;
  9046. /**
  9047. * Updates in place the current Size from the given floats.
  9048. * @param width width to set
  9049. * @param height height to set
  9050. * @returns the updated Size.
  9051. */
  9052. set(width: number, height: number): Size;
  9053. /**
  9054. * Multiplies the width and height by numbers
  9055. * @param w factor to multiple the width by
  9056. * @param h factor to multiple the height by
  9057. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9058. */
  9059. multiplyByFloats(w: number, h: number): Size;
  9060. /**
  9061. * Clones the size
  9062. * @returns a new Size copied from the given one.
  9063. */
  9064. clone(): Size;
  9065. /**
  9066. * True if the current Size and the given one width and height are strictly equal.
  9067. * @param other the other size to compare against
  9068. * @returns True if the current Size and the given one width and height are strictly equal.
  9069. */
  9070. equals(other: Size): boolean;
  9071. /**
  9072. * The surface of the Size : width * height (float).
  9073. */
  9074. get surface(): number;
  9075. /**
  9076. * Create a new size of zero
  9077. * @returns a new Size set to (0.0, 0.0)
  9078. */
  9079. static Zero(): Size;
  9080. /**
  9081. * Sums the width and height of two sizes
  9082. * @param otherSize size to add to this size
  9083. * @returns a new Size set as the addition result of the current Size and the given one.
  9084. */
  9085. add(otherSize: Size): Size;
  9086. /**
  9087. * Subtracts the width and height of two
  9088. * @param otherSize size to subtract to this size
  9089. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9090. */
  9091. subtract(otherSize: Size): Size;
  9092. /**
  9093. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9094. * @param start starting size to lerp between
  9095. * @param end end size to lerp between
  9096. * @param amount amount to lerp between the start and end values
  9097. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9098. */
  9099. static Lerp(start: Size, end: Size, amount: number): Size;
  9100. }
  9101. }
  9102. declare module "babylonjs/Maths/math.vertexFormat" {
  9103. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9104. /**
  9105. * Contains position and normal vectors for a vertex
  9106. */
  9107. export class PositionNormalVertex {
  9108. /** the position of the vertex (defaut: 0,0,0) */
  9109. position: Vector3;
  9110. /** the normal of the vertex (defaut: 0,1,0) */
  9111. normal: Vector3;
  9112. /**
  9113. * Creates a PositionNormalVertex
  9114. * @param position the position of the vertex (defaut: 0,0,0)
  9115. * @param normal the normal of the vertex (defaut: 0,1,0)
  9116. */
  9117. constructor(
  9118. /** the position of the vertex (defaut: 0,0,0) */
  9119. position?: Vector3,
  9120. /** the normal of the vertex (defaut: 0,1,0) */
  9121. normal?: Vector3);
  9122. /**
  9123. * Clones the PositionNormalVertex
  9124. * @returns the cloned PositionNormalVertex
  9125. */
  9126. clone(): PositionNormalVertex;
  9127. }
  9128. /**
  9129. * Contains position, normal and uv vectors for a vertex
  9130. */
  9131. export class PositionNormalTextureVertex {
  9132. /** the position of the vertex (defaut: 0,0,0) */
  9133. position: Vector3;
  9134. /** the normal of the vertex (defaut: 0,1,0) */
  9135. normal: Vector3;
  9136. /** the uv of the vertex (default: 0,0) */
  9137. uv: Vector2;
  9138. /**
  9139. * Creates a PositionNormalTextureVertex
  9140. * @param position the position of the vertex (defaut: 0,0,0)
  9141. * @param normal the normal of the vertex (defaut: 0,1,0)
  9142. * @param uv the uv of the vertex (default: 0,0)
  9143. */
  9144. constructor(
  9145. /** the position of the vertex (defaut: 0,0,0) */
  9146. position?: Vector3,
  9147. /** the normal of the vertex (defaut: 0,1,0) */
  9148. normal?: Vector3,
  9149. /** the uv of the vertex (default: 0,0) */
  9150. uv?: Vector2);
  9151. /**
  9152. * Clones the PositionNormalTextureVertex
  9153. * @returns the cloned PositionNormalTextureVertex
  9154. */
  9155. clone(): PositionNormalTextureVertex;
  9156. }
  9157. }
  9158. declare module "babylonjs/Maths/math" {
  9159. export * from "babylonjs/Maths/math.axis";
  9160. export * from "babylonjs/Maths/math.color";
  9161. export * from "babylonjs/Maths/math.constants";
  9162. export * from "babylonjs/Maths/math.frustum";
  9163. export * from "babylonjs/Maths/math.path";
  9164. export * from "babylonjs/Maths/math.plane";
  9165. export * from "babylonjs/Maths/math.size";
  9166. export * from "babylonjs/Maths/math.vector";
  9167. export * from "babylonjs/Maths/math.vertexFormat";
  9168. export * from "babylonjs/Maths/math.viewport";
  9169. }
  9170. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9171. /**
  9172. * Enum defining the type of animations supported by InputBlock
  9173. */
  9174. export enum AnimatedInputBlockTypes {
  9175. /** No animation */
  9176. None = 0,
  9177. /** Time based animation. Will only work for floats */
  9178. Time = 1
  9179. }
  9180. }
  9181. declare module "babylonjs/Lights/shadowLight" {
  9182. import { Camera } from "babylonjs/Cameras/camera";
  9183. import { Scene } from "babylonjs/scene";
  9184. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9186. import { Light } from "babylonjs/Lights/light";
  9187. /**
  9188. * Interface describing all the common properties and methods a shadow light needs to implement.
  9189. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9190. * as well as binding the different shadow properties to the effects.
  9191. */
  9192. export interface IShadowLight extends Light {
  9193. /**
  9194. * The light id in the scene (used in scene.findLighById for instance)
  9195. */
  9196. id: string;
  9197. /**
  9198. * The position the shdow will be casted from.
  9199. */
  9200. position: Vector3;
  9201. /**
  9202. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9203. */
  9204. direction: Vector3;
  9205. /**
  9206. * The transformed position. Position of the light in world space taking parenting in account.
  9207. */
  9208. transformedPosition: Vector3;
  9209. /**
  9210. * The transformed direction. Direction of the light in world space taking parenting in account.
  9211. */
  9212. transformedDirection: Vector3;
  9213. /**
  9214. * The friendly name of the light in the scene.
  9215. */
  9216. name: string;
  9217. /**
  9218. * Defines the shadow projection clipping minimum z value.
  9219. */
  9220. shadowMinZ: number;
  9221. /**
  9222. * Defines the shadow projection clipping maximum z value.
  9223. */
  9224. shadowMaxZ: number;
  9225. /**
  9226. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9227. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9228. */
  9229. computeTransformedInformation(): boolean;
  9230. /**
  9231. * Gets the scene the light belongs to.
  9232. * @returns The scene
  9233. */
  9234. getScene(): Scene;
  9235. /**
  9236. * Callback defining a custom Projection Matrix Builder.
  9237. * This can be used to override the default projection matrix computation.
  9238. */
  9239. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9240. /**
  9241. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9242. * @param matrix The materix to updated with the projection information
  9243. * @param viewMatrix The transform matrix of the light
  9244. * @param renderList The list of mesh to render in the map
  9245. * @returns The current light
  9246. */
  9247. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9248. /**
  9249. * Gets the current depth scale used in ESM.
  9250. * @returns The scale
  9251. */
  9252. getDepthScale(): number;
  9253. /**
  9254. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9255. * @returns true if a cube texture needs to be use
  9256. */
  9257. needCube(): boolean;
  9258. /**
  9259. * Detects if the projection matrix requires to be recomputed this frame.
  9260. * @returns true if it requires to be recomputed otherwise, false.
  9261. */
  9262. needProjectionMatrixCompute(): boolean;
  9263. /**
  9264. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9265. */
  9266. forceProjectionMatrixCompute(): void;
  9267. /**
  9268. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9269. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9270. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9271. */
  9272. getShadowDirection(faceIndex?: number): Vector3;
  9273. /**
  9274. * Gets the minZ used for shadow according to both the scene and the light.
  9275. * @param activeCamera The camera we are returning the min for
  9276. * @returns the depth min z
  9277. */
  9278. getDepthMinZ(activeCamera: Camera): number;
  9279. /**
  9280. * Gets the maxZ used for shadow according to both the scene and the light.
  9281. * @param activeCamera The camera we are returning the max for
  9282. * @returns the depth max z
  9283. */
  9284. getDepthMaxZ(activeCamera: Camera): number;
  9285. }
  9286. /**
  9287. * Base implementation IShadowLight
  9288. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9289. */
  9290. export abstract class ShadowLight extends Light implements IShadowLight {
  9291. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9292. protected _position: Vector3;
  9293. protected _setPosition(value: Vector3): void;
  9294. /**
  9295. * Sets the position the shadow will be casted from. Also use as the light position for both
  9296. * point and spot lights.
  9297. */
  9298. get position(): Vector3;
  9299. /**
  9300. * Sets the position the shadow will be casted from. Also use as the light position for both
  9301. * point and spot lights.
  9302. */
  9303. set position(value: Vector3);
  9304. protected _direction: Vector3;
  9305. protected _setDirection(value: Vector3): void;
  9306. /**
  9307. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9308. * Also use as the light direction on spot and directional lights.
  9309. */
  9310. get direction(): Vector3;
  9311. /**
  9312. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9313. * Also use as the light direction on spot and directional lights.
  9314. */
  9315. set direction(value: Vector3);
  9316. protected _shadowMinZ: number;
  9317. /**
  9318. * Gets the shadow projection clipping minimum z value.
  9319. */
  9320. get shadowMinZ(): number;
  9321. /**
  9322. * Sets the shadow projection clipping minimum z value.
  9323. */
  9324. set shadowMinZ(value: number);
  9325. protected _shadowMaxZ: number;
  9326. /**
  9327. * Sets the shadow projection clipping maximum z value.
  9328. */
  9329. get shadowMaxZ(): number;
  9330. /**
  9331. * Gets the shadow projection clipping maximum z value.
  9332. */
  9333. set shadowMaxZ(value: number);
  9334. /**
  9335. * Callback defining a custom Projection Matrix Builder.
  9336. * This can be used to override the default projection matrix computation.
  9337. */
  9338. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9339. /**
  9340. * The transformed position. Position of the light in world space taking parenting in account.
  9341. */
  9342. transformedPosition: Vector3;
  9343. /**
  9344. * The transformed direction. Direction of the light in world space taking parenting in account.
  9345. */
  9346. transformedDirection: Vector3;
  9347. private _needProjectionMatrixCompute;
  9348. /**
  9349. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9350. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9351. */
  9352. computeTransformedInformation(): boolean;
  9353. /**
  9354. * Return the depth scale used for the shadow map.
  9355. * @returns the depth scale.
  9356. */
  9357. getDepthScale(): number;
  9358. /**
  9359. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9360. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9361. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9362. */
  9363. getShadowDirection(faceIndex?: number): Vector3;
  9364. /**
  9365. * Returns the ShadowLight absolute position in the World.
  9366. * @returns the position vector in world space
  9367. */
  9368. getAbsolutePosition(): Vector3;
  9369. /**
  9370. * Sets the ShadowLight direction toward the passed target.
  9371. * @param target The point to target in local space
  9372. * @returns the updated ShadowLight direction
  9373. */
  9374. setDirectionToTarget(target: Vector3): Vector3;
  9375. /**
  9376. * Returns the light rotation in euler definition.
  9377. * @returns the x y z rotation in local space.
  9378. */
  9379. getRotation(): Vector3;
  9380. /**
  9381. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9382. * @returns true if a cube texture needs to be use
  9383. */
  9384. needCube(): boolean;
  9385. /**
  9386. * Detects if the projection matrix requires to be recomputed this frame.
  9387. * @returns true if it requires to be recomputed otherwise, false.
  9388. */
  9389. needProjectionMatrixCompute(): boolean;
  9390. /**
  9391. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9392. */
  9393. forceProjectionMatrixCompute(): void;
  9394. /** @hidden */
  9395. _initCache(): void;
  9396. /** @hidden */
  9397. _isSynchronized(): boolean;
  9398. /**
  9399. * Computes the world matrix of the node
  9400. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9401. * @returns the world matrix
  9402. */
  9403. computeWorldMatrix(force?: boolean): Matrix;
  9404. /**
  9405. * Gets the minZ used for shadow according to both the scene and the light.
  9406. * @param activeCamera The camera we are returning the min for
  9407. * @returns the depth min z
  9408. */
  9409. getDepthMinZ(activeCamera: Camera): number;
  9410. /**
  9411. * Gets the maxZ used for shadow according to both the scene and the light.
  9412. * @param activeCamera The camera we are returning the max for
  9413. * @returns the depth max z
  9414. */
  9415. getDepthMaxZ(activeCamera: Camera): number;
  9416. /**
  9417. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9418. * @param matrix The materix to updated with the projection information
  9419. * @param viewMatrix The transform matrix of the light
  9420. * @param renderList The list of mesh to render in the map
  9421. * @returns The current light
  9422. */
  9423. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9424. }
  9425. }
  9426. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9427. /** @hidden */
  9428. export var packingFunctions: {
  9429. name: string;
  9430. shader: string;
  9431. };
  9432. }
  9433. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9434. /** @hidden */
  9435. export var bayerDitherFunctions: {
  9436. name: string;
  9437. shader: string;
  9438. };
  9439. }
  9440. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9441. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9442. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9443. /** @hidden */
  9444. export var shadowMapFragmentDeclaration: {
  9445. name: string;
  9446. shader: string;
  9447. };
  9448. }
  9449. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9450. /** @hidden */
  9451. export var clipPlaneFragmentDeclaration: {
  9452. name: string;
  9453. shader: string;
  9454. };
  9455. }
  9456. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9457. /** @hidden */
  9458. export var clipPlaneFragment: {
  9459. name: string;
  9460. shader: string;
  9461. };
  9462. }
  9463. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9464. /** @hidden */
  9465. export var shadowMapFragment: {
  9466. name: string;
  9467. shader: string;
  9468. };
  9469. }
  9470. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9471. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9472. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9473. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9474. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9475. /** @hidden */
  9476. export var shadowMapPixelShader: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9482. /** @hidden */
  9483. export var bonesDeclaration: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9489. /** @hidden */
  9490. export var morphTargetsVertexGlobalDeclaration: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9496. /** @hidden */
  9497. export var morphTargetsVertexDeclaration: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9503. /** @hidden */
  9504. export var instancesDeclaration: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9510. /** @hidden */
  9511. export var helperFunctions: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9517. /** @hidden */
  9518. export var shadowMapVertexDeclaration: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9524. /** @hidden */
  9525. export var clipPlaneVertexDeclaration: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9531. /** @hidden */
  9532. export var morphTargetsVertex: {
  9533. name: string;
  9534. shader: string;
  9535. };
  9536. }
  9537. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9538. /** @hidden */
  9539. export var instancesVertex: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9545. /** @hidden */
  9546. export var bonesVertex: {
  9547. name: string;
  9548. shader: string;
  9549. };
  9550. }
  9551. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9552. /** @hidden */
  9553. export var shadowMapVertexNormalBias: {
  9554. name: string;
  9555. shader: string;
  9556. };
  9557. }
  9558. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9559. /** @hidden */
  9560. export var shadowMapVertexMetric: {
  9561. name: string;
  9562. shader: string;
  9563. };
  9564. }
  9565. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9566. /** @hidden */
  9567. export var clipPlaneVertex: {
  9568. name: string;
  9569. shader: string;
  9570. };
  9571. }
  9572. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9573. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9574. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9575. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9576. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9577. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9578. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9579. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9580. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9581. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9582. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9583. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9584. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9585. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9586. /** @hidden */
  9587. export var shadowMapVertexShader: {
  9588. name: string;
  9589. shader: string;
  9590. };
  9591. }
  9592. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9593. /** @hidden */
  9594. export var depthBoxBlurPixelShader: {
  9595. name: string;
  9596. shader: string;
  9597. };
  9598. }
  9599. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9600. /** @hidden */
  9601. export var shadowMapFragmentSoftTransparentShadow: {
  9602. name: string;
  9603. shader: string;
  9604. };
  9605. }
  9606. declare module "babylonjs/Materials/effectFallbacks" {
  9607. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9608. import { Effect } from "babylonjs/Materials/effect";
  9609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9610. /**
  9611. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9612. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9613. */
  9614. export class EffectFallbacks implements IEffectFallbacks {
  9615. private _defines;
  9616. private _currentRank;
  9617. private _maxRank;
  9618. private _mesh;
  9619. /**
  9620. * Removes the fallback from the bound mesh.
  9621. */
  9622. unBindMesh(): void;
  9623. /**
  9624. * Adds a fallback on the specified property.
  9625. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9626. * @param define The name of the define in the shader
  9627. */
  9628. addFallback(rank: number, define: string): void;
  9629. /**
  9630. * Sets the mesh to use CPU skinning when needing to fallback.
  9631. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9632. * @param mesh The mesh to use the fallbacks.
  9633. */
  9634. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9635. /**
  9636. * Checks to see if more fallbacks are still availible.
  9637. */
  9638. get hasMoreFallbacks(): boolean;
  9639. /**
  9640. * Removes the defines that should be removed when falling back.
  9641. * @param currentDefines defines the current define statements for the shader.
  9642. * @param effect defines the current effect we try to compile
  9643. * @returns The resulting defines with defines of the current rank removed.
  9644. */
  9645. reduce(currentDefines: string, effect: Effect): string;
  9646. }
  9647. }
  9648. declare module "babylonjs/Actions/action" {
  9649. import { Observable } from "babylonjs/Misc/observable";
  9650. import { Condition } from "babylonjs/Actions/condition";
  9651. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9652. import { Nullable } from "babylonjs/types";
  9653. import { Scene } from "babylonjs/scene";
  9654. import { ActionManager } from "babylonjs/Actions/actionManager";
  9655. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9656. import { Node } from "babylonjs/node";
  9657. /**
  9658. * Interface used to define Action
  9659. */
  9660. export interface IAction {
  9661. /**
  9662. * Trigger for the action
  9663. */
  9664. trigger: number;
  9665. /** Options of the trigger */
  9666. triggerOptions: any;
  9667. /**
  9668. * Gets the trigger parameters
  9669. * @returns the trigger parameters
  9670. */
  9671. getTriggerParameter(): any;
  9672. /**
  9673. * Internal only - executes current action event
  9674. * @hidden
  9675. */
  9676. _executeCurrent(evt?: ActionEvent): void;
  9677. /**
  9678. * Serialize placeholder for child classes
  9679. * @param parent of child
  9680. * @returns the serialized object
  9681. */
  9682. serialize(parent: any): any;
  9683. /**
  9684. * Internal only
  9685. * @hidden
  9686. */
  9687. _prepare(): void;
  9688. /**
  9689. * Internal only - manager for action
  9690. * @hidden
  9691. */
  9692. _actionManager: Nullable<AbstractActionManager>;
  9693. /**
  9694. * Adds action to chain of actions, may be a DoNothingAction
  9695. * @param action defines the next action to execute
  9696. * @returns The action passed in
  9697. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9698. */
  9699. then(action: IAction): IAction;
  9700. }
  9701. /**
  9702. * The action to be carried out following a trigger
  9703. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9704. */
  9705. export class Action implements IAction {
  9706. /** the trigger, with or without parameters, for the action */
  9707. triggerOptions: any;
  9708. /**
  9709. * Trigger for the action
  9710. */
  9711. trigger: number;
  9712. /**
  9713. * Internal only - manager for action
  9714. * @hidden
  9715. */
  9716. _actionManager: ActionManager;
  9717. private _nextActiveAction;
  9718. private _child;
  9719. private _condition?;
  9720. private _triggerParameter;
  9721. /**
  9722. * An event triggered prior to action being executed.
  9723. */
  9724. onBeforeExecuteObservable: Observable<Action>;
  9725. /**
  9726. * Creates a new Action
  9727. * @param triggerOptions the trigger, with or without parameters, for the action
  9728. * @param condition an optional determinant of action
  9729. */
  9730. constructor(
  9731. /** the trigger, with or without parameters, for the action */
  9732. triggerOptions: any, condition?: Condition);
  9733. /**
  9734. * Internal only
  9735. * @hidden
  9736. */
  9737. _prepare(): void;
  9738. /**
  9739. * Gets the trigger parameters
  9740. * @returns the trigger parameters
  9741. */
  9742. getTriggerParameter(): any;
  9743. /**
  9744. * Internal only - executes current action event
  9745. * @hidden
  9746. */
  9747. _executeCurrent(evt?: ActionEvent): void;
  9748. /**
  9749. * Execute placeholder for child classes
  9750. * @param evt optional action event
  9751. */
  9752. execute(evt?: ActionEvent): void;
  9753. /**
  9754. * Skips to next active action
  9755. */
  9756. skipToNextActiveAction(): void;
  9757. /**
  9758. * Adds action to chain of actions, may be a DoNothingAction
  9759. * @param action defines the next action to execute
  9760. * @returns The action passed in
  9761. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9762. */
  9763. then(action: Action): Action;
  9764. /**
  9765. * Internal only
  9766. * @hidden
  9767. */
  9768. _getProperty(propertyPath: string): string;
  9769. /**
  9770. * Internal only
  9771. * @hidden
  9772. */
  9773. _getEffectiveTarget(target: any, propertyPath: string): any;
  9774. /**
  9775. * Serialize placeholder for child classes
  9776. * @param parent of child
  9777. * @returns the serialized object
  9778. */
  9779. serialize(parent: any): any;
  9780. /**
  9781. * Internal only called by serialize
  9782. * @hidden
  9783. */
  9784. protected _serialize(serializedAction: any, parent?: any): any;
  9785. /**
  9786. * Internal only
  9787. * @hidden
  9788. */
  9789. static _SerializeValueAsString: (value: any) => string;
  9790. /**
  9791. * Internal only
  9792. * @hidden
  9793. */
  9794. static _GetTargetProperty: (target: Scene | Node) => {
  9795. name: string;
  9796. targetType: string;
  9797. value: string;
  9798. };
  9799. }
  9800. }
  9801. declare module "babylonjs/Actions/condition" {
  9802. import { ActionManager } from "babylonjs/Actions/actionManager";
  9803. /**
  9804. * A Condition applied to an Action
  9805. */
  9806. export class Condition {
  9807. /**
  9808. * Internal only - manager for action
  9809. * @hidden
  9810. */
  9811. _actionManager: ActionManager;
  9812. /**
  9813. * Internal only
  9814. * @hidden
  9815. */
  9816. _evaluationId: number;
  9817. /**
  9818. * Internal only
  9819. * @hidden
  9820. */
  9821. _currentResult: boolean;
  9822. /**
  9823. * Creates a new Condition
  9824. * @param actionManager the manager of the action the condition is applied to
  9825. */
  9826. constructor(actionManager: ActionManager);
  9827. /**
  9828. * Check if the current condition is valid
  9829. * @returns a boolean
  9830. */
  9831. isValid(): boolean;
  9832. /**
  9833. * Internal only
  9834. * @hidden
  9835. */
  9836. _getProperty(propertyPath: string): string;
  9837. /**
  9838. * Internal only
  9839. * @hidden
  9840. */
  9841. _getEffectiveTarget(target: any, propertyPath: string): any;
  9842. /**
  9843. * Serialize placeholder for child classes
  9844. * @returns the serialized object
  9845. */
  9846. serialize(): any;
  9847. /**
  9848. * Internal only
  9849. * @hidden
  9850. */
  9851. protected _serialize(serializedCondition: any): any;
  9852. }
  9853. /**
  9854. * Defines specific conditional operators as extensions of Condition
  9855. */
  9856. export class ValueCondition extends Condition {
  9857. /** path to specify the property of the target the conditional operator uses */
  9858. propertyPath: string;
  9859. /** the value compared by the conditional operator against the current value of the property */
  9860. value: any;
  9861. /** the conditional operator, default ValueCondition.IsEqual */
  9862. operator: number;
  9863. /**
  9864. * Internal only
  9865. * @hidden
  9866. */
  9867. private static _IsEqual;
  9868. /**
  9869. * Internal only
  9870. * @hidden
  9871. */
  9872. private static _IsDifferent;
  9873. /**
  9874. * Internal only
  9875. * @hidden
  9876. */
  9877. private static _IsGreater;
  9878. /**
  9879. * Internal only
  9880. * @hidden
  9881. */
  9882. private static _IsLesser;
  9883. /**
  9884. * returns the number for IsEqual
  9885. */
  9886. static get IsEqual(): number;
  9887. /**
  9888. * Returns the number for IsDifferent
  9889. */
  9890. static get IsDifferent(): number;
  9891. /**
  9892. * Returns the number for IsGreater
  9893. */
  9894. static get IsGreater(): number;
  9895. /**
  9896. * Returns the number for IsLesser
  9897. */
  9898. static get IsLesser(): number;
  9899. /**
  9900. * Internal only The action manager for the condition
  9901. * @hidden
  9902. */
  9903. _actionManager: ActionManager;
  9904. /**
  9905. * Internal only
  9906. * @hidden
  9907. */
  9908. private _target;
  9909. /**
  9910. * Internal only
  9911. * @hidden
  9912. */
  9913. private _effectiveTarget;
  9914. /**
  9915. * Internal only
  9916. * @hidden
  9917. */
  9918. private _property;
  9919. /**
  9920. * Creates a new ValueCondition
  9921. * @param actionManager manager for the action the condition applies to
  9922. * @param target for the action
  9923. * @param propertyPath path to specify the property of the target the conditional operator uses
  9924. * @param value the value compared by the conditional operator against the current value of the property
  9925. * @param operator the conditional operator, default ValueCondition.IsEqual
  9926. */
  9927. constructor(actionManager: ActionManager, target: any,
  9928. /** path to specify the property of the target the conditional operator uses */
  9929. propertyPath: string,
  9930. /** the value compared by the conditional operator against the current value of the property */
  9931. value: any,
  9932. /** the conditional operator, default ValueCondition.IsEqual */
  9933. operator?: number);
  9934. /**
  9935. * Compares the given value with the property value for the specified conditional operator
  9936. * @returns the result of the comparison
  9937. */
  9938. isValid(): boolean;
  9939. /**
  9940. * Serialize the ValueCondition into a JSON compatible object
  9941. * @returns serialization object
  9942. */
  9943. serialize(): any;
  9944. /**
  9945. * Gets the name of the conditional operator for the ValueCondition
  9946. * @param operator the conditional operator
  9947. * @returns the name
  9948. */
  9949. static GetOperatorName(operator: number): string;
  9950. }
  9951. /**
  9952. * Defines a predicate condition as an extension of Condition
  9953. */
  9954. export class PredicateCondition extends Condition {
  9955. /** defines the predicate function used to validate the condition */
  9956. predicate: () => boolean;
  9957. /**
  9958. * Internal only - manager for action
  9959. * @hidden
  9960. */
  9961. _actionManager: ActionManager;
  9962. /**
  9963. * Creates a new PredicateCondition
  9964. * @param actionManager manager for the action the condition applies to
  9965. * @param predicate defines the predicate function used to validate the condition
  9966. */
  9967. constructor(actionManager: ActionManager,
  9968. /** defines the predicate function used to validate the condition */
  9969. predicate: () => boolean);
  9970. /**
  9971. * @returns the validity of the predicate condition
  9972. */
  9973. isValid(): boolean;
  9974. }
  9975. /**
  9976. * Defines a state condition as an extension of Condition
  9977. */
  9978. export class StateCondition extends Condition {
  9979. /** Value to compare with target state */
  9980. value: string;
  9981. /**
  9982. * Internal only - manager for action
  9983. * @hidden
  9984. */
  9985. _actionManager: ActionManager;
  9986. /**
  9987. * Internal only
  9988. * @hidden
  9989. */
  9990. private _target;
  9991. /**
  9992. * Creates a new StateCondition
  9993. * @param actionManager manager for the action the condition applies to
  9994. * @param target of the condition
  9995. * @param value to compare with target state
  9996. */
  9997. constructor(actionManager: ActionManager, target: any,
  9998. /** Value to compare with target state */
  9999. value: string);
  10000. /**
  10001. * Gets a boolean indicating if the current condition is met
  10002. * @returns the validity of the state
  10003. */
  10004. isValid(): boolean;
  10005. /**
  10006. * Serialize the StateCondition into a JSON compatible object
  10007. * @returns serialization object
  10008. */
  10009. serialize(): any;
  10010. }
  10011. }
  10012. declare module "babylonjs/Actions/directActions" {
  10013. import { Action } from "babylonjs/Actions/action";
  10014. import { Condition } from "babylonjs/Actions/condition";
  10015. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10016. /**
  10017. * This defines an action responsible to toggle a boolean once triggered.
  10018. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10019. */
  10020. export class SwitchBooleanAction extends Action {
  10021. /**
  10022. * The path to the boolean property in the target object
  10023. */
  10024. propertyPath: string;
  10025. private _target;
  10026. private _effectiveTarget;
  10027. private _property;
  10028. /**
  10029. * Instantiate the action
  10030. * @param triggerOptions defines the trigger options
  10031. * @param target defines the object containing the boolean
  10032. * @param propertyPath defines the path to the boolean property in the target object
  10033. * @param condition defines the trigger related conditions
  10034. */
  10035. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10036. /** @hidden */
  10037. _prepare(): void;
  10038. /**
  10039. * Execute the action toggle the boolean value.
  10040. */
  10041. execute(): void;
  10042. /**
  10043. * Serializes the actions and its related information.
  10044. * @param parent defines the object to serialize in
  10045. * @returns the serialized object
  10046. */
  10047. serialize(parent: any): any;
  10048. }
  10049. /**
  10050. * This defines an action responsible to set a the state field of the target
  10051. * to a desired value once triggered.
  10052. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10053. */
  10054. export class SetStateAction extends Action {
  10055. /**
  10056. * The value to store in the state field.
  10057. */
  10058. value: string;
  10059. private _target;
  10060. /**
  10061. * Instantiate the action
  10062. * @param triggerOptions defines the trigger options
  10063. * @param target defines the object containing the state property
  10064. * @param value defines the value to store in the state field
  10065. * @param condition defines the trigger related conditions
  10066. */
  10067. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10068. /**
  10069. * Execute the action and store the value on the target state property.
  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 set a property of the target
  10081. * to a desired value once triggered.
  10082. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10083. */
  10084. export class SetValueAction extends Action {
  10085. /**
  10086. * The path of the property to set in the target.
  10087. */
  10088. propertyPath: string;
  10089. /**
  10090. * The value to set in the property
  10091. */
  10092. value: any;
  10093. private _target;
  10094. private _effectiveTarget;
  10095. private _property;
  10096. /**
  10097. * Instantiate the action
  10098. * @param triggerOptions defines the trigger options
  10099. * @param target defines the object containing the property
  10100. * @param propertyPath defines the path of the property to set in the target
  10101. * @param value defines the value to set in the property
  10102. * @param condition defines the trigger related conditions
  10103. */
  10104. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10105. /** @hidden */
  10106. _prepare(): void;
  10107. /**
  10108. * Execute the action and set the targetted property to the desired value.
  10109. */
  10110. execute(): void;
  10111. /**
  10112. * Serializes the actions and its related information.
  10113. * @param parent defines the object to serialize in
  10114. * @returns the serialized object
  10115. */
  10116. serialize(parent: any): any;
  10117. }
  10118. /**
  10119. * This defines an action responsible to increment the target value
  10120. * to a desired value once triggered.
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10122. */
  10123. export class IncrementValueAction extends Action {
  10124. /**
  10125. * The path of the property to increment in the target.
  10126. */
  10127. propertyPath: string;
  10128. /**
  10129. * The value we should increment the property by.
  10130. */
  10131. value: any;
  10132. private _target;
  10133. private _effectiveTarget;
  10134. private _property;
  10135. /**
  10136. * Instantiate the action
  10137. * @param triggerOptions defines the trigger options
  10138. * @param target defines the object containing the property
  10139. * @param propertyPath defines the path of the property to increment in the target
  10140. * @param value defines the value value we should increment the property by
  10141. * @param condition defines the trigger related conditions
  10142. */
  10143. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10144. /** @hidden */
  10145. _prepare(): void;
  10146. /**
  10147. * Execute the action and increment the target of the value amount.
  10148. */
  10149. execute(): void;
  10150. /**
  10151. * Serializes the actions and its related information.
  10152. * @param parent defines the object to serialize in
  10153. * @returns the serialized object
  10154. */
  10155. serialize(parent: any): any;
  10156. }
  10157. /**
  10158. * This defines an action responsible to start an animation once triggered.
  10159. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10160. */
  10161. export class PlayAnimationAction extends Action {
  10162. /**
  10163. * Where the animation should start (animation frame)
  10164. */
  10165. from: number;
  10166. /**
  10167. * Where the animation should stop (animation frame)
  10168. */
  10169. to: number;
  10170. /**
  10171. * Define if the animation should loop or stop after the first play.
  10172. */
  10173. loop?: boolean;
  10174. private _target;
  10175. /**
  10176. * Instantiate the action
  10177. * @param triggerOptions defines the trigger options
  10178. * @param target defines the target animation or animation name
  10179. * @param from defines from where the animation should start (animation frame)
  10180. * @param end defines where the animation should stop (animation frame)
  10181. * @param loop defines if the animation should loop or stop after the first play
  10182. * @param condition defines the trigger related conditions
  10183. */
  10184. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10185. /** @hidden */
  10186. _prepare(): void;
  10187. /**
  10188. * Execute the action and play the animation.
  10189. */
  10190. execute(): void;
  10191. /**
  10192. * Serializes the actions and its related information.
  10193. * @param parent defines the object to serialize in
  10194. * @returns the serialized object
  10195. */
  10196. serialize(parent: any): any;
  10197. }
  10198. /**
  10199. * This defines an action responsible to stop an animation once triggered.
  10200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10201. */
  10202. export class StopAnimationAction extends Action {
  10203. private _target;
  10204. /**
  10205. * Instantiate the action
  10206. * @param triggerOptions defines the trigger options
  10207. * @param target defines the target animation or animation name
  10208. * @param condition defines the trigger related conditions
  10209. */
  10210. constructor(triggerOptions: any, target: any, condition?: Condition);
  10211. /** @hidden */
  10212. _prepare(): void;
  10213. /**
  10214. * Execute the action and stop the animation.
  10215. */
  10216. execute(): void;
  10217. /**
  10218. * Serializes the actions and its related information.
  10219. * @param parent defines the object to serialize in
  10220. * @returns the serialized object
  10221. */
  10222. serialize(parent: any): any;
  10223. }
  10224. /**
  10225. * This defines an action responsible that does nothing once triggered.
  10226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10227. */
  10228. export class DoNothingAction extends Action {
  10229. /**
  10230. * Instantiate the action
  10231. * @param triggerOptions defines the trigger options
  10232. * @param condition defines the trigger related conditions
  10233. */
  10234. constructor(triggerOptions?: any, condition?: Condition);
  10235. /**
  10236. * Execute the action and do nothing.
  10237. */
  10238. execute(): void;
  10239. /**
  10240. * Serializes the actions and its related information.
  10241. * @param parent defines the object to serialize in
  10242. * @returns the serialized object
  10243. */
  10244. serialize(parent: any): any;
  10245. }
  10246. /**
  10247. * This defines an action responsible to trigger several actions once triggered.
  10248. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10249. */
  10250. export class CombineAction extends Action {
  10251. /**
  10252. * The list of aggregated animations to run.
  10253. */
  10254. children: Action[];
  10255. /**
  10256. * Instantiate the action
  10257. * @param triggerOptions defines the trigger options
  10258. * @param children defines the list of aggregated animations to run
  10259. * @param condition defines the trigger related conditions
  10260. */
  10261. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10262. /** @hidden */
  10263. _prepare(): void;
  10264. /**
  10265. * Execute the action and executes all the aggregated actions.
  10266. */
  10267. execute(evt: ActionEvent): void;
  10268. /**
  10269. * Serializes the actions and its related information.
  10270. * @param parent defines the object to serialize in
  10271. * @returns the serialized object
  10272. */
  10273. serialize(parent: any): any;
  10274. }
  10275. /**
  10276. * This defines an action responsible to run code (external event) once triggered.
  10277. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10278. */
  10279. export class ExecuteCodeAction extends Action {
  10280. /**
  10281. * The callback function to run.
  10282. */
  10283. func: (evt: ActionEvent) => void;
  10284. /**
  10285. * Instantiate the action
  10286. * @param triggerOptions defines the trigger options
  10287. * @param func defines the callback function to run
  10288. * @param condition defines the trigger related conditions
  10289. */
  10290. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10291. /**
  10292. * Execute the action and run the attached code.
  10293. */
  10294. execute(evt: ActionEvent): void;
  10295. }
  10296. /**
  10297. * This defines an action responsible to set the parent property of the target once triggered.
  10298. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10299. */
  10300. export class SetParentAction extends Action {
  10301. private _parent;
  10302. private _target;
  10303. /**
  10304. * Instantiate the action
  10305. * @param triggerOptions defines the trigger options
  10306. * @param target defines the target containing the parent property
  10307. * @param parent defines from where the animation should start (animation frame)
  10308. * @param condition defines the trigger related conditions
  10309. */
  10310. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10311. /** @hidden */
  10312. _prepare(): void;
  10313. /**
  10314. * Execute the action and set the parent property.
  10315. */
  10316. execute(): void;
  10317. /**
  10318. * Serializes the actions and its related information.
  10319. * @param parent defines the object to serialize in
  10320. * @returns the serialized object
  10321. */
  10322. serialize(parent: any): any;
  10323. }
  10324. }
  10325. declare module "babylonjs/Actions/actionManager" {
  10326. import { Nullable } from "babylonjs/types";
  10327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10328. import { Scene } from "babylonjs/scene";
  10329. import { IAction } from "babylonjs/Actions/action";
  10330. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10331. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10332. /**
  10333. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10334. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10335. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10336. */
  10337. export class ActionManager extends AbstractActionManager {
  10338. /**
  10339. * Nothing
  10340. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10341. */
  10342. static readonly NothingTrigger: number;
  10343. /**
  10344. * On pick
  10345. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10346. */
  10347. static readonly OnPickTrigger: number;
  10348. /**
  10349. * On left pick
  10350. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10351. */
  10352. static readonly OnLeftPickTrigger: number;
  10353. /**
  10354. * On right pick
  10355. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10356. */
  10357. static readonly OnRightPickTrigger: number;
  10358. /**
  10359. * On center pick
  10360. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10361. */
  10362. static readonly OnCenterPickTrigger: number;
  10363. /**
  10364. * On pick down
  10365. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10366. */
  10367. static readonly OnPickDownTrigger: number;
  10368. /**
  10369. * On double pick
  10370. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10371. */
  10372. static readonly OnDoublePickTrigger: number;
  10373. /**
  10374. * On pick up
  10375. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10376. */
  10377. static readonly OnPickUpTrigger: number;
  10378. /**
  10379. * On pick out.
  10380. * This trigger will only be raised if you also declared a OnPickDown
  10381. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10382. */
  10383. static readonly OnPickOutTrigger: number;
  10384. /**
  10385. * On long press
  10386. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10387. */
  10388. static readonly OnLongPressTrigger: number;
  10389. /**
  10390. * On pointer over
  10391. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10392. */
  10393. static readonly OnPointerOverTrigger: number;
  10394. /**
  10395. * On pointer out
  10396. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10397. */
  10398. static readonly OnPointerOutTrigger: number;
  10399. /**
  10400. * On every frame
  10401. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10402. */
  10403. static readonly OnEveryFrameTrigger: number;
  10404. /**
  10405. * On intersection enter
  10406. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10407. */
  10408. static readonly OnIntersectionEnterTrigger: number;
  10409. /**
  10410. * On intersection exit
  10411. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10412. */
  10413. static readonly OnIntersectionExitTrigger: number;
  10414. /**
  10415. * On key down
  10416. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10417. */
  10418. static readonly OnKeyDownTrigger: number;
  10419. /**
  10420. * On key up
  10421. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10422. */
  10423. static readonly OnKeyUpTrigger: number;
  10424. private _scene;
  10425. /**
  10426. * Creates a new action manager
  10427. * @param scene defines the hosting scene
  10428. */
  10429. constructor(scene: Scene);
  10430. /**
  10431. * Releases all associated resources
  10432. */
  10433. dispose(): void;
  10434. /**
  10435. * Gets hosting scene
  10436. * @returns the hosting scene
  10437. */
  10438. getScene(): Scene;
  10439. /**
  10440. * Does this action manager handles actions of any of the given triggers
  10441. * @param triggers defines the triggers to be tested
  10442. * @return a boolean indicating whether one (or more) of the triggers is handled
  10443. */
  10444. hasSpecificTriggers(triggers: number[]): boolean;
  10445. /**
  10446. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10447. * speed.
  10448. * @param triggerA defines the trigger to be tested
  10449. * @param triggerB defines the trigger to be tested
  10450. * @return a boolean indicating whether one (or more) of the triggers is handled
  10451. */
  10452. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10453. /**
  10454. * Does this action manager handles actions of a given trigger
  10455. * @param trigger defines the trigger to be tested
  10456. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10457. * @return whether the trigger is handled
  10458. */
  10459. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10460. /**
  10461. * Does this action manager has pointer triggers
  10462. */
  10463. get hasPointerTriggers(): boolean;
  10464. /**
  10465. * Does this action manager has pick triggers
  10466. */
  10467. get hasPickTriggers(): boolean;
  10468. /**
  10469. * Registers an action to this action manager
  10470. * @param action defines the action to be registered
  10471. * @return the action amended (prepared) after registration
  10472. */
  10473. registerAction(action: IAction): Nullable<IAction>;
  10474. /**
  10475. * Unregisters an action to this action manager
  10476. * @param action defines the action to be unregistered
  10477. * @return a boolean indicating whether the action has been unregistered
  10478. */
  10479. unregisterAction(action: IAction): Boolean;
  10480. /**
  10481. * Process a specific trigger
  10482. * @param trigger defines the trigger to process
  10483. * @param evt defines the event details to be processed
  10484. */
  10485. processTrigger(trigger: number, evt?: IActionEvent): void;
  10486. /** @hidden */
  10487. _getEffectiveTarget(target: any, propertyPath: string): any;
  10488. /** @hidden */
  10489. _getProperty(propertyPath: string): string;
  10490. /**
  10491. * Serialize this manager to a JSON object
  10492. * @param name defines the property name to store this manager
  10493. * @returns a JSON representation of this manager
  10494. */
  10495. serialize(name: string): any;
  10496. /**
  10497. * Creates a new ActionManager from a JSON data
  10498. * @param parsedActions defines the JSON data to read from
  10499. * @param object defines the hosting mesh
  10500. * @param scene defines the hosting scene
  10501. */
  10502. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10503. /**
  10504. * Get a trigger name by index
  10505. * @param trigger defines the trigger index
  10506. * @returns a trigger name
  10507. */
  10508. static GetTriggerName(trigger: number): string;
  10509. }
  10510. }
  10511. declare module "babylonjs/Sprites/sprite" {
  10512. import { Vector3 } from "babylonjs/Maths/math.vector";
  10513. import { Nullable } from "babylonjs/types";
  10514. import { ActionManager } from "babylonjs/Actions/actionManager";
  10515. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10516. import { Color4 } from "babylonjs/Maths/math.color";
  10517. import { Observable } from "babylonjs/Misc/observable";
  10518. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10519. import { Animation } from "babylonjs/Animations/animation";
  10520. /**
  10521. * Class used to represent a sprite
  10522. * @see https://doc.babylonjs.com/babylon101/sprites
  10523. */
  10524. export class Sprite implements IAnimatable {
  10525. /** defines the name */
  10526. name: string;
  10527. /** Gets or sets the current world position */
  10528. position: Vector3;
  10529. /** Gets or sets the main color */
  10530. color: Color4;
  10531. /** Gets or sets the width */
  10532. width: number;
  10533. /** Gets or sets the height */
  10534. height: number;
  10535. /** Gets or sets rotation angle */
  10536. angle: number;
  10537. /** Gets or sets the cell index in the sprite sheet */
  10538. cellIndex: number;
  10539. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10540. cellRef: string;
  10541. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10542. invertU: boolean;
  10543. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10544. invertV: boolean;
  10545. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10546. disposeWhenFinishedAnimating: boolean;
  10547. /** Gets the list of attached animations */
  10548. animations: Nullable<Array<Animation>>;
  10549. /** Gets or sets a boolean indicating if the sprite can be picked */
  10550. isPickable: boolean;
  10551. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10552. useAlphaForPicking: boolean;
  10553. /** @hidden */
  10554. _xOffset: number;
  10555. /** @hidden */
  10556. _yOffset: number;
  10557. /** @hidden */
  10558. _xSize: number;
  10559. /** @hidden */
  10560. _ySize: number;
  10561. /**
  10562. * Gets or sets the associated action manager
  10563. */
  10564. actionManager: Nullable<ActionManager>;
  10565. /**
  10566. * An event triggered when the control has been disposed
  10567. */
  10568. onDisposeObservable: Observable<Sprite>;
  10569. private _animationStarted;
  10570. private _loopAnimation;
  10571. private _fromIndex;
  10572. private _toIndex;
  10573. private _delay;
  10574. private _direction;
  10575. private _manager;
  10576. private _time;
  10577. private _onAnimationEnd;
  10578. /**
  10579. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10580. */
  10581. isVisible: boolean;
  10582. /**
  10583. * Gets or sets the sprite size
  10584. */
  10585. get size(): number;
  10586. set size(value: number);
  10587. /**
  10588. * Returns a boolean indicating if the animation is started
  10589. */
  10590. get animationStarted(): boolean;
  10591. /**
  10592. * Gets or sets the unique id of the sprite
  10593. */
  10594. uniqueId: number;
  10595. /**
  10596. * Gets the manager of this sprite
  10597. */
  10598. get manager(): ISpriteManager;
  10599. /**
  10600. * Creates a new Sprite
  10601. * @param name defines the name
  10602. * @param manager defines the manager
  10603. */
  10604. constructor(
  10605. /** defines the name */
  10606. name: string, manager: ISpriteManager);
  10607. /**
  10608. * Returns the string "Sprite"
  10609. * @returns "Sprite"
  10610. */
  10611. getClassName(): string;
  10612. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10613. get fromIndex(): number;
  10614. set fromIndex(value: number);
  10615. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10616. get toIndex(): number;
  10617. set toIndex(value: number);
  10618. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10619. get loopAnimation(): boolean;
  10620. set loopAnimation(value: boolean);
  10621. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10622. get delay(): number;
  10623. set delay(value: number);
  10624. /**
  10625. * Starts an animation
  10626. * @param from defines the initial key
  10627. * @param to defines the end key
  10628. * @param loop defines if the animation must loop
  10629. * @param delay defines the start delay (in ms)
  10630. * @param onAnimationEnd defines a callback to call when animation ends
  10631. */
  10632. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10633. /** Stops current animation (if any) */
  10634. stopAnimation(): void;
  10635. /** @hidden */
  10636. _animate(deltaTime: number): void;
  10637. /** Release associated resources */
  10638. dispose(): void;
  10639. /**
  10640. * Serializes the sprite to a JSON object
  10641. * @returns the JSON object
  10642. */
  10643. serialize(): any;
  10644. /**
  10645. * Parses a JSON object to create a new sprite
  10646. * @param parsedSprite The JSON object to parse
  10647. * @param manager defines the hosting manager
  10648. * @returns the new sprite
  10649. */
  10650. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10651. }
  10652. }
  10653. declare module "babylonjs/Collisions/pickingInfo" {
  10654. import { Nullable } from "babylonjs/types";
  10655. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10657. import { Sprite } from "babylonjs/Sprites/sprite";
  10658. import { Ray } from "babylonjs/Culling/ray";
  10659. /**
  10660. * Information about the result of picking within a scene
  10661. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10662. */
  10663. export class PickingInfo {
  10664. /** @hidden */
  10665. _pickingUnavailable: boolean;
  10666. /**
  10667. * If the pick collided with an object
  10668. */
  10669. hit: boolean;
  10670. /**
  10671. * Distance away where the pick collided
  10672. */
  10673. distance: number;
  10674. /**
  10675. * The location of pick collision
  10676. */
  10677. pickedPoint: Nullable<Vector3>;
  10678. /**
  10679. * The mesh corresponding the the pick collision
  10680. */
  10681. pickedMesh: Nullable<AbstractMesh>;
  10682. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10683. bu: number;
  10684. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10685. bv: number;
  10686. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10687. faceId: number;
  10688. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10689. subMeshFaceId: number;
  10690. /** Id of the the submesh that was picked */
  10691. subMeshId: number;
  10692. /** If a sprite was picked, this will be the sprite the pick collided with */
  10693. pickedSprite: Nullable<Sprite>;
  10694. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10695. thinInstanceIndex: number;
  10696. /**
  10697. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10698. */
  10699. originMesh: Nullable<AbstractMesh>;
  10700. /**
  10701. * The ray that was used to perform the picking.
  10702. */
  10703. ray: Nullable<Ray>;
  10704. /**
  10705. * Gets the normal correspodning to the face the pick collided with
  10706. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10707. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10708. * @returns The normal correspodning to the face the pick collided with
  10709. */
  10710. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10711. /**
  10712. * Gets the texture coordinates of where the pick occured
  10713. * @returns the vector containing the coordnates of the texture
  10714. */
  10715. getTextureCoordinates(): Nullable<Vector2>;
  10716. }
  10717. }
  10718. declare module "babylonjs/Culling/ray" {
  10719. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10720. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10722. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10723. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10724. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10725. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10726. import { Plane } from "babylonjs/Maths/math.plane";
  10727. /**
  10728. * Class representing a ray with position and direction
  10729. */
  10730. export class Ray {
  10731. /** origin point */
  10732. origin: Vector3;
  10733. /** direction */
  10734. direction: Vector3;
  10735. /** length of the ray */
  10736. length: number;
  10737. private static readonly _TmpVector3;
  10738. private _tmpRay;
  10739. /**
  10740. * Creates a new ray
  10741. * @param origin origin point
  10742. * @param direction direction
  10743. * @param length length of the ray
  10744. */
  10745. constructor(
  10746. /** origin point */
  10747. origin: Vector3,
  10748. /** direction */
  10749. direction: Vector3,
  10750. /** length of the ray */
  10751. length?: number);
  10752. /**
  10753. * Checks if the ray intersects a box
  10754. * This does not account for the ray lenght by design to improve perfs.
  10755. * @param minimum bound of the box
  10756. * @param maximum bound of the box
  10757. * @param intersectionTreshold extra extend to be added to the box in all direction
  10758. * @returns if the box was hit
  10759. */
  10760. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10761. /**
  10762. * Checks if the ray intersects a box
  10763. * This does not account for the ray lenght by design to improve perfs.
  10764. * @param box the bounding box to check
  10765. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10766. * @returns if the box was hit
  10767. */
  10768. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10769. /**
  10770. * If the ray hits a sphere
  10771. * @param sphere the bounding sphere to check
  10772. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10773. * @returns true if it hits the sphere
  10774. */
  10775. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10776. /**
  10777. * If the ray hits a triange
  10778. * @param vertex0 triangle vertex
  10779. * @param vertex1 triangle vertex
  10780. * @param vertex2 triangle vertex
  10781. * @returns intersection information if hit
  10782. */
  10783. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10784. /**
  10785. * Checks if ray intersects a plane
  10786. * @param plane the plane to check
  10787. * @returns the distance away it was hit
  10788. */
  10789. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10790. /**
  10791. * Calculate the intercept of a ray on a given axis
  10792. * @param axis to check 'x' | 'y' | 'z'
  10793. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10794. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10795. */
  10796. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10797. /**
  10798. * Checks if ray intersects a mesh
  10799. * @param mesh the mesh to check
  10800. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10801. * @returns picking info of the intersecton
  10802. */
  10803. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10804. /**
  10805. * Checks if ray intersects a mesh
  10806. * @param meshes the meshes to check
  10807. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10808. * @param results array to store result in
  10809. * @returns Array of picking infos
  10810. */
  10811. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10812. private _comparePickingInfo;
  10813. private static smallnum;
  10814. private static rayl;
  10815. /**
  10816. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10817. * @param sega the first point of the segment to test the intersection against
  10818. * @param segb the second point of the segment to test the intersection against
  10819. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10820. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10821. */
  10822. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10823. /**
  10824. * Update the ray from viewport position
  10825. * @param x position
  10826. * @param y y position
  10827. * @param viewportWidth viewport width
  10828. * @param viewportHeight viewport height
  10829. * @param world world matrix
  10830. * @param view view matrix
  10831. * @param projection projection matrix
  10832. * @returns this ray updated
  10833. */
  10834. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10835. /**
  10836. * Creates a ray with origin and direction of 0,0,0
  10837. * @returns the new ray
  10838. */
  10839. static Zero(): Ray;
  10840. /**
  10841. * Creates a new ray from screen space and viewport
  10842. * @param x position
  10843. * @param y y position
  10844. * @param viewportWidth viewport width
  10845. * @param viewportHeight viewport height
  10846. * @param world world matrix
  10847. * @param view view matrix
  10848. * @param projection projection matrix
  10849. * @returns new ray
  10850. */
  10851. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10852. /**
  10853. * 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
  10854. * transformed to the given world matrix.
  10855. * @param origin The origin point
  10856. * @param end The end point
  10857. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10858. * @returns the new ray
  10859. */
  10860. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10861. /**
  10862. * Transforms a ray by a matrix
  10863. * @param ray ray to transform
  10864. * @param matrix matrix to apply
  10865. * @returns the resulting new ray
  10866. */
  10867. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10868. /**
  10869. * Transforms a ray by a matrix
  10870. * @param ray ray to transform
  10871. * @param matrix matrix to apply
  10872. * @param result ray to store result in
  10873. */
  10874. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10875. /**
  10876. * Unproject a ray from screen space to object space
  10877. * @param sourceX defines the screen space x coordinate to use
  10878. * @param sourceY defines the screen space y coordinate to use
  10879. * @param viewportWidth defines the current width of the viewport
  10880. * @param viewportHeight defines the current height of the viewport
  10881. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10882. * @param view defines the view matrix to use
  10883. * @param projection defines the projection matrix to use
  10884. */
  10885. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10886. }
  10887. /**
  10888. * Type used to define predicate used to select faces when a mesh intersection is detected
  10889. */
  10890. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10891. module "babylonjs/scene" {
  10892. interface Scene {
  10893. /** @hidden */
  10894. _tempPickingRay: Nullable<Ray>;
  10895. /** @hidden */
  10896. _cachedRayForTransform: Ray;
  10897. /** @hidden */
  10898. _pickWithRayInverseMatrix: Matrix;
  10899. /** @hidden */
  10900. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10901. /** @hidden */
  10902. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10903. /** @hidden */
  10904. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10905. }
  10906. }
  10907. }
  10908. declare module "babylonjs/sceneComponent" {
  10909. import { Scene } from "babylonjs/scene";
  10910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10911. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10912. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10913. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10914. import { Nullable } from "babylonjs/types";
  10915. import { Camera } from "babylonjs/Cameras/camera";
  10916. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10917. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10918. import { AbstractScene } from "babylonjs/abstractScene";
  10919. import { Mesh } from "babylonjs/Meshes/mesh";
  10920. /**
  10921. * Groups all the scene component constants in one place to ease maintenance.
  10922. * @hidden
  10923. */
  10924. export class SceneComponentConstants {
  10925. static readonly NAME_EFFECTLAYER: string;
  10926. static readonly NAME_LAYER: string;
  10927. static readonly NAME_LENSFLARESYSTEM: string;
  10928. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10929. static readonly NAME_PARTICLESYSTEM: string;
  10930. static readonly NAME_GAMEPAD: string;
  10931. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10932. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10933. static readonly NAME_PREPASSRENDERER: string;
  10934. static readonly NAME_DEPTHRENDERER: string;
  10935. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10936. static readonly NAME_SPRITE: string;
  10937. static readonly NAME_SUBSURFACE: string;
  10938. static readonly NAME_OUTLINERENDERER: string;
  10939. static readonly NAME_PROCEDURALTEXTURE: string;
  10940. static readonly NAME_SHADOWGENERATOR: string;
  10941. static readonly NAME_OCTREE: string;
  10942. static readonly NAME_PHYSICSENGINE: string;
  10943. static readonly NAME_AUDIO: string;
  10944. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10945. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10946. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10947. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10948. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10949. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10950. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10951. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10952. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10953. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10954. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10955. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10956. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10957. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10958. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10959. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10960. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10961. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10962. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10963. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10964. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10965. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10966. static readonly STEP_AFTERRENDER_AUDIO: number;
  10967. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10968. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10969. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10970. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10971. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10972. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10973. static readonly STEP_POINTERMOVE_SPRITE: number;
  10974. static readonly STEP_POINTERDOWN_SPRITE: number;
  10975. static readonly STEP_POINTERUP_SPRITE: number;
  10976. }
  10977. /**
  10978. * This represents a scene component.
  10979. *
  10980. * This is used to decouple the dependency the scene is having on the different workloads like
  10981. * layers, post processes...
  10982. */
  10983. export interface ISceneComponent {
  10984. /**
  10985. * The name of the component. Each component must have a unique name.
  10986. */
  10987. name: string;
  10988. /**
  10989. * The scene the component belongs to.
  10990. */
  10991. scene: Scene;
  10992. /**
  10993. * Register the component to one instance of a scene.
  10994. */
  10995. register(): void;
  10996. /**
  10997. * Rebuilds the elements related to this component in case of
  10998. * context lost for instance.
  10999. */
  11000. rebuild(): void;
  11001. /**
  11002. * Disposes the component and the associated ressources.
  11003. */
  11004. dispose(): void;
  11005. }
  11006. /**
  11007. * This represents a SERIALIZABLE scene component.
  11008. *
  11009. * This extends Scene Component to add Serialization methods on top.
  11010. */
  11011. export interface ISceneSerializableComponent extends ISceneComponent {
  11012. /**
  11013. * Adds all the elements from the container to the scene
  11014. * @param container the container holding the elements
  11015. */
  11016. addFromContainer(container: AbstractScene): void;
  11017. /**
  11018. * Removes all the elements in the container from the scene
  11019. * @param container contains the elements to remove
  11020. * @param dispose if the removed element should be disposed (default: false)
  11021. */
  11022. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11023. /**
  11024. * Serializes the component data to the specified json object
  11025. * @param serializationObject The object to serialize to
  11026. */
  11027. serialize(serializationObject: any): void;
  11028. }
  11029. /**
  11030. * Strong typing of a Mesh related stage step action
  11031. */
  11032. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11033. /**
  11034. * Strong typing of a Evaluate Sub Mesh related stage step action
  11035. */
  11036. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11037. /**
  11038. * Strong typing of a pre active Mesh related stage step action
  11039. */
  11040. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11041. /**
  11042. * Strong typing of a Camera related stage step action
  11043. */
  11044. export type CameraStageAction = (camera: Camera) => void;
  11045. /**
  11046. * Strong typing of a Camera Frame buffer related stage step action
  11047. */
  11048. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11049. /**
  11050. * Strong typing of a Render Target related stage step action
  11051. */
  11052. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11053. /**
  11054. * Strong typing of a RenderingGroup related stage step action
  11055. */
  11056. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11057. /**
  11058. * Strong typing of a Mesh Render related stage step action
  11059. */
  11060. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11061. /**
  11062. * Strong typing of a simple stage step action
  11063. */
  11064. export type SimpleStageAction = () => void;
  11065. /**
  11066. * Strong typing of a render target action.
  11067. */
  11068. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11069. /**
  11070. * Strong typing of a pointer move action.
  11071. */
  11072. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11073. /**
  11074. * Strong typing of a pointer up/down action.
  11075. */
  11076. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11077. /**
  11078. * Representation of a stage in the scene (Basically a list of ordered steps)
  11079. * @hidden
  11080. */
  11081. export class Stage<T extends Function> extends Array<{
  11082. index: number;
  11083. component: ISceneComponent;
  11084. action: T;
  11085. }> {
  11086. /**
  11087. * Hide ctor from the rest of the world.
  11088. * @param items The items to add.
  11089. */
  11090. private constructor();
  11091. /**
  11092. * Creates a new Stage.
  11093. * @returns A new instance of a Stage
  11094. */
  11095. static Create<T extends Function>(): Stage<T>;
  11096. /**
  11097. * Registers a step in an ordered way in the targeted stage.
  11098. * @param index Defines the position to register the step in
  11099. * @param component Defines the component attached to the step
  11100. * @param action Defines the action to launch during the step
  11101. */
  11102. registerStep(index: number, component: ISceneComponent, action: T): void;
  11103. /**
  11104. * Clears all the steps from the stage.
  11105. */
  11106. clear(): void;
  11107. }
  11108. }
  11109. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11110. import { Nullable } from "babylonjs/types";
  11111. import { Observable } from "babylonjs/Misc/observable";
  11112. import { Scene } from "babylonjs/scene";
  11113. import { Sprite } from "babylonjs/Sprites/sprite";
  11114. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11115. import { Ray } from "babylonjs/Culling/ray";
  11116. import { Camera } from "babylonjs/Cameras/camera";
  11117. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11118. import { ISceneComponent } from "babylonjs/sceneComponent";
  11119. module "babylonjs/scene" {
  11120. interface Scene {
  11121. /** @hidden */
  11122. _pointerOverSprite: Nullable<Sprite>;
  11123. /** @hidden */
  11124. _pickedDownSprite: Nullable<Sprite>;
  11125. /** @hidden */
  11126. _tempSpritePickingRay: Nullable<Ray>;
  11127. /**
  11128. * All of the sprite managers added to this scene
  11129. * @see https://doc.babylonjs.com/babylon101/sprites
  11130. */
  11131. spriteManagers: Array<ISpriteManager>;
  11132. /**
  11133. * An event triggered when sprites rendering is about to start
  11134. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11135. */
  11136. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11137. /**
  11138. * An event triggered when sprites rendering is done
  11139. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11140. */
  11141. onAfterSpritesRenderingObservable: Observable<Scene>;
  11142. /** @hidden */
  11143. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11144. /** Launch a ray to try to pick a sprite in the scene
  11145. * @param x position on screen
  11146. * @param y position on screen
  11147. * @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
  11148. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11149. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11150. * @returns a PickingInfo
  11151. */
  11152. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11153. /** Use the given ray to pick a sprite in the scene
  11154. * @param ray The ray (in world space) to use to pick meshes
  11155. * @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
  11156. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11157. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11158. * @returns a PickingInfo
  11159. */
  11160. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11161. /** @hidden */
  11162. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11163. /** Launch a ray to try to pick sprites in the scene
  11164. * @param x position on screen
  11165. * @param y position on screen
  11166. * @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
  11167. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11168. * @returns a PickingInfo array
  11169. */
  11170. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11171. /** Use the given ray to pick sprites in the scene
  11172. * @param ray The ray (in world space) to use to pick meshes
  11173. * @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
  11174. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11175. * @returns a PickingInfo array
  11176. */
  11177. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11178. /**
  11179. * Force the sprite under the pointer
  11180. * @param sprite defines the sprite to use
  11181. */
  11182. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11183. /**
  11184. * Gets the sprite under the pointer
  11185. * @returns a Sprite or null if no sprite is under the pointer
  11186. */
  11187. getPointerOverSprite(): Nullable<Sprite>;
  11188. }
  11189. }
  11190. /**
  11191. * Defines the sprite scene component responsible to manage sprites
  11192. * in a given scene.
  11193. */
  11194. export class SpriteSceneComponent implements ISceneComponent {
  11195. /**
  11196. * The component name helpfull to identify the component in the list of scene components.
  11197. */
  11198. readonly name: string;
  11199. /**
  11200. * The scene the component belongs to.
  11201. */
  11202. scene: Scene;
  11203. /** @hidden */
  11204. private _spritePredicate;
  11205. /**
  11206. * Creates a new instance of the component for the given scene
  11207. * @param scene Defines the scene to register the component in
  11208. */
  11209. constructor(scene: Scene);
  11210. /**
  11211. * Registers the component in a given scene
  11212. */
  11213. register(): void;
  11214. /**
  11215. * Rebuilds the elements related to this component in case of
  11216. * context lost for instance.
  11217. */
  11218. rebuild(): void;
  11219. /**
  11220. * Disposes the component and the associated ressources.
  11221. */
  11222. dispose(): void;
  11223. private _pickSpriteButKeepRay;
  11224. private _pointerMove;
  11225. private _pointerDown;
  11226. private _pointerUp;
  11227. }
  11228. }
  11229. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11230. /** @hidden */
  11231. export var fogFragmentDeclaration: {
  11232. name: string;
  11233. shader: string;
  11234. };
  11235. }
  11236. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11237. /** @hidden */
  11238. export var fogFragment: {
  11239. name: string;
  11240. shader: string;
  11241. };
  11242. }
  11243. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  11244. /** @hidden */
  11245. export var imageProcessingCompatibility: {
  11246. name: string;
  11247. shader: string;
  11248. };
  11249. }
  11250. declare module "babylonjs/Shaders/sprites.fragment" {
  11251. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11252. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11253. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  11254. /** @hidden */
  11255. export var spritesPixelShader: {
  11256. name: string;
  11257. shader: string;
  11258. };
  11259. }
  11260. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11261. /** @hidden */
  11262. export var fogVertexDeclaration: {
  11263. name: string;
  11264. shader: string;
  11265. };
  11266. }
  11267. declare module "babylonjs/Shaders/sprites.vertex" {
  11268. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11269. /** @hidden */
  11270. export var spritesVertexShader: {
  11271. name: string;
  11272. shader: string;
  11273. };
  11274. }
  11275. declare module "babylonjs/Sprites/spriteManager" {
  11276. import { IDisposable, Scene } from "babylonjs/scene";
  11277. import { Nullable } from "babylonjs/types";
  11278. import { Observable } from "babylonjs/Misc/observable";
  11279. import { Sprite } from "babylonjs/Sprites/sprite";
  11280. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11281. import { Camera } from "babylonjs/Cameras/camera";
  11282. import { Texture } from "babylonjs/Materials/Textures/texture";
  11283. import "babylonjs/Shaders/sprites.fragment";
  11284. import "babylonjs/Shaders/sprites.vertex";
  11285. import { Ray } from "babylonjs/Culling/ray";
  11286. /**
  11287. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11288. */
  11289. export interface ISpriteManager extends IDisposable {
  11290. /**
  11291. * Gets manager's name
  11292. */
  11293. name: string;
  11294. /**
  11295. * Restricts the camera to viewing objects with the same layerMask.
  11296. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11297. */
  11298. layerMask: number;
  11299. /**
  11300. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11301. */
  11302. isPickable: boolean;
  11303. /**
  11304. * Gets the hosting scene
  11305. */
  11306. scene: Scene;
  11307. /**
  11308. * Specifies the rendering group id for this mesh (0 by default)
  11309. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11310. */
  11311. renderingGroupId: number;
  11312. /**
  11313. * Defines the list of sprites managed by the manager.
  11314. */
  11315. sprites: Array<Sprite>;
  11316. /**
  11317. * Gets or sets the spritesheet texture
  11318. */
  11319. texture: Texture;
  11320. /** Defines the default width of a cell in the spritesheet */
  11321. cellWidth: number;
  11322. /** Defines the default height of a cell in the spritesheet */
  11323. cellHeight: number;
  11324. /**
  11325. * Tests the intersection of a sprite with a specific ray.
  11326. * @param ray The ray we are sending to test the collision
  11327. * @param camera The camera space we are sending rays in
  11328. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11329. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11330. * @returns picking info or null.
  11331. */
  11332. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11333. /**
  11334. * Intersects the sprites with a ray
  11335. * @param ray defines the ray to intersect with
  11336. * @param camera defines the current active camera
  11337. * @param predicate defines a predicate used to select candidate sprites
  11338. * @returns null if no hit or a PickingInfo array
  11339. */
  11340. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11341. /**
  11342. * Renders the list of sprites on screen.
  11343. */
  11344. render(): void;
  11345. }
  11346. /**
  11347. * Class used to manage multiple sprites on the same spritesheet
  11348. * @see https://doc.babylonjs.com/babylon101/sprites
  11349. */
  11350. export class SpriteManager implements ISpriteManager {
  11351. /** defines the manager's name */
  11352. name: string;
  11353. /** Define the Url to load snippets */
  11354. static SnippetUrl: string;
  11355. /** Snippet ID if the manager was created from the snippet server */
  11356. snippetId: string;
  11357. /** Gets the list of sprites */
  11358. sprites: Sprite[];
  11359. /** Gets or sets the rendering group id (0 by default) */
  11360. renderingGroupId: number;
  11361. /** Gets or sets camera layer mask */
  11362. layerMask: number;
  11363. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11364. fogEnabled: boolean;
  11365. /** Gets or sets a boolean indicating if the sprites are pickable */
  11366. isPickable: boolean;
  11367. /** Defines the default width of a cell in the spritesheet */
  11368. cellWidth: number;
  11369. /** Defines the default height of a cell in the spritesheet */
  11370. cellHeight: number;
  11371. /** Associative array from JSON sprite data file */
  11372. private _cellData;
  11373. /** Array of sprite names from JSON sprite data file */
  11374. private _spriteMap;
  11375. /** True when packed cell data from JSON file is ready*/
  11376. private _packedAndReady;
  11377. private _textureContent;
  11378. private _useInstancing;
  11379. /**
  11380. * An event triggered when the manager is disposed.
  11381. */
  11382. onDisposeObservable: Observable<SpriteManager>;
  11383. private _onDisposeObserver;
  11384. /**
  11385. * Callback called when the manager is disposed
  11386. */
  11387. set onDispose(callback: () => void);
  11388. private _capacity;
  11389. private _fromPacked;
  11390. private _spriteTexture;
  11391. private _epsilon;
  11392. private _scene;
  11393. private _vertexData;
  11394. private _buffer;
  11395. private _vertexBuffers;
  11396. private _spriteBuffer;
  11397. private _indexBuffer;
  11398. private _effectBase;
  11399. private _effectFog;
  11400. private _vertexBufferSize;
  11401. /**
  11402. * Gets or sets the unique id of the sprite
  11403. */
  11404. uniqueId: number;
  11405. /**
  11406. * Gets the array of sprites
  11407. */
  11408. get children(): Sprite[];
  11409. /**
  11410. * Gets the hosting scene
  11411. */
  11412. get scene(): Scene;
  11413. /**
  11414. * Gets the capacity of the manager
  11415. */
  11416. get capacity(): number;
  11417. /**
  11418. * Gets or sets the spritesheet texture
  11419. */
  11420. get texture(): Texture;
  11421. set texture(value: Texture);
  11422. private _blendMode;
  11423. /**
  11424. * Blend mode use to render the particle, it can be any of
  11425. * the static Constants.ALPHA_x properties provided in this class.
  11426. * Default value is Constants.ALPHA_COMBINE
  11427. */
  11428. get blendMode(): number;
  11429. set blendMode(blendMode: number);
  11430. /** Disables writing to the depth buffer when rendering the sprites.
  11431. * It can be handy to disable depth writing when using textures without alpha channel
  11432. * and setting some specific blend modes.
  11433. */
  11434. disableDepthWrite: boolean;
  11435. /**
  11436. * Creates a new sprite manager
  11437. * @param name defines the manager's name
  11438. * @param imgUrl defines the sprite sheet url
  11439. * @param capacity defines the maximum allowed number of sprites
  11440. * @param cellSize defines the size of a sprite cell
  11441. * @param scene defines the hosting scene
  11442. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11443. * @param samplingMode defines the smapling mode to use with spritesheet
  11444. * @param fromPacked set to false; do not alter
  11445. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11446. */
  11447. constructor(
  11448. /** defines the manager's name */
  11449. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11450. /**
  11451. * Returns the string "SpriteManager"
  11452. * @returns "SpriteManager"
  11453. */
  11454. getClassName(): string;
  11455. private _makePacked;
  11456. private _appendSpriteVertex;
  11457. private _checkTextureAlpha;
  11458. /**
  11459. * Intersects the sprites with a ray
  11460. * @param ray defines the ray to intersect with
  11461. * @param camera defines the current active camera
  11462. * @param predicate defines a predicate used to select candidate sprites
  11463. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11464. * @returns null if no hit or a PickingInfo
  11465. */
  11466. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11467. /**
  11468. * Intersects the sprites with a ray
  11469. * @param ray defines the ray to intersect with
  11470. * @param camera defines the current active camera
  11471. * @param predicate defines a predicate used to select candidate sprites
  11472. * @returns null if no hit or a PickingInfo array
  11473. */
  11474. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11475. /**
  11476. * Render all child sprites
  11477. */
  11478. render(): void;
  11479. /**
  11480. * Release associated resources
  11481. */
  11482. dispose(): void;
  11483. /**
  11484. * Serializes the sprite manager to a JSON object
  11485. * @param serializeTexture defines if the texture must be serialized as well
  11486. * @returns the JSON object
  11487. */
  11488. serialize(serializeTexture?: boolean): any;
  11489. /**
  11490. * Parses a JSON object to create a new sprite manager.
  11491. * @param parsedManager The JSON object to parse
  11492. * @param scene The scene to create the sprite managerin
  11493. * @param rootUrl The root url to use to load external dependencies like texture
  11494. * @returns the new sprite manager
  11495. */
  11496. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11497. /**
  11498. * Creates a sprite manager from a snippet saved in a remote file
  11499. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11500. * @param url defines the url to load from
  11501. * @param scene defines the hosting scene
  11502. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11503. * @returns a promise that will resolve to the new sprite manager
  11504. */
  11505. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11506. /**
  11507. * Creates a sprite manager from a snippet saved by the sprite editor
  11508. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11509. * @param scene defines the hosting scene
  11510. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11511. * @returns a promise that will resolve to the new sprite manager
  11512. */
  11513. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11514. }
  11515. }
  11516. declare module "babylonjs/Misc/gradients" {
  11517. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11518. /** Interface used by value gradients (color, factor, ...) */
  11519. export interface IValueGradient {
  11520. /**
  11521. * Gets or sets the gradient value (between 0 and 1)
  11522. */
  11523. gradient: number;
  11524. }
  11525. /** Class used to store color4 gradient */
  11526. export class ColorGradient implements IValueGradient {
  11527. /**
  11528. * Gets or sets the gradient value (between 0 and 1)
  11529. */
  11530. gradient: number;
  11531. /**
  11532. * Gets or sets first associated color
  11533. */
  11534. color1: Color4;
  11535. /**
  11536. * Gets or sets second associated color
  11537. */
  11538. color2?: Color4 | undefined;
  11539. /**
  11540. * Creates a new color4 gradient
  11541. * @param gradient gets or sets the gradient value (between 0 and 1)
  11542. * @param color1 gets or sets first associated color
  11543. * @param color2 gets or sets first second color
  11544. */
  11545. constructor(
  11546. /**
  11547. * Gets or sets the gradient value (between 0 and 1)
  11548. */
  11549. gradient: number,
  11550. /**
  11551. * Gets or sets first associated color
  11552. */
  11553. color1: Color4,
  11554. /**
  11555. * Gets or sets second associated color
  11556. */
  11557. color2?: Color4 | undefined);
  11558. /**
  11559. * Will get a color picked randomly between color1 and color2.
  11560. * If color2 is undefined then color1 will be used
  11561. * @param result defines the target Color4 to store the result in
  11562. */
  11563. getColorToRef(result: Color4): void;
  11564. }
  11565. /** Class used to store color 3 gradient */
  11566. export class Color3Gradient implements IValueGradient {
  11567. /**
  11568. * Gets or sets the gradient value (between 0 and 1)
  11569. */
  11570. gradient: number;
  11571. /**
  11572. * Gets or sets the associated color
  11573. */
  11574. color: Color3;
  11575. /**
  11576. * Creates a new color3 gradient
  11577. * @param gradient gets or sets the gradient value (between 0 and 1)
  11578. * @param color gets or sets associated color
  11579. */
  11580. constructor(
  11581. /**
  11582. * Gets or sets the gradient value (between 0 and 1)
  11583. */
  11584. gradient: number,
  11585. /**
  11586. * Gets or sets the associated color
  11587. */
  11588. color: Color3);
  11589. }
  11590. /** Class used to store factor gradient */
  11591. export class FactorGradient implements IValueGradient {
  11592. /**
  11593. * Gets or sets the gradient value (between 0 and 1)
  11594. */
  11595. gradient: number;
  11596. /**
  11597. * Gets or sets first associated factor
  11598. */
  11599. factor1: number;
  11600. /**
  11601. * Gets or sets second associated factor
  11602. */
  11603. factor2?: number | undefined;
  11604. /**
  11605. * Creates a new factor gradient
  11606. * @param gradient gets or sets the gradient value (between 0 and 1)
  11607. * @param factor1 gets or sets first associated factor
  11608. * @param factor2 gets or sets second associated factor
  11609. */
  11610. constructor(
  11611. /**
  11612. * Gets or sets the gradient value (between 0 and 1)
  11613. */
  11614. gradient: number,
  11615. /**
  11616. * Gets or sets first associated factor
  11617. */
  11618. factor1: number,
  11619. /**
  11620. * Gets or sets second associated factor
  11621. */
  11622. factor2?: number | undefined);
  11623. /**
  11624. * Will get a number picked randomly between factor1 and factor2.
  11625. * If factor2 is undefined then factor1 will be used
  11626. * @returns the picked number
  11627. */
  11628. getFactor(): number;
  11629. }
  11630. /**
  11631. * Helper used to simplify some generic gradient tasks
  11632. */
  11633. export class GradientHelper {
  11634. /**
  11635. * Gets the current gradient from an array of IValueGradient
  11636. * @param ratio defines the current ratio to get
  11637. * @param gradients defines the array of IValueGradient
  11638. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11639. */
  11640. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11641. }
  11642. }
  11643. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11644. import { Nullable } from "babylonjs/types";
  11645. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11646. import { Scene } from "babylonjs/scene";
  11647. module "babylonjs/Engines/thinEngine" {
  11648. interface ThinEngine {
  11649. /**
  11650. * Creates a raw texture
  11651. * @param data defines the data to store in the texture
  11652. * @param width defines the width of the texture
  11653. * @param height defines the height of the texture
  11654. * @param format defines the format of the data
  11655. * @param generateMipMaps defines if the engine should generate the mip levels
  11656. * @param invertY defines if data must be stored with Y axis inverted
  11657. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11658. * @param compression defines the compression used (null by default)
  11659. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11660. * @returns the raw texture inside an InternalTexture
  11661. */
  11662. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11663. /**
  11664. * Update a raw texture
  11665. * @param texture defines the texture to update
  11666. * @param data defines the data to store in the texture
  11667. * @param format defines the format of the data
  11668. * @param invertY defines if data must be stored with Y axis inverted
  11669. */
  11670. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11671. /**
  11672. * Update a raw texture
  11673. * @param texture defines the texture to update
  11674. * @param data defines the data to store in the texture
  11675. * @param format defines the format of the data
  11676. * @param invertY defines if data must be stored with Y axis inverted
  11677. * @param compression defines the compression used (null by default)
  11678. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11679. */
  11680. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11681. /**
  11682. * Creates a new raw cube texture
  11683. * @param data defines the array of data to use to create each face
  11684. * @param size defines the size of the textures
  11685. * @param format defines the format of the data
  11686. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11687. * @param generateMipMaps defines if the engine should generate the mip levels
  11688. * @param invertY defines if data must be stored with Y axis inverted
  11689. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11690. * @param compression defines the compression used (null by default)
  11691. * @returns the cube texture as an InternalTexture
  11692. */
  11693. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11694. /**
  11695. * Update a raw cube texture
  11696. * @param texture defines the texture to udpdate
  11697. * @param data defines the data to store
  11698. * @param format defines the data format
  11699. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11700. * @param invertY defines if data must be stored with Y axis inverted
  11701. */
  11702. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11703. /**
  11704. * Update a raw cube texture
  11705. * @param texture defines the texture to udpdate
  11706. * @param data defines the data to store
  11707. * @param format defines the data format
  11708. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. * @param compression defines the compression used (null by default)
  11711. */
  11712. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11713. /**
  11714. * Update a raw cube texture
  11715. * @param texture defines the texture to udpdate
  11716. * @param data defines the data to store
  11717. * @param format defines the data format
  11718. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11719. * @param invertY defines if data must be stored with Y axis inverted
  11720. * @param compression defines the compression used (null by default)
  11721. * @param level defines which level of the texture to update
  11722. */
  11723. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11724. /**
  11725. * Creates a new raw cube texture from a specified url
  11726. * @param url defines the url where the data is located
  11727. * @param scene defines the current scene
  11728. * @param size defines the size of the textures
  11729. * @param format defines the format of the data
  11730. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11731. * @param noMipmap defines if the engine should avoid generating the mip levels
  11732. * @param callback defines a callback used to extract texture data from loaded data
  11733. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11734. * @param onLoad defines a callback called when texture is loaded
  11735. * @param onError defines a callback called if there is an error
  11736. * @returns the cube texture as an InternalTexture
  11737. */
  11738. 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;
  11739. /**
  11740. * Creates a new raw cube texture from a specified url
  11741. * @param url defines the url where the data is located
  11742. * @param scene defines the current scene
  11743. * @param size defines the size of the textures
  11744. * @param format defines the format of the data
  11745. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11746. * @param noMipmap defines if the engine should avoid generating the mip levels
  11747. * @param callback defines a callback used to extract texture data from loaded data
  11748. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11749. * @param onLoad defines a callback called when texture is loaded
  11750. * @param onError defines a callback called if there is an error
  11751. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11752. * @param invertY defines if data must be stored with Y axis inverted
  11753. * @returns the cube texture as an InternalTexture
  11754. */
  11755. 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;
  11756. /**
  11757. * Creates a new raw 3D texture
  11758. * @param data defines the data used to create the texture
  11759. * @param width defines the width of the texture
  11760. * @param height defines the height of the texture
  11761. * @param depth defines the depth of the texture
  11762. * @param format defines the format of the texture
  11763. * @param generateMipMaps defines if the engine must generate mip levels
  11764. * @param invertY defines if data must be stored with Y axis inverted
  11765. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11766. * @param compression defines the compressed used (can be null)
  11767. * @param textureType defines the compressed used (can be null)
  11768. * @returns a new raw 3D texture (stored in an InternalTexture)
  11769. */
  11770. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11771. /**
  11772. * Update a raw 3D texture
  11773. * @param texture defines the texture to update
  11774. * @param data defines the data to store
  11775. * @param format defines the data format
  11776. * @param invertY defines if data must be stored with Y axis inverted
  11777. */
  11778. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11779. /**
  11780. * Update a raw 3D texture
  11781. * @param texture defines the texture to update
  11782. * @param data defines the data to store
  11783. * @param format defines the data format
  11784. * @param invertY defines if data must be stored with Y axis inverted
  11785. * @param compression defines the used compression (can be null)
  11786. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11787. */
  11788. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11789. /**
  11790. * Creates a new raw 2D array texture
  11791. * @param data defines the data used to create the texture
  11792. * @param width defines the width of the texture
  11793. * @param height defines the height of the texture
  11794. * @param depth defines the number of layers of the texture
  11795. * @param format defines the format of the texture
  11796. * @param generateMipMaps defines if the engine must generate mip levels
  11797. * @param invertY defines if data must be stored with Y axis inverted
  11798. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11799. * @param compression defines the compressed used (can be null)
  11800. * @param textureType defines the compressed used (can be null)
  11801. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11802. */
  11803. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11804. /**
  11805. * Update a raw 2D array texture
  11806. * @param texture defines the texture to update
  11807. * @param data defines the data to store
  11808. * @param format defines the data format
  11809. * @param invertY defines if data must be stored with Y axis inverted
  11810. */
  11811. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11812. /**
  11813. * Update a raw 2D array texture
  11814. * @param texture defines the texture to update
  11815. * @param data defines the data to store
  11816. * @param format defines the data format
  11817. * @param invertY defines if data must be stored with Y axis inverted
  11818. * @param compression defines the used compression (can be null)
  11819. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11820. */
  11821. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11822. }
  11823. }
  11824. }
  11825. declare module "babylonjs/Materials/Textures/rawTexture" {
  11826. import { Texture } from "babylonjs/Materials/Textures/texture";
  11827. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11828. import { Nullable } from "babylonjs/types";
  11829. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11830. import { Scene } from "babylonjs/scene";
  11831. /**
  11832. * Raw texture can help creating a texture directly from an array of data.
  11833. * This can be super useful if you either get the data from an uncompressed source or
  11834. * if you wish to create your texture pixel by pixel.
  11835. */
  11836. export class RawTexture extends Texture {
  11837. /**
  11838. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11839. */
  11840. format: number;
  11841. /**
  11842. * Instantiates a new RawTexture.
  11843. * Raw texture can help creating a texture directly from an array of data.
  11844. * This can be super useful if you either get the data from an uncompressed source or
  11845. * if you wish to create your texture pixel by pixel.
  11846. * @param data define the array of data to use to create the texture
  11847. * @param width define the width of the texture
  11848. * @param height define the height of the texture
  11849. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11850. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11851. * @param generateMipMaps define whether mip maps should be generated or not
  11852. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11853. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11854. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11855. */
  11856. constructor(data: ArrayBufferView, width: number, height: number,
  11857. /**
  11858. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11859. */
  11860. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11861. /**
  11862. * Updates the texture underlying data.
  11863. * @param data Define the new data of the texture
  11864. */
  11865. update(data: ArrayBufferView): void;
  11866. /**
  11867. * Creates a luminance texture from some data.
  11868. * @param data Define the texture data
  11869. * @param width Define the width of the texture
  11870. * @param height Define the height of the texture
  11871. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11872. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11873. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11874. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11875. * @returns the luminance texture
  11876. */
  11877. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11878. /**
  11879. * Creates a luminance alpha texture from some data.
  11880. * @param data Define the texture data
  11881. * @param width Define the width of the texture
  11882. * @param height Define the height of the texture
  11883. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11884. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11885. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11886. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11887. * @returns the luminance alpha texture
  11888. */
  11889. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11890. /**
  11891. * Creates an alpha texture from some data.
  11892. * @param data Define the texture data
  11893. * @param width Define the width of the texture
  11894. * @param height Define the height of the texture
  11895. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11896. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11897. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11898. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11899. * @returns the alpha texture
  11900. */
  11901. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11902. /**
  11903. * Creates a RGB texture from some data.
  11904. * @param data Define the texture data
  11905. * @param width Define the width of the texture
  11906. * @param height Define the height of the texture
  11907. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11908. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11909. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11910. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11911. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11912. * @returns the RGB alpha texture
  11913. */
  11914. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11915. /**
  11916. * Creates a RGBA texture from some data.
  11917. * @param data Define the texture data
  11918. * @param width Define the width of the texture
  11919. * @param height Define the height of the texture
  11920. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11921. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11922. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11923. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11924. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11925. * @returns the RGBA texture
  11926. */
  11927. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11928. /**
  11929. * Creates a R texture from some data.
  11930. * @param data Define the texture data
  11931. * @param width Define the width of the texture
  11932. * @param height Define the height of the texture
  11933. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11934. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11935. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11936. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11937. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11938. * @returns the R texture
  11939. */
  11940. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11941. }
  11942. }
  11943. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11944. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11945. import { IndicesArray, DataArray } from "babylonjs/types";
  11946. module "babylonjs/Engines/thinEngine" {
  11947. interface ThinEngine {
  11948. /**
  11949. * Update a dynamic index buffer
  11950. * @param indexBuffer defines the target index buffer
  11951. * @param indices defines the data to update
  11952. * @param offset defines the offset in the target index buffer where update should start
  11953. */
  11954. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11955. /**
  11956. * Updates a dynamic vertex buffer.
  11957. * @param vertexBuffer the vertex buffer to update
  11958. * @param data the data used to update the vertex buffer
  11959. * @param byteOffset the byte offset of the data
  11960. * @param byteLength the byte length of the data
  11961. */
  11962. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11963. }
  11964. }
  11965. }
  11966. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11967. import { Scene } from "babylonjs/scene";
  11968. import { ISceneComponent } from "babylonjs/sceneComponent";
  11969. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11970. module "babylonjs/abstractScene" {
  11971. interface AbstractScene {
  11972. /**
  11973. * The list of procedural textures added to the scene
  11974. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11975. */
  11976. proceduralTextures: Array<ProceduralTexture>;
  11977. }
  11978. }
  11979. /**
  11980. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11981. * in a given scene.
  11982. */
  11983. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11984. /**
  11985. * The component name helpfull to identify the component in the list of scene components.
  11986. */
  11987. readonly name: string;
  11988. /**
  11989. * The scene the component belongs to.
  11990. */
  11991. scene: Scene;
  11992. /**
  11993. * Creates a new instance of the component for the given scene
  11994. * @param scene Defines the scene to register the component in
  11995. */
  11996. constructor(scene: Scene);
  11997. /**
  11998. * Registers the component in a given scene
  11999. */
  12000. register(): void;
  12001. /**
  12002. * Rebuilds the elements related to this component in case of
  12003. * context lost for instance.
  12004. */
  12005. rebuild(): void;
  12006. /**
  12007. * Disposes the component and the associated ressources.
  12008. */
  12009. dispose(): void;
  12010. private _beforeClear;
  12011. }
  12012. }
  12013. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  12014. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12015. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  12016. module "babylonjs/Engines/thinEngine" {
  12017. interface ThinEngine {
  12018. /**
  12019. * Creates a new render target cube texture
  12020. * @param size defines the size of the texture
  12021. * @param options defines the options used to create the texture
  12022. * @returns a new render target cube texture stored in an InternalTexture
  12023. */
  12024. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  12025. }
  12026. }
  12027. }
  12028. declare module "babylonjs/Shaders/procedural.vertex" {
  12029. /** @hidden */
  12030. export var proceduralVertexShader: {
  12031. name: string;
  12032. shader: string;
  12033. };
  12034. }
  12035. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  12036. import { Observable } from "babylonjs/Misc/observable";
  12037. import { Nullable } from "babylonjs/types";
  12038. import { Scene } from "babylonjs/scene";
  12039. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12040. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12041. import { Effect } from "babylonjs/Materials/effect";
  12042. import { Texture } from "babylonjs/Materials/Textures/texture";
  12043. import "babylonjs/Engines/Extensions/engine.renderTarget";
  12044. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  12045. import "babylonjs/Shaders/procedural.vertex";
  12046. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12047. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  12048. /**
  12049. * 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.
  12050. * This is the base class of any Procedural texture and contains most of the shareable code.
  12051. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12052. */
  12053. export class ProceduralTexture extends Texture {
  12054. /**
  12055. * Define if the texture is enabled or not (disabled texture will not render)
  12056. */
  12057. isEnabled: boolean;
  12058. /**
  12059. * Define if the texture must be cleared before rendering (default is true)
  12060. */
  12061. autoClear: boolean;
  12062. /**
  12063. * Callback called when the texture is generated
  12064. */
  12065. onGenerated: () => void;
  12066. /**
  12067. * Event raised when the texture is generated
  12068. */
  12069. onGeneratedObservable: Observable<ProceduralTexture>;
  12070. /**
  12071. * Event raised before the texture is generated
  12072. */
  12073. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12074. /**
  12075. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12076. */
  12077. nodeMaterialSource: Nullable<NodeMaterial>;
  12078. /** @hidden */
  12079. _generateMipMaps: boolean;
  12080. /** @hidden **/
  12081. _effect: Effect;
  12082. /** @hidden */
  12083. _textures: {
  12084. [key: string]: Texture;
  12085. };
  12086. /** @hidden */
  12087. protected _fallbackTexture: Nullable<Texture>;
  12088. private _size;
  12089. private _currentRefreshId;
  12090. private _frameId;
  12091. private _refreshRate;
  12092. private _vertexBuffers;
  12093. private _indexBuffer;
  12094. private _uniforms;
  12095. private _samplers;
  12096. private _fragment;
  12097. private _floats;
  12098. private _ints;
  12099. private _floatsArrays;
  12100. private _colors3;
  12101. private _colors4;
  12102. private _vectors2;
  12103. private _vectors3;
  12104. private _matrices;
  12105. private _fallbackTextureUsed;
  12106. private _fullEngine;
  12107. private _cachedDefines;
  12108. private _contentUpdateId;
  12109. private _contentData;
  12110. /**
  12111. * Instantiates a new procedural texture.
  12112. * 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.
  12113. * This is the base class of any Procedural texture and contains most of the shareable code.
  12114. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12115. * @param name Define the name of the texture
  12116. * @param size Define the size of the texture to create
  12117. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12118. * @param scene Define the scene the texture belongs to
  12119. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12120. * @param generateMipMaps Define if the texture should creates mip maps or not
  12121. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12122. * @param textureType The FBO internal texture type
  12123. */
  12124. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12125. /**
  12126. * The effect that is created when initializing the post process.
  12127. * @returns The created effect corresponding the the postprocess.
  12128. */
  12129. getEffect(): Effect;
  12130. /**
  12131. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12132. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12133. */
  12134. getContent(): Nullable<ArrayBufferView>;
  12135. private _createIndexBuffer;
  12136. /** @hidden */
  12137. _rebuild(): void;
  12138. /**
  12139. * Resets the texture in order to recreate its associated resources.
  12140. * This can be called in case of context loss
  12141. */
  12142. reset(): void;
  12143. protected _getDefines(): string;
  12144. /**
  12145. * Is the texture ready to be used ? (rendered at least once)
  12146. * @returns true if ready, otherwise, false.
  12147. */
  12148. isReady(): boolean;
  12149. /**
  12150. * Resets the refresh counter of the texture and start bak from scratch.
  12151. * Could be useful to regenerate the texture if it is setup to render only once.
  12152. */
  12153. resetRefreshCounter(): void;
  12154. /**
  12155. * Set the fragment shader to use in order to render the texture.
  12156. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12157. */
  12158. setFragment(fragment: any): void;
  12159. /**
  12160. * Define the refresh rate of the texture or the rendering frequency.
  12161. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12162. */
  12163. get refreshRate(): number;
  12164. set refreshRate(value: number);
  12165. /** @hidden */
  12166. _shouldRender(): boolean;
  12167. /**
  12168. * Get the size the texture is rendering at.
  12169. * @returns the size (on cube texture it is always squared)
  12170. */
  12171. getRenderSize(): RenderTargetTextureSize;
  12172. /**
  12173. * Resize the texture to new value.
  12174. * @param size Define the new size the texture should have
  12175. * @param generateMipMaps Define whether the new texture should create mip maps
  12176. */
  12177. resize(size: number, generateMipMaps: boolean): void;
  12178. private _checkUniform;
  12179. /**
  12180. * Set a texture in the shader program used to render.
  12181. * @param name Define the name of the uniform samplers as defined in the shader
  12182. * @param texture Define the texture to bind to this sampler
  12183. * @return the texture itself allowing "fluent" like uniform updates
  12184. */
  12185. setTexture(name: string, texture: Texture): ProceduralTexture;
  12186. /**
  12187. * Set a float in the shader.
  12188. * @param name Define the name of the uniform as defined in the shader
  12189. * @param value Define the value to give to the uniform
  12190. * @return the texture itself allowing "fluent" like uniform updates
  12191. */
  12192. setFloat(name: string, value: number): ProceduralTexture;
  12193. /**
  12194. * Set a int in the shader.
  12195. * @param name Define the name of the uniform as defined in the shader
  12196. * @param value Define the value to give to the uniform
  12197. * @return the texture itself allowing "fluent" like uniform updates
  12198. */
  12199. setInt(name: string, value: number): ProceduralTexture;
  12200. /**
  12201. * Set an array of floats in the shader.
  12202. * @param name Define the name of the uniform as defined in the shader
  12203. * @param value Define the value to give to the uniform
  12204. * @return the texture itself allowing "fluent" like uniform updates
  12205. */
  12206. setFloats(name: string, value: number[]): ProceduralTexture;
  12207. /**
  12208. * Set a vec3 in the shader from a Color3.
  12209. * @param name Define the name of the uniform as defined in the shader
  12210. * @param value Define the value to give to the uniform
  12211. * @return the texture itself allowing "fluent" like uniform updates
  12212. */
  12213. setColor3(name: string, value: Color3): ProceduralTexture;
  12214. /**
  12215. * Set a vec4 in the shader from a Color4.
  12216. * @param name Define the name of the uniform as defined in the shader
  12217. * @param value Define the value to give to the uniform
  12218. * @return the texture itself allowing "fluent" like uniform updates
  12219. */
  12220. setColor4(name: string, value: Color4): ProceduralTexture;
  12221. /**
  12222. * Set a vec2 in the shader from a Vector2.
  12223. * @param name Define the name of the uniform as defined in the shader
  12224. * @param value Define the value to give to the uniform
  12225. * @return the texture itself allowing "fluent" like uniform updates
  12226. */
  12227. setVector2(name: string, value: Vector2): ProceduralTexture;
  12228. /**
  12229. * Set a vec3 in the shader from a Vector3.
  12230. * @param name Define the name of the uniform as defined in the shader
  12231. * @param value Define the value to give to the uniform
  12232. * @return the texture itself allowing "fluent" like uniform updates
  12233. */
  12234. setVector3(name: string, value: Vector3): ProceduralTexture;
  12235. /**
  12236. * Set a mat4 in the shader from a MAtrix.
  12237. * @param name Define the name of the uniform as defined in the shader
  12238. * @param value Define the value to give to the uniform
  12239. * @return the texture itself allowing "fluent" like uniform updates
  12240. */
  12241. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12242. /**
  12243. * Render the texture to its associated render target.
  12244. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12245. */
  12246. render(useCameraPostProcess?: boolean): void;
  12247. /**
  12248. * Clone the texture.
  12249. * @returns the cloned texture
  12250. */
  12251. clone(): ProceduralTexture;
  12252. /**
  12253. * Dispose the texture and release its asoociated resources.
  12254. */
  12255. dispose(): void;
  12256. }
  12257. }
  12258. declare module "babylonjs/Particles/baseParticleSystem" {
  12259. import { Nullable } from "babylonjs/types";
  12260. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12262. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12263. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12264. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12265. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12266. import { Color4 } from "babylonjs/Maths/math.color";
  12267. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12268. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12269. import { Animation } from "babylonjs/Animations/animation";
  12270. import { Scene } from "babylonjs/scene";
  12271. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12272. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12273. /**
  12274. * This represents the base class for particle system in Babylon.
  12275. * 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.
  12276. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12277. * @example https://doc.babylonjs.com/babylon101/particles
  12278. */
  12279. export class BaseParticleSystem {
  12280. /**
  12281. * Source color is added to the destination color without alpha affecting the result
  12282. */
  12283. static BLENDMODE_ONEONE: number;
  12284. /**
  12285. * Blend current color and particle color using particle’s alpha
  12286. */
  12287. static BLENDMODE_STANDARD: number;
  12288. /**
  12289. * Add current color and particle color multiplied by particle’s alpha
  12290. */
  12291. static BLENDMODE_ADD: number;
  12292. /**
  12293. * Multiply current color with particle color
  12294. */
  12295. static BLENDMODE_MULTIPLY: number;
  12296. /**
  12297. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12298. */
  12299. static BLENDMODE_MULTIPLYADD: number;
  12300. /**
  12301. * List of animations used by the particle system.
  12302. */
  12303. animations: Animation[];
  12304. /**
  12305. * Gets or sets the unique id of the particle system
  12306. */
  12307. uniqueId: number;
  12308. /**
  12309. * The id of the Particle system.
  12310. */
  12311. id: string;
  12312. /**
  12313. * The friendly name of the Particle system.
  12314. */
  12315. name: string;
  12316. /**
  12317. * Snippet ID if the particle system was created from the snippet server
  12318. */
  12319. snippetId: string;
  12320. /**
  12321. * The rendering group used by the Particle system to chose when to render.
  12322. */
  12323. renderingGroupId: number;
  12324. /**
  12325. * The emitter represents the Mesh or position we are attaching the particle system to.
  12326. */
  12327. emitter: Nullable<AbstractMesh | Vector3>;
  12328. /**
  12329. * The maximum number of particles to emit per frame
  12330. */
  12331. emitRate: number;
  12332. /**
  12333. * If you want to launch only a few particles at once, that can be done, as well.
  12334. */
  12335. manualEmitCount: number;
  12336. /**
  12337. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12338. */
  12339. updateSpeed: number;
  12340. /**
  12341. * The amount of time the particle system is running (depends of the overall update speed).
  12342. */
  12343. targetStopDuration: number;
  12344. /**
  12345. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12346. */
  12347. disposeOnStop: boolean;
  12348. /**
  12349. * Minimum power of emitting particles.
  12350. */
  12351. minEmitPower: number;
  12352. /**
  12353. * Maximum power of emitting particles.
  12354. */
  12355. maxEmitPower: number;
  12356. /**
  12357. * Minimum life time of emitting particles.
  12358. */
  12359. minLifeTime: number;
  12360. /**
  12361. * Maximum life time of emitting particles.
  12362. */
  12363. maxLifeTime: number;
  12364. /**
  12365. * Minimum Size of emitting particles.
  12366. */
  12367. minSize: number;
  12368. /**
  12369. * Maximum Size of emitting particles.
  12370. */
  12371. maxSize: number;
  12372. /**
  12373. * Minimum scale of emitting particles on X axis.
  12374. */
  12375. minScaleX: number;
  12376. /**
  12377. * Maximum scale of emitting particles on X axis.
  12378. */
  12379. maxScaleX: number;
  12380. /**
  12381. * Minimum scale of emitting particles on Y axis.
  12382. */
  12383. minScaleY: number;
  12384. /**
  12385. * Maximum scale of emitting particles on Y axis.
  12386. */
  12387. maxScaleY: number;
  12388. /**
  12389. * Gets or sets the minimal initial rotation in radians.
  12390. */
  12391. minInitialRotation: number;
  12392. /**
  12393. * Gets or sets the maximal initial rotation in radians.
  12394. */
  12395. maxInitialRotation: number;
  12396. /**
  12397. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12398. */
  12399. minAngularSpeed: number;
  12400. /**
  12401. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12402. */
  12403. maxAngularSpeed: number;
  12404. /**
  12405. * The texture used to render each particle. (this can be a spritesheet)
  12406. */
  12407. particleTexture: Nullable<BaseTexture>;
  12408. /**
  12409. * The layer mask we are rendering the particles through.
  12410. */
  12411. layerMask: number;
  12412. /**
  12413. * This can help using your own shader to render the particle system.
  12414. * The according effect will be created
  12415. */
  12416. customShader: any;
  12417. /**
  12418. * By default particle system starts as soon as they are created. This prevents the
  12419. * automatic start to happen and let you decide when to start emitting particles.
  12420. */
  12421. preventAutoStart: boolean;
  12422. private _noiseTexture;
  12423. /**
  12424. * Gets or sets a texture used to add random noise to particle positions
  12425. */
  12426. get noiseTexture(): Nullable<ProceduralTexture>;
  12427. set noiseTexture(value: Nullable<ProceduralTexture>);
  12428. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12429. noiseStrength: Vector3;
  12430. /**
  12431. * Callback triggered when the particle animation is ending.
  12432. */
  12433. onAnimationEnd: Nullable<() => void>;
  12434. /**
  12435. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12436. */
  12437. blendMode: number;
  12438. /**
  12439. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12440. * to override the particles.
  12441. */
  12442. forceDepthWrite: boolean;
  12443. /** 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 */
  12444. preWarmCycles: number;
  12445. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12446. preWarmStepOffset: number;
  12447. /**
  12448. * 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)
  12449. */
  12450. spriteCellChangeSpeed: number;
  12451. /**
  12452. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12453. */
  12454. startSpriteCellID: number;
  12455. /**
  12456. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12457. */
  12458. endSpriteCellID: number;
  12459. /**
  12460. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12461. */
  12462. spriteCellWidth: number;
  12463. /**
  12464. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12465. */
  12466. spriteCellHeight: number;
  12467. /**
  12468. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12469. */
  12470. spriteRandomStartCell: boolean;
  12471. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12472. translationPivot: Vector2;
  12473. /** @hidden */
  12474. protected _isAnimationSheetEnabled: boolean;
  12475. /**
  12476. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12477. */
  12478. beginAnimationOnStart: boolean;
  12479. /**
  12480. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12481. */
  12482. beginAnimationFrom: number;
  12483. /**
  12484. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12485. */
  12486. beginAnimationTo: number;
  12487. /**
  12488. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12489. */
  12490. beginAnimationLoop: boolean;
  12491. /**
  12492. * Gets or sets a world offset applied to all particles
  12493. */
  12494. worldOffset: Vector3;
  12495. /**
  12496. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12497. */
  12498. get isAnimationSheetEnabled(): boolean;
  12499. set isAnimationSheetEnabled(value: boolean);
  12500. /**
  12501. * Get hosting scene
  12502. * @returns the scene
  12503. */
  12504. getScene(): Nullable<Scene>;
  12505. /**
  12506. * You can use gravity if you want to give an orientation to your particles.
  12507. */
  12508. gravity: Vector3;
  12509. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12510. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12511. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12512. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12513. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12514. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12515. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12516. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12517. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12518. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12519. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12520. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12521. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12522. /**
  12523. * Defines the delay in milliseconds before starting the system (0 by default)
  12524. */
  12525. startDelay: number;
  12526. /**
  12527. * Gets the current list of drag gradients.
  12528. * You must use addDragGradient and removeDragGradient to udpate this list
  12529. * @returns the list of drag gradients
  12530. */
  12531. getDragGradients(): Nullable<Array<FactorGradient>>;
  12532. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12533. limitVelocityDamping: number;
  12534. /**
  12535. * Gets the current list of limit velocity gradients.
  12536. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12537. * @returns the list of limit velocity gradients
  12538. */
  12539. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12540. /**
  12541. * Gets the current list of color gradients.
  12542. * You must use addColorGradient and removeColorGradient to udpate this list
  12543. * @returns the list of color gradients
  12544. */
  12545. getColorGradients(): Nullable<Array<ColorGradient>>;
  12546. /**
  12547. * Gets the current list of size gradients.
  12548. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12549. * @returns the list of size gradients
  12550. */
  12551. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12552. /**
  12553. * Gets the current list of color remap gradients.
  12554. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12555. * @returns the list of color remap gradients
  12556. */
  12557. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12558. /**
  12559. * Gets the current list of alpha remap gradients.
  12560. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12561. * @returns the list of alpha remap gradients
  12562. */
  12563. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12564. /**
  12565. * Gets the current list of life time gradients.
  12566. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12567. * @returns the list of life time gradients
  12568. */
  12569. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12570. /**
  12571. * Gets the current list of angular speed gradients.
  12572. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12573. * @returns the list of angular speed gradients
  12574. */
  12575. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12576. /**
  12577. * Gets the current list of velocity gradients.
  12578. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12579. * @returns the list of velocity gradients
  12580. */
  12581. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12582. /**
  12583. * Gets the current list of start size gradients.
  12584. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12585. * @returns the list of start size gradients
  12586. */
  12587. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12588. /**
  12589. * Gets the current list of emit rate gradients.
  12590. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12591. * @returns the list of emit rate gradients
  12592. */
  12593. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12594. /**
  12595. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12596. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12597. */
  12598. get direction1(): Vector3;
  12599. set direction1(value: Vector3);
  12600. /**
  12601. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12602. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12603. */
  12604. get direction2(): Vector3;
  12605. set direction2(value: Vector3);
  12606. /**
  12607. * 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.
  12608. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12609. */
  12610. get minEmitBox(): Vector3;
  12611. set minEmitBox(value: Vector3);
  12612. /**
  12613. * 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.
  12614. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12615. */
  12616. get maxEmitBox(): Vector3;
  12617. set maxEmitBox(value: Vector3);
  12618. /**
  12619. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12620. */
  12621. color1: Color4;
  12622. /**
  12623. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12624. */
  12625. color2: Color4;
  12626. /**
  12627. * Color the particle will have at the end of its lifetime
  12628. */
  12629. colorDead: Color4;
  12630. /**
  12631. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12632. */
  12633. textureMask: Color4;
  12634. /**
  12635. * The particle emitter type defines the emitter used by the particle system.
  12636. * It can be for example box, sphere, or cone...
  12637. */
  12638. particleEmitterType: IParticleEmitterType;
  12639. /** @hidden */
  12640. _isSubEmitter: boolean;
  12641. /**
  12642. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12643. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12644. */
  12645. billboardMode: number;
  12646. protected _isBillboardBased: boolean;
  12647. /**
  12648. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12649. */
  12650. get isBillboardBased(): boolean;
  12651. set isBillboardBased(value: boolean);
  12652. /**
  12653. * The scene the particle system belongs to.
  12654. */
  12655. protected _scene: Nullable<Scene>;
  12656. /**
  12657. * The engine the particle system belongs to.
  12658. */
  12659. protected _engine: ThinEngine;
  12660. /**
  12661. * Local cache of defines for image processing.
  12662. */
  12663. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12664. /**
  12665. * Default configuration related to image processing available in the standard Material.
  12666. */
  12667. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12668. /**
  12669. * Gets the image processing configuration used either in this material.
  12670. */
  12671. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12672. /**
  12673. * Sets the Default image processing configuration used either in the this material.
  12674. *
  12675. * If sets to null, the scene one is in use.
  12676. */
  12677. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12678. /**
  12679. * Attaches a new image processing configuration to the Standard Material.
  12680. * @param configuration
  12681. */
  12682. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12683. /** @hidden */
  12684. protected _reset(): void;
  12685. /** @hidden */
  12686. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12687. /**
  12688. * Instantiates a particle system.
  12689. * 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.
  12690. * @param name The name of the particle system
  12691. */
  12692. constructor(name: string);
  12693. /**
  12694. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12695. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12696. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12697. * @returns the emitter
  12698. */
  12699. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12700. /**
  12701. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12702. * @param radius The radius of the hemisphere to emit from
  12703. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12704. * @returns the emitter
  12705. */
  12706. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12707. /**
  12708. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12709. * @param radius The radius of the sphere to emit from
  12710. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12711. * @returns the emitter
  12712. */
  12713. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12714. /**
  12715. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12716. * @param radius The radius of the sphere to emit from
  12717. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12718. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12719. * @returns the emitter
  12720. */
  12721. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12722. /**
  12723. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12724. * @param radius The radius of the emission cylinder
  12725. * @param height The height of the emission cylinder
  12726. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12727. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12728. * @returns the emitter
  12729. */
  12730. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12731. /**
  12732. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12733. * @param radius The radius of the cylinder to emit from
  12734. * @param height The height of the emission cylinder
  12735. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12736. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12737. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12738. * @returns the emitter
  12739. */
  12740. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12741. /**
  12742. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12743. * @param radius The radius of the cone to emit from
  12744. * @param angle The base angle of the cone
  12745. * @returns the emitter
  12746. */
  12747. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12748. /**
  12749. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12750. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12751. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12752. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12753. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12754. * @returns the emitter
  12755. */
  12756. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12757. }
  12758. }
  12759. declare module "babylonjs/Particles/subEmitter" {
  12760. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12761. import { Scene } from "babylonjs/scene";
  12762. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12763. /**
  12764. * Type of sub emitter
  12765. */
  12766. export enum SubEmitterType {
  12767. /**
  12768. * Attached to the particle over it's lifetime
  12769. */
  12770. ATTACHED = 0,
  12771. /**
  12772. * Created when the particle dies
  12773. */
  12774. END = 1
  12775. }
  12776. /**
  12777. * Sub emitter class used to emit particles from an existing particle
  12778. */
  12779. export class SubEmitter {
  12780. /**
  12781. * the particle system to be used by the sub emitter
  12782. */
  12783. particleSystem: ParticleSystem;
  12784. /**
  12785. * Type of the submitter (Default: END)
  12786. */
  12787. type: SubEmitterType;
  12788. /**
  12789. * 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)
  12790. * Note: This only is supported when using an emitter of type Mesh
  12791. */
  12792. inheritDirection: boolean;
  12793. /**
  12794. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12795. */
  12796. inheritedVelocityAmount: number;
  12797. /**
  12798. * Creates a sub emitter
  12799. * @param particleSystem the particle system to be used by the sub emitter
  12800. */
  12801. constructor(
  12802. /**
  12803. * the particle system to be used by the sub emitter
  12804. */
  12805. particleSystem: ParticleSystem);
  12806. /**
  12807. * Clones the sub emitter
  12808. * @returns the cloned sub emitter
  12809. */
  12810. clone(): SubEmitter;
  12811. /**
  12812. * Serialize current object to a JSON object
  12813. * @returns the serialized object
  12814. */
  12815. serialize(): any;
  12816. /** @hidden */
  12817. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12818. /**
  12819. * Creates a new SubEmitter from a serialized JSON version
  12820. * @param serializationObject defines the JSON object to read from
  12821. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12822. * @param rootUrl defines the rootUrl for data loading
  12823. * @returns a new SubEmitter
  12824. */
  12825. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12826. /** Release associated resources */
  12827. dispose(): void;
  12828. }
  12829. }
  12830. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12831. /** @hidden */
  12832. export var imageProcessingDeclaration: {
  12833. name: string;
  12834. shader: string;
  12835. };
  12836. }
  12837. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12838. /** @hidden */
  12839. export var imageProcessingFunctions: {
  12840. name: string;
  12841. shader: string;
  12842. };
  12843. }
  12844. declare module "babylonjs/Shaders/particles.fragment" {
  12845. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12846. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12847. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12848. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12849. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12850. /** @hidden */
  12851. export var particlesPixelShader: {
  12852. name: string;
  12853. shader: string;
  12854. };
  12855. }
  12856. declare module "babylonjs/Shaders/particles.vertex" {
  12857. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12858. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12859. /** @hidden */
  12860. export var particlesVertexShader: {
  12861. name: string;
  12862. shader: string;
  12863. };
  12864. }
  12865. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12866. import { Nullable } from "babylonjs/types";
  12867. import { Plane } from "babylonjs/Maths/math";
  12868. /**
  12869. * Interface used to define entities containing multiple clip planes
  12870. */
  12871. export interface IClipPlanesHolder {
  12872. /**
  12873. * Gets or sets the active clipplane 1
  12874. */
  12875. clipPlane: Nullable<Plane>;
  12876. /**
  12877. * Gets or sets the active clipplane 2
  12878. */
  12879. clipPlane2: Nullable<Plane>;
  12880. /**
  12881. * Gets or sets the active clipplane 3
  12882. */
  12883. clipPlane3: Nullable<Plane>;
  12884. /**
  12885. * Gets or sets the active clipplane 4
  12886. */
  12887. clipPlane4: Nullable<Plane>;
  12888. /**
  12889. * Gets or sets the active clipplane 5
  12890. */
  12891. clipPlane5: Nullable<Plane>;
  12892. /**
  12893. * Gets or sets the active clipplane 6
  12894. */
  12895. clipPlane6: Nullable<Plane>;
  12896. }
  12897. }
  12898. declare module "babylonjs/Materials/thinMaterialHelper" {
  12899. import { Effect } from "babylonjs/Materials/effect";
  12900. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12901. /**
  12902. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12903. *
  12904. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12905. *
  12906. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12907. */
  12908. export class ThinMaterialHelper {
  12909. /**
  12910. * Binds the clip plane information from the holder to the effect.
  12911. * @param effect The effect we are binding the data to
  12912. * @param holder The entity containing the clip plane information
  12913. */
  12914. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12915. }
  12916. }
  12917. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12918. module "babylonjs/Engines/thinEngine" {
  12919. interface ThinEngine {
  12920. /**
  12921. * Sets alpha constants used by some alpha blending modes
  12922. * @param r defines the red component
  12923. * @param g defines the green component
  12924. * @param b defines the blue component
  12925. * @param a defines the alpha component
  12926. */
  12927. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12928. /**
  12929. * Sets the current alpha mode
  12930. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12931. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12932. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12933. */
  12934. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12935. /**
  12936. * Gets the current alpha mode
  12937. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12938. * @returns the current alpha mode
  12939. */
  12940. getAlphaMode(): number;
  12941. /**
  12942. * Sets the current alpha equation
  12943. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12944. */
  12945. setAlphaEquation(equation: number): void;
  12946. /**
  12947. * Gets the current alpha equation.
  12948. * @returns the current alpha equation
  12949. */
  12950. getAlphaEquation(): number;
  12951. }
  12952. }
  12953. }
  12954. declare module "babylonjs/Particles/particleSystem" {
  12955. import { Nullable } from "babylonjs/types";
  12956. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12957. import { Observable } from "babylonjs/Misc/observable";
  12958. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12959. import { Effect } from "babylonjs/Materials/effect";
  12960. import { IDisposable } from "babylonjs/scene";
  12961. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12962. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12963. import { Particle } from "babylonjs/Particles/particle";
  12964. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12965. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12966. import "babylonjs/Shaders/particles.fragment";
  12967. import "babylonjs/Shaders/particles.vertex";
  12968. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12969. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12970. import "babylonjs/Engines/Extensions/engine.alpha";
  12971. import { Scene } from "babylonjs/scene";
  12972. /**
  12973. * This represents a particle system in Babylon.
  12974. * 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.
  12975. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12976. * @example https://doc.babylonjs.com/babylon101/particles
  12977. */
  12978. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12979. /**
  12980. * Billboard mode will only apply to Y axis
  12981. */
  12982. static readonly BILLBOARDMODE_Y: number;
  12983. /**
  12984. * Billboard mode will apply to all axes
  12985. */
  12986. static readonly BILLBOARDMODE_ALL: number;
  12987. /**
  12988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12989. */
  12990. static readonly BILLBOARDMODE_STRETCHED: number;
  12991. /**
  12992. * This function can be defined to provide custom update for active particles.
  12993. * This function will be called instead of regular update (age, position, color, etc.).
  12994. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12995. */
  12996. updateFunction: (particles: Particle[]) => void;
  12997. private _emitterWorldMatrix;
  12998. /**
  12999. * This function can be defined to specify initial direction for every new particle.
  13000. * It by default use the emitterType defined function
  13001. */
  13002. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  13003. /**
  13004. * This function can be defined to specify initial position for every new particle.
  13005. * It by default use the emitterType defined function
  13006. */
  13007. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  13008. /**
  13009. * @hidden
  13010. */
  13011. _inheritedVelocityOffset: Vector3;
  13012. /**
  13013. * An event triggered when the system is disposed
  13014. */
  13015. onDisposeObservable: Observable<IParticleSystem>;
  13016. /**
  13017. * An event triggered when the system is stopped
  13018. */
  13019. onStoppedObservable: Observable<IParticleSystem>;
  13020. private _onDisposeObserver;
  13021. /**
  13022. * Sets a callback that will be triggered when the system is disposed
  13023. */
  13024. set onDispose(callback: () => void);
  13025. private _particles;
  13026. private _epsilon;
  13027. private _capacity;
  13028. private _stockParticles;
  13029. private _newPartsExcess;
  13030. private _vertexData;
  13031. private _vertexBuffer;
  13032. private _vertexBuffers;
  13033. private _spriteBuffer;
  13034. private _indexBuffer;
  13035. private _effect;
  13036. private _customEffect;
  13037. private _cachedDefines;
  13038. private _scaledColorStep;
  13039. private _colorDiff;
  13040. private _scaledDirection;
  13041. private _scaledGravity;
  13042. private _currentRenderId;
  13043. private _alive;
  13044. private _useInstancing;
  13045. private _vertexArrayObject;
  13046. private _started;
  13047. private _stopped;
  13048. private _actualFrame;
  13049. private _scaledUpdateSpeed;
  13050. private _vertexBufferSize;
  13051. /** @hidden */
  13052. _currentEmitRateGradient: Nullable<FactorGradient>;
  13053. /** @hidden */
  13054. _currentEmitRate1: number;
  13055. /** @hidden */
  13056. _currentEmitRate2: number;
  13057. /** @hidden */
  13058. _currentStartSizeGradient: Nullable<FactorGradient>;
  13059. /** @hidden */
  13060. _currentStartSize1: number;
  13061. /** @hidden */
  13062. _currentStartSize2: number;
  13063. private readonly _rawTextureWidth;
  13064. private _rampGradientsTexture;
  13065. private _useRampGradients;
  13066. /** Gets or sets a matrix to use to compute projection */
  13067. defaultProjectionMatrix: Matrix;
  13068. /** Gets or sets a matrix to use to compute view */
  13069. defaultViewMatrix: Matrix;
  13070. /** Gets or sets a boolean indicating that ramp gradients must be used
  13071. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13072. */
  13073. get useRampGradients(): boolean;
  13074. set useRampGradients(value: boolean);
  13075. /**
  13076. * 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.
  13077. * 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: [])
  13078. */
  13079. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13080. private _subEmitters;
  13081. /**
  13082. * @hidden
  13083. * If the particle systems emitter should be disposed when the particle system is disposed
  13084. */
  13085. _disposeEmitterOnDispose: boolean;
  13086. /**
  13087. * The current active Sub-systems, this property is used by the root particle system only.
  13088. */
  13089. activeSubSystems: Array<ParticleSystem>;
  13090. /**
  13091. * Specifies if the particles are updated in emitter local space or world space
  13092. */
  13093. isLocal: boolean;
  13094. private _rootParticleSystem;
  13095. /**
  13096. * Gets the current list of active particles
  13097. */
  13098. get particles(): Particle[];
  13099. /**
  13100. * Gets the number of particles active at the same time.
  13101. * @returns The number of active particles.
  13102. */
  13103. getActiveCount(): number;
  13104. /**
  13105. * Returns the string "ParticleSystem"
  13106. * @returns a string containing the class name
  13107. */
  13108. getClassName(): string;
  13109. /**
  13110. * Gets a boolean indicating that the system is stopping
  13111. * @returns true if the system is currently stopping
  13112. */
  13113. isStopping(): boolean;
  13114. /**
  13115. * Gets the custom effect used to render the particles
  13116. * @param blendMode Blend mode for which the effect should be retrieved
  13117. * @returns The effect
  13118. */
  13119. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13120. /**
  13121. * Sets the custom effect used to render the particles
  13122. * @param effect The effect to set
  13123. * @param blendMode Blend mode for which the effect should be set
  13124. */
  13125. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13126. /** @hidden */
  13127. private _onBeforeDrawParticlesObservable;
  13128. /**
  13129. * Observable that will be called just before the particles are drawn
  13130. */
  13131. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13132. /**
  13133. * Gets the name of the particle vertex shader
  13134. */
  13135. get vertexShaderName(): string;
  13136. /**
  13137. * Instantiates a particle system.
  13138. * 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.
  13139. * @param name The name of the particle system
  13140. * @param capacity The max number of particles alive at the same time
  13141. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13142. * @param customEffect a custom effect used to change the way particles are rendered by default
  13143. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13144. * @param epsilon Offset used to render the particles
  13145. */
  13146. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13147. private _addFactorGradient;
  13148. private _removeFactorGradient;
  13149. /**
  13150. * Adds a new life time gradient
  13151. * @param gradient defines the gradient to use (between 0 and 1)
  13152. * @param factor defines the life time factor to affect to the specified gradient
  13153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13154. * @returns the current particle system
  13155. */
  13156. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13157. /**
  13158. * Remove a specific life time gradient
  13159. * @param gradient defines the gradient to remove
  13160. * @returns the current particle system
  13161. */
  13162. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13163. /**
  13164. * Adds a new size gradient
  13165. * @param gradient defines the gradient to use (between 0 and 1)
  13166. * @param factor defines the size factor to affect to the specified gradient
  13167. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13168. * @returns the current particle system
  13169. */
  13170. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13171. /**
  13172. * Remove a specific size gradient
  13173. * @param gradient defines the gradient to remove
  13174. * @returns the current particle system
  13175. */
  13176. removeSizeGradient(gradient: number): IParticleSystem;
  13177. /**
  13178. * Adds a new color remap gradient
  13179. * @param gradient defines the gradient to use (between 0 and 1)
  13180. * @param min defines the color remap minimal range
  13181. * @param max defines the color remap maximal range
  13182. * @returns the current particle system
  13183. */
  13184. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13185. /**
  13186. * Remove a specific color remap gradient
  13187. * @param gradient defines the gradient to remove
  13188. * @returns the current particle system
  13189. */
  13190. removeColorRemapGradient(gradient: number): IParticleSystem;
  13191. /**
  13192. * Adds a new alpha remap gradient
  13193. * @param gradient defines the gradient to use (between 0 and 1)
  13194. * @param min defines the alpha remap minimal range
  13195. * @param max defines the alpha remap maximal range
  13196. * @returns the current particle system
  13197. */
  13198. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13199. /**
  13200. * Remove a specific alpha remap gradient
  13201. * @param gradient defines the gradient to remove
  13202. * @returns the current particle system
  13203. */
  13204. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13205. /**
  13206. * Adds a new angular speed gradient
  13207. * @param gradient defines the gradient to use (between 0 and 1)
  13208. * @param factor defines the angular speed to affect to the specified gradient
  13209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13210. * @returns the current particle system
  13211. */
  13212. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13213. /**
  13214. * Remove a specific angular speed gradient
  13215. * @param gradient defines the gradient to remove
  13216. * @returns the current particle system
  13217. */
  13218. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13219. /**
  13220. * Adds a new velocity gradient
  13221. * @param gradient defines the gradient to use (between 0 and 1)
  13222. * @param factor defines the velocity to affect to the specified gradient
  13223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13224. * @returns the current particle system
  13225. */
  13226. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13227. /**
  13228. * Remove a specific velocity gradient
  13229. * @param gradient defines the gradient to remove
  13230. * @returns the current particle system
  13231. */
  13232. removeVelocityGradient(gradient: number): IParticleSystem;
  13233. /**
  13234. * Adds a new limit velocity gradient
  13235. * @param gradient defines the gradient to use (between 0 and 1)
  13236. * @param factor defines the limit velocity value to affect to the specified gradient
  13237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13238. * @returns the current particle system
  13239. */
  13240. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13241. /**
  13242. * Remove a specific limit velocity gradient
  13243. * @param gradient defines the gradient to remove
  13244. * @returns the current particle system
  13245. */
  13246. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13247. /**
  13248. * Adds a new drag gradient
  13249. * @param gradient defines the gradient to use (between 0 and 1)
  13250. * @param factor defines the drag value to affect to the specified gradient
  13251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13252. * @returns the current particle system
  13253. */
  13254. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13255. /**
  13256. * Remove a specific drag gradient
  13257. * @param gradient defines the gradient to remove
  13258. * @returns the current particle system
  13259. */
  13260. removeDragGradient(gradient: number): IParticleSystem;
  13261. /**
  13262. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13263. * @param gradient defines the gradient to use (between 0 and 1)
  13264. * @param factor defines the emit rate value to affect to the specified gradient
  13265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13266. * @returns the current particle system
  13267. */
  13268. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13269. /**
  13270. * Remove a specific emit rate gradient
  13271. * @param gradient defines the gradient to remove
  13272. * @returns the current particle system
  13273. */
  13274. removeEmitRateGradient(gradient: number): IParticleSystem;
  13275. /**
  13276. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13277. * @param gradient defines the gradient to use (between 0 and 1)
  13278. * @param factor defines the start size value to affect to the specified gradient
  13279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13280. * @returns the current particle system
  13281. */
  13282. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13283. /**
  13284. * Remove a specific start size gradient
  13285. * @param gradient defines the gradient to remove
  13286. * @returns the current particle system
  13287. */
  13288. removeStartSizeGradient(gradient: number): IParticleSystem;
  13289. private _createRampGradientTexture;
  13290. /**
  13291. * Gets the current list of ramp gradients.
  13292. * You must use addRampGradient and removeRampGradient to udpate this list
  13293. * @returns the list of ramp gradients
  13294. */
  13295. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13296. /** Force the system to rebuild all gradients that need to be resync */
  13297. forceRefreshGradients(): void;
  13298. private _syncRampGradientTexture;
  13299. /**
  13300. * Adds a new ramp gradient used to remap particle colors
  13301. * @param gradient defines the gradient to use (between 0 and 1)
  13302. * @param color defines the color to affect to the specified gradient
  13303. * @returns the current particle system
  13304. */
  13305. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13306. /**
  13307. * Remove a specific ramp gradient
  13308. * @param gradient defines the gradient to remove
  13309. * @returns the current particle system
  13310. */
  13311. removeRampGradient(gradient: number): ParticleSystem;
  13312. /**
  13313. * Adds a new color gradient
  13314. * @param gradient defines the gradient to use (between 0 and 1)
  13315. * @param color1 defines the color to affect to the specified gradient
  13316. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13317. * @returns this particle system
  13318. */
  13319. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13320. /**
  13321. * Remove a specific color gradient
  13322. * @param gradient defines the gradient to remove
  13323. * @returns this particle system
  13324. */
  13325. removeColorGradient(gradient: number): IParticleSystem;
  13326. private _fetchR;
  13327. protected _reset(): void;
  13328. private _resetEffect;
  13329. private _createVertexBuffers;
  13330. private _createIndexBuffer;
  13331. /**
  13332. * Gets the maximum number of particles active at the same time.
  13333. * @returns The max number of active particles.
  13334. */
  13335. getCapacity(): number;
  13336. /**
  13337. * Gets whether there are still active particles in the system.
  13338. * @returns True if it is alive, otherwise false.
  13339. */
  13340. isAlive(): boolean;
  13341. /**
  13342. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13343. * @returns True if it has been started, otherwise false.
  13344. */
  13345. isStarted(): boolean;
  13346. private _prepareSubEmitterInternalArray;
  13347. /**
  13348. * Starts the particle system and begins to emit
  13349. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13350. */
  13351. start(delay?: number): void;
  13352. /**
  13353. * Stops the particle system.
  13354. * @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.
  13355. */
  13356. stop(stopSubEmitters?: boolean): void;
  13357. /**
  13358. * Remove all active particles
  13359. */
  13360. reset(): void;
  13361. /**
  13362. * @hidden (for internal use only)
  13363. */
  13364. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13365. /**
  13366. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13367. * Its lifetime will start back at 0.
  13368. */
  13369. recycleParticle: (particle: Particle) => void;
  13370. private _stopSubEmitters;
  13371. private _createParticle;
  13372. private _removeFromRoot;
  13373. private _emitFromParticle;
  13374. private _update;
  13375. /** @hidden */
  13376. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13377. /** @hidden */
  13378. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13379. /**
  13380. * Fill the defines array according to the current settings of the particle system
  13381. * @param defines Array to be updated
  13382. * @param blendMode blend mode to take into account when updating the array
  13383. */
  13384. fillDefines(defines: Array<string>, blendMode: number): void;
  13385. /**
  13386. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13387. * @param uniforms Uniforms array to fill
  13388. * @param attributes Attributes array to fill
  13389. * @param samplers Samplers array to fill
  13390. */
  13391. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13392. /** @hidden */
  13393. private _getEffect;
  13394. /**
  13395. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13396. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13397. */
  13398. animate(preWarmOnly?: boolean): void;
  13399. private _appendParticleVertices;
  13400. /**
  13401. * Rebuilds the particle system.
  13402. */
  13403. rebuild(): void;
  13404. /**
  13405. * Is this system ready to be used/rendered
  13406. * @return true if the system is ready
  13407. */
  13408. isReady(): boolean;
  13409. private _render;
  13410. /**
  13411. * Renders the particle system in its current state.
  13412. * @returns the current number of particles
  13413. */
  13414. render(): number;
  13415. /**
  13416. * Disposes the particle system and free the associated resources
  13417. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13418. */
  13419. dispose(disposeTexture?: boolean): void;
  13420. /**
  13421. * Clones the particle system.
  13422. * @param name The name of the cloned object
  13423. * @param newEmitter The new emitter to use
  13424. * @returns the cloned particle system
  13425. */
  13426. clone(name: string, newEmitter: any): ParticleSystem;
  13427. /**
  13428. * Serializes the particle system to a JSON object
  13429. * @param serializeTexture defines if the texture must be serialized as well
  13430. * @returns the JSON object
  13431. */
  13432. serialize(serializeTexture?: boolean): any;
  13433. /** @hidden */
  13434. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13435. /** @hidden */
  13436. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13437. /**
  13438. * Parses a JSON object to create a particle system.
  13439. * @param parsedParticleSystem The JSON object to parse
  13440. * @param sceneOrEngine The scene or the engine to create the particle system in
  13441. * @param rootUrl The root url to use to load external dependencies like texture
  13442. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13443. * @returns the Parsed particle system
  13444. */
  13445. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13446. }
  13447. }
  13448. declare module "babylonjs/Particles/particle" {
  13449. import { Nullable } from "babylonjs/types";
  13450. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13451. import { Color4 } from "babylonjs/Maths/math.color";
  13452. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13453. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13454. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13455. /**
  13456. * A particle represents one of the element emitted by a particle system.
  13457. * This is mainly define by its coordinates, direction, velocity and age.
  13458. */
  13459. export class Particle {
  13460. /**
  13461. * The particle system the particle belongs to.
  13462. */
  13463. particleSystem: ParticleSystem;
  13464. private static _Count;
  13465. /**
  13466. * Unique ID of the particle
  13467. */
  13468. id: number;
  13469. /**
  13470. * The world position of the particle in the scene.
  13471. */
  13472. position: Vector3;
  13473. /**
  13474. * The world direction of the particle in the scene.
  13475. */
  13476. direction: Vector3;
  13477. /**
  13478. * The color of the particle.
  13479. */
  13480. color: Color4;
  13481. /**
  13482. * The color change of the particle per step.
  13483. */
  13484. colorStep: Color4;
  13485. /**
  13486. * Defines how long will the life of the particle be.
  13487. */
  13488. lifeTime: number;
  13489. /**
  13490. * The current age of the particle.
  13491. */
  13492. age: number;
  13493. /**
  13494. * The current size of the particle.
  13495. */
  13496. size: number;
  13497. /**
  13498. * The current scale of the particle.
  13499. */
  13500. scale: Vector2;
  13501. /**
  13502. * The current angle of the particle.
  13503. */
  13504. angle: number;
  13505. /**
  13506. * Defines how fast is the angle changing.
  13507. */
  13508. angularSpeed: number;
  13509. /**
  13510. * Defines the cell index used by the particle to be rendered from a sprite.
  13511. */
  13512. cellIndex: number;
  13513. /**
  13514. * The information required to support color remapping
  13515. */
  13516. remapData: Vector4;
  13517. /** @hidden */
  13518. _randomCellOffset?: number;
  13519. /** @hidden */
  13520. _initialDirection: Nullable<Vector3>;
  13521. /** @hidden */
  13522. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13523. /** @hidden */
  13524. _initialStartSpriteCellID: number;
  13525. /** @hidden */
  13526. _initialEndSpriteCellID: number;
  13527. /** @hidden */
  13528. _currentColorGradient: Nullable<ColorGradient>;
  13529. /** @hidden */
  13530. _currentColor1: Color4;
  13531. /** @hidden */
  13532. _currentColor2: Color4;
  13533. /** @hidden */
  13534. _currentSizeGradient: Nullable<FactorGradient>;
  13535. /** @hidden */
  13536. _currentSize1: number;
  13537. /** @hidden */
  13538. _currentSize2: number;
  13539. /** @hidden */
  13540. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13541. /** @hidden */
  13542. _currentAngularSpeed1: number;
  13543. /** @hidden */
  13544. _currentAngularSpeed2: number;
  13545. /** @hidden */
  13546. _currentVelocityGradient: Nullable<FactorGradient>;
  13547. /** @hidden */
  13548. _currentVelocity1: number;
  13549. /** @hidden */
  13550. _currentVelocity2: number;
  13551. /** @hidden */
  13552. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13553. /** @hidden */
  13554. _currentLimitVelocity1: number;
  13555. /** @hidden */
  13556. _currentLimitVelocity2: number;
  13557. /** @hidden */
  13558. _currentDragGradient: Nullable<FactorGradient>;
  13559. /** @hidden */
  13560. _currentDrag1: number;
  13561. /** @hidden */
  13562. _currentDrag2: number;
  13563. /** @hidden */
  13564. _randomNoiseCoordinates1: Vector3;
  13565. /** @hidden */
  13566. _randomNoiseCoordinates2: Vector3;
  13567. /** @hidden */
  13568. _localPosition?: Vector3;
  13569. /**
  13570. * Creates a new instance Particle
  13571. * @param particleSystem the particle system the particle belongs to
  13572. */
  13573. constructor(
  13574. /**
  13575. * The particle system the particle belongs to.
  13576. */
  13577. particleSystem: ParticleSystem);
  13578. private updateCellInfoFromSystem;
  13579. /**
  13580. * Defines how the sprite cell index is updated for the particle
  13581. */
  13582. updateCellIndex(): void;
  13583. /** @hidden */
  13584. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13585. /** @hidden */
  13586. _inheritParticleInfoToSubEmitters(): void;
  13587. /** @hidden */
  13588. _reset(): void;
  13589. /**
  13590. * Copy the properties of particle to another one.
  13591. * @param other the particle to copy the information to.
  13592. */
  13593. copyTo(other: Particle): void;
  13594. }
  13595. }
  13596. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13597. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13598. import { Effect } from "babylonjs/Materials/effect";
  13599. import { Particle } from "babylonjs/Particles/particle";
  13600. import { Nullable } from "babylonjs/types";
  13601. import { Scene } from "babylonjs/scene";
  13602. /**
  13603. * Particle emitter represents a volume emitting particles.
  13604. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13605. */
  13606. export interface IParticleEmitterType {
  13607. /**
  13608. * Called by the particle System when the direction is computed for the created particle.
  13609. * @param worldMatrix is the world matrix of the particle system
  13610. * @param directionToUpdate is the direction vector to update with the result
  13611. * @param particle is the particle we are computed the direction for
  13612. * @param isLocal defines if the direction should be set in local space
  13613. */
  13614. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13615. /**
  13616. * Called by the particle System when the position is computed for the created particle.
  13617. * @param worldMatrix is the world matrix of the particle system
  13618. * @param positionToUpdate is the position vector to update with the result
  13619. * @param particle is the particle we are computed the position for
  13620. * @param isLocal defines if the position should be set in local space
  13621. */
  13622. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13623. /**
  13624. * Clones the current emitter and returns a copy of it
  13625. * @returns the new emitter
  13626. */
  13627. clone(): IParticleEmitterType;
  13628. /**
  13629. * Called by the GPUParticleSystem to setup the update shader
  13630. * @param effect defines the update shader
  13631. */
  13632. applyToShader(effect: Effect): void;
  13633. /**
  13634. * Returns a string to use to update the GPU particles update shader
  13635. * @returns the effect defines string
  13636. */
  13637. getEffectDefines(): string;
  13638. /**
  13639. * Returns a string representing the class name
  13640. * @returns a string containing the class name
  13641. */
  13642. getClassName(): string;
  13643. /**
  13644. * Serializes the particle system to a JSON object.
  13645. * @returns the JSON object
  13646. */
  13647. serialize(): any;
  13648. /**
  13649. * Parse properties from a JSON object
  13650. * @param serializationObject defines the JSON object
  13651. * @param scene defines the hosting scene
  13652. */
  13653. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13654. }
  13655. }
  13656. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13657. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13658. import { Effect } from "babylonjs/Materials/effect";
  13659. import { Particle } from "babylonjs/Particles/particle";
  13660. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13661. /**
  13662. * Particle emitter emitting particles from the inside of a box.
  13663. * It emits the particles randomly between 2 given directions.
  13664. */
  13665. export class BoxParticleEmitter implements IParticleEmitterType {
  13666. /**
  13667. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13668. */
  13669. direction1: Vector3;
  13670. /**
  13671. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13672. */
  13673. direction2: Vector3;
  13674. /**
  13675. * 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.
  13676. */
  13677. minEmitBox: Vector3;
  13678. /**
  13679. * 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.
  13680. */
  13681. maxEmitBox: Vector3;
  13682. /**
  13683. * Creates a new instance BoxParticleEmitter
  13684. */
  13685. constructor();
  13686. /**
  13687. * Called by the particle System when the direction is computed for the created particle.
  13688. * @param worldMatrix is the world matrix of the particle system
  13689. * @param directionToUpdate is the direction vector to update with the result
  13690. * @param particle is the particle we are computed the direction for
  13691. * @param isLocal defines if the direction should be set in local space
  13692. */
  13693. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13694. /**
  13695. * Called by the particle System when the position is computed for the created particle.
  13696. * @param worldMatrix is the world matrix of the particle system
  13697. * @param positionToUpdate is the position vector to update with the result
  13698. * @param particle is the particle we are computed the position for
  13699. * @param isLocal defines if the position should be set in local space
  13700. */
  13701. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13702. /**
  13703. * Clones the current emitter and returns a copy of it
  13704. * @returns the new emitter
  13705. */
  13706. clone(): BoxParticleEmitter;
  13707. /**
  13708. * Called by the GPUParticleSystem to setup the update shader
  13709. * @param effect defines the update shader
  13710. */
  13711. applyToShader(effect: Effect): void;
  13712. /**
  13713. * Returns a string to use to update the GPU particles update shader
  13714. * @returns a string containng the defines string
  13715. */
  13716. getEffectDefines(): string;
  13717. /**
  13718. * Returns the string "BoxParticleEmitter"
  13719. * @returns a string containing the class name
  13720. */
  13721. getClassName(): string;
  13722. /**
  13723. * Serializes the particle system to a JSON object.
  13724. * @returns the JSON object
  13725. */
  13726. serialize(): any;
  13727. /**
  13728. * Parse properties from a JSON object
  13729. * @param serializationObject defines the JSON object
  13730. */
  13731. parse(serializationObject: any): void;
  13732. }
  13733. }
  13734. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13735. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13736. import { Effect } from "babylonjs/Materials/effect";
  13737. import { Particle } from "babylonjs/Particles/particle";
  13738. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13739. /**
  13740. * Particle emitter emitting particles from the inside of a cone.
  13741. * It emits the particles alongside the cone volume from the base to the particle.
  13742. * The emission direction might be randomized.
  13743. */
  13744. export class ConeParticleEmitter implements IParticleEmitterType {
  13745. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13746. directionRandomizer: number;
  13747. private _radius;
  13748. private _angle;
  13749. private _height;
  13750. /**
  13751. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13752. */
  13753. radiusRange: number;
  13754. /**
  13755. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13756. */
  13757. heightRange: number;
  13758. /**
  13759. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13760. */
  13761. emitFromSpawnPointOnly: boolean;
  13762. /**
  13763. * Gets or sets the radius of the emission cone
  13764. */
  13765. get radius(): number;
  13766. set radius(value: number);
  13767. /**
  13768. * Gets or sets the angle of the emission cone
  13769. */
  13770. get angle(): number;
  13771. set angle(value: number);
  13772. private _buildHeight;
  13773. /**
  13774. * Creates a new instance ConeParticleEmitter
  13775. * @param radius the radius of the emission cone (1 by default)
  13776. * @param angle the cone base angle (PI by default)
  13777. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13778. */
  13779. constructor(radius?: number, angle?: number,
  13780. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13781. directionRandomizer?: number);
  13782. /**
  13783. * Called by the particle System when the direction is computed for the created particle.
  13784. * @param worldMatrix is the world matrix of the particle system
  13785. * @param directionToUpdate is the direction vector to update with the result
  13786. * @param particle is the particle we are computed the direction for
  13787. * @param isLocal defines if the direction should be set in local space
  13788. */
  13789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13790. /**
  13791. * Called by the particle System when the position is computed for the created particle.
  13792. * @param worldMatrix is the world matrix of the particle system
  13793. * @param positionToUpdate is the position vector to update with the result
  13794. * @param particle is the particle we are computed the position for
  13795. * @param isLocal defines if the position should be set in local space
  13796. */
  13797. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13798. /**
  13799. * Clones the current emitter and returns a copy of it
  13800. * @returns the new emitter
  13801. */
  13802. clone(): ConeParticleEmitter;
  13803. /**
  13804. * Called by the GPUParticleSystem to setup the update shader
  13805. * @param effect defines the update shader
  13806. */
  13807. applyToShader(effect: Effect): void;
  13808. /**
  13809. * Returns a string to use to update the GPU particles update shader
  13810. * @returns a string containng the defines string
  13811. */
  13812. getEffectDefines(): string;
  13813. /**
  13814. * Returns the string "ConeParticleEmitter"
  13815. * @returns a string containing the class name
  13816. */
  13817. getClassName(): string;
  13818. /**
  13819. * Serializes the particle system to a JSON object.
  13820. * @returns the JSON object
  13821. */
  13822. serialize(): any;
  13823. /**
  13824. * Parse properties from a JSON object
  13825. * @param serializationObject defines the JSON object
  13826. */
  13827. parse(serializationObject: any): void;
  13828. }
  13829. }
  13830. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13831. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13832. import { Effect } from "babylonjs/Materials/effect";
  13833. import { Particle } from "babylonjs/Particles/particle";
  13834. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13835. /**
  13836. * Particle emitter emitting particles from the inside of a cylinder.
  13837. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13838. */
  13839. export class CylinderParticleEmitter implements IParticleEmitterType {
  13840. /**
  13841. * The radius of the emission cylinder.
  13842. */
  13843. radius: number;
  13844. /**
  13845. * The height of the emission cylinder.
  13846. */
  13847. height: number;
  13848. /**
  13849. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13850. */
  13851. radiusRange: number;
  13852. /**
  13853. * How much to randomize the particle direction [0-1].
  13854. */
  13855. directionRandomizer: number;
  13856. /**
  13857. * Creates a new instance CylinderParticleEmitter
  13858. * @param radius the radius of the emission cylinder (1 by default)
  13859. * @param height the height of the emission cylinder (1 by default)
  13860. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13861. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13862. */
  13863. constructor(
  13864. /**
  13865. * The radius of the emission cylinder.
  13866. */
  13867. radius?: number,
  13868. /**
  13869. * The height of the emission cylinder.
  13870. */
  13871. height?: number,
  13872. /**
  13873. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13874. */
  13875. radiusRange?: number,
  13876. /**
  13877. * How much to randomize the particle direction [0-1].
  13878. */
  13879. directionRandomizer?: number);
  13880. /**
  13881. * Called by the particle System when the direction is computed for the created particle.
  13882. * @param worldMatrix is the world matrix of the particle system
  13883. * @param directionToUpdate is the direction vector to update with the result
  13884. * @param particle is the particle we are computed the direction for
  13885. * @param isLocal defines if the direction should be set in local space
  13886. */
  13887. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13888. /**
  13889. * Called by the particle System when the position is computed for the created particle.
  13890. * @param worldMatrix is the world matrix of the particle system
  13891. * @param positionToUpdate is the position vector to update with the result
  13892. * @param particle is the particle we are computed the position for
  13893. * @param isLocal defines if the position should be set in local space
  13894. */
  13895. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13896. /**
  13897. * Clones the current emitter and returns a copy of it
  13898. * @returns the new emitter
  13899. */
  13900. clone(): CylinderParticleEmitter;
  13901. /**
  13902. * Called by the GPUParticleSystem to setup the update shader
  13903. * @param effect defines the update shader
  13904. */
  13905. applyToShader(effect: Effect): void;
  13906. /**
  13907. * Returns a string to use to update the GPU particles update shader
  13908. * @returns a string containng the defines string
  13909. */
  13910. getEffectDefines(): string;
  13911. /**
  13912. * Returns the string "CylinderParticleEmitter"
  13913. * @returns a string containing the class name
  13914. */
  13915. getClassName(): string;
  13916. /**
  13917. * Serializes the particle system to a JSON object.
  13918. * @returns the JSON object
  13919. */
  13920. serialize(): any;
  13921. /**
  13922. * Parse properties from a JSON object
  13923. * @param serializationObject defines the JSON object
  13924. */
  13925. parse(serializationObject: any): void;
  13926. }
  13927. /**
  13928. * Particle emitter emitting particles from the inside of a cylinder.
  13929. * It emits the particles randomly between two vectors.
  13930. */
  13931. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13932. /**
  13933. * The min limit of the emission direction.
  13934. */
  13935. direction1: Vector3;
  13936. /**
  13937. * The max limit of the emission direction.
  13938. */
  13939. direction2: Vector3;
  13940. /**
  13941. * Creates a new instance CylinderDirectedParticleEmitter
  13942. * @param radius the radius of the emission cylinder (1 by default)
  13943. * @param height the height of the emission cylinder (1 by default)
  13944. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13945. * @param direction1 the min limit of the emission direction (up vector by default)
  13946. * @param direction2 the max limit of the emission direction (up vector by default)
  13947. */
  13948. constructor(radius?: number, height?: number, radiusRange?: number,
  13949. /**
  13950. * The min limit of the emission direction.
  13951. */
  13952. direction1?: Vector3,
  13953. /**
  13954. * The max limit of the emission direction.
  13955. */
  13956. direction2?: Vector3);
  13957. /**
  13958. * Called by the particle System when the direction is computed for the created particle.
  13959. * @param worldMatrix is the world matrix of the particle system
  13960. * @param directionToUpdate is the direction vector to update with the result
  13961. * @param particle is the particle we are computed the direction for
  13962. */
  13963. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13964. /**
  13965. * Clones the current emitter and returns a copy of it
  13966. * @returns the new emitter
  13967. */
  13968. clone(): CylinderDirectedParticleEmitter;
  13969. /**
  13970. * Called by the GPUParticleSystem to setup the update shader
  13971. * @param effect defines the update shader
  13972. */
  13973. applyToShader(effect: Effect): void;
  13974. /**
  13975. * Returns a string to use to update the GPU particles update shader
  13976. * @returns a string containng the defines string
  13977. */
  13978. getEffectDefines(): string;
  13979. /**
  13980. * Returns the string "CylinderDirectedParticleEmitter"
  13981. * @returns a string containing the class name
  13982. */
  13983. getClassName(): string;
  13984. /**
  13985. * Serializes the particle system to a JSON object.
  13986. * @returns the JSON object
  13987. */
  13988. serialize(): any;
  13989. /**
  13990. * Parse properties from a JSON object
  13991. * @param serializationObject defines the JSON object
  13992. */
  13993. parse(serializationObject: any): void;
  13994. }
  13995. }
  13996. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13997. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13998. import { Effect } from "babylonjs/Materials/effect";
  13999. import { Particle } from "babylonjs/Particles/particle";
  14000. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14001. /**
  14002. * Particle emitter emitting particles from the inside of a hemisphere.
  14003. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  14004. */
  14005. export class HemisphericParticleEmitter implements IParticleEmitterType {
  14006. /**
  14007. * The radius of the emission hemisphere.
  14008. */
  14009. radius: number;
  14010. /**
  14011. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14012. */
  14013. radiusRange: number;
  14014. /**
  14015. * How much to randomize the particle direction [0-1].
  14016. */
  14017. directionRandomizer: number;
  14018. /**
  14019. * Creates a new instance HemisphericParticleEmitter
  14020. * @param radius the radius of the emission hemisphere (1 by default)
  14021. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14022. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14023. */
  14024. constructor(
  14025. /**
  14026. * The radius of the emission hemisphere.
  14027. */
  14028. radius?: number,
  14029. /**
  14030. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14031. */
  14032. radiusRange?: number,
  14033. /**
  14034. * How much to randomize the particle direction [0-1].
  14035. */
  14036. directionRandomizer?: number);
  14037. /**
  14038. * Called by the particle System when the direction is computed for the created particle.
  14039. * @param worldMatrix is the world matrix of the particle system
  14040. * @param directionToUpdate is the direction vector to update with the result
  14041. * @param particle is the particle we are computed the direction for
  14042. * @param isLocal defines if the direction should be set in local space
  14043. */
  14044. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14045. /**
  14046. * Called by the particle System when the position is computed for the created particle.
  14047. * @param worldMatrix is the world matrix of the particle system
  14048. * @param positionToUpdate is the position vector to update with the result
  14049. * @param particle is the particle we are computed the position for
  14050. * @param isLocal defines if the position should be set in local space
  14051. */
  14052. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14053. /**
  14054. * Clones the current emitter and returns a copy of it
  14055. * @returns the new emitter
  14056. */
  14057. clone(): HemisphericParticleEmitter;
  14058. /**
  14059. * Called by the GPUParticleSystem to setup the update shader
  14060. * @param effect defines the update shader
  14061. */
  14062. applyToShader(effect: Effect): void;
  14063. /**
  14064. * Returns a string to use to update the GPU particles update shader
  14065. * @returns a string containng the defines string
  14066. */
  14067. getEffectDefines(): string;
  14068. /**
  14069. * Returns the string "HemisphericParticleEmitter"
  14070. * @returns a string containing the class name
  14071. */
  14072. getClassName(): string;
  14073. /**
  14074. * Serializes the particle system to a JSON object.
  14075. * @returns the JSON object
  14076. */
  14077. serialize(): any;
  14078. /**
  14079. * Parse properties from a JSON object
  14080. * @param serializationObject defines the JSON object
  14081. */
  14082. parse(serializationObject: any): void;
  14083. }
  14084. }
  14085. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14086. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14087. import { Effect } from "babylonjs/Materials/effect";
  14088. import { Particle } from "babylonjs/Particles/particle";
  14089. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14090. /**
  14091. * Particle emitter emitting particles from a point.
  14092. * It emits the particles randomly between 2 given directions.
  14093. */
  14094. export class PointParticleEmitter implements IParticleEmitterType {
  14095. /**
  14096. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14097. */
  14098. direction1: Vector3;
  14099. /**
  14100. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14101. */
  14102. direction2: Vector3;
  14103. /**
  14104. * Creates a new instance PointParticleEmitter
  14105. */
  14106. constructor();
  14107. /**
  14108. * Called by the particle System when the direction is computed for the created particle.
  14109. * @param worldMatrix is the world matrix of the particle system
  14110. * @param directionToUpdate is the direction vector to update with the result
  14111. * @param particle is the particle we are computed the direction for
  14112. * @param isLocal defines if the direction should be set in local space
  14113. */
  14114. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14115. /**
  14116. * Called by the particle System when the position is computed for the created particle.
  14117. * @param worldMatrix is the world matrix of the particle system
  14118. * @param positionToUpdate is the position vector to update with the result
  14119. * @param particle is the particle we are computed the position for
  14120. * @param isLocal defines if the position should be set in local space
  14121. */
  14122. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14123. /**
  14124. * Clones the current emitter and returns a copy of it
  14125. * @returns the new emitter
  14126. */
  14127. clone(): PointParticleEmitter;
  14128. /**
  14129. * Called by the GPUParticleSystem to setup the update shader
  14130. * @param effect defines the update shader
  14131. */
  14132. applyToShader(effect: Effect): void;
  14133. /**
  14134. * Returns a string to use to update the GPU particles update shader
  14135. * @returns a string containng the defines string
  14136. */
  14137. getEffectDefines(): string;
  14138. /**
  14139. * Returns the string "PointParticleEmitter"
  14140. * @returns a string containing the class name
  14141. */
  14142. getClassName(): string;
  14143. /**
  14144. * Serializes the particle system to a JSON object.
  14145. * @returns the JSON object
  14146. */
  14147. serialize(): any;
  14148. /**
  14149. * Parse properties from a JSON object
  14150. * @param serializationObject defines the JSON object
  14151. */
  14152. parse(serializationObject: any): void;
  14153. }
  14154. }
  14155. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14156. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14157. import { Effect } from "babylonjs/Materials/effect";
  14158. import { Particle } from "babylonjs/Particles/particle";
  14159. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14160. /**
  14161. * Particle emitter emitting particles from the inside of a sphere.
  14162. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14163. */
  14164. export class SphereParticleEmitter implements IParticleEmitterType {
  14165. /**
  14166. * The radius of the emission sphere.
  14167. */
  14168. radius: number;
  14169. /**
  14170. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14171. */
  14172. radiusRange: number;
  14173. /**
  14174. * How much to randomize the particle direction [0-1].
  14175. */
  14176. directionRandomizer: number;
  14177. /**
  14178. * Creates a new instance SphereParticleEmitter
  14179. * @param radius the radius of the emission sphere (1 by default)
  14180. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14181. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14182. */
  14183. constructor(
  14184. /**
  14185. * The radius of the emission sphere.
  14186. */
  14187. radius?: number,
  14188. /**
  14189. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14190. */
  14191. radiusRange?: number,
  14192. /**
  14193. * How much to randomize the particle direction [0-1].
  14194. */
  14195. directionRandomizer?: number);
  14196. /**
  14197. * Called by the particle System when the direction is computed for the created particle.
  14198. * @param worldMatrix is the world matrix of the particle system
  14199. * @param directionToUpdate is the direction vector to update with the result
  14200. * @param particle is the particle we are computed the direction for
  14201. * @param isLocal defines if the direction should be set in local space
  14202. */
  14203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14204. /**
  14205. * Called by the particle System when the position is computed for the created particle.
  14206. * @param worldMatrix is the world matrix of the particle system
  14207. * @param positionToUpdate is the position vector to update with the result
  14208. * @param particle is the particle we are computed the position for
  14209. * @param isLocal defines if the position should be set in local space
  14210. */
  14211. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14212. /**
  14213. * Clones the current emitter and returns a copy of it
  14214. * @returns the new emitter
  14215. */
  14216. clone(): SphereParticleEmitter;
  14217. /**
  14218. * Called by the GPUParticleSystem to setup the update shader
  14219. * @param effect defines the update shader
  14220. */
  14221. applyToShader(effect: Effect): void;
  14222. /**
  14223. * Returns a string to use to update the GPU particles update shader
  14224. * @returns a string containng the defines string
  14225. */
  14226. getEffectDefines(): string;
  14227. /**
  14228. * Returns the string "SphereParticleEmitter"
  14229. * @returns a string containing the class name
  14230. */
  14231. getClassName(): string;
  14232. /**
  14233. * Serializes the particle system to a JSON object.
  14234. * @returns the JSON object
  14235. */
  14236. serialize(): any;
  14237. /**
  14238. * Parse properties from a JSON object
  14239. * @param serializationObject defines the JSON object
  14240. */
  14241. parse(serializationObject: any): void;
  14242. }
  14243. /**
  14244. * Particle emitter emitting particles from the inside of a sphere.
  14245. * It emits the particles randomly between two vectors.
  14246. */
  14247. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14248. /**
  14249. * The min limit of the emission direction.
  14250. */
  14251. direction1: Vector3;
  14252. /**
  14253. * The max limit of the emission direction.
  14254. */
  14255. direction2: Vector3;
  14256. /**
  14257. * Creates a new instance SphereDirectedParticleEmitter
  14258. * @param radius the radius of the emission sphere (1 by default)
  14259. * @param direction1 the min limit of the emission direction (up vector by default)
  14260. * @param direction2 the max limit of the emission direction (up vector by default)
  14261. */
  14262. constructor(radius?: number,
  14263. /**
  14264. * The min limit of the emission direction.
  14265. */
  14266. direction1?: Vector3,
  14267. /**
  14268. * The max limit of the emission direction.
  14269. */
  14270. direction2?: Vector3);
  14271. /**
  14272. * Called by the particle System when the direction is computed for the created particle.
  14273. * @param worldMatrix is the world matrix of the particle system
  14274. * @param directionToUpdate is the direction vector to update with the result
  14275. * @param particle is the particle we are computed the direction for
  14276. */
  14277. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14278. /**
  14279. * Clones the current emitter and returns a copy of it
  14280. * @returns the new emitter
  14281. */
  14282. clone(): SphereDirectedParticleEmitter;
  14283. /**
  14284. * Called by the GPUParticleSystem to setup the update shader
  14285. * @param effect defines the update shader
  14286. */
  14287. applyToShader(effect: Effect): void;
  14288. /**
  14289. * Returns a string to use to update the GPU particles update shader
  14290. * @returns a string containng the defines string
  14291. */
  14292. getEffectDefines(): string;
  14293. /**
  14294. * Returns the string "SphereDirectedParticleEmitter"
  14295. * @returns a string containing the class name
  14296. */
  14297. getClassName(): string;
  14298. /**
  14299. * Serializes the particle system to a JSON object.
  14300. * @returns the JSON object
  14301. */
  14302. serialize(): any;
  14303. /**
  14304. * Parse properties from a JSON object
  14305. * @param serializationObject defines the JSON object
  14306. */
  14307. parse(serializationObject: any): void;
  14308. }
  14309. }
  14310. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14311. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14312. import { Effect } from "babylonjs/Materials/effect";
  14313. import { Particle } from "babylonjs/Particles/particle";
  14314. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14315. import { Nullable } from "babylonjs/types";
  14316. /**
  14317. * Particle emitter emitting particles from a custom list of positions.
  14318. */
  14319. export class CustomParticleEmitter implements IParticleEmitterType {
  14320. /**
  14321. * Gets or sets the position generator that will create the inital position of each particle.
  14322. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14323. */
  14324. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14325. /**
  14326. * Gets or sets the destination generator that will create the final destination of each particle.
  14327. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14328. */
  14329. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14330. /**
  14331. * Creates a new instance CustomParticleEmitter
  14332. */
  14333. constructor();
  14334. /**
  14335. * Called by the particle System when the direction is computed for the created particle.
  14336. * @param worldMatrix is the world matrix of the particle system
  14337. * @param directionToUpdate is the direction vector to update with the result
  14338. * @param particle is the particle we are computed the direction for
  14339. * @param isLocal defines if the direction should be set in local space
  14340. */
  14341. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14342. /**
  14343. * Called by the particle System when the position is computed for the created particle.
  14344. * @param worldMatrix is the world matrix of the particle system
  14345. * @param positionToUpdate is the position vector to update with the result
  14346. * @param particle is the particle we are computed the position for
  14347. * @param isLocal defines if the position should be set in local space
  14348. */
  14349. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14350. /**
  14351. * Clones the current emitter and returns a copy of it
  14352. * @returns the new emitter
  14353. */
  14354. clone(): CustomParticleEmitter;
  14355. /**
  14356. * Called by the GPUParticleSystem to setup the update shader
  14357. * @param effect defines the update shader
  14358. */
  14359. applyToShader(effect: Effect): void;
  14360. /**
  14361. * Returns a string to use to update the GPU particles update shader
  14362. * @returns a string containng the defines string
  14363. */
  14364. getEffectDefines(): string;
  14365. /**
  14366. * Returns the string "PointParticleEmitter"
  14367. * @returns a string containing the class name
  14368. */
  14369. getClassName(): string;
  14370. /**
  14371. * Serializes the particle system to a JSON object.
  14372. * @returns the JSON object
  14373. */
  14374. serialize(): any;
  14375. /**
  14376. * Parse properties from a JSON object
  14377. * @param serializationObject defines the JSON object
  14378. */
  14379. parse(serializationObject: any): void;
  14380. }
  14381. }
  14382. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14383. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14384. import { Effect } from "babylonjs/Materials/effect";
  14385. import { Particle } from "babylonjs/Particles/particle";
  14386. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14387. import { Nullable } from "babylonjs/types";
  14388. import { Scene } from "babylonjs/scene";
  14389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14390. /**
  14391. * Particle emitter emitting particles from the inside of a box.
  14392. * It emits the particles randomly between 2 given directions.
  14393. */
  14394. export class MeshParticleEmitter implements IParticleEmitterType {
  14395. private _indices;
  14396. private _positions;
  14397. private _normals;
  14398. private _storedNormal;
  14399. private _mesh;
  14400. /**
  14401. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14402. */
  14403. direction1: Vector3;
  14404. /**
  14405. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14406. */
  14407. direction2: Vector3;
  14408. /**
  14409. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14410. */
  14411. useMeshNormalsForDirection: boolean;
  14412. /** Defines the mesh to use as source */
  14413. get mesh(): Nullable<AbstractMesh>;
  14414. set mesh(value: Nullable<AbstractMesh>);
  14415. /**
  14416. * Creates a new instance MeshParticleEmitter
  14417. * @param mesh defines the mesh to use as source
  14418. */
  14419. constructor(mesh?: Nullable<AbstractMesh>);
  14420. /**
  14421. * Called by the particle System when the direction is computed for the created particle.
  14422. * @param worldMatrix is the world matrix of the particle system
  14423. * @param directionToUpdate is the direction vector to update with the result
  14424. * @param particle is the particle we are computed the direction for
  14425. * @param isLocal defines if the direction should be set in local space
  14426. */
  14427. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14428. /**
  14429. * Called by the particle System when the position is computed for the created particle.
  14430. * @param worldMatrix is the world matrix of the particle system
  14431. * @param positionToUpdate is the position vector to update with the result
  14432. * @param particle is the particle we are computed the position for
  14433. * @param isLocal defines if the position should be set in local space
  14434. */
  14435. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14436. /**
  14437. * Clones the current emitter and returns a copy of it
  14438. * @returns the new emitter
  14439. */
  14440. clone(): MeshParticleEmitter;
  14441. /**
  14442. * Called by the GPUParticleSystem to setup the update shader
  14443. * @param effect defines the update shader
  14444. */
  14445. applyToShader(effect: Effect): void;
  14446. /**
  14447. * Returns a string to use to update the GPU particles update shader
  14448. * @returns a string containng the defines string
  14449. */
  14450. getEffectDefines(): string;
  14451. /**
  14452. * Returns the string "BoxParticleEmitter"
  14453. * @returns a string containing the class name
  14454. */
  14455. getClassName(): string;
  14456. /**
  14457. * Serializes the particle system to a JSON object.
  14458. * @returns the JSON object
  14459. */
  14460. serialize(): any;
  14461. /**
  14462. * Parse properties from a JSON object
  14463. * @param serializationObject defines the JSON object
  14464. * @param scene defines the hosting scene
  14465. */
  14466. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14467. }
  14468. }
  14469. declare module "babylonjs/Particles/EmitterTypes/index" {
  14470. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14471. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14472. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14473. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14474. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14475. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14476. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14477. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14478. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14479. }
  14480. declare module "babylonjs/Particles/IParticleSystem" {
  14481. import { Nullable } from "babylonjs/types";
  14482. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14483. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14485. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14486. import { Scene } from "babylonjs/scene";
  14487. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14488. import { Effect } from "babylonjs/Materials/effect";
  14489. import { Observable } from "babylonjs/Misc/observable";
  14490. import { Animation } from "babylonjs/Animations/animation";
  14491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14492. /**
  14493. * Interface representing a particle system in Babylon.js.
  14494. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14495. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14496. */
  14497. export interface IParticleSystem {
  14498. /**
  14499. * List of animations used by the particle system.
  14500. */
  14501. animations: Animation[];
  14502. /**
  14503. * The id of the Particle system.
  14504. */
  14505. id: string;
  14506. /**
  14507. * The name of the Particle system.
  14508. */
  14509. name: string;
  14510. /**
  14511. * The emitter represents the Mesh or position we are attaching the particle system to.
  14512. */
  14513. emitter: Nullable<AbstractMesh | Vector3>;
  14514. /**
  14515. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14516. */
  14517. isBillboardBased: boolean;
  14518. /**
  14519. * The rendering group used by the Particle system to chose when to render.
  14520. */
  14521. renderingGroupId: number;
  14522. /**
  14523. * The layer mask we are rendering the particles through.
  14524. */
  14525. layerMask: number;
  14526. /**
  14527. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14528. */
  14529. updateSpeed: number;
  14530. /**
  14531. * The amount of time the particle system is running (depends of the overall update speed).
  14532. */
  14533. targetStopDuration: number;
  14534. /**
  14535. * The texture used to render each particle. (this can be a spritesheet)
  14536. */
  14537. particleTexture: Nullable<BaseTexture>;
  14538. /**
  14539. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14540. */
  14541. blendMode: number;
  14542. /**
  14543. * Minimum life time of emitting particles.
  14544. */
  14545. minLifeTime: number;
  14546. /**
  14547. * Maximum life time of emitting particles.
  14548. */
  14549. maxLifeTime: number;
  14550. /**
  14551. * Minimum Size of emitting particles.
  14552. */
  14553. minSize: number;
  14554. /**
  14555. * Maximum Size of emitting particles.
  14556. */
  14557. maxSize: number;
  14558. /**
  14559. * Minimum scale of emitting particles on X axis.
  14560. */
  14561. minScaleX: number;
  14562. /**
  14563. * Maximum scale of emitting particles on X axis.
  14564. */
  14565. maxScaleX: number;
  14566. /**
  14567. * Minimum scale of emitting particles on Y axis.
  14568. */
  14569. minScaleY: number;
  14570. /**
  14571. * Maximum scale of emitting particles on Y axis.
  14572. */
  14573. maxScaleY: number;
  14574. /**
  14575. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14576. */
  14577. color1: Color4;
  14578. /**
  14579. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14580. */
  14581. color2: Color4;
  14582. /**
  14583. * Color the particle will have at the end of its lifetime.
  14584. */
  14585. colorDead: Color4;
  14586. /**
  14587. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14588. */
  14589. emitRate: number;
  14590. /**
  14591. * You can use gravity if you want to give an orientation to your particles.
  14592. */
  14593. gravity: Vector3;
  14594. /**
  14595. * Minimum power of emitting particles.
  14596. */
  14597. minEmitPower: number;
  14598. /**
  14599. * Maximum power of emitting particles.
  14600. */
  14601. maxEmitPower: number;
  14602. /**
  14603. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14604. */
  14605. minAngularSpeed: number;
  14606. /**
  14607. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14608. */
  14609. maxAngularSpeed: number;
  14610. /**
  14611. * Gets or sets the minimal initial rotation in radians.
  14612. */
  14613. minInitialRotation: number;
  14614. /**
  14615. * Gets or sets the maximal initial rotation in radians.
  14616. */
  14617. maxInitialRotation: number;
  14618. /**
  14619. * The particle emitter type defines the emitter used by the particle system.
  14620. * It can be for example box, sphere, or cone...
  14621. */
  14622. particleEmitterType: Nullable<IParticleEmitterType>;
  14623. /**
  14624. * Defines the delay in milliseconds before starting the system (0 by default)
  14625. */
  14626. startDelay: number;
  14627. /**
  14628. * 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
  14629. */
  14630. preWarmCycles: number;
  14631. /**
  14632. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14633. */
  14634. preWarmStepOffset: number;
  14635. /**
  14636. * 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)
  14637. */
  14638. spriteCellChangeSpeed: number;
  14639. /**
  14640. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14641. */
  14642. startSpriteCellID: number;
  14643. /**
  14644. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14645. */
  14646. endSpriteCellID: number;
  14647. /**
  14648. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14649. */
  14650. spriteCellWidth: number;
  14651. /**
  14652. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14653. */
  14654. spriteCellHeight: number;
  14655. /**
  14656. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14657. */
  14658. spriteRandomStartCell: boolean;
  14659. /**
  14660. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14661. */
  14662. isAnimationSheetEnabled: boolean;
  14663. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14664. translationPivot: Vector2;
  14665. /**
  14666. * Gets or sets a texture used to add random noise to particle positions
  14667. */
  14668. noiseTexture: Nullable<BaseTexture>;
  14669. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14670. noiseStrength: Vector3;
  14671. /**
  14672. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14673. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14674. */
  14675. billboardMode: number;
  14676. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14677. limitVelocityDamping: number;
  14678. /**
  14679. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14680. */
  14681. beginAnimationOnStart: boolean;
  14682. /**
  14683. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14684. */
  14685. beginAnimationFrom: number;
  14686. /**
  14687. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14688. */
  14689. beginAnimationTo: number;
  14690. /**
  14691. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14692. */
  14693. beginAnimationLoop: boolean;
  14694. /**
  14695. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14696. */
  14697. disposeOnStop: boolean;
  14698. /**
  14699. * Specifies if the particles are updated in emitter local space or world space
  14700. */
  14701. isLocal: boolean;
  14702. /** Snippet ID if the particle system was created from the snippet server */
  14703. snippetId: string;
  14704. /** Gets or sets a matrix to use to compute projection */
  14705. defaultProjectionMatrix: Matrix;
  14706. /**
  14707. * Gets the maximum number of particles active at the same time.
  14708. * @returns The max number of active particles.
  14709. */
  14710. getCapacity(): number;
  14711. /**
  14712. * Gets the number of particles active at the same time.
  14713. * @returns The number of active particles.
  14714. */
  14715. getActiveCount(): number;
  14716. /**
  14717. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14718. * @returns True if it has been started, otherwise false.
  14719. */
  14720. isStarted(): boolean;
  14721. /**
  14722. * Animates the particle system for this frame.
  14723. */
  14724. animate(): void;
  14725. /**
  14726. * Renders the particle system in its current state.
  14727. * @returns the current number of particles
  14728. */
  14729. render(): number;
  14730. /**
  14731. * Dispose the particle system and frees its associated resources.
  14732. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14733. */
  14734. dispose(disposeTexture?: boolean): void;
  14735. /**
  14736. * An event triggered when the system is disposed
  14737. */
  14738. onDisposeObservable: Observable<IParticleSystem>;
  14739. /**
  14740. * An event triggered when the system is stopped
  14741. */
  14742. onStoppedObservable: Observable<IParticleSystem>;
  14743. /**
  14744. * Clones the particle system.
  14745. * @param name The name of the cloned object
  14746. * @param newEmitter The new emitter to use
  14747. * @returns the cloned particle system
  14748. */
  14749. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14750. /**
  14751. * Serializes the particle system to a JSON object
  14752. * @param serializeTexture defines if the texture must be serialized as well
  14753. * @returns the JSON object
  14754. */
  14755. serialize(serializeTexture: boolean): any;
  14756. /**
  14757. * Rebuild the particle system
  14758. */
  14759. rebuild(): void;
  14760. /** Force the system to rebuild all gradients that need to be resync */
  14761. forceRefreshGradients(): void;
  14762. /**
  14763. * Starts the particle system and begins to emit
  14764. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14765. */
  14766. start(delay?: number): void;
  14767. /**
  14768. * Stops the particle system.
  14769. */
  14770. stop(): void;
  14771. /**
  14772. * Remove all active particles
  14773. */
  14774. reset(): void;
  14775. /**
  14776. * Gets a boolean indicating that the system is stopping
  14777. * @returns true if the system is currently stopping
  14778. */
  14779. isStopping(): boolean;
  14780. /**
  14781. * Is this system ready to be used/rendered
  14782. * @return true if the system is ready
  14783. */
  14784. isReady(): boolean;
  14785. /**
  14786. * Returns the string "ParticleSystem"
  14787. * @returns a string containing the class name
  14788. */
  14789. getClassName(): string;
  14790. /**
  14791. * Gets the custom effect used to render the particles
  14792. * @param blendMode Blend mode for which the effect should be retrieved
  14793. * @returns The effect
  14794. */
  14795. getCustomEffect(blendMode: number): Nullable<Effect>;
  14796. /**
  14797. * Sets the custom effect used to render the particles
  14798. * @param effect The effect to set
  14799. * @param blendMode Blend mode for which the effect should be set
  14800. */
  14801. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14802. /**
  14803. * Fill the defines array according to the current settings of the particle system
  14804. * @param defines Array to be updated
  14805. * @param blendMode blend mode to take into account when updating the array
  14806. */
  14807. fillDefines(defines: Array<string>, blendMode: number): void;
  14808. /**
  14809. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14810. * @param uniforms Uniforms array to fill
  14811. * @param attributes Attributes array to fill
  14812. * @param samplers Samplers array to fill
  14813. */
  14814. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14815. /**
  14816. * Observable that will be called just before the particles are drawn
  14817. */
  14818. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14819. /**
  14820. * Gets the name of the particle vertex shader
  14821. */
  14822. vertexShaderName: string;
  14823. /**
  14824. * Adds a new color gradient
  14825. * @param gradient defines the gradient to use (between 0 and 1)
  14826. * @param color1 defines the color to affect to the specified gradient
  14827. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14828. * @returns the current particle system
  14829. */
  14830. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14831. /**
  14832. * Remove a specific color gradient
  14833. * @param gradient defines the gradient to remove
  14834. * @returns the current particle system
  14835. */
  14836. removeColorGradient(gradient: number): IParticleSystem;
  14837. /**
  14838. * Adds a new size gradient
  14839. * @param gradient defines the gradient to use (between 0 and 1)
  14840. * @param factor defines the size factor to affect to the specified gradient
  14841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14842. * @returns the current particle system
  14843. */
  14844. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14845. /**
  14846. * Remove a specific size gradient
  14847. * @param gradient defines the gradient to remove
  14848. * @returns the current particle system
  14849. */
  14850. removeSizeGradient(gradient: number): IParticleSystem;
  14851. /**
  14852. * Gets the current list of color gradients.
  14853. * You must use addColorGradient and removeColorGradient to udpate this list
  14854. * @returns the list of color gradients
  14855. */
  14856. getColorGradients(): Nullable<Array<ColorGradient>>;
  14857. /**
  14858. * Gets the current list of size gradients.
  14859. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14860. * @returns the list of size gradients
  14861. */
  14862. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14863. /**
  14864. * Gets the current list of angular speed gradients.
  14865. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14866. * @returns the list of angular speed gradients
  14867. */
  14868. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14869. /**
  14870. * Adds a new angular speed gradient
  14871. * @param gradient defines the gradient to use (between 0 and 1)
  14872. * @param factor defines the angular speed to affect to the specified gradient
  14873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14874. * @returns the current particle system
  14875. */
  14876. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14877. /**
  14878. * Remove a specific angular speed gradient
  14879. * @param gradient defines the gradient to remove
  14880. * @returns the current particle system
  14881. */
  14882. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14883. /**
  14884. * Gets the current list of velocity gradients.
  14885. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14886. * @returns the list of velocity gradients
  14887. */
  14888. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14889. /**
  14890. * Adds a new velocity gradient
  14891. * @param gradient defines the gradient to use (between 0 and 1)
  14892. * @param factor defines the velocity to affect to the specified gradient
  14893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14894. * @returns the current particle system
  14895. */
  14896. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14897. /**
  14898. * Remove a specific velocity gradient
  14899. * @param gradient defines the gradient to remove
  14900. * @returns the current particle system
  14901. */
  14902. removeVelocityGradient(gradient: number): IParticleSystem;
  14903. /**
  14904. * Gets the current list of limit velocity gradients.
  14905. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14906. * @returns the list of limit velocity gradients
  14907. */
  14908. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14909. /**
  14910. * Adds a new limit velocity gradient
  14911. * @param gradient defines the gradient to use (between 0 and 1)
  14912. * @param factor defines the limit velocity to affect to the specified gradient
  14913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14914. * @returns the current particle system
  14915. */
  14916. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14917. /**
  14918. * Remove a specific limit velocity gradient
  14919. * @param gradient defines the gradient to remove
  14920. * @returns the current particle system
  14921. */
  14922. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14923. /**
  14924. * Adds a new drag gradient
  14925. * @param gradient defines the gradient to use (between 0 and 1)
  14926. * @param factor defines the drag to affect to the specified gradient
  14927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14928. * @returns the current particle system
  14929. */
  14930. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14931. /**
  14932. * Remove a specific drag gradient
  14933. * @param gradient defines the gradient to remove
  14934. * @returns the current particle system
  14935. */
  14936. removeDragGradient(gradient: number): IParticleSystem;
  14937. /**
  14938. * Gets the current list of drag gradients.
  14939. * You must use addDragGradient and removeDragGradient to udpate this list
  14940. * @returns the list of drag gradients
  14941. */
  14942. getDragGradients(): Nullable<Array<FactorGradient>>;
  14943. /**
  14944. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14945. * @param gradient defines the gradient to use (between 0 and 1)
  14946. * @param factor defines the emit rate to affect to the specified gradient
  14947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14948. * @returns the current particle system
  14949. */
  14950. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14951. /**
  14952. * Remove a specific emit rate gradient
  14953. * @param gradient defines the gradient to remove
  14954. * @returns the current particle system
  14955. */
  14956. removeEmitRateGradient(gradient: number): IParticleSystem;
  14957. /**
  14958. * Gets the current list of emit rate gradients.
  14959. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14960. * @returns the list of emit rate gradients
  14961. */
  14962. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14963. /**
  14964. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14965. * @param gradient defines the gradient to use (between 0 and 1)
  14966. * @param factor defines the start size to affect to the specified gradient
  14967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14968. * @returns the current particle system
  14969. */
  14970. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14971. /**
  14972. * Remove a specific start size gradient
  14973. * @param gradient defines the gradient to remove
  14974. * @returns the current particle system
  14975. */
  14976. removeStartSizeGradient(gradient: number): IParticleSystem;
  14977. /**
  14978. * Gets the current list of start size gradients.
  14979. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14980. * @returns the list of start size gradients
  14981. */
  14982. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14983. /**
  14984. * Adds a new life time gradient
  14985. * @param gradient defines the gradient to use (between 0 and 1)
  14986. * @param factor defines the life time factor to affect to the specified gradient
  14987. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14988. * @returns the current particle system
  14989. */
  14990. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14991. /**
  14992. * Remove a specific life time gradient
  14993. * @param gradient defines the gradient to remove
  14994. * @returns the current particle system
  14995. */
  14996. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14997. /**
  14998. * Gets the current list of life time gradients.
  14999. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15000. * @returns the list of life time gradients
  15001. */
  15002. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15003. /**
  15004. * Gets the current list of color gradients.
  15005. * You must use addColorGradient and removeColorGradient to udpate this list
  15006. * @returns the list of color gradients
  15007. */
  15008. getColorGradients(): Nullable<Array<ColorGradient>>;
  15009. /**
  15010. * Adds a new ramp gradient used to remap particle colors
  15011. * @param gradient defines the gradient to use (between 0 and 1)
  15012. * @param color defines the color to affect to the specified gradient
  15013. * @returns the current particle system
  15014. */
  15015. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  15016. /**
  15017. * Gets the current list of ramp gradients.
  15018. * You must use addRampGradient and removeRampGradient to udpate this list
  15019. * @returns the list of ramp gradients
  15020. */
  15021. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15022. /** Gets or sets a boolean indicating that ramp gradients must be used
  15023. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15024. */
  15025. useRampGradients: boolean;
  15026. /**
  15027. * Adds a new color remap gradient
  15028. * @param gradient defines the gradient to use (between 0 and 1)
  15029. * @param min defines the color remap minimal range
  15030. * @param max defines the color remap maximal range
  15031. * @returns the current particle system
  15032. */
  15033. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15034. /**
  15035. * Gets the current list of color remap gradients.
  15036. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15037. * @returns the list of color remap gradients
  15038. */
  15039. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15040. /**
  15041. * Adds a new alpha remap gradient
  15042. * @param gradient defines the gradient to use (between 0 and 1)
  15043. * @param min defines the alpha remap minimal range
  15044. * @param max defines the alpha remap maximal range
  15045. * @returns the current particle system
  15046. */
  15047. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15048. /**
  15049. * Gets the current list of alpha remap gradients.
  15050. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15051. * @returns the list of alpha remap gradients
  15052. */
  15053. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15054. /**
  15055. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15056. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15057. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15058. * @returns the emitter
  15059. */
  15060. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15061. /**
  15062. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15063. * @param radius The radius of the hemisphere to emit from
  15064. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15065. * @returns the emitter
  15066. */
  15067. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15068. /**
  15069. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15070. * @param radius The radius of the sphere to emit from
  15071. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15072. * @returns the emitter
  15073. */
  15074. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15075. /**
  15076. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15077. * @param radius The radius of the sphere to emit from
  15078. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15079. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15080. * @returns the emitter
  15081. */
  15082. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15083. /**
  15084. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15085. * @param radius The radius of the emission cylinder
  15086. * @param height The height of the emission cylinder
  15087. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15088. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15089. * @returns the emitter
  15090. */
  15091. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15092. /**
  15093. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15094. * @param radius The radius of the cylinder to emit from
  15095. * @param height The height of the emission cylinder
  15096. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15097. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15098. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15099. * @returns the emitter
  15100. */
  15101. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15102. /**
  15103. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15104. * @param radius The radius of the cone to emit from
  15105. * @param angle The base angle of the cone
  15106. * @returns the emitter
  15107. */
  15108. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15109. /**
  15110. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15111. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15112. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15113. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15114. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15115. * @returns the emitter
  15116. */
  15117. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15118. /**
  15119. * Get hosting scene
  15120. * @returns the scene
  15121. */
  15122. getScene(): Nullable<Scene>;
  15123. }
  15124. }
  15125. declare module "babylonjs/Meshes/transformNode" {
  15126. import { DeepImmutable } from "babylonjs/types";
  15127. import { Observable } from "babylonjs/Misc/observable";
  15128. import { Nullable } from "babylonjs/types";
  15129. import { Camera } from "babylonjs/Cameras/camera";
  15130. import { Scene } from "babylonjs/scene";
  15131. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15132. import { Node } from "babylonjs/node";
  15133. import { Bone } from "babylonjs/Bones/bone";
  15134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15135. import { Space } from "babylonjs/Maths/math.axis";
  15136. /**
  15137. * 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.
  15138. * @see https://doc.babylonjs.com/how_to/transformnode
  15139. */
  15140. export class TransformNode extends Node {
  15141. /**
  15142. * Object will not rotate to face the camera
  15143. */
  15144. static BILLBOARDMODE_NONE: number;
  15145. /**
  15146. * Object will rotate to face the camera but only on the x axis
  15147. */
  15148. static BILLBOARDMODE_X: number;
  15149. /**
  15150. * Object will rotate to face the camera but only on the y axis
  15151. */
  15152. static BILLBOARDMODE_Y: number;
  15153. /**
  15154. * Object will rotate to face the camera but only on the z axis
  15155. */
  15156. static BILLBOARDMODE_Z: number;
  15157. /**
  15158. * Object will rotate to face the camera
  15159. */
  15160. static BILLBOARDMODE_ALL: number;
  15161. /**
  15162. * Object will rotate to face the camera's position instead of orientation
  15163. */
  15164. static BILLBOARDMODE_USE_POSITION: number;
  15165. private static _TmpRotation;
  15166. private static _TmpScaling;
  15167. private static _TmpTranslation;
  15168. private _forward;
  15169. private _forwardInverted;
  15170. private _up;
  15171. private _right;
  15172. private _rightInverted;
  15173. private _position;
  15174. private _rotation;
  15175. private _rotationQuaternion;
  15176. protected _scaling: Vector3;
  15177. protected _isDirty: boolean;
  15178. private _transformToBoneReferal;
  15179. private _isAbsoluteSynced;
  15180. private _billboardMode;
  15181. /**
  15182. * Gets or sets the billboard mode. Default is 0.
  15183. *
  15184. * | Value | Type | Description |
  15185. * | --- | --- | --- |
  15186. * | 0 | BILLBOARDMODE_NONE | |
  15187. * | 1 | BILLBOARDMODE_X | |
  15188. * | 2 | BILLBOARDMODE_Y | |
  15189. * | 4 | BILLBOARDMODE_Z | |
  15190. * | 7 | BILLBOARDMODE_ALL | |
  15191. *
  15192. */
  15193. get billboardMode(): number;
  15194. set billboardMode(value: number);
  15195. private _preserveParentRotationForBillboard;
  15196. /**
  15197. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15198. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15199. */
  15200. get preserveParentRotationForBillboard(): boolean;
  15201. set preserveParentRotationForBillboard(value: boolean);
  15202. /**
  15203. * 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
  15204. */
  15205. scalingDeterminant: number;
  15206. private _infiniteDistance;
  15207. /**
  15208. * Gets or sets the distance of the object to max, often used by skybox
  15209. */
  15210. get infiniteDistance(): boolean;
  15211. set infiniteDistance(value: boolean);
  15212. /**
  15213. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15214. * By default the system will update normals to compensate
  15215. */
  15216. ignoreNonUniformScaling: boolean;
  15217. /**
  15218. * 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
  15219. */
  15220. reIntegrateRotationIntoRotationQuaternion: boolean;
  15221. /** @hidden */
  15222. _poseMatrix: Nullable<Matrix>;
  15223. /** @hidden */
  15224. _localMatrix: Matrix;
  15225. private _usePivotMatrix;
  15226. private _absolutePosition;
  15227. private _absoluteScaling;
  15228. private _absoluteRotationQuaternion;
  15229. private _pivotMatrix;
  15230. private _pivotMatrixInverse;
  15231. /** @hidden */
  15232. _postMultiplyPivotMatrix: boolean;
  15233. protected _isWorldMatrixFrozen: boolean;
  15234. /** @hidden */
  15235. _indexInSceneTransformNodesArray: number;
  15236. /**
  15237. * An event triggered after the world matrix is updated
  15238. */
  15239. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15240. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15241. /**
  15242. * Gets a string identifying the name of the class
  15243. * @returns "TransformNode" string
  15244. */
  15245. getClassName(): string;
  15246. /**
  15247. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15248. */
  15249. get position(): Vector3;
  15250. set position(newPosition: Vector3);
  15251. /**
  15252. * 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)).
  15253. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15254. */
  15255. get rotation(): Vector3;
  15256. set rotation(newRotation: Vector3);
  15257. /**
  15258. * 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)).
  15259. */
  15260. get scaling(): Vector3;
  15261. set scaling(newScaling: Vector3);
  15262. /**
  15263. * 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).
  15264. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15265. */
  15266. get rotationQuaternion(): Nullable<Quaternion>;
  15267. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15268. /**
  15269. * The forward direction of that transform in world space.
  15270. */
  15271. get forward(): Vector3;
  15272. /**
  15273. * The up direction of that transform in world space.
  15274. */
  15275. get up(): Vector3;
  15276. /**
  15277. * The right direction of that transform in world space.
  15278. */
  15279. get right(): Vector3;
  15280. /**
  15281. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15282. * @param matrix the matrix to copy the pose from
  15283. * @returns this TransformNode.
  15284. */
  15285. updatePoseMatrix(matrix: Matrix): TransformNode;
  15286. /**
  15287. * Returns the mesh Pose matrix.
  15288. * @returns the pose matrix
  15289. */
  15290. getPoseMatrix(): Matrix;
  15291. /** @hidden */
  15292. _isSynchronized(): boolean;
  15293. /** @hidden */
  15294. _initCache(): void;
  15295. /**
  15296. * Flag the transform node as dirty (Forcing it to update everything)
  15297. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15298. * @returns this transform node
  15299. */
  15300. markAsDirty(property: string): TransformNode;
  15301. /**
  15302. * Returns the current mesh absolute position.
  15303. * Returns a Vector3.
  15304. */
  15305. get absolutePosition(): Vector3;
  15306. /**
  15307. * Returns the current mesh absolute scaling.
  15308. * Returns a Vector3.
  15309. */
  15310. get absoluteScaling(): Vector3;
  15311. /**
  15312. * Returns the current mesh absolute rotation.
  15313. * Returns a Quaternion.
  15314. */
  15315. get absoluteRotationQuaternion(): Quaternion;
  15316. /**
  15317. * Sets a new matrix to apply before all other transformation
  15318. * @param matrix defines the transform matrix
  15319. * @returns the current TransformNode
  15320. */
  15321. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15322. /**
  15323. * Sets a new pivot matrix to the current node
  15324. * @param matrix defines the new pivot matrix to use
  15325. * @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
  15326. * @returns the current TransformNode
  15327. */
  15328. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15329. /**
  15330. * Returns the mesh pivot matrix.
  15331. * Default : Identity.
  15332. * @returns the matrix
  15333. */
  15334. getPivotMatrix(): Matrix;
  15335. /**
  15336. * Instantiate (when possible) or clone that node with its hierarchy
  15337. * @param newParent defines the new parent to use for the instance (or clone)
  15338. * @param options defines options to configure how copy is done
  15339. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15340. * @returns an instance (or a clone) of the current node with its hiearchy
  15341. */
  15342. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15343. doNotInstantiate: boolean;
  15344. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15345. /**
  15346. * Prevents the World matrix to be computed any longer
  15347. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15348. * @returns the TransformNode.
  15349. */
  15350. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15351. /**
  15352. * Allows back the World matrix computation.
  15353. * @returns the TransformNode.
  15354. */
  15355. unfreezeWorldMatrix(): this;
  15356. /**
  15357. * True if the World matrix has been frozen.
  15358. */
  15359. get isWorldMatrixFrozen(): boolean;
  15360. /**
  15361. * Retuns the mesh absolute position in the World.
  15362. * @returns a Vector3.
  15363. */
  15364. getAbsolutePosition(): Vector3;
  15365. /**
  15366. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15367. * @param absolutePosition the absolute position to set
  15368. * @returns the TransformNode.
  15369. */
  15370. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15371. /**
  15372. * Sets the mesh position in its local space.
  15373. * @param vector3 the position to set in localspace
  15374. * @returns the TransformNode.
  15375. */
  15376. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15377. /**
  15378. * Returns the mesh position in the local space from the current World matrix values.
  15379. * @returns a new Vector3.
  15380. */
  15381. getPositionExpressedInLocalSpace(): Vector3;
  15382. /**
  15383. * Translates the mesh along the passed Vector3 in its local space.
  15384. * @param vector3 the distance to translate in localspace
  15385. * @returns the TransformNode.
  15386. */
  15387. locallyTranslate(vector3: Vector3): TransformNode;
  15388. private static _lookAtVectorCache;
  15389. /**
  15390. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15391. * @param targetPoint the position (must be in same space as current mesh) to look at
  15392. * @param yawCor optional yaw (y-axis) correction in radians
  15393. * @param pitchCor optional pitch (x-axis) correction in radians
  15394. * @param rollCor optional roll (z-axis) correction in radians
  15395. * @param space the choosen space of the target
  15396. * @returns the TransformNode.
  15397. */
  15398. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15399. /**
  15400. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15401. * This Vector3 is expressed in the World space.
  15402. * @param localAxis axis to rotate
  15403. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15404. */
  15405. getDirection(localAxis: Vector3): Vector3;
  15406. /**
  15407. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15408. * localAxis is expressed in the mesh local space.
  15409. * result is computed in the Wordl space from the mesh World matrix.
  15410. * @param localAxis axis to rotate
  15411. * @param result the resulting transformnode
  15412. * @returns this TransformNode.
  15413. */
  15414. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15415. /**
  15416. * Sets this transform node rotation to the given local axis.
  15417. * @param localAxis the axis in local space
  15418. * @param yawCor optional yaw (y-axis) correction in radians
  15419. * @param pitchCor optional pitch (x-axis) correction in radians
  15420. * @param rollCor optional roll (z-axis) correction in radians
  15421. * @returns this TransformNode
  15422. */
  15423. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15424. /**
  15425. * Sets a new pivot point to the current node
  15426. * @param point defines the new pivot point to use
  15427. * @param space defines if the point is in world or local space (local by default)
  15428. * @returns the current TransformNode
  15429. */
  15430. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15431. /**
  15432. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15433. * @returns the pivot point
  15434. */
  15435. getPivotPoint(): Vector3;
  15436. /**
  15437. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15438. * @param result the vector3 to store the result
  15439. * @returns this TransformNode.
  15440. */
  15441. getPivotPointToRef(result: Vector3): TransformNode;
  15442. /**
  15443. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15444. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15445. */
  15446. getAbsolutePivotPoint(): Vector3;
  15447. /**
  15448. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15449. * @param result vector3 to store the result
  15450. * @returns this TransformNode.
  15451. */
  15452. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15453. /**
  15454. * Defines the passed node as the parent of the current node.
  15455. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15456. * @see https://doc.babylonjs.com/how_to/parenting
  15457. * @param node the node ot set as the parent
  15458. * @returns this TransformNode.
  15459. */
  15460. setParent(node: Nullable<Node>): TransformNode;
  15461. private _nonUniformScaling;
  15462. /**
  15463. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15464. */
  15465. get nonUniformScaling(): boolean;
  15466. /** @hidden */
  15467. _updateNonUniformScalingState(value: boolean): boolean;
  15468. /**
  15469. * Attach the current TransformNode to another TransformNode associated with a bone
  15470. * @param bone Bone affecting the TransformNode
  15471. * @param affectedTransformNode TransformNode associated with the bone
  15472. * @returns this object
  15473. */
  15474. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15475. /**
  15476. * Detach the transform node if its associated with a bone
  15477. * @returns this object
  15478. */
  15479. detachFromBone(): TransformNode;
  15480. private static _rotationAxisCache;
  15481. /**
  15482. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15483. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15484. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15485. * The passed axis is also normalized.
  15486. * @param axis the axis to rotate around
  15487. * @param amount the amount to rotate in radians
  15488. * @param space Space to rotate in (Default: local)
  15489. * @returns the TransformNode.
  15490. */
  15491. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15492. /**
  15493. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15494. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15495. * The passed axis is also normalized. .
  15496. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15497. * @param point the point to rotate around
  15498. * @param axis the axis to rotate around
  15499. * @param amount the amount to rotate in radians
  15500. * @returns the TransformNode
  15501. */
  15502. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15503. /**
  15504. * Translates the mesh along the axis vector for the passed distance in the given space.
  15505. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15506. * @param axis the axis to translate in
  15507. * @param distance the distance to translate
  15508. * @param space Space to rotate in (Default: local)
  15509. * @returns the TransformNode.
  15510. */
  15511. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15512. /**
  15513. * Adds a rotation step to the mesh current rotation.
  15514. * x, y, z are Euler angles expressed in radians.
  15515. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15516. * This means this rotation is made in the mesh local space only.
  15517. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15518. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15519. * ```javascript
  15520. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15521. * ```
  15522. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15523. * 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.
  15524. * @param x Rotation to add
  15525. * @param y Rotation to add
  15526. * @param z Rotation to add
  15527. * @returns the TransformNode.
  15528. */
  15529. addRotation(x: number, y: number, z: number): TransformNode;
  15530. /**
  15531. * @hidden
  15532. */
  15533. protected _getEffectiveParent(): Nullable<Node>;
  15534. /**
  15535. * Computes the world matrix of the node
  15536. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15537. * @returns the world matrix
  15538. */
  15539. computeWorldMatrix(force?: boolean): Matrix;
  15540. /**
  15541. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15542. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15543. */
  15544. resetLocalMatrix(independentOfChildren?: boolean): void;
  15545. protected _afterComputeWorldMatrix(): void;
  15546. /**
  15547. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15548. * @param func callback function to add
  15549. *
  15550. * @returns the TransformNode.
  15551. */
  15552. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15553. /**
  15554. * Removes a registered callback function.
  15555. * @param func callback function to remove
  15556. * @returns the TransformNode.
  15557. */
  15558. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15559. /**
  15560. * Gets the position of the current mesh in camera space
  15561. * @param camera defines the camera to use
  15562. * @returns a position
  15563. */
  15564. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15565. /**
  15566. * Returns the distance from the mesh to the active camera
  15567. * @param camera defines the camera to use
  15568. * @returns the distance
  15569. */
  15570. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15571. /**
  15572. * Clone the current transform node
  15573. * @param name Name of the new clone
  15574. * @param newParent New parent for the clone
  15575. * @param doNotCloneChildren Do not clone children hierarchy
  15576. * @returns the new transform node
  15577. */
  15578. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15579. /**
  15580. * Serializes the objects information.
  15581. * @param currentSerializationObject defines the object to serialize in
  15582. * @returns the serialized object
  15583. */
  15584. serialize(currentSerializationObject?: any): any;
  15585. /**
  15586. * Returns a new TransformNode object parsed from the source provided.
  15587. * @param parsedTransformNode is the source.
  15588. * @param scene the scne the object belongs to
  15589. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15590. * @returns a new TransformNode object parsed from the source provided.
  15591. */
  15592. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15593. /**
  15594. * Get all child-transformNodes of this node
  15595. * @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
  15596. * @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
  15597. * @returns an array of TransformNode
  15598. */
  15599. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15600. /**
  15601. * Releases resources associated with this transform node.
  15602. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15603. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15604. */
  15605. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15606. /**
  15607. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15608. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15609. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15610. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15611. * @returns the current mesh
  15612. */
  15613. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15614. private _syncAbsoluteScalingAndRotation;
  15615. }
  15616. }
  15617. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15618. /**
  15619. * Class used to override all child animations of a given target
  15620. */
  15621. export class AnimationPropertiesOverride {
  15622. /**
  15623. * Gets or sets a value indicating if animation blending must be used
  15624. */
  15625. enableBlending: boolean;
  15626. /**
  15627. * Gets or sets the blending speed to use when enableBlending is true
  15628. */
  15629. blendingSpeed: number;
  15630. /**
  15631. * Gets or sets the default loop mode to use
  15632. */
  15633. loopMode: number;
  15634. }
  15635. }
  15636. declare module "babylonjs/Bones/bone" {
  15637. import { Skeleton } from "babylonjs/Bones/skeleton";
  15638. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15639. import { Nullable } from "babylonjs/types";
  15640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15641. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15642. import { Node } from "babylonjs/node";
  15643. import { Space } from "babylonjs/Maths/math.axis";
  15644. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15645. /**
  15646. * Class used to store bone information
  15647. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15648. */
  15649. export class Bone extends Node {
  15650. /**
  15651. * defines the bone name
  15652. */
  15653. name: string;
  15654. private static _tmpVecs;
  15655. private static _tmpQuat;
  15656. private static _tmpMats;
  15657. /**
  15658. * Gets the list of child bones
  15659. */
  15660. children: Bone[];
  15661. /** Gets the animations associated with this bone */
  15662. animations: import("babylonjs/Animations/animation").Animation[];
  15663. /**
  15664. * Gets or sets bone length
  15665. */
  15666. length: number;
  15667. /**
  15668. * @hidden Internal only
  15669. * Set this value to map this bone to a different index in the transform matrices
  15670. * Set this value to -1 to exclude the bone from the transform matrices
  15671. */
  15672. _index: Nullable<number>;
  15673. private _skeleton;
  15674. private _localMatrix;
  15675. private _restPose;
  15676. private _bindPose;
  15677. private _baseMatrix;
  15678. private _absoluteTransform;
  15679. private _invertedAbsoluteTransform;
  15680. private _parent;
  15681. private _scalingDeterminant;
  15682. private _worldTransform;
  15683. private _localScaling;
  15684. private _localRotation;
  15685. private _localPosition;
  15686. private _needToDecompose;
  15687. private _needToCompose;
  15688. /** @hidden */
  15689. _linkedTransformNode: Nullable<TransformNode>;
  15690. /** @hidden */
  15691. _waitingTransformNodeId: Nullable<string>;
  15692. /** @hidden */
  15693. get _matrix(): Matrix;
  15694. /** @hidden */
  15695. set _matrix(value: Matrix);
  15696. /**
  15697. * Create a new bone
  15698. * @param name defines the bone name
  15699. * @param skeleton defines the parent skeleton
  15700. * @param parentBone defines the parent (can be null if the bone is the root)
  15701. * @param localMatrix defines the local matrix
  15702. * @param restPose defines the rest pose matrix
  15703. * @param baseMatrix defines the base matrix
  15704. * @param index defines index of the bone in the hiearchy
  15705. */
  15706. constructor(
  15707. /**
  15708. * defines the bone name
  15709. */
  15710. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15711. /**
  15712. * Gets the current object class name.
  15713. * @return the class name
  15714. */
  15715. getClassName(): string;
  15716. /**
  15717. * Gets the parent skeleton
  15718. * @returns a skeleton
  15719. */
  15720. getSkeleton(): Skeleton;
  15721. /**
  15722. * Gets parent bone
  15723. * @returns a bone or null if the bone is the root of the bone hierarchy
  15724. */
  15725. getParent(): Nullable<Bone>;
  15726. /**
  15727. * Returns an array containing the root bones
  15728. * @returns an array containing the root bones
  15729. */
  15730. getChildren(): Array<Bone>;
  15731. /**
  15732. * Gets the node index in matrix array generated for rendering
  15733. * @returns the node index
  15734. */
  15735. getIndex(): number;
  15736. /**
  15737. * Sets the parent bone
  15738. * @param parent defines the parent (can be null if the bone is the root)
  15739. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15740. */
  15741. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15742. /**
  15743. * Gets the local matrix
  15744. * @returns a matrix
  15745. */
  15746. getLocalMatrix(): Matrix;
  15747. /**
  15748. * Gets the base matrix (initial matrix which remains unchanged)
  15749. * @returns a matrix
  15750. */
  15751. getBaseMatrix(): Matrix;
  15752. /**
  15753. * Gets the rest pose matrix
  15754. * @returns a matrix
  15755. */
  15756. getRestPose(): Matrix;
  15757. /**
  15758. * Sets the rest pose matrix
  15759. * @param matrix the local-space rest pose to set for this bone
  15760. */
  15761. setRestPose(matrix: Matrix): void;
  15762. /**
  15763. * Gets the bind pose matrix
  15764. * @returns the bind pose matrix
  15765. */
  15766. getBindPose(): Matrix;
  15767. /**
  15768. * Sets the bind pose matrix
  15769. * @param matrix the local-space bind pose to set for this bone
  15770. */
  15771. setBindPose(matrix: Matrix): void;
  15772. /**
  15773. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15774. */
  15775. getWorldMatrix(): Matrix;
  15776. /**
  15777. * Sets the local matrix to rest pose matrix
  15778. */
  15779. returnToRest(): void;
  15780. /**
  15781. * Gets the inverse of the absolute transform matrix.
  15782. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15783. * @returns a matrix
  15784. */
  15785. getInvertedAbsoluteTransform(): Matrix;
  15786. /**
  15787. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15788. * @returns a matrix
  15789. */
  15790. getAbsoluteTransform(): Matrix;
  15791. /**
  15792. * Links with the given transform node.
  15793. * The local matrix of this bone is copied from the transform node every frame.
  15794. * @param transformNode defines the transform node to link to
  15795. */
  15796. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15797. /**
  15798. * Gets the node used to drive the bone's transformation
  15799. * @returns a transform node or null
  15800. */
  15801. getTransformNode(): Nullable<TransformNode>;
  15802. /** Gets or sets current position (in local space) */
  15803. get position(): Vector3;
  15804. set position(newPosition: Vector3);
  15805. /** Gets or sets current rotation (in local space) */
  15806. get rotation(): Vector3;
  15807. set rotation(newRotation: Vector3);
  15808. /** Gets or sets current rotation quaternion (in local space) */
  15809. get rotationQuaternion(): Quaternion;
  15810. set rotationQuaternion(newRotation: Quaternion);
  15811. /** Gets or sets current scaling (in local space) */
  15812. get scaling(): Vector3;
  15813. set scaling(newScaling: Vector3);
  15814. /**
  15815. * Gets the animation properties override
  15816. */
  15817. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15818. private _decompose;
  15819. private _compose;
  15820. /**
  15821. * Update the base and local matrices
  15822. * @param matrix defines the new base or local matrix
  15823. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15824. * @param updateLocalMatrix defines if the local matrix should be updated
  15825. */
  15826. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15827. /** @hidden */
  15828. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15829. /**
  15830. * Flag the bone as dirty (Forcing it to update everything)
  15831. */
  15832. markAsDirty(): void;
  15833. /** @hidden */
  15834. _markAsDirtyAndCompose(): void;
  15835. private _markAsDirtyAndDecompose;
  15836. /**
  15837. * Translate the bone in local or world space
  15838. * @param vec The amount to translate the bone
  15839. * @param space The space that the translation is in
  15840. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15841. */
  15842. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15843. /**
  15844. * Set the postion of the bone in local or world space
  15845. * @param position The position to set the bone
  15846. * @param space The space that the position is in
  15847. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15848. */
  15849. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15850. /**
  15851. * Set the absolute position of the bone (world space)
  15852. * @param position The position to set the bone
  15853. * @param mesh The mesh that this bone is attached to
  15854. */
  15855. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15856. /**
  15857. * Scale the bone on the x, y and z axes (in local space)
  15858. * @param x The amount to scale the bone on the x axis
  15859. * @param y The amount to scale the bone on the y axis
  15860. * @param z The amount to scale the bone on the z axis
  15861. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15862. */
  15863. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15864. /**
  15865. * Set the bone scaling in local space
  15866. * @param scale defines the scaling vector
  15867. */
  15868. setScale(scale: Vector3): void;
  15869. /**
  15870. * Gets the current scaling in local space
  15871. * @returns the current scaling vector
  15872. */
  15873. getScale(): Vector3;
  15874. /**
  15875. * Gets the current scaling in local space and stores it in a target vector
  15876. * @param result defines the target vector
  15877. */
  15878. getScaleToRef(result: Vector3): void;
  15879. /**
  15880. * Set the yaw, pitch, and roll of the bone in local or world space
  15881. * @param yaw The rotation of the bone on the y axis
  15882. * @param pitch The rotation of the bone on the x axis
  15883. * @param roll The rotation of the bone on the z axis
  15884. * @param space The space that the axes of rotation are in
  15885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15886. */
  15887. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15888. /**
  15889. * Add a rotation to the bone on an axis in local or world space
  15890. * @param axis The axis to rotate the bone on
  15891. * @param amount The amount to rotate the bone
  15892. * @param space The space that the axis is in
  15893. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15894. */
  15895. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15896. /**
  15897. * Set the rotation of the bone to a particular axis angle in local or world space
  15898. * @param axis The axis to rotate the bone on
  15899. * @param angle The angle that the bone should be rotated to
  15900. * @param space The space that the axis is in
  15901. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15902. */
  15903. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15904. /**
  15905. * Set the euler rotation of the bone in local or world space
  15906. * @param rotation The euler rotation that the bone should be set to
  15907. * @param space The space that the rotation is in
  15908. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15909. */
  15910. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15911. /**
  15912. * Set the quaternion rotation of the bone in local or world space
  15913. * @param quat The quaternion rotation that the bone should be set to
  15914. * @param space The space that the rotation is in
  15915. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15916. */
  15917. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15918. /**
  15919. * Set the rotation matrix of the bone in local or world space
  15920. * @param rotMat The rotation matrix that the bone should be set to
  15921. * @param space The space that the rotation is in
  15922. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15923. */
  15924. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15925. private _rotateWithMatrix;
  15926. private _getNegativeRotationToRef;
  15927. /**
  15928. * Get the position of the bone in local or world space
  15929. * @param space The space that the returned position is in
  15930. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15931. * @returns The position of the bone
  15932. */
  15933. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15934. /**
  15935. * Copy the position of the bone to a vector3 in local or world space
  15936. * @param space The space that the returned position is in
  15937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15938. * @param result The vector3 to copy the position to
  15939. */
  15940. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15941. /**
  15942. * Get the absolute position of the bone (world space)
  15943. * @param mesh The mesh that this bone is attached to
  15944. * @returns The absolute position of the bone
  15945. */
  15946. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15947. /**
  15948. * Copy the absolute position of the bone (world space) to the result param
  15949. * @param mesh The mesh that this bone is attached to
  15950. * @param result The vector3 to copy the absolute position to
  15951. */
  15952. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15953. /**
  15954. * Compute the absolute transforms of this bone and its children
  15955. */
  15956. computeAbsoluteTransforms(): void;
  15957. /**
  15958. * Get the world direction from an axis that is in the local space of the bone
  15959. * @param localAxis The local direction that is used to compute the world direction
  15960. * @param mesh The mesh that this bone is attached to
  15961. * @returns The world direction
  15962. */
  15963. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15964. /**
  15965. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15966. * @param localAxis The local direction that is used to compute the world direction
  15967. * @param mesh The mesh that this bone is attached to
  15968. * @param result The vector3 that the world direction will be copied to
  15969. */
  15970. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15971. /**
  15972. * Get the euler rotation of the bone in local or world space
  15973. * @param space The space that the rotation should be in
  15974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15975. * @returns The euler rotation
  15976. */
  15977. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15978. /**
  15979. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15980. * @param space The space that the rotation should be in
  15981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15982. * @param result The vector3 that the rotation should be copied to
  15983. */
  15984. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15985. /**
  15986. * Get the quaternion rotation of the bone in either local or world space
  15987. * @param space The space that the rotation should be in
  15988. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15989. * @returns The quaternion rotation
  15990. */
  15991. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15992. /**
  15993. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15994. * @param space The space that the rotation should be in
  15995. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15996. * @param result The quaternion that the rotation should be copied to
  15997. */
  15998. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15999. /**
  16000. * Get the rotation matrix of the bone in local or world space
  16001. * @param space The space that the rotation should be in
  16002. * @param mesh The mesh that this bone is attached to. This is only used in world space
  16003. * @returns The rotation matrix
  16004. */
  16005. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  16006. /**
  16007. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  16008. * @param space The space that the rotation should be in
  16009. * @param mesh The mesh that this bone is attached to. This is only used in world space
  16010. * @param result The quaternion that the rotation should be copied to
  16011. */
  16012. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  16013. /**
  16014. * Get the world position of a point that is in the local space of the bone
  16015. * @param position The local position
  16016. * @param mesh The mesh that this bone is attached to
  16017. * @returns The world position
  16018. */
  16019. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  16020. /**
  16021. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  16022. * @param position The local position
  16023. * @param mesh The mesh that this bone is attached to
  16024. * @param result The vector3 that the world position should be copied to
  16025. */
  16026. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  16027. /**
  16028. * Get the local position of a point that is in world space
  16029. * @param position The world position
  16030. * @param mesh The mesh that this bone is attached to
  16031. * @returns The local position
  16032. */
  16033. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  16034. /**
  16035. * Get the local position of a point that is in world space and copy it to the result param
  16036. * @param position The world position
  16037. * @param mesh The mesh that this bone is attached to
  16038. * @param result The vector3 that the local position should be copied to
  16039. */
  16040. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  16041. /**
  16042. * Set the current local matrix as the restPose for this bone.
  16043. */
  16044. setCurrentPoseAsRest(): void;
  16045. }
  16046. }
  16047. declare module "babylonjs/Animations/runtimeAnimation" {
  16048. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  16049. import { Animatable } from "babylonjs/Animations/animatable";
  16050. import { Scene } from "babylonjs/scene";
  16051. /**
  16052. * Defines a runtime animation
  16053. */
  16054. export class RuntimeAnimation {
  16055. private _events;
  16056. /**
  16057. * The current frame of the runtime animation
  16058. */
  16059. private _currentFrame;
  16060. /**
  16061. * The animation used by the runtime animation
  16062. */
  16063. private _animation;
  16064. /**
  16065. * The target of the runtime animation
  16066. */
  16067. private _target;
  16068. /**
  16069. * The initiating animatable
  16070. */
  16071. private _host;
  16072. /**
  16073. * The original value of the runtime animation
  16074. */
  16075. private _originalValue;
  16076. /**
  16077. * The original blend value of the runtime animation
  16078. */
  16079. private _originalBlendValue;
  16080. /**
  16081. * The offsets cache of the runtime animation
  16082. */
  16083. private _offsetsCache;
  16084. /**
  16085. * The high limits cache of the runtime animation
  16086. */
  16087. private _highLimitsCache;
  16088. /**
  16089. * Specifies if the runtime animation has been stopped
  16090. */
  16091. private _stopped;
  16092. /**
  16093. * The blending factor of the runtime animation
  16094. */
  16095. private _blendingFactor;
  16096. /**
  16097. * The BabylonJS scene
  16098. */
  16099. private _scene;
  16100. /**
  16101. * The current value of the runtime animation
  16102. */
  16103. private _currentValue;
  16104. /** @hidden */
  16105. _animationState: _IAnimationState;
  16106. /**
  16107. * The active target of the runtime animation
  16108. */
  16109. private _activeTargets;
  16110. private _currentActiveTarget;
  16111. private _directTarget;
  16112. /**
  16113. * The target path of the runtime animation
  16114. */
  16115. private _targetPath;
  16116. /**
  16117. * The weight of the runtime animation
  16118. */
  16119. private _weight;
  16120. /**
  16121. * The ratio offset of the runtime animation
  16122. */
  16123. private _ratioOffset;
  16124. /**
  16125. * The previous delay of the runtime animation
  16126. */
  16127. private _previousDelay;
  16128. /**
  16129. * The previous ratio of the runtime animation
  16130. */
  16131. private _previousRatio;
  16132. private _enableBlending;
  16133. private _keys;
  16134. private _minFrame;
  16135. private _maxFrame;
  16136. private _minValue;
  16137. private _maxValue;
  16138. private _targetIsArray;
  16139. /**
  16140. * Gets the current frame of the runtime animation
  16141. */
  16142. get currentFrame(): number;
  16143. /**
  16144. * Gets the weight of the runtime animation
  16145. */
  16146. get weight(): number;
  16147. /**
  16148. * Gets the current value of the runtime animation
  16149. */
  16150. get currentValue(): any;
  16151. /**
  16152. * Gets the target path of the runtime animation
  16153. */
  16154. get targetPath(): string;
  16155. /**
  16156. * Gets the actual target of the runtime animation
  16157. */
  16158. get target(): any;
  16159. /**
  16160. * Gets the additive state of the runtime animation
  16161. */
  16162. get isAdditive(): boolean;
  16163. /** @hidden */
  16164. _onLoop: () => void;
  16165. /**
  16166. * Create a new RuntimeAnimation object
  16167. * @param target defines the target of the animation
  16168. * @param animation defines the source animation object
  16169. * @param scene defines the hosting scene
  16170. * @param host defines the initiating Animatable
  16171. */
  16172. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16173. private _preparePath;
  16174. /**
  16175. * Gets the animation from the runtime animation
  16176. */
  16177. get animation(): Animation;
  16178. /**
  16179. * Resets the runtime animation to the beginning
  16180. * @param restoreOriginal defines whether to restore the target property to the original value
  16181. */
  16182. reset(restoreOriginal?: boolean): void;
  16183. /**
  16184. * Specifies if the runtime animation is stopped
  16185. * @returns Boolean specifying if the runtime animation is stopped
  16186. */
  16187. isStopped(): boolean;
  16188. /**
  16189. * Disposes of the runtime animation
  16190. */
  16191. dispose(): void;
  16192. /**
  16193. * Apply the interpolated value to the target
  16194. * @param currentValue defines the value computed by the animation
  16195. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16196. */
  16197. setValue(currentValue: any, weight: number): void;
  16198. private _getOriginalValues;
  16199. private _setValue;
  16200. /**
  16201. * Gets the loop pmode of the runtime animation
  16202. * @returns Loop Mode
  16203. */
  16204. private _getCorrectLoopMode;
  16205. /**
  16206. * Move the current animation to a given frame
  16207. * @param frame defines the frame to move to
  16208. */
  16209. goToFrame(frame: number): void;
  16210. /**
  16211. * @hidden Internal use only
  16212. */
  16213. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16214. /**
  16215. * Execute the current animation
  16216. * @param delay defines the delay to add to the current frame
  16217. * @param from defines the lower bound of the animation range
  16218. * @param to defines the upper bound of the animation range
  16219. * @param loop defines if the current animation must loop
  16220. * @param speedRatio defines the current speed ratio
  16221. * @param weight defines the weight of the animation (default is -1 so no weight)
  16222. * @param onLoop optional callback called when animation loops
  16223. * @returns a boolean indicating if the animation is running
  16224. */
  16225. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16226. }
  16227. }
  16228. declare module "babylonjs/Animations/animatable" {
  16229. import { Animation } from "babylonjs/Animations/animation";
  16230. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16231. import { Nullable } from "babylonjs/types";
  16232. import { Observable } from "babylonjs/Misc/observable";
  16233. import { Scene } from "babylonjs/scene";
  16234. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16235. import { Node } from "babylonjs/node";
  16236. /**
  16237. * Class used to store an actual running animation
  16238. */
  16239. export class Animatable {
  16240. /** defines the target object */
  16241. target: any;
  16242. /** defines the starting frame number (default is 0) */
  16243. fromFrame: number;
  16244. /** defines the ending frame number (default is 100) */
  16245. toFrame: number;
  16246. /** defines if the animation must loop (default is false) */
  16247. loopAnimation: boolean;
  16248. /** defines a callback to call when animation ends if it is not looping */
  16249. onAnimationEnd?: (() => void) | null | undefined;
  16250. /** defines a callback to call when animation loops */
  16251. onAnimationLoop?: (() => void) | null | undefined;
  16252. /** defines whether the animation should be evaluated additively */
  16253. isAdditive: boolean;
  16254. private _localDelayOffset;
  16255. private _pausedDelay;
  16256. private _runtimeAnimations;
  16257. private _paused;
  16258. private _scene;
  16259. private _speedRatio;
  16260. private _weight;
  16261. private _syncRoot;
  16262. /**
  16263. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16264. * This will only apply for non looping animation (default is true)
  16265. */
  16266. disposeOnEnd: boolean;
  16267. /**
  16268. * Gets a boolean indicating if the animation has started
  16269. */
  16270. animationStarted: boolean;
  16271. /**
  16272. * Observer raised when the animation ends
  16273. */
  16274. onAnimationEndObservable: Observable<Animatable>;
  16275. /**
  16276. * Observer raised when the animation loops
  16277. */
  16278. onAnimationLoopObservable: Observable<Animatable>;
  16279. /**
  16280. * Gets the root Animatable used to synchronize and normalize animations
  16281. */
  16282. get syncRoot(): Nullable<Animatable>;
  16283. /**
  16284. * Gets the current frame of the first RuntimeAnimation
  16285. * Used to synchronize Animatables
  16286. */
  16287. get masterFrame(): number;
  16288. /**
  16289. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16290. */
  16291. get weight(): number;
  16292. set weight(value: number);
  16293. /**
  16294. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16295. */
  16296. get speedRatio(): number;
  16297. set speedRatio(value: number);
  16298. /**
  16299. * Creates a new Animatable
  16300. * @param scene defines the hosting scene
  16301. * @param target defines the target object
  16302. * @param fromFrame defines the starting frame number (default is 0)
  16303. * @param toFrame defines the ending frame number (default is 100)
  16304. * @param loopAnimation defines if the animation must loop (default is false)
  16305. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16306. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16307. * @param animations defines a group of animation to add to the new Animatable
  16308. * @param onAnimationLoop defines a callback to call when animation loops
  16309. * @param isAdditive defines whether the animation should be evaluated additively
  16310. */
  16311. constructor(scene: Scene,
  16312. /** defines the target object */
  16313. target: any,
  16314. /** defines the starting frame number (default is 0) */
  16315. fromFrame?: number,
  16316. /** defines the ending frame number (default is 100) */
  16317. toFrame?: number,
  16318. /** defines if the animation must loop (default is false) */
  16319. loopAnimation?: boolean, speedRatio?: number,
  16320. /** defines a callback to call when animation ends if it is not looping */
  16321. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16322. /** defines a callback to call when animation loops */
  16323. onAnimationLoop?: (() => void) | null | undefined,
  16324. /** defines whether the animation should be evaluated additively */
  16325. isAdditive?: boolean);
  16326. /**
  16327. * Synchronize and normalize current Animatable with a source Animatable
  16328. * This is useful when using animation weights and when animations are not of the same length
  16329. * @param root defines the root Animatable to synchronize with
  16330. * @returns the current Animatable
  16331. */
  16332. syncWith(root: Animatable): Animatable;
  16333. /**
  16334. * Gets the list of runtime animations
  16335. * @returns an array of RuntimeAnimation
  16336. */
  16337. getAnimations(): RuntimeAnimation[];
  16338. /**
  16339. * Adds more animations to the current animatable
  16340. * @param target defines the target of the animations
  16341. * @param animations defines the new animations to add
  16342. */
  16343. appendAnimations(target: any, animations: Animation[]): void;
  16344. /**
  16345. * Gets the source animation for a specific property
  16346. * @param property defines the propertyu to look for
  16347. * @returns null or the source animation for the given property
  16348. */
  16349. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16350. /**
  16351. * Gets the runtime animation for a specific property
  16352. * @param property defines the propertyu to look for
  16353. * @returns null or the runtime animation for the given property
  16354. */
  16355. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16356. /**
  16357. * Resets the animatable to its original state
  16358. */
  16359. reset(): void;
  16360. /**
  16361. * Allows the animatable to blend with current running animations
  16362. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16363. * @param blendingSpeed defines the blending speed to use
  16364. */
  16365. enableBlending(blendingSpeed: number): void;
  16366. /**
  16367. * Disable animation blending
  16368. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16369. */
  16370. disableBlending(): void;
  16371. /**
  16372. * Jump directly to a given frame
  16373. * @param frame defines the frame to jump to
  16374. */
  16375. goToFrame(frame: number): void;
  16376. /**
  16377. * Pause the animation
  16378. */
  16379. pause(): void;
  16380. /**
  16381. * Restart the animation
  16382. */
  16383. restart(): void;
  16384. private _raiseOnAnimationEnd;
  16385. /**
  16386. * Stop and delete the current animation
  16387. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16388. * @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)
  16389. */
  16390. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16391. /**
  16392. * Wait asynchronously for the animation to end
  16393. * @returns a promise which will be fullfilled when the animation ends
  16394. */
  16395. waitAsync(): Promise<Animatable>;
  16396. /** @hidden */
  16397. _animate(delay: number): boolean;
  16398. }
  16399. module "babylonjs/scene" {
  16400. interface Scene {
  16401. /** @hidden */
  16402. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16403. /** @hidden */
  16404. _processLateAnimationBindingsForMatrices(holder: {
  16405. totalWeight: number;
  16406. totalAdditiveWeight: number;
  16407. animations: RuntimeAnimation[];
  16408. additiveAnimations: RuntimeAnimation[];
  16409. originalValue: Matrix;
  16410. }): any;
  16411. /** @hidden */
  16412. _processLateAnimationBindingsForQuaternions(holder: {
  16413. totalWeight: number;
  16414. totalAdditiveWeight: number;
  16415. animations: RuntimeAnimation[];
  16416. additiveAnimations: RuntimeAnimation[];
  16417. originalValue: Quaternion;
  16418. }, refQuaternion: Quaternion): Quaternion;
  16419. /** @hidden */
  16420. _processLateAnimationBindings(): void;
  16421. /**
  16422. * Will start the animation sequence of a given target
  16423. * @param target defines the target
  16424. * @param from defines from which frame should animation start
  16425. * @param to defines until which frame should animation run.
  16426. * @param weight defines the weight to apply to the animation (1.0 by default)
  16427. * @param loop defines if the animation loops
  16428. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16429. * @param onAnimationEnd defines the function to be executed when the animation ends
  16430. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16431. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16432. * @param onAnimationLoop defines the callback to call when an animation loops
  16433. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16434. * @returns the animatable object created for this animation
  16435. */
  16436. 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;
  16437. /**
  16438. * Will start the animation sequence of a given target
  16439. * @param target defines the target
  16440. * @param from defines from which frame should animation start
  16441. * @param to defines until which frame should animation run.
  16442. * @param loop defines if the animation loops
  16443. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16444. * @param onAnimationEnd defines the function to be executed when the animation ends
  16445. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16446. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16447. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16448. * @param onAnimationLoop defines the callback to call when an animation loops
  16449. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16450. * @returns the animatable object created for this animation
  16451. */
  16452. 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;
  16453. /**
  16454. * Will start the animation sequence of a given target and its hierarchy
  16455. * @param target defines the target
  16456. * @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.
  16457. * @param from defines from which frame should animation start
  16458. * @param to defines until which frame should animation run.
  16459. * @param loop defines if the animation loops
  16460. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16461. * @param onAnimationEnd defines the function to be executed when the animation ends
  16462. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16463. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16464. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16465. * @param onAnimationLoop defines the callback to call when an animation loops
  16466. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16467. * @returns the list of created animatables
  16468. */
  16469. 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[];
  16470. /**
  16471. * Begin a new animation on a given node
  16472. * @param target defines the target where the animation will take place
  16473. * @param animations defines the list of animations to start
  16474. * @param from defines the initial value
  16475. * @param to defines the final value
  16476. * @param loop defines if you want animation to loop (off by default)
  16477. * @param speedRatio defines the speed ratio to apply to all animations
  16478. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16479. * @param onAnimationLoop defines the callback to call when an animation loops
  16480. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16481. * @returns the list of created animatables
  16482. */
  16483. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16484. /**
  16485. * Begin a new animation on a given node and its hierarchy
  16486. * @param target defines the root node where the animation will take place
  16487. * @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.
  16488. * @param animations defines the list of animations to start
  16489. * @param from defines the initial value
  16490. * @param to defines the final value
  16491. * @param loop defines if you want animation to loop (off by default)
  16492. * @param speedRatio defines the speed ratio to apply to all animations
  16493. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16494. * @param onAnimationLoop defines the callback to call when an animation loops
  16495. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16496. * @returns the list of animatables created for all nodes
  16497. */
  16498. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16499. /**
  16500. * Gets the animatable associated with a specific target
  16501. * @param target defines the target of the animatable
  16502. * @returns the required animatable if found
  16503. */
  16504. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16505. /**
  16506. * Gets all animatables associated with a given target
  16507. * @param target defines the target to look animatables for
  16508. * @returns an array of Animatables
  16509. */
  16510. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16511. /**
  16512. * Stops and removes all animations that have been applied to the scene
  16513. */
  16514. stopAllAnimations(): void;
  16515. /**
  16516. * Gets the current delta time used by animation engine
  16517. */
  16518. deltaTime: number;
  16519. }
  16520. }
  16521. module "babylonjs/Bones/bone" {
  16522. interface Bone {
  16523. /**
  16524. * Copy an animation range from another bone
  16525. * @param source defines the source bone
  16526. * @param rangeName defines the range name to copy
  16527. * @param frameOffset defines the frame offset
  16528. * @param rescaleAsRequired defines if rescaling must be applied if required
  16529. * @param skelDimensionsRatio defines the scaling ratio
  16530. * @returns true if operation was successful
  16531. */
  16532. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16533. }
  16534. }
  16535. }
  16536. declare module "babylonjs/Bones/skeleton" {
  16537. import { Bone } from "babylonjs/Bones/bone";
  16538. import { Observable } from "babylonjs/Misc/observable";
  16539. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16540. import { Scene } from "babylonjs/scene";
  16541. import { Nullable } from "babylonjs/types";
  16542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16543. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16544. import { Animatable } from "babylonjs/Animations/animatable";
  16545. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16546. import { Animation } from "babylonjs/Animations/animation";
  16547. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16548. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16549. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16550. /**
  16551. * Class used to handle skinning animations
  16552. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16553. */
  16554. export class Skeleton implements IAnimatable {
  16555. /** defines the skeleton name */
  16556. name: string;
  16557. /** defines the skeleton Id */
  16558. id: string;
  16559. /**
  16560. * Defines the list of child bones
  16561. */
  16562. bones: Bone[];
  16563. /**
  16564. * Defines an estimate of the dimension of the skeleton at rest
  16565. */
  16566. dimensionsAtRest: Vector3;
  16567. /**
  16568. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16569. */
  16570. needInitialSkinMatrix: boolean;
  16571. /**
  16572. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16573. */
  16574. overrideMesh: Nullable<AbstractMesh>;
  16575. /**
  16576. * Gets the list of animations attached to this skeleton
  16577. */
  16578. animations: Array<Animation>;
  16579. private _scene;
  16580. private _isDirty;
  16581. private _transformMatrices;
  16582. private _transformMatrixTexture;
  16583. private _meshesWithPoseMatrix;
  16584. private _animatables;
  16585. private _identity;
  16586. private _synchronizedWithMesh;
  16587. private _ranges;
  16588. private _lastAbsoluteTransformsUpdateId;
  16589. private _canUseTextureForBones;
  16590. private _uniqueId;
  16591. /** @hidden */
  16592. _numBonesWithLinkedTransformNode: number;
  16593. /** @hidden */
  16594. _hasWaitingData: Nullable<boolean>;
  16595. /** @hidden */
  16596. _waitingOverrideMeshId: Nullable<string>;
  16597. /**
  16598. * Specifies if the skeleton should be serialized
  16599. */
  16600. doNotSerialize: boolean;
  16601. private _useTextureToStoreBoneMatrices;
  16602. /**
  16603. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16604. * Please note that this option is not available if the hardware does not support it
  16605. */
  16606. get useTextureToStoreBoneMatrices(): boolean;
  16607. set useTextureToStoreBoneMatrices(value: boolean);
  16608. private _animationPropertiesOverride;
  16609. /**
  16610. * Gets or sets the animation properties override
  16611. */
  16612. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16613. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16614. /**
  16615. * List of inspectable custom properties (used by the Inspector)
  16616. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16617. */
  16618. inspectableCustomProperties: IInspectable[];
  16619. /**
  16620. * An observable triggered before computing the skeleton's matrices
  16621. */
  16622. onBeforeComputeObservable: Observable<Skeleton>;
  16623. /**
  16624. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16625. */
  16626. get isUsingTextureForMatrices(): boolean;
  16627. /**
  16628. * Gets the unique ID of this skeleton
  16629. */
  16630. get uniqueId(): number;
  16631. /**
  16632. * Creates a new skeleton
  16633. * @param name defines the skeleton name
  16634. * @param id defines the skeleton Id
  16635. * @param scene defines the hosting scene
  16636. */
  16637. constructor(
  16638. /** defines the skeleton name */
  16639. name: string,
  16640. /** defines the skeleton Id */
  16641. id: string, scene: Scene);
  16642. /**
  16643. * Gets the current object class name.
  16644. * @return the class name
  16645. */
  16646. getClassName(): string;
  16647. /**
  16648. * Returns an array containing the root bones
  16649. * @returns an array containing the root bones
  16650. */
  16651. getChildren(): Array<Bone>;
  16652. /**
  16653. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16654. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16655. * @returns a Float32Array containing matrices data
  16656. */
  16657. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16658. /**
  16659. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16660. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16661. * @returns a raw texture containing the data
  16662. */
  16663. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16664. /**
  16665. * Gets the current hosting scene
  16666. * @returns a scene object
  16667. */
  16668. getScene(): Scene;
  16669. /**
  16670. * Gets a string representing the current skeleton data
  16671. * @param fullDetails defines a boolean indicating if we want a verbose version
  16672. * @returns a string representing the current skeleton data
  16673. */
  16674. toString(fullDetails?: boolean): string;
  16675. /**
  16676. * Get bone's index searching by name
  16677. * @param name defines bone's name to search for
  16678. * @return the indice of the bone. Returns -1 if not found
  16679. */
  16680. getBoneIndexByName(name: string): number;
  16681. /**
  16682. * Creater a new animation range
  16683. * @param name defines the name of the range
  16684. * @param from defines the start key
  16685. * @param to defines the end key
  16686. */
  16687. createAnimationRange(name: string, from: number, to: number): void;
  16688. /**
  16689. * Delete a specific animation range
  16690. * @param name defines the name of the range
  16691. * @param deleteFrames defines if frames must be removed as well
  16692. */
  16693. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16694. /**
  16695. * Gets a specific animation range
  16696. * @param name defines the name of the range to look for
  16697. * @returns the requested animation range or null if not found
  16698. */
  16699. getAnimationRange(name: string): Nullable<AnimationRange>;
  16700. /**
  16701. * Gets the list of all animation ranges defined on this skeleton
  16702. * @returns an array
  16703. */
  16704. getAnimationRanges(): Nullable<AnimationRange>[];
  16705. /**
  16706. * Copy animation range from a source skeleton.
  16707. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16708. * @param source defines the source skeleton
  16709. * @param name defines the name of the range to copy
  16710. * @param rescaleAsRequired defines if rescaling must be applied if required
  16711. * @returns true if operation was successful
  16712. */
  16713. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16714. /**
  16715. * Forces the skeleton to go to rest pose
  16716. */
  16717. returnToRest(): void;
  16718. private _getHighestAnimationFrame;
  16719. /**
  16720. * Begin a specific animation range
  16721. * @param name defines the name of the range to start
  16722. * @param loop defines if looping must be turned on (false by default)
  16723. * @param speedRatio defines the speed ratio to apply (1 by default)
  16724. * @param onAnimationEnd defines a callback which will be called when animation will end
  16725. * @returns a new animatable
  16726. */
  16727. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16728. /**
  16729. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16730. * @param skeleton defines the Skeleton containing the animation range to convert
  16731. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16732. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16733. * @returns the original skeleton
  16734. */
  16735. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16736. /** @hidden */
  16737. _markAsDirty(): void;
  16738. /** @hidden */
  16739. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16740. /** @hidden */
  16741. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16742. private _computeTransformMatrices;
  16743. /**
  16744. * Build all resources required to render a skeleton
  16745. */
  16746. prepare(): void;
  16747. /**
  16748. * Gets the list of animatables currently running for this skeleton
  16749. * @returns an array of animatables
  16750. */
  16751. getAnimatables(): IAnimatable[];
  16752. /**
  16753. * Clone the current skeleton
  16754. * @param name defines the name of the new skeleton
  16755. * @param id defines the id of the new skeleton
  16756. * @returns the new skeleton
  16757. */
  16758. clone(name: string, id?: string): Skeleton;
  16759. /**
  16760. * Enable animation blending for this skeleton
  16761. * @param blendingSpeed defines the blending speed to apply
  16762. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16763. */
  16764. enableBlending(blendingSpeed?: number): void;
  16765. /**
  16766. * Releases all resources associated with the current skeleton
  16767. */
  16768. dispose(): void;
  16769. /**
  16770. * Serialize the skeleton in a JSON object
  16771. * @returns a JSON object
  16772. */
  16773. serialize(): any;
  16774. /**
  16775. * Creates a new skeleton from serialized data
  16776. * @param parsedSkeleton defines the serialized data
  16777. * @param scene defines the hosting scene
  16778. * @returns a new skeleton
  16779. */
  16780. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16781. /**
  16782. * Compute all node absolute transforms
  16783. * @param forceUpdate defines if computation must be done even if cache is up to date
  16784. */
  16785. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16786. /**
  16787. * Gets the root pose matrix
  16788. * @returns a matrix
  16789. */
  16790. getPoseMatrix(): Nullable<Matrix>;
  16791. /**
  16792. * Sorts bones per internal index
  16793. */
  16794. sortBones(): void;
  16795. private _sortBones;
  16796. /**
  16797. * Set the current local matrix as the restPose for all bones in the skeleton.
  16798. */
  16799. setCurrentPoseAsRest(): void;
  16800. }
  16801. }
  16802. declare module "babylonjs/Meshes/instancedMesh" {
  16803. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16804. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16805. import { Camera } from "babylonjs/Cameras/camera";
  16806. import { Node } from "babylonjs/node";
  16807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16808. import { Mesh } from "babylonjs/Meshes/mesh";
  16809. import { Material } from "babylonjs/Materials/material";
  16810. import { Skeleton } from "babylonjs/Bones/skeleton";
  16811. import { Light } from "babylonjs/Lights/light";
  16812. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16813. /**
  16814. * Creates an instance based on a source mesh.
  16815. */
  16816. export class InstancedMesh extends AbstractMesh {
  16817. private _sourceMesh;
  16818. private _currentLOD;
  16819. /** @hidden */
  16820. _indexInSourceMeshInstanceArray: number;
  16821. constructor(name: string, source: Mesh);
  16822. /**
  16823. * Returns the string "InstancedMesh".
  16824. */
  16825. getClassName(): string;
  16826. /** Gets the list of lights affecting that mesh */
  16827. get lightSources(): Light[];
  16828. _resyncLightSources(): void;
  16829. _resyncLightSource(light: Light): void;
  16830. _removeLightSource(light: Light, dispose: boolean): void;
  16831. /**
  16832. * If the source mesh receives shadows
  16833. */
  16834. get receiveShadows(): boolean;
  16835. /**
  16836. * The material of the source mesh
  16837. */
  16838. get material(): Nullable<Material>;
  16839. /**
  16840. * Visibility of the source mesh
  16841. */
  16842. get visibility(): number;
  16843. /**
  16844. * Skeleton of the source mesh
  16845. */
  16846. get skeleton(): Nullable<Skeleton>;
  16847. /**
  16848. * Rendering ground id of the source mesh
  16849. */
  16850. get renderingGroupId(): number;
  16851. set renderingGroupId(value: number);
  16852. /**
  16853. * Returns the total number of vertices (integer).
  16854. */
  16855. getTotalVertices(): number;
  16856. /**
  16857. * Returns a positive integer : the total number of indices in this mesh geometry.
  16858. * @returns the numner of indices or zero if the mesh has no geometry.
  16859. */
  16860. getTotalIndices(): number;
  16861. /**
  16862. * The source mesh of the instance
  16863. */
  16864. get sourceMesh(): Mesh;
  16865. /**
  16866. * Creates a new InstancedMesh object from the mesh model.
  16867. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16868. * @param name defines the name of the new instance
  16869. * @returns a new InstancedMesh
  16870. */
  16871. createInstance(name: string): InstancedMesh;
  16872. /**
  16873. * Is this node ready to be used/rendered
  16874. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16875. * @return {boolean} is it ready
  16876. */
  16877. isReady(completeCheck?: boolean): boolean;
  16878. /**
  16879. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16880. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16881. * @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.
  16882. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16883. */
  16884. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16885. /**
  16886. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16887. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16888. * The `data` are either a numeric array either a Float32Array.
  16889. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16890. * 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).
  16891. * Note that a new underlying VertexBuffer object is created each call.
  16892. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16893. *
  16894. * Possible `kind` values :
  16895. * - VertexBuffer.PositionKind
  16896. * - VertexBuffer.UVKind
  16897. * - VertexBuffer.UV2Kind
  16898. * - VertexBuffer.UV3Kind
  16899. * - VertexBuffer.UV4Kind
  16900. * - VertexBuffer.UV5Kind
  16901. * - VertexBuffer.UV6Kind
  16902. * - VertexBuffer.ColorKind
  16903. * - VertexBuffer.MatricesIndicesKind
  16904. * - VertexBuffer.MatricesIndicesExtraKind
  16905. * - VertexBuffer.MatricesWeightsKind
  16906. * - VertexBuffer.MatricesWeightsExtraKind
  16907. *
  16908. * Returns the Mesh.
  16909. */
  16910. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16911. /**
  16912. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16913. * If the mesh has no geometry, it is simply returned as it is.
  16914. * The `data` are either a numeric array either a Float32Array.
  16915. * No new underlying VertexBuffer object is created.
  16916. * 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.
  16917. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16918. *
  16919. * Possible `kind` values :
  16920. * - VertexBuffer.PositionKind
  16921. * - VertexBuffer.UVKind
  16922. * - VertexBuffer.UV2Kind
  16923. * - VertexBuffer.UV3Kind
  16924. * - VertexBuffer.UV4Kind
  16925. * - VertexBuffer.UV5Kind
  16926. * - VertexBuffer.UV6Kind
  16927. * - VertexBuffer.ColorKind
  16928. * - VertexBuffer.MatricesIndicesKind
  16929. * - VertexBuffer.MatricesIndicesExtraKind
  16930. * - VertexBuffer.MatricesWeightsKind
  16931. * - VertexBuffer.MatricesWeightsExtraKind
  16932. *
  16933. * Returns the Mesh.
  16934. */
  16935. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16936. /**
  16937. * Sets the mesh indices.
  16938. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16939. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16940. * This method creates a new index buffer each call.
  16941. * Returns the Mesh.
  16942. */
  16943. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16944. /**
  16945. * Boolean : True if the mesh owns the requested kind of data.
  16946. */
  16947. isVerticesDataPresent(kind: string): boolean;
  16948. /**
  16949. * Returns an array of indices (IndicesArray).
  16950. */
  16951. getIndices(): Nullable<IndicesArray>;
  16952. get _positions(): Nullable<Vector3[]>;
  16953. /**
  16954. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16955. * This means the mesh underlying bounding box and sphere are recomputed.
  16956. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16957. * @returns the current mesh
  16958. */
  16959. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16960. /** @hidden */
  16961. _preActivate(): InstancedMesh;
  16962. /** @hidden */
  16963. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16964. /** @hidden */
  16965. _postActivate(): void;
  16966. getWorldMatrix(): Matrix;
  16967. get isAnInstance(): boolean;
  16968. /**
  16969. * Returns the current associated LOD AbstractMesh.
  16970. */
  16971. getLOD(camera: Camera): AbstractMesh;
  16972. /** @hidden */
  16973. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16974. /** @hidden */
  16975. _syncSubMeshes(): InstancedMesh;
  16976. /** @hidden */
  16977. _generatePointsArray(): boolean;
  16978. /** @hidden */
  16979. _updateBoundingInfo(): AbstractMesh;
  16980. /**
  16981. * Creates a new InstancedMesh from the current mesh.
  16982. * - name (string) : the cloned mesh name
  16983. * - newParent (optional Node) : the optional Node to parent the clone to.
  16984. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16985. *
  16986. * Returns the clone.
  16987. */
  16988. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16989. /**
  16990. * Disposes the InstancedMesh.
  16991. * Returns nothing.
  16992. */
  16993. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16994. }
  16995. module "babylonjs/Meshes/mesh" {
  16996. interface Mesh {
  16997. /**
  16998. * Register a custom buffer that will be instanced
  16999. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  17000. * @param kind defines the buffer kind
  17001. * @param stride defines the stride in floats
  17002. */
  17003. registerInstancedBuffer(kind: string, stride: number): void;
  17004. /**
  17005. * true to use the edge renderer for all instances of this mesh
  17006. */
  17007. edgesShareWithInstances: boolean;
  17008. /** @hidden */
  17009. _userInstancedBuffersStorage: {
  17010. data: {
  17011. [key: string]: Float32Array;
  17012. };
  17013. sizes: {
  17014. [key: string]: number;
  17015. };
  17016. vertexBuffers: {
  17017. [key: string]: Nullable<VertexBuffer>;
  17018. };
  17019. strides: {
  17020. [key: string]: number;
  17021. };
  17022. };
  17023. }
  17024. }
  17025. module "babylonjs/Meshes/abstractMesh" {
  17026. interface AbstractMesh {
  17027. /**
  17028. * Object used to store instanced buffers defined by user
  17029. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  17030. */
  17031. instancedBuffers: {
  17032. [key: string]: any;
  17033. };
  17034. }
  17035. }
  17036. }
  17037. declare module "babylonjs/Materials/shaderMaterial" {
  17038. import { Nullable } from "babylonjs/types";
  17039. import { Scene } from "babylonjs/scene";
  17040. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  17041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17042. import { Mesh } from "babylonjs/Meshes/mesh";
  17043. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17045. import { Effect } from "babylonjs/Materials/effect";
  17046. import { Material } from "babylonjs/Materials/material";
  17047. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17048. /**
  17049. * Defines the options associated with the creation of a shader material.
  17050. */
  17051. export interface IShaderMaterialOptions {
  17052. /**
  17053. * Does the material work in alpha blend mode
  17054. */
  17055. needAlphaBlending: boolean;
  17056. /**
  17057. * Does the material work in alpha test mode
  17058. */
  17059. needAlphaTesting: boolean;
  17060. /**
  17061. * The list of attribute names used in the shader
  17062. */
  17063. attributes: string[];
  17064. /**
  17065. * The list of unifrom names used in the shader
  17066. */
  17067. uniforms: string[];
  17068. /**
  17069. * The list of UBO names used in the shader
  17070. */
  17071. uniformBuffers: string[];
  17072. /**
  17073. * The list of sampler names used in the shader
  17074. */
  17075. samplers: string[];
  17076. /**
  17077. * The list of defines used in the shader
  17078. */
  17079. defines: string[];
  17080. }
  17081. /**
  17082. * 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.
  17083. *
  17084. * This returned material effects how the mesh will look based on the code in the shaders.
  17085. *
  17086. * @see https://doc.babylonjs.com/how_to/shader_material
  17087. */
  17088. export class ShaderMaterial extends Material {
  17089. private _shaderPath;
  17090. private _options;
  17091. private _textures;
  17092. private _textureArrays;
  17093. private _floats;
  17094. private _ints;
  17095. private _floatsArrays;
  17096. private _colors3;
  17097. private _colors3Arrays;
  17098. private _colors4;
  17099. private _colors4Arrays;
  17100. private _vectors2;
  17101. private _vectors3;
  17102. private _vectors4;
  17103. private _matrices;
  17104. private _matrixArrays;
  17105. private _matrices3x3;
  17106. private _matrices2x2;
  17107. private _vectors2Arrays;
  17108. private _vectors3Arrays;
  17109. private _vectors4Arrays;
  17110. private _cachedWorldViewMatrix;
  17111. private _cachedWorldViewProjectionMatrix;
  17112. private _renderId;
  17113. private _multiview;
  17114. private _cachedDefines;
  17115. /** Define the Url to load snippets */
  17116. static SnippetUrl: string;
  17117. /** Snippet ID if the material was created from the snippet server */
  17118. snippetId: string;
  17119. /**
  17120. * Instantiate a new shader material.
  17121. * 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.
  17122. * This returned material effects how the mesh will look based on the code in the shaders.
  17123. * @see https://doc.babylonjs.com/how_to/shader_material
  17124. * @param name Define the name of the material in the scene
  17125. * @param scene Define the scene the material belongs to
  17126. * @param shaderPath Defines the route to the shader code in one of three ways:
  17127. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17128. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17129. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17130. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17131. * @param options Define the options used to create the shader
  17132. */
  17133. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17134. /**
  17135. * Gets the shader path used to define the shader code
  17136. * It can be modified to trigger a new compilation
  17137. */
  17138. get shaderPath(): any;
  17139. /**
  17140. * Sets the shader path used to define the shader code
  17141. * It can be modified to trigger a new compilation
  17142. */
  17143. set shaderPath(shaderPath: any);
  17144. /**
  17145. * Gets the options used to compile the shader.
  17146. * They can be modified to trigger a new compilation
  17147. */
  17148. get options(): IShaderMaterialOptions;
  17149. /**
  17150. * Gets the current class name of the material e.g. "ShaderMaterial"
  17151. * Mainly use in serialization.
  17152. * @returns the class name
  17153. */
  17154. getClassName(): string;
  17155. /**
  17156. * Specifies if the material will require alpha blending
  17157. * @returns a boolean specifying if alpha blending is needed
  17158. */
  17159. needAlphaBlending(): boolean;
  17160. /**
  17161. * Specifies if this material should be rendered in alpha test mode
  17162. * @returns a boolean specifying if an alpha test is needed.
  17163. */
  17164. needAlphaTesting(): boolean;
  17165. private _checkUniform;
  17166. /**
  17167. * Set a texture in the shader.
  17168. * @param name Define the name of the uniform samplers as defined in the shader
  17169. * @param texture Define the texture to bind to this sampler
  17170. * @return the material itself allowing "fluent" like uniform updates
  17171. */
  17172. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17173. /**
  17174. * Set a texture array in the shader.
  17175. * @param name Define the name of the uniform sampler array as defined in the shader
  17176. * @param textures Define the list of textures to bind to this sampler
  17177. * @return the material itself allowing "fluent" like uniform updates
  17178. */
  17179. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17180. /**
  17181. * Set a float in the shader.
  17182. * @param name Define the name of the uniform as defined in the shader
  17183. * @param value Define the value to give to the uniform
  17184. * @return the material itself allowing "fluent" like uniform updates
  17185. */
  17186. setFloat(name: string, value: number): ShaderMaterial;
  17187. /**
  17188. * Set a int in the shader.
  17189. * @param name Define the name of the uniform as defined in the shader
  17190. * @param value Define the value to give to the uniform
  17191. * @return the material itself allowing "fluent" like uniform updates
  17192. */
  17193. setInt(name: string, value: number): ShaderMaterial;
  17194. /**
  17195. * Set an array of floats in the shader.
  17196. * @param name Define the name of the uniform as defined in the shader
  17197. * @param value Define the value to give to the uniform
  17198. * @return the material itself allowing "fluent" like uniform updates
  17199. */
  17200. setFloats(name: string, value: number[]): ShaderMaterial;
  17201. /**
  17202. * Set a vec3 in the shader from a Color3.
  17203. * @param name Define the name of the uniform as defined in the shader
  17204. * @param value Define the value to give to the uniform
  17205. * @return the material itself allowing "fluent" like uniform updates
  17206. */
  17207. setColor3(name: string, value: Color3): ShaderMaterial;
  17208. /**
  17209. * Set a vec3 array in the shader from a Color3 array.
  17210. * @param name Define the name of the uniform as defined in the shader
  17211. * @param value Define the value to give to the uniform
  17212. * @return the material itself allowing "fluent" like uniform updates
  17213. */
  17214. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17215. /**
  17216. * Set a vec4 in the shader from a Color4.
  17217. * @param name Define the name of the uniform as defined in the shader
  17218. * @param value Define the value to give to the uniform
  17219. * @return the material itself allowing "fluent" like uniform updates
  17220. */
  17221. setColor4(name: string, value: Color4): ShaderMaterial;
  17222. /**
  17223. * Set a vec4 array in the shader from a Color4 array.
  17224. * @param name Define the name of the uniform as defined in the shader
  17225. * @param value Define the value to give to the uniform
  17226. * @return the material itself allowing "fluent" like uniform updates
  17227. */
  17228. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17229. /**
  17230. * Set a vec2 in the shader from a Vector2.
  17231. * @param name Define the name of the uniform as defined in the shader
  17232. * @param value Define the value to give to the uniform
  17233. * @return the material itself allowing "fluent" like uniform updates
  17234. */
  17235. setVector2(name: string, value: Vector2): ShaderMaterial;
  17236. /**
  17237. * Set a vec3 in the shader from a Vector3.
  17238. * @param name Define the name of the uniform as defined in the shader
  17239. * @param value Define the value to give to the uniform
  17240. * @return the material itself allowing "fluent" like uniform updates
  17241. */
  17242. setVector3(name: string, value: Vector3): ShaderMaterial;
  17243. /**
  17244. * Set a vec4 in the shader from a Vector4.
  17245. * @param name Define the name of the uniform as defined in the shader
  17246. * @param value Define the value to give to the uniform
  17247. * @return the material itself allowing "fluent" like uniform updates
  17248. */
  17249. setVector4(name: string, value: Vector4): ShaderMaterial;
  17250. /**
  17251. * Set a mat4 in the shader from a Matrix.
  17252. * @param name Define the name of the uniform as defined in the shader
  17253. * @param value Define the value to give to the uniform
  17254. * @return the material itself allowing "fluent" like uniform updates
  17255. */
  17256. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17257. /**
  17258. * Set a float32Array in the shader from a matrix array.
  17259. * @param name Define the name of the uniform as defined in the shader
  17260. * @param value Define the value to give to the uniform
  17261. * @return the material itself allowing "fluent" like uniform updates
  17262. */
  17263. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17264. /**
  17265. * Set a mat3 in the shader from a Float32Array.
  17266. * @param name Define the name of the uniform as defined in the shader
  17267. * @param value Define the value to give to the uniform
  17268. * @return the material itself allowing "fluent" like uniform updates
  17269. */
  17270. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17271. /**
  17272. * Set a mat2 in the shader from a Float32Array.
  17273. * @param name Define the name of the uniform as defined in the shader
  17274. * @param value Define the value to give to the uniform
  17275. * @return the material itself allowing "fluent" like uniform updates
  17276. */
  17277. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17278. /**
  17279. * Set a vec2 array in the shader from a number array.
  17280. * @param name Define the name of the uniform as defined in the shader
  17281. * @param value Define the value to give to the uniform
  17282. * @return the material itself allowing "fluent" like uniform updates
  17283. */
  17284. setArray2(name: string, value: number[]): ShaderMaterial;
  17285. /**
  17286. * Set a vec3 array in the shader from a number array.
  17287. * @param name Define the name of the uniform as defined in the shader
  17288. * @param value Define the value to give to the uniform
  17289. * @return the material itself allowing "fluent" like uniform updates
  17290. */
  17291. setArray3(name: string, value: number[]): ShaderMaterial;
  17292. /**
  17293. * Set a vec4 array in the shader from a number array.
  17294. * @param name Define the name of the uniform as defined in the shader
  17295. * @param value Define the value to give to the uniform
  17296. * @return the material itself allowing "fluent" like uniform updates
  17297. */
  17298. setArray4(name: string, value: number[]): ShaderMaterial;
  17299. private _checkCache;
  17300. /**
  17301. * Specifies that the submesh is ready to be used
  17302. * @param mesh defines the mesh to check
  17303. * @param subMesh defines which submesh to check
  17304. * @param useInstances specifies that instances should be used
  17305. * @returns a boolean indicating that the submesh is ready or not
  17306. */
  17307. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17308. /**
  17309. * Checks if the material is ready to render the requested mesh
  17310. * @param mesh Define the mesh to render
  17311. * @param useInstances Define whether or not the material is used with instances
  17312. * @returns true if ready, otherwise false
  17313. */
  17314. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17315. /**
  17316. * Binds the world matrix to the material
  17317. * @param world defines the world transformation matrix
  17318. * @param effectOverride - If provided, use this effect instead of internal effect
  17319. */
  17320. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17321. /**
  17322. * Binds the submesh to this material by preparing the effect and shader to draw
  17323. * @param world defines the world transformation matrix
  17324. * @param mesh defines the mesh containing the submesh
  17325. * @param subMesh defines the submesh to bind the material to
  17326. */
  17327. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17328. /**
  17329. * Binds the material to the mesh
  17330. * @param world defines the world transformation matrix
  17331. * @param mesh defines the mesh to bind the material to
  17332. * @param effectOverride - If provided, use this effect instead of internal effect
  17333. */
  17334. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17335. protected _afterBind(mesh?: Mesh): void;
  17336. /**
  17337. * Gets the active textures from the material
  17338. * @returns an array of textures
  17339. */
  17340. getActiveTextures(): BaseTexture[];
  17341. /**
  17342. * Specifies if the material uses a texture
  17343. * @param texture defines the texture to check against the material
  17344. * @returns a boolean specifying if the material uses the texture
  17345. */
  17346. hasTexture(texture: BaseTexture): boolean;
  17347. /**
  17348. * Makes a duplicate of the material, and gives it a new name
  17349. * @param name defines the new name for the duplicated material
  17350. * @returns the cloned material
  17351. */
  17352. clone(name: string): ShaderMaterial;
  17353. /**
  17354. * Disposes the material
  17355. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17356. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17357. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17358. */
  17359. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17360. /**
  17361. * Serializes this material in a JSON representation
  17362. * @returns the serialized material object
  17363. */
  17364. serialize(): any;
  17365. /**
  17366. * Creates a shader material from parsed shader material data
  17367. * @param source defines the JSON represnetation of the material
  17368. * @param scene defines the hosting scene
  17369. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17370. * @returns a new material
  17371. */
  17372. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17373. /**
  17374. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17375. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17376. * @param url defines the url to load from
  17377. * @param scene defines the hosting scene
  17378. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17379. * @returns a promise that will resolve to the new ShaderMaterial
  17380. */
  17381. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17382. /**
  17383. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17384. * @param snippetId defines the snippet to load
  17385. * @param scene defines the hosting scene
  17386. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17387. * @returns a promise that will resolve to the new ShaderMaterial
  17388. */
  17389. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17390. }
  17391. }
  17392. declare module "babylonjs/Shaders/color.fragment" {
  17393. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17394. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17395. /** @hidden */
  17396. export var colorPixelShader: {
  17397. name: string;
  17398. shader: string;
  17399. };
  17400. }
  17401. declare module "babylonjs/Shaders/color.vertex" {
  17402. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17403. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17404. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17405. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17406. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17407. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17408. /** @hidden */
  17409. export var colorVertexShader: {
  17410. name: string;
  17411. shader: string;
  17412. };
  17413. }
  17414. declare module "babylonjs/Meshes/linesMesh" {
  17415. import { Nullable } from "babylonjs/types";
  17416. import { Scene } from "babylonjs/scene";
  17417. import { Color3 } from "babylonjs/Maths/math.color";
  17418. import { Node } from "babylonjs/node";
  17419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17420. import { Mesh } from "babylonjs/Meshes/mesh";
  17421. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17422. import { Effect } from "babylonjs/Materials/effect";
  17423. import { Material } from "babylonjs/Materials/material";
  17424. import "babylonjs/Shaders/color.fragment";
  17425. import "babylonjs/Shaders/color.vertex";
  17426. /**
  17427. * Line mesh
  17428. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17429. */
  17430. export class LinesMesh extends Mesh {
  17431. /**
  17432. * If vertex color should be applied to the mesh
  17433. */
  17434. readonly useVertexColor?: boolean | undefined;
  17435. /**
  17436. * If vertex alpha should be applied to the mesh
  17437. */
  17438. readonly useVertexAlpha?: boolean | undefined;
  17439. /**
  17440. * Color of the line (Default: White)
  17441. */
  17442. color: Color3;
  17443. /**
  17444. * Alpha of the line (Default: 1)
  17445. */
  17446. alpha: number;
  17447. /**
  17448. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17449. * This margin is expressed in world space coordinates, so its value may vary.
  17450. * Default value is 0.1
  17451. */
  17452. intersectionThreshold: number;
  17453. private _colorShader;
  17454. private color4;
  17455. /**
  17456. * Creates a new LinesMesh
  17457. * @param name defines the name
  17458. * @param scene defines the hosting scene
  17459. * @param parent defines the parent mesh if any
  17460. * @param source defines the optional source LinesMesh used to clone data from
  17461. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17462. * When false, achieved by calling a clone(), also passing False.
  17463. * This will make creation of children, recursive.
  17464. * @param useVertexColor defines if this LinesMesh supports vertex color
  17465. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17466. */
  17467. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17468. /**
  17469. * If vertex color should be applied to the mesh
  17470. */
  17471. useVertexColor?: boolean | undefined,
  17472. /**
  17473. * If vertex alpha should be applied to the mesh
  17474. */
  17475. useVertexAlpha?: boolean | undefined);
  17476. private _addClipPlaneDefine;
  17477. private _removeClipPlaneDefine;
  17478. isReady(): boolean;
  17479. /**
  17480. * Returns the string "LineMesh"
  17481. */
  17482. getClassName(): string;
  17483. /**
  17484. * @hidden
  17485. */
  17486. get material(): Material;
  17487. /**
  17488. * @hidden
  17489. */
  17490. set material(value: Material);
  17491. /**
  17492. * @hidden
  17493. */
  17494. get checkCollisions(): boolean;
  17495. /** @hidden */
  17496. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17497. /** @hidden */
  17498. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17499. /**
  17500. * Disposes of the line mesh
  17501. * @param doNotRecurse If children should be disposed
  17502. */
  17503. dispose(doNotRecurse?: boolean): void;
  17504. /**
  17505. * Returns a new LineMesh object cloned from the current one.
  17506. */
  17507. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17508. /**
  17509. * Creates a new InstancedLinesMesh object from the mesh model.
  17510. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17511. * @param name defines the name of the new instance
  17512. * @returns a new InstancedLinesMesh
  17513. */
  17514. createInstance(name: string): InstancedLinesMesh;
  17515. }
  17516. /**
  17517. * Creates an instance based on a source LinesMesh
  17518. */
  17519. export class InstancedLinesMesh extends InstancedMesh {
  17520. /**
  17521. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17522. * This margin is expressed in world space coordinates, so its value may vary.
  17523. * Initilized with the intersectionThreshold value of the source LinesMesh
  17524. */
  17525. intersectionThreshold: number;
  17526. constructor(name: string, source: LinesMesh);
  17527. /**
  17528. * Returns the string "InstancedLinesMesh".
  17529. */
  17530. getClassName(): string;
  17531. }
  17532. }
  17533. declare module "babylonjs/Shaders/line.fragment" {
  17534. /** @hidden */
  17535. export var linePixelShader: {
  17536. name: string;
  17537. shader: string;
  17538. };
  17539. }
  17540. declare module "babylonjs/Shaders/line.vertex" {
  17541. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17542. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17543. /** @hidden */
  17544. export var lineVertexShader: {
  17545. name: string;
  17546. shader: string;
  17547. };
  17548. }
  17549. declare module "babylonjs/Rendering/edgesRenderer" {
  17550. import { Nullable } from "babylonjs/types";
  17551. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17553. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17554. import { IDisposable } from "babylonjs/scene";
  17555. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17556. import "babylonjs/Shaders/line.fragment";
  17557. import "babylonjs/Shaders/line.vertex";
  17558. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17559. import { SmartArray } from "babylonjs/Misc/smartArray";
  17560. module "babylonjs/scene" {
  17561. interface Scene {
  17562. /** @hidden */
  17563. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17564. }
  17565. }
  17566. module "babylonjs/Meshes/abstractMesh" {
  17567. interface AbstractMesh {
  17568. /**
  17569. * Gets the edgesRenderer associated with the mesh
  17570. */
  17571. edgesRenderer: Nullable<EdgesRenderer>;
  17572. }
  17573. }
  17574. module "babylonjs/Meshes/linesMesh" {
  17575. interface LinesMesh {
  17576. /**
  17577. * Enables the edge rendering mode on the mesh.
  17578. * This mode makes the mesh edges visible
  17579. * @param epsilon defines the maximal distance between two angles to detect a face
  17580. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17581. * @returns the currentAbstractMesh
  17582. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17583. */
  17584. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17585. }
  17586. }
  17587. module "babylonjs/Meshes/linesMesh" {
  17588. interface InstancedLinesMesh {
  17589. /**
  17590. * Enables the edge rendering mode on the mesh.
  17591. * This mode makes the mesh edges visible
  17592. * @param epsilon defines the maximal distance between two angles to detect a face
  17593. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17594. * @returns the current InstancedLinesMesh
  17595. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17596. */
  17597. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17598. }
  17599. }
  17600. /**
  17601. * Defines the minimum contract an Edges renderer should follow.
  17602. */
  17603. export interface IEdgesRenderer extends IDisposable {
  17604. /**
  17605. * Gets or sets a boolean indicating if the edgesRenderer is active
  17606. */
  17607. isEnabled: boolean;
  17608. /**
  17609. * Renders the edges of the attached mesh,
  17610. */
  17611. render(): void;
  17612. /**
  17613. * Checks wether or not the edges renderer is ready to render.
  17614. * @return true if ready, otherwise false.
  17615. */
  17616. isReady(): boolean;
  17617. /**
  17618. * List of instances to render in case the source mesh has instances
  17619. */
  17620. customInstances: SmartArray<Matrix>;
  17621. }
  17622. /**
  17623. * Defines the additional options of the edges renderer
  17624. */
  17625. export interface IEdgesRendererOptions {
  17626. /**
  17627. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17628. * If not defined, the default value is true
  17629. */
  17630. useAlternateEdgeFinder?: boolean;
  17631. /**
  17632. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17633. * If not defined, the default value is true.
  17634. * 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)
  17635. * This option is used only if useAlternateEdgeFinder = true
  17636. */
  17637. useFastVertexMerger?: boolean;
  17638. /**
  17639. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17640. * The default value is 1e-6
  17641. * This option is used only if useAlternateEdgeFinder = true
  17642. */
  17643. epsilonVertexMerge?: number;
  17644. /**
  17645. * 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
  17646. * 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.
  17647. * This option is used only if useAlternateEdgeFinder = true
  17648. */
  17649. applyTessellation?: boolean;
  17650. /**
  17651. * 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
  17652. * The default value is 1e-6
  17653. * This option is used only if useAlternateEdgeFinder = true
  17654. */
  17655. epsilonVertexAligned?: number;
  17656. }
  17657. /**
  17658. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17659. */
  17660. export class EdgesRenderer implements IEdgesRenderer {
  17661. /**
  17662. * Define the size of the edges with an orthographic camera
  17663. */
  17664. edgesWidthScalerForOrthographic: number;
  17665. /**
  17666. * Define the size of the edges with a perspective camera
  17667. */
  17668. edgesWidthScalerForPerspective: number;
  17669. protected _source: AbstractMesh;
  17670. protected _linesPositions: number[];
  17671. protected _linesNormals: number[];
  17672. protected _linesIndices: number[];
  17673. protected _epsilon: number;
  17674. protected _indicesCount: number;
  17675. protected _lineShader: ShaderMaterial;
  17676. protected _ib: DataBuffer;
  17677. protected _buffers: {
  17678. [key: string]: Nullable<VertexBuffer>;
  17679. };
  17680. protected _buffersForInstances: {
  17681. [key: string]: Nullable<VertexBuffer>;
  17682. };
  17683. protected _checkVerticesInsteadOfIndices: boolean;
  17684. protected _options: Nullable<IEdgesRendererOptions>;
  17685. private _meshRebuildObserver;
  17686. private _meshDisposeObserver;
  17687. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17688. isEnabled: boolean;
  17689. /**
  17690. * List of instances to render in case the source mesh has instances
  17691. */
  17692. customInstances: SmartArray<Matrix>;
  17693. private static GetShader;
  17694. /**
  17695. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17696. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17697. * @param source Mesh used to create edges
  17698. * @param epsilon sum of angles in adjacency to check for edge
  17699. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17700. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17701. * @param options The options to apply when generating the edges
  17702. */
  17703. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17704. protected _prepareRessources(): void;
  17705. /** @hidden */
  17706. _rebuild(): void;
  17707. /**
  17708. * Releases the required resources for the edges renderer
  17709. */
  17710. dispose(): void;
  17711. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17712. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17713. /**
  17714. * Checks if the pair of p0 and p1 is en edge
  17715. * @param faceIndex
  17716. * @param edge
  17717. * @param faceNormals
  17718. * @param p0
  17719. * @param p1
  17720. * @private
  17721. */
  17722. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17723. /**
  17724. * push line into the position, normal and index buffer
  17725. * @protected
  17726. */
  17727. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17728. /**
  17729. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17730. */
  17731. private _tessellateTriangle;
  17732. private _generateEdgesLinesAlternate;
  17733. /**
  17734. * Generates lines edges from adjacencjes
  17735. * @private
  17736. */
  17737. _generateEdgesLines(): void;
  17738. /**
  17739. * Checks wether or not the edges renderer is ready to render.
  17740. * @return true if ready, otherwise false.
  17741. */
  17742. isReady(): boolean;
  17743. /**
  17744. * Renders the edges of the attached mesh,
  17745. */
  17746. render(): void;
  17747. }
  17748. /**
  17749. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17750. */
  17751. export class LineEdgesRenderer extends EdgesRenderer {
  17752. /**
  17753. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17754. * @param source LineMesh used to generate edges
  17755. * @param epsilon not important (specified angle for edge detection)
  17756. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17757. */
  17758. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17759. /**
  17760. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17761. */
  17762. _generateEdgesLines(): void;
  17763. }
  17764. }
  17765. declare module "babylonjs/Rendering/renderingGroup" {
  17766. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17767. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17769. import { Nullable } from "babylonjs/types";
  17770. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17771. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17772. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17773. import { Material } from "babylonjs/Materials/material";
  17774. import { Scene } from "babylonjs/scene";
  17775. /**
  17776. * This represents the object necessary to create a rendering group.
  17777. * This is exclusively used and created by the rendering manager.
  17778. * To modify the behavior, you use the available helpers in your scene or meshes.
  17779. * @hidden
  17780. */
  17781. export class RenderingGroup {
  17782. index: number;
  17783. private static _zeroVector;
  17784. private _scene;
  17785. private _opaqueSubMeshes;
  17786. private _transparentSubMeshes;
  17787. private _alphaTestSubMeshes;
  17788. private _depthOnlySubMeshes;
  17789. private _particleSystems;
  17790. private _spriteManagers;
  17791. private _opaqueSortCompareFn;
  17792. private _alphaTestSortCompareFn;
  17793. private _transparentSortCompareFn;
  17794. private _renderOpaque;
  17795. private _renderAlphaTest;
  17796. private _renderTransparent;
  17797. /** @hidden */
  17798. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17799. onBeforeTransparentRendering: () => void;
  17800. /**
  17801. * Set the opaque sort comparison function.
  17802. * If null the sub meshes will be render in the order they were created
  17803. */
  17804. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17805. /**
  17806. * Set the alpha test sort comparison function.
  17807. * If null the sub meshes will be render in the order they were created
  17808. */
  17809. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17810. /**
  17811. * Set the transparent sort comparison function.
  17812. * If null the sub meshes will be render in the order they were created
  17813. */
  17814. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17815. /**
  17816. * Creates a new rendering group.
  17817. * @param index The rendering group index
  17818. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17819. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17820. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17821. */
  17822. 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>);
  17823. /**
  17824. * Render all the sub meshes contained in the group.
  17825. * @param customRenderFunction Used to override the default render behaviour of the group.
  17826. * @returns true if rendered some submeshes.
  17827. */
  17828. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17829. /**
  17830. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17831. * @param subMeshes The submeshes to render
  17832. */
  17833. private renderOpaqueSorted;
  17834. /**
  17835. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17836. * @param subMeshes The submeshes to render
  17837. */
  17838. private renderAlphaTestSorted;
  17839. /**
  17840. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17841. * @param subMeshes The submeshes to render
  17842. */
  17843. private renderTransparentSorted;
  17844. /**
  17845. * Renders the submeshes in a specified order.
  17846. * @param subMeshes The submeshes to sort before render
  17847. * @param sortCompareFn The comparison function use to sort
  17848. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17849. * @param transparent Specifies to activate blending if true
  17850. */
  17851. private static renderSorted;
  17852. /**
  17853. * Renders the submeshes in the order they were dispatched (no sort applied).
  17854. * @param subMeshes The submeshes to render
  17855. */
  17856. private static renderUnsorted;
  17857. /**
  17858. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17859. * are rendered back to front if in the same alpha index.
  17860. *
  17861. * @param a The first submesh
  17862. * @param b The second submesh
  17863. * @returns The result of the comparison
  17864. */
  17865. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17866. /**
  17867. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17868. * are rendered back to front.
  17869. *
  17870. * @param a The first submesh
  17871. * @param b The second submesh
  17872. * @returns The result of the comparison
  17873. */
  17874. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17875. /**
  17876. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17877. * are rendered front to back (prevent overdraw).
  17878. *
  17879. * @param a The first submesh
  17880. * @param b The second submesh
  17881. * @returns The result of the comparison
  17882. */
  17883. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17884. /**
  17885. * Resets the different lists of submeshes to prepare a new frame.
  17886. */
  17887. prepare(): void;
  17888. dispose(): void;
  17889. /**
  17890. * Inserts the submesh in its correct queue depending on its material.
  17891. * @param subMesh The submesh to dispatch
  17892. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17893. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17894. */
  17895. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17896. dispatchSprites(spriteManager: ISpriteManager): void;
  17897. dispatchParticles(particleSystem: IParticleSystem): void;
  17898. private _renderParticles;
  17899. private _renderSprites;
  17900. }
  17901. }
  17902. declare module "babylonjs/Rendering/renderingManager" {
  17903. import { Nullable } from "babylonjs/types";
  17904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17905. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17906. import { SmartArray } from "babylonjs/Misc/smartArray";
  17907. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17908. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17909. import { Material } from "babylonjs/Materials/material";
  17910. import { Scene } from "babylonjs/scene";
  17911. import { Camera } from "babylonjs/Cameras/camera";
  17912. /**
  17913. * Interface describing the different options available in the rendering manager
  17914. * regarding Auto Clear between groups.
  17915. */
  17916. export interface IRenderingManagerAutoClearSetup {
  17917. /**
  17918. * Defines whether or not autoclear is enable.
  17919. */
  17920. autoClear: boolean;
  17921. /**
  17922. * Defines whether or not to autoclear the depth buffer.
  17923. */
  17924. depth: boolean;
  17925. /**
  17926. * Defines whether or not to autoclear the stencil buffer.
  17927. */
  17928. stencil: boolean;
  17929. }
  17930. /**
  17931. * This class is used by the onRenderingGroupObservable
  17932. */
  17933. export class RenderingGroupInfo {
  17934. /**
  17935. * The Scene that being rendered
  17936. */
  17937. scene: Scene;
  17938. /**
  17939. * The camera currently used for the rendering pass
  17940. */
  17941. camera: Nullable<Camera>;
  17942. /**
  17943. * The ID of the renderingGroup being processed
  17944. */
  17945. renderingGroupId: number;
  17946. }
  17947. /**
  17948. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17949. * It is enable to manage the different groups as well as the different necessary sort functions.
  17950. * This should not be used directly aside of the few static configurations
  17951. */
  17952. export class RenderingManager {
  17953. /**
  17954. * The max id used for rendering groups (not included)
  17955. */
  17956. static MAX_RENDERINGGROUPS: number;
  17957. /**
  17958. * The min id used for rendering groups (included)
  17959. */
  17960. static MIN_RENDERINGGROUPS: number;
  17961. /**
  17962. * Used to globally prevent autoclearing scenes.
  17963. */
  17964. static AUTOCLEAR: boolean;
  17965. /**
  17966. * @hidden
  17967. */
  17968. _useSceneAutoClearSetup: boolean;
  17969. private _scene;
  17970. private _renderingGroups;
  17971. private _depthStencilBufferAlreadyCleaned;
  17972. private _autoClearDepthStencil;
  17973. private _customOpaqueSortCompareFn;
  17974. private _customAlphaTestSortCompareFn;
  17975. private _customTransparentSortCompareFn;
  17976. private _renderingGroupInfo;
  17977. /**
  17978. * Instantiates a new rendering group for a particular scene
  17979. * @param scene Defines the scene the groups belongs to
  17980. */
  17981. constructor(scene: Scene);
  17982. private _clearDepthStencilBuffer;
  17983. /**
  17984. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17985. * @hidden
  17986. */
  17987. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17988. /**
  17989. * Resets the different information of the group to prepare a new frame
  17990. * @hidden
  17991. */
  17992. reset(): void;
  17993. /**
  17994. * Dispose and release the group and its associated resources.
  17995. * @hidden
  17996. */
  17997. dispose(): void;
  17998. /**
  17999. * Clear the info related to rendering groups preventing retention points during dispose.
  18000. */
  18001. freeRenderingGroups(): void;
  18002. private _prepareRenderingGroup;
  18003. /**
  18004. * Add a sprite manager to the rendering manager in order to render it this frame.
  18005. * @param spriteManager Define the sprite manager to render
  18006. */
  18007. dispatchSprites(spriteManager: ISpriteManager): void;
  18008. /**
  18009. * Add a particle system to the rendering manager in order to render it this frame.
  18010. * @param particleSystem Define the particle system to render
  18011. */
  18012. dispatchParticles(particleSystem: IParticleSystem): void;
  18013. /**
  18014. * Add a submesh to the manager in order to render it this frame
  18015. * @param subMesh The submesh to dispatch
  18016. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18017. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18018. */
  18019. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18020. /**
  18021. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18022. * This allowed control for front to back rendering or reversly depending of the special needs.
  18023. *
  18024. * @param renderingGroupId The rendering group id corresponding to its index
  18025. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18026. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18027. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18028. */
  18029. 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;
  18030. /**
  18031. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18032. *
  18033. * @param renderingGroupId The rendering group id corresponding to its index
  18034. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18035. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18036. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18037. */
  18038. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18039. /**
  18040. * Gets the current auto clear configuration for one rendering group of the rendering
  18041. * manager.
  18042. * @param index the rendering group index to get the information for
  18043. * @returns The auto clear setup for the requested rendering group
  18044. */
  18045. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18046. }
  18047. }
  18048. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  18049. import { SmartArray } from "babylonjs/Misc/smartArray";
  18050. import { Nullable } from "babylonjs/types";
  18051. import { Scene } from "babylonjs/scene";
  18052. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  18053. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18055. import { Mesh } from "babylonjs/Meshes/mesh";
  18056. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  18057. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18058. import { Effect } from "babylonjs/Materials/effect";
  18059. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18060. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18061. import "babylonjs/Shaders/shadowMap.fragment";
  18062. import "babylonjs/Shaders/shadowMap.vertex";
  18063. import "babylonjs/Shaders/depthBoxBlur.fragment";
  18064. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  18065. import { Observable } from "babylonjs/Misc/observable";
  18066. /**
  18067. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18068. */
  18069. export interface ICustomShaderOptions {
  18070. /**
  18071. * Gets or sets the custom shader name to use
  18072. */
  18073. shaderName: string;
  18074. /**
  18075. * The list of attribute names used in the shader
  18076. */
  18077. attributes?: string[];
  18078. /**
  18079. * The list of unifrom names used in the shader
  18080. */
  18081. uniforms?: string[];
  18082. /**
  18083. * The list of sampler names used in the shader
  18084. */
  18085. samplers?: string[];
  18086. /**
  18087. * The list of defines used in the shader
  18088. */
  18089. defines?: string[];
  18090. }
  18091. /**
  18092. * Interface to implement to create a shadow generator compatible with BJS.
  18093. */
  18094. export interface IShadowGenerator {
  18095. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18096. id: string;
  18097. /**
  18098. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18099. * @returns The render target texture if present otherwise, null
  18100. */
  18101. getShadowMap(): Nullable<RenderTargetTexture>;
  18102. /**
  18103. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18104. * @param subMesh The submesh we want to render in the shadow map
  18105. * @param useInstances Defines wether will draw in the map using instances
  18106. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18107. * @returns true if ready otherwise, false
  18108. */
  18109. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18110. /**
  18111. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18112. * @param defines Defines of the material we want to update
  18113. * @param lightIndex Index of the light in the enabled light list of the material
  18114. */
  18115. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18116. /**
  18117. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18118. * defined in the generator but impacting the effect).
  18119. * It implies the unifroms available on the materials are the standard BJS ones.
  18120. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18121. * @param effect The effect we are binfing the information for
  18122. */
  18123. bindShadowLight(lightIndex: string, effect: Effect): void;
  18124. /**
  18125. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18126. * (eq to shadow prjection matrix * light transform matrix)
  18127. * @returns The transform matrix used to create the shadow map
  18128. */
  18129. getTransformMatrix(): Matrix;
  18130. /**
  18131. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18132. * Cube and 2D textures for instance.
  18133. */
  18134. recreateShadowMap(): void;
  18135. /**
  18136. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18137. * @param onCompiled Callback triggered at the and of the effects compilation
  18138. * @param options Sets of optional options forcing the compilation with different modes
  18139. */
  18140. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18141. useInstances: boolean;
  18142. }>): void;
  18143. /**
  18144. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18145. * @param options Sets of optional options forcing the compilation with different modes
  18146. * @returns A promise that resolves when the compilation completes
  18147. */
  18148. forceCompilationAsync(options?: Partial<{
  18149. useInstances: boolean;
  18150. }>): Promise<void>;
  18151. /**
  18152. * Serializes the shadow generator setup to a json object.
  18153. * @returns The serialized JSON object
  18154. */
  18155. serialize(): any;
  18156. /**
  18157. * Disposes the Shadow map and related Textures and effects.
  18158. */
  18159. dispose(): void;
  18160. }
  18161. /**
  18162. * Default implementation IShadowGenerator.
  18163. * This is the main object responsible of generating shadows in the framework.
  18164. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18165. */
  18166. export class ShadowGenerator implements IShadowGenerator {
  18167. /**
  18168. * Name of the shadow generator class
  18169. */
  18170. static CLASSNAME: string;
  18171. /**
  18172. * Shadow generator mode None: no filtering applied.
  18173. */
  18174. static readonly FILTER_NONE: number;
  18175. /**
  18176. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18177. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18178. */
  18179. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18180. /**
  18181. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18182. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18183. */
  18184. static readonly FILTER_POISSONSAMPLING: number;
  18185. /**
  18186. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18187. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18188. */
  18189. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18190. /**
  18191. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18192. * edge artifacts on steep falloff.
  18193. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18194. */
  18195. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18196. /**
  18197. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18198. * edge artifacts on steep falloff.
  18199. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18200. */
  18201. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18202. /**
  18203. * Shadow generator mode PCF: Percentage Closer Filtering
  18204. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18205. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18206. */
  18207. static readonly FILTER_PCF: number;
  18208. /**
  18209. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18210. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18211. * Contact Hardening
  18212. */
  18213. static readonly FILTER_PCSS: number;
  18214. /**
  18215. * Reserved for PCF and PCSS
  18216. * Highest Quality.
  18217. *
  18218. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18219. *
  18220. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18221. */
  18222. static readonly QUALITY_HIGH: number;
  18223. /**
  18224. * Reserved for PCF and PCSS
  18225. * Good tradeoff for quality/perf cross devices
  18226. *
  18227. * Execute PCF on a 3*3 kernel.
  18228. *
  18229. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18230. */
  18231. static readonly QUALITY_MEDIUM: number;
  18232. /**
  18233. * Reserved for PCF and PCSS
  18234. * The lowest quality but the fastest.
  18235. *
  18236. * Execute PCF on a 1*1 kernel.
  18237. *
  18238. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18239. */
  18240. static readonly QUALITY_LOW: number;
  18241. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18242. id: string;
  18243. /** Gets or sets the custom shader name to use */
  18244. customShaderOptions: ICustomShaderOptions;
  18245. /**
  18246. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18247. */
  18248. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18249. /**
  18250. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18251. */
  18252. onAfterShadowMapRenderObservable: Observable<Effect>;
  18253. /**
  18254. * Observable triggered before a mesh is rendered in the shadow map.
  18255. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18256. */
  18257. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18258. /**
  18259. * Observable triggered after a mesh is rendered in the shadow map.
  18260. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18261. */
  18262. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18263. protected _bias: number;
  18264. /**
  18265. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18266. */
  18267. get bias(): number;
  18268. /**
  18269. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18270. */
  18271. set bias(bias: number);
  18272. protected _normalBias: number;
  18273. /**
  18274. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18275. */
  18276. get normalBias(): number;
  18277. /**
  18278. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18279. */
  18280. set normalBias(normalBias: number);
  18281. protected _blurBoxOffset: number;
  18282. /**
  18283. * Gets the blur box offset: offset applied during the blur pass.
  18284. * Only useful if useKernelBlur = false
  18285. */
  18286. get blurBoxOffset(): number;
  18287. /**
  18288. * Sets the blur box offset: offset applied during the blur pass.
  18289. * Only useful if useKernelBlur = false
  18290. */
  18291. set blurBoxOffset(value: number);
  18292. protected _blurScale: number;
  18293. /**
  18294. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18295. * 2 means half of the size.
  18296. */
  18297. get blurScale(): number;
  18298. /**
  18299. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18300. * 2 means half of the size.
  18301. */
  18302. set blurScale(value: number);
  18303. protected _blurKernel: number;
  18304. /**
  18305. * Gets the blur kernel: kernel size of the blur pass.
  18306. * Only useful if useKernelBlur = true
  18307. */
  18308. get blurKernel(): number;
  18309. /**
  18310. * Sets the blur kernel: kernel size of the blur pass.
  18311. * Only useful if useKernelBlur = true
  18312. */
  18313. set blurKernel(value: number);
  18314. protected _useKernelBlur: boolean;
  18315. /**
  18316. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18317. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18318. */
  18319. get useKernelBlur(): boolean;
  18320. /**
  18321. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18322. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18323. */
  18324. set useKernelBlur(value: boolean);
  18325. protected _depthScale: number;
  18326. /**
  18327. * Gets the depth scale used in ESM mode.
  18328. */
  18329. get depthScale(): number;
  18330. /**
  18331. * Sets the depth scale used in ESM mode.
  18332. * This can override the scale stored on the light.
  18333. */
  18334. set depthScale(value: number);
  18335. protected _validateFilter(filter: number): number;
  18336. protected _filter: number;
  18337. /**
  18338. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18339. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18340. */
  18341. get filter(): number;
  18342. /**
  18343. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18344. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18345. */
  18346. set filter(value: number);
  18347. /**
  18348. * Gets if the current filter is set to Poisson Sampling.
  18349. */
  18350. get usePoissonSampling(): boolean;
  18351. /**
  18352. * Sets the current filter to Poisson Sampling.
  18353. */
  18354. set usePoissonSampling(value: boolean);
  18355. /**
  18356. * Gets if the current filter is set to ESM.
  18357. */
  18358. get useExponentialShadowMap(): boolean;
  18359. /**
  18360. * Sets the current filter is to ESM.
  18361. */
  18362. set useExponentialShadowMap(value: boolean);
  18363. /**
  18364. * Gets if the current filter is set to filtered ESM.
  18365. */
  18366. get useBlurExponentialShadowMap(): boolean;
  18367. /**
  18368. * Gets if the current filter is set to filtered ESM.
  18369. */
  18370. set useBlurExponentialShadowMap(value: boolean);
  18371. /**
  18372. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18373. * exponential to prevent steep falloff artifacts).
  18374. */
  18375. get useCloseExponentialShadowMap(): boolean;
  18376. /**
  18377. * Sets the current filter to "close ESM" (using the inverse of the
  18378. * exponential to prevent steep falloff artifacts).
  18379. */
  18380. set useCloseExponentialShadowMap(value: boolean);
  18381. /**
  18382. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18383. * exponential to prevent steep falloff artifacts).
  18384. */
  18385. get useBlurCloseExponentialShadowMap(): boolean;
  18386. /**
  18387. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18388. * exponential to prevent steep falloff artifacts).
  18389. */
  18390. set useBlurCloseExponentialShadowMap(value: boolean);
  18391. /**
  18392. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18393. */
  18394. get usePercentageCloserFiltering(): boolean;
  18395. /**
  18396. * Sets the current filter to "PCF" (percentage closer filtering).
  18397. */
  18398. set usePercentageCloserFiltering(value: boolean);
  18399. protected _filteringQuality: number;
  18400. /**
  18401. * Gets the PCF or PCSS Quality.
  18402. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18403. */
  18404. get filteringQuality(): number;
  18405. /**
  18406. * Sets the PCF or PCSS Quality.
  18407. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18408. */
  18409. set filteringQuality(filteringQuality: number);
  18410. /**
  18411. * Gets if the current filter is set to "PCSS" (contact hardening).
  18412. */
  18413. get useContactHardeningShadow(): boolean;
  18414. /**
  18415. * Sets the current filter to "PCSS" (contact hardening).
  18416. */
  18417. set useContactHardeningShadow(value: boolean);
  18418. protected _contactHardeningLightSizeUVRatio: number;
  18419. /**
  18420. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18421. * Using a ratio helps keeping shape stability independently of the map size.
  18422. *
  18423. * It does not account for the light projection as it was having too much
  18424. * instability during the light setup or during light position changes.
  18425. *
  18426. * Only valid if useContactHardeningShadow is true.
  18427. */
  18428. get contactHardeningLightSizeUVRatio(): number;
  18429. /**
  18430. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18431. * Using a ratio helps keeping shape stability independently of the map size.
  18432. *
  18433. * It does not account for the light projection as it was having too much
  18434. * instability during the light setup or during light position changes.
  18435. *
  18436. * Only valid if useContactHardeningShadow is true.
  18437. */
  18438. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18439. protected _darkness: number;
  18440. /** Gets or sets the actual darkness of a shadow */
  18441. get darkness(): number;
  18442. set darkness(value: number);
  18443. /**
  18444. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18445. * 0 means strongest and 1 would means no shadow.
  18446. * @returns the darkness.
  18447. */
  18448. getDarkness(): number;
  18449. /**
  18450. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18451. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18452. * @returns the shadow generator allowing fluent coding.
  18453. */
  18454. setDarkness(darkness: number): ShadowGenerator;
  18455. protected _transparencyShadow: boolean;
  18456. /** Gets or sets the ability to have transparent shadow */
  18457. get transparencyShadow(): boolean;
  18458. set transparencyShadow(value: boolean);
  18459. /**
  18460. * Sets the ability to have transparent shadow (boolean).
  18461. * @param transparent True if transparent else False
  18462. * @returns the shadow generator allowing fluent coding
  18463. */
  18464. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18465. /**
  18466. * Enables or disables shadows with varying strength based on the transparency
  18467. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18468. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18469. * mesh.visibility * alphaTexture.a
  18470. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18471. */
  18472. enableSoftTransparentShadow: boolean;
  18473. protected _shadowMap: Nullable<RenderTargetTexture>;
  18474. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18475. /**
  18476. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18477. * @returns The render target texture if present otherwise, null
  18478. */
  18479. getShadowMap(): Nullable<RenderTargetTexture>;
  18480. /**
  18481. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18482. * @returns The render target texture if the shadow map is present otherwise, null
  18483. */
  18484. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18485. /**
  18486. * Gets the class name of that object
  18487. * @returns "ShadowGenerator"
  18488. */
  18489. getClassName(): string;
  18490. /**
  18491. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18492. * @param mesh Mesh to add
  18493. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18494. * @returns the Shadow Generator itself
  18495. */
  18496. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18497. /**
  18498. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18499. * @param mesh Mesh to remove
  18500. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18501. * @returns the Shadow Generator itself
  18502. */
  18503. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18504. /**
  18505. * Controls the extent to which the shadows fade out at the edge of the frustum
  18506. */
  18507. frustumEdgeFalloff: number;
  18508. protected _light: IShadowLight;
  18509. /**
  18510. * Returns the associated light object.
  18511. * @returns the light generating the shadow
  18512. */
  18513. getLight(): IShadowLight;
  18514. /**
  18515. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18516. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18517. * It might on the other hand introduce peter panning.
  18518. */
  18519. forceBackFacesOnly: boolean;
  18520. protected _scene: Scene;
  18521. protected _lightDirection: Vector3;
  18522. protected _effect: Effect;
  18523. protected _viewMatrix: Matrix;
  18524. protected _projectionMatrix: Matrix;
  18525. protected _transformMatrix: Matrix;
  18526. protected _cachedPosition: Vector3;
  18527. protected _cachedDirection: Vector3;
  18528. protected _cachedDefines: string;
  18529. protected _currentRenderID: number;
  18530. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18531. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18532. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18533. protected _blurPostProcesses: PostProcess[];
  18534. protected _mapSize: number;
  18535. protected _currentFaceIndex: number;
  18536. protected _currentFaceIndexCache: number;
  18537. protected _textureType: number;
  18538. protected _defaultTextureMatrix: Matrix;
  18539. protected _storedUniqueId: Nullable<number>;
  18540. /** @hidden */
  18541. static _SceneComponentInitialization: (scene: Scene) => void;
  18542. /**
  18543. * Gets or sets the size of the texture what stores the shadows
  18544. */
  18545. get mapSize(): number;
  18546. set mapSize(size: number);
  18547. /**
  18548. * Creates a ShadowGenerator object.
  18549. * A ShadowGenerator is the required tool to use the shadows.
  18550. * Each light casting shadows needs to use its own ShadowGenerator.
  18551. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18552. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18553. * @param light The light object generating the shadows.
  18554. * @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.
  18555. */
  18556. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18557. protected _initializeGenerator(): void;
  18558. protected _createTargetRenderTexture(): void;
  18559. protected _initializeShadowMap(): void;
  18560. protected _initializeBlurRTTAndPostProcesses(): void;
  18561. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18562. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18563. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18564. protected _applyFilterValues(): void;
  18565. /**
  18566. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18567. * @param onCompiled Callback triggered at the and of the effects compilation
  18568. * @param options Sets of optional options forcing the compilation with different modes
  18569. */
  18570. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18571. useInstances: boolean;
  18572. }>): void;
  18573. /**
  18574. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18575. * @param options Sets of optional options forcing the compilation with different modes
  18576. * @returns A promise that resolves when the compilation completes
  18577. */
  18578. forceCompilationAsync(options?: Partial<{
  18579. useInstances: boolean;
  18580. }>): Promise<void>;
  18581. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18582. private _prepareShadowDefines;
  18583. /**
  18584. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18585. * @param subMesh The submesh we want to render in the shadow map
  18586. * @param useInstances Defines wether will draw in the map using instances
  18587. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18588. * @returns true if ready otherwise, false
  18589. */
  18590. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18591. /**
  18592. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18593. * @param defines Defines of the material we want to update
  18594. * @param lightIndex Index of the light in the enabled light list of the material
  18595. */
  18596. prepareDefines(defines: any, lightIndex: number): void;
  18597. /**
  18598. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18599. * defined in the generator but impacting the effect).
  18600. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18601. * @param effect The effect we are binfing the information for
  18602. */
  18603. bindShadowLight(lightIndex: string, effect: Effect): void;
  18604. /**
  18605. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18606. * (eq to shadow prjection matrix * light transform matrix)
  18607. * @returns The transform matrix used to create the shadow map
  18608. */
  18609. getTransformMatrix(): Matrix;
  18610. /**
  18611. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18612. * Cube and 2D textures for instance.
  18613. */
  18614. recreateShadowMap(): void;
  18615. protected _disposeBlurPostProcesses(): void;
  18616. protected _disposeRTTandPostProcesses(): void;
  18617. /**
  18618. * Disposes the ShadowGenerator.
  18619. * Returns nothing.
  18620. */
  18621. dispose(): void;
  18622. /**
  18623. * Serializes the shadow generator setup to a json object.
  18624. * @returns The serialized JSON object
  18625. */
  18626. serialize(): any;
  18627. /**
  18628. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18629. * @param parsedShadowGenerator The JSON object to parse
  18630. * @param scene The scene to create the shadow map for
  18631. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18632. * @returns The parsed shadow generator
  18633. */
  18634. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18635. }
  18636. }
  18637. declare module "babylonjs/Lights/light" {
  18638. import { Nullable } from "babylonjs/types";
  18639. import { Scene } from "babylonjs/scene";
  18640. import { Vector3 } from "babylonjs/Maths/math.vector";
  18641. import { Color3 } from "babylonjs/Maths/math.color";
  18642. import { Node } from "babylonjs/node";
  18643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18644. import { Effect } from "babylonjs/Materials/effect";
  18645. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18646. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18647. /**
  18648. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18649. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18650. * 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.
  18651. */
  18652. export abstract class Light extends Node {
  18653. /**
  18654. * Falloff Default: light is falling off following the material specification:
  18655. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18656. */
  18657. static readonly FALLOFF_DEFAULT: number;
  18658. /**
  18659. * Falloff Physical: light is falling off following the inverse squared distance law.
  18660. */
  18661. static readonly FALLOFF_PHYSICAL: number;
  18662. /**
  18663. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18664. * to enhance interoperability with other engines.
  18665. */
  18666. static readonly FALLOFF_GLTF: number;
  18667. /**
  18668. * Falloff Standard: light is falling off like in the standard material
  18669. * to enhance interoperability with other materials.
  18670. */
  18671. static readonly FALLOFF_STANDARD: number;
  18672. /**
  18673. * If every light affecting the material is in this lightmapMode,
  18674. * material.lightmapTexture adds or multiplies
  18675. * (depends on material.useLightmapAsShadowmap)
  18676. * after every other light calculations.
  18677. */
  18678. static readonly LIGHTMAP_DEFAULT: number;
  18679. /**
  18680. * material.lightmapTexture as only diffuse lighting from this light
  18681. * adds only specular lighting from this light
  18682. * adds dynamic shadows
  18683. */
  18684. static readonly LIGHTMAP_SPECULAR: number;
  18685. /**
  18686. * material.lightmapTexture as only lighting
  18687. * no light calculation from this light
  18688. * only adds dynamic shadows from this light
  18689. */
  18690. static readonly LIGHTMAP_SHADOWSONLY: number;
  18691. /**
  18692. * Each light type uses the default quantity according to its type:
  18693. * point/spot lights use luminous intensity
  18694. * directional lights use illuminance
  18695. */
  18696. static readonly INTENSITYMODE_AUTOMATIC: number;
  18697. /**
  18698. * lumen (lm)
  18699. */
  18700. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18701. /**
  18702. * candela (lm/sr)
  18703. */
  18704. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18705. /**
  18706. * lux (lm/m^2)
  18707. */
  18708. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18709. /**
  18710. * nit (cd/m^2)
  18711. */
  18712. static readonly INTENSITYMODE_LUMINANCE: number;
  18713. /**
  18714. * Light type const id of the point light.
  18715. */
  18716. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18717. /**
  18718. * Light type const id of the directional light.
  18719. */
  18720. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18721. /**
  18722. * Light type const id of the spot light.
  18723. */
  18724. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18725. /**
  18726. * Light type const id of the hemispheric light.
  18727. */
  18728. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18729. /**
  18730. * Diffuse gives the basic color to an object.
  18731. */
  18732. diffuse: Color3;
  18733. /**
  18734. * Specular produces a highlight color on an object.
  18735. * Note: This is note affecting PBR materials.
  18736. */
  18737. specular: Color3;
  18738. /**
  18739. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18740. * falling off base on range or angle.
  18741. * This can be set to any values in Light.FALLOFF_x.
  18742. *
  18743. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18744. * other types of materials.
  18745. */
  18746. falloffType: number;
  18747. /**
  18748. * Strength of the light.
  18749. * Note: By default it is define in the framework own unit.
  18750. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18751. */
  18752. intensity: number;
  18753. private _range;
  18754. protected _inverseSquaredRange: number;
  18755. /**
  18756. * Defines how far from the source the light is impacting in scene units.
  18757. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18758. */
  18759. get range(): number;
  18760. /**
  18761. * Defines how far from the source the light is impacting in scene units.
  18762. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18763. */
  18764. set range(value: number);
  18765. /**
  18766. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18767. * of light.
  18768. */
  18769. private _photometricScale;
  18770. private _intensityMode;
  18771. /**
  18772. * Gets the photometric scale used to interpret the intensity.
  18773. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18774. */
  18775. get intensityMode(): number;
  18776. /**
  18777. * Sets the photometric scale used to interpret the intensity.
  18778. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18779. */
  18780. set intensityMode(value: number);
  18781. private _radius;
  18782. /**
  18783. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18784. */
  18785. get radius(): number;
  18786. /**
  18787. * sets the light radius used by PBR Materials to simulate soft area lights.
  18788. */
  18789. set radius(value: number);
  18790. private _renderPriority;
  18791. /**
  18792. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18793. * exceeding the number allowed of the materials.
  18794. */
  18795. renderPriority: number;
  18796. private _shadowEnabled;
  18797. /**
  18798. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18799. * the current shadow generator.
  18800. */
  18801. get shadowEnabled(): boolean;
  18802. /**
  18803. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18804. * the current shadow generator.
  18805. */
  18806. set shadowEnabled(value: boolean);
  18807. private _includedOnlyMeshes;
  18808. /**
  18809. * Gets the only meshes impacted by this light.
  18810. */
  18811. get includedOnlyMeshes(): AbstractMesh[];
  18812. /**
  18813. * Sets the only meshes impacted by this light.
  18814. */
  18815. set includedOnlyMeshes(value: AbstractMesh[]);
  18816. private _excludedMeshes;
  18817. /**
  18818. * Gets the meshes not impacted by this light.
  18819. */
  18820. get excludedMeshes(): AbstractMesh[];
  18821. /**
  18822. * Sets the meshes not impacted by this light.
  18823. */
  18824. set excludedMeshes(value: AbstractMesh[]);
  18825. private _excludeWithLayerMask;
  18826. /**
  18827. * Gets the layer id use to find what meshes are not impacted by the light.
  18828. * Inactive if 0
  18829. */
  18830. get excludeWithLayerMask(): number;
  18831. /**
  18832. * Sets the layer id use to find what meshes are not impacted by the light.
  18833. * Inactive if 0
  18834. */
  18835. set excludeWithLayerMask(value: number);
  18836. private _includeOnlyWithLayerMask;
  18837. /**
  18838. * Gets the layer id use to find what meshes are impacted by the light.
  18839. * Inactive if 0
  18840. */
  18841. get includeOnlyWithLayerMask(): number;
  18842. /**
  18843. * Sets the layer id use to find what meshes are impacted by the light.
  18844. * Inactive if 0
  18845. */
  18846. set includeOnlyWithLayerMask(value: number);
  18847. private _lightmapMode;
  18848. /**
  18849. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18850. */
  18851. get lightmapMode(): number;
  18852. /**
  18853. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18854. */
  18855. set lightmapMode(value: number);
  18856. /**
  18857. * Shadow generator associted to the light.
  18858. * @hidden Internal use only.
  18859. */
  18860. _shadowGenerator: Nullable<IShadowGenerator>;
  18861. /**
  18862. * @hidden Internal use only.
  18863. */
  18864. _excludedMeshesIds: string[];
  18865. /**
  18866. * @hidden Internal use only.
  18867. */
  18868. _includedOnlyMeshesIds: string[];
  18869. /**
  18870. * The current light unifom buffer.
  18871. * @hidden Internal use only.
  18872. */
  18873. _uniformBuffer: UniformBuffer;
  18874. /** @hidden */
  18875. _renderId: number;
  18876. /**
  18877. * Creates a Light object in the scene.
  18878. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18879. * @param name The firendly name of the light
  18880. * @param scene The scene the light belongs too
  18881. */
  18882. constructor(name: string, scene: Scene);
  18883. protected abstract _buildUniformLayout(): void;
  18884. /**
  18885. * Sets the passed Effect "effect" with the Light information.
  18886. * @param effect The effect to update
  18887. * @param lightIndex The index of the light in the effect to update
  18888. * @returns The light
  18889. */
  18890. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18891. /**
  18892. * Sets the passed Effect "effect" with the Light textures.
  18893. * @param effect The effect to update
  18894. * @param lightIndex The index of the light in the effect to update
  18895. * @returns The light
  18896. */
  18897. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18898. /**
  18899. * Binds the lights information from the scene to the effect for the given mesh.
  18900. * @param lightIndex Light index
  18901. * @param scene The scene where the light belongs to
  18902. * @param effect The effect we are binding the data to
  18903. * @param useSpecular Defines if specular is supported
  18904. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18905. */
  18906. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18907. /**
  18908. * Sets the passed Effect "effect" with the Light information.
  18909. * @param effect The effect to update
  18910. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18911. * @returns The light
  18912. */
  18913. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18914. /**
  18915. * Returns the string "Light".
  18916. * @returns the class name
  18917. */
  18918. getClassName(): string;
  18919. /** @hidden */
  18920. readonly _isLight: boolean;
  18921. /**
  18922. * Converts the light information to a readable string for debug purpose.
  18923. * @param fullDetails Supports for multiple levels of logging within scene loading
  18924. * @returns the human readable light info
  18925. */
  18926. toString(fullDetails?: boolean): string;
  18927. /** @hidden */
  18928. protected _syncParentEnabledState(): void;
  18929. /**
  18930. * Set the enabled state of this node.
  18931. * @param value - the new enabled state
  18932. */
  18933. setEnabled(value: boolean): void;
  18934. /**
  18935. * Returns the Light associated shadow generator if any.
  18936. * @return the associated shadow generator.
  18937. */
  18938. getShadowGenerator(): Nullable<IShadowGenerator>;
  18939. /**
  18940. * Returns a Vector3, the absolute light position in the World.
  18941. * @returns the world space position of the light
  18942. */
  18943. getAbsolutePosition(): Vector3;
  18944. /**
  18945. * Specifies if the light will affect the passed mesh.
  18946. * @param mesh The mesh to test against the light
  18947. * @return true the mesh is affected otherwise, false.
  18948. */
  18949. canAffectMesh(mesh: AbstractMesh): boolean;
  18950. /**
  18951. * Sort function to order lights for rendering.
  18952. * @param a First Light object to compare to second.
  18953. * @param b Second Light object to compare first.
  18954. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18955. */
  18956. static CompareLightsPriority(a: Light, b: Light): number;
  18957. /**
  18958. * Releases resources associated with this node.
  18959. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18960. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18961. */
  18962. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18963. /**
  18964. * Returns the light type ID (integer).
  18965. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18966. */
  18967. getTypeID(): number;
  18968. /**
  18969. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18970. * @returns the scaled intensity in intensity mode unit
  18971. */
  18972. getScaledIntensity(): number;
  18973. /**
  18974. * Returns a new Light object, named "name", from the current one.
  18975. * @param name The name of the cloned light
  18976. * @param newParent The parent of this light, if it has one
  18977. * @returns the new created light
  18978. */
  18979. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18980. /**
  18981. * Serializes the current light into a Serialization object.
  18982. * @returns the serialized object.
  18983. */
  18984. serialize(): any;
  18985. /**
  18986. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18987. * This new light is named "name" and added to the passed scene.
  18988. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18989. * @param name The friendly name of the light
  18990. * @param scene The scene the new light will belong to
  18991. * @returns the constructor function
  18992. */
  18993. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18994. /**
  18995. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18996. * @param parsedLight The JSON representation of the light
  18997. * @param scene The scene to create the parsed light in
  18998. * @returns the created light after parsing
  18999. */
  19000. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  19001. private _hookArrayForExcluded;
  19002. private _hookArrayForIncludedOnly;
  19003. private _resyncMeshes;
  19004. /**
  19005. * Forces the meshes to update their light related information in their rendering used effects
  19006. * @hidden Internal Use Only
  19007. */
  19008. _markMeshesAsLightDirty(): void;
  19009. /**
  19010. * Recomputes the cached photometric scale if needed.
  19011. */
  19012. private _computePhotometricScale;
  19013. /**
  19014. * Returns the Photometric Scale according to the light type and intensity mode.
  19015. */
  19016. private _getPhotometricScale;
  19017. /**
  19018. * Reorder the light in the scene according to their defined priority.
  19019. * @hidden Internal Use Only
  19020. */
  19021. _reorderLightsInScene(): void;
  19022. /**
  19023. * Prepares the list of defines specific to the light type.
  19024. * @param defines the list of defines
  19025. * @param lightIndex defines the index of the light for the effect
  19026. */
  19027. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19028. }
  19029. }
  19030. declare module "babylonjs/Materials/prePassConfiguration" {
  19031. import { Matrix } from "babylonjs/Maths/math.vector";
  19032. import { Mesh } from "babylonjs/Meshes/mesh";
  19033. import { Scene } from "babylonjs/scene";
  19034. import { Effect } from "babylonjs/Materials/effect";
  19035. /**
  19036. * Configuration needed for prepass-capable materials
  19037. */
  19038. export class PrePassConfiguration {
  19039. /**
  19040. * Previous world matrices of meshes carrying this material
  19041. * Used for computing velocity
  19042. */
  19043. previousWorldMatrices: {
  19044. [index: number]: Matrix;
  19045. };
  19046. /**
  19047. * Previous view project matrix
  19048. * Used for computing velocity
  19049. */
  19050. previousViewProjection: Matrix;
  19051. /**
  19052. * Previous bones of meshes carrying this material
  19053. * Used for computing velocity
  19054. */
  19055. previousBones: {
  19056. [index: number]: Float32Array;
  19057. };
  19058. /**
  19059. * Add the required uniforms to the current list.
  19060. * @param uniforms defines the current uniform list.
  19061. */
  19062. static AddUniforms(uniforms: string[]): void;
  19063. /**
  19064. * Add the required samplers to the current list.
  19065. * @param samplers defines the current sampler list.
  19066. */
  19067. static AddSamplers(samplers: string[]): void;
  19068. /**
  19069. * Binds the material data.
  19070. * @param effect defines the effect to update
  19071. * @param scene defines the scene the material belongs to.
  19072. * @param mesh The mesh
  19073. * @param world World matrix of this mesh
  19074. * @param isFrozen Is the material frozen
  19075. */
  19076. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19077. }
  19078. }
  19079. declare module "babylonjs/Cameras/targetCamera" {
  19080. import { Nullable } from "babylonjs/types";
  19081. import { Camera } from "babylonjs/Cameras/camera";
  19082. import { Scene } from "babylonjs/scene";
  19083. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19084. /**
  19085. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19086. * This is the base of the follow, arc rotate cameras and Free camera
  19087. * @see https://doc.babylonjs.com/features/cameras
  19088. */
  19089. export class TargetCamera extends Camera {
  19090. private static _RigCamTransformMatrix;
  19091. private static _TargetTransformMatrix;
  19092. private static _TargetFocalPoint;
  19093. private _tmpUpVector;
  19094. private _tmpTargetVector;
  19095. /**
  19096. * Define the current direction the camera is moving to
  19097. */
  19098. cameraDirection: Vector3;
  19099. /**
  19100. * Define the current rotation the camera is rotating to
  19101. */
  19102. cameraRotation: Vector2;
  19103. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19104. ignoreParentScaling: boolean;
  19105. /**
  19106. * When set, the up vector of the camera will be updated by the rotation of the camera
  19107. */
  19108. updateUpVectorFromRotation: boolean;
  19109. private _tmpQuaternion;
  19110. /**
  19111. * Define the current rotation of the camera
  19112. */
  19113. rotation: Vector3;
  19114. /**
  19115. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19116. */
  19117. rotationQuaternion: Quaternion;
  19118. /**
  19119. * Define the current speed of the camera
  19120. */
  19121. speed: number;
  19122. /**
  19123. * Add constraint to the camera to prevent it to move freely in all directions and
  19124. * around all axis.
  19125. */
  19126. noRotationConstraint: boolean;
  19127. /**
  19128. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19129. * panning
  19130. */
  19131. invertRotation: boolean;
  19132. /**
  19133. * Speed multiplier for inverse camera panning
  19134. */
  19135. inverseRotationSpeed: number;
  19136. /**
  19137. * Define the current target of the camera as an object or a position.
  19138. */
  19139. lockedTarget: any;
  19140. /** @hidden */
  19141. _currentTarget: Vector3;
  19142. /** @hidden */
  19143. _initialFocalDistance: number;
  19144. /** @hidden */
  19145. _viewMatrix: Matrix;
  19146. /** @hidden */
  19147. _camMatrix: Matrix;
  19148. /** @hidden */
  19149. _cameraTransformMatrix: Matrix;
  19150. /** @hidden */
  19151. _cameraRotationMatrix: Matrix;
  19152. /** @hidden */
  19153. _referencePoint: Vector3;
  19154. /** @hidden */
  19155. _transformedReferencePoint: Vector3;
  19156. /** @hidden */
  19157. _reset: () => void;
  19158. private _defaultUp;
  19159. /**
  19160. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19161. * This is the base of the follow, arc rotate cameras and Free camera
  19162. * @see https://doc.babylonjs.com/features/cameras
  19163. * @param name Defines the name of the camera in the scene
  19164. * @param position Defines the start position of the camera in the scene
  19165. * @param scene Defines the scene the camera belongs to
  19166. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19167. */
  19168. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19169. /**
  19170. * Gets the position in front of the camera at a given distance.
  19171. * @param distance The distance from the camera we want the position to be
  19172. * @returns the position
  19173. */
  19174. getFrontPosition(distance: number): Vector3;
  19175. /** @hidden */
  19176. _getLockedTargetPosition(): Nullable<Vector3>;
  19177. private _storedPosition;
  19178. private _storedRotation;
  19179. private _storedRotationQuaternion;
  19180. /**
  19181. * Store current camera state of the camera (fov, position, rotation, etc..)
  19182. * @returns the camera
  19183. */
  19184. storeState(): Camera;
  19185. /**
  19186. * Restored camera state. You must call storeState() first
  19187. * @returns whether it was successful or not
  19188. * @hidden
  19189. */
  19190. _restoreStateValues(): boolean;
  19191. /** @hidden */
  19192. _initCache(): void;
  19193. /** @hidden */
  19194. _updateCache(ignoreParentClass?: boolean): void;
  19195. /** @hidden */
  19196. _isSynchronizedViewMatrix(): boolean;
  19197. /** @hidden */
  19198. _computeLocalCameraSpeed(): number;
  19199. /**
  19200. * Defines the target the camera should look at.
  19201. * @param target Defines the new target as a Vector or a mesh
  19202. */
  19203. setTarget(target: Vector3): void;
  19204. /**
  19205. * Defines the target point of the camera.
  19206. * The camera looks towards it form the radius distance.
  19207. */
  19208. get target(): Vector3;
  19209. set target(value: Vector3);
  19210. /**
  19211. * Return the current target position of the camera. This value is expressed in local space.
  19212. * @returns the target position
  19213. */
  19214. getTarget(): Vector3;
  19215. /** @hidden */
  19216. _decideIfNeedsToMove(): boolean;
  19217. /** @hidden */
  19218. _updatePosition(): void;
  19219. /** @hidden */
  19220. _checkInputs(): void;
  19221. protected _updateCameraRotationMatrix(): void;
  19222. /**
  19223. * 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)
  19224. * @returns the current camera
  19225. */
  19226. private _rotateUpVectorWithCameraRotationMatrix;
  19227. private _cachedRotationZ;
  19228. private _cachedQuaternionRotationZ;
  19229. /** @hidden */
  19230. _getViewMatrix(): Matrix;
  19231. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19232. /**
  19233. * @hidden
  19234. */
  19235. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19236. /**
  19237. * @hidden
  19238. */
  19239. _updateRigCameras(): void;
  19240. private _getRigCamPositionAndTarget;
  19241. /**
  19242. * Gets the current object class name.
  19243. * @return the class name
  19244. */
  19245. getClassName(): string;
  19246. }
  19247. }
  19248. declare module "babylonjs/Events/keyboardEvents" {
  19249. /**
  19250. * Gather the list of keyboard event types as constants.
  19251. */
  19252. export class KeyboardEventTypes {
  19253. /**
  19254. * The keydown event is fired when a key becomes active (pressed).
  19255. */
  19256. static readonly KEYDOWN: number;
  19257. /**
  19258. * The keyup event is fired when a key has been released.
  19259. */
  19260. static readonly KEYUP: number;
  19261. }
  19262. /**
  19263. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19264. */
  19265. export class KeyboardInfo {
  19266. /**
  19267. * Defines the type of event (KeyboardEventTypes)
  19268. */
  19269. type: number;
  19270. /**
  19271. * Defines the related dom event
  19272. */
  19273. event: KeyboardEvent;
  19274. /**
  19275. * Instantiates a new keyboard info.
  19276. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19277. * @param type Defines the type of event (KeyboardEventTypes)
  19278. * @param event Defines the related dom event
  19279. */
  19280. constructor(
  19281. /**
  19282. * Defines the type of event (KeyboardEventTypes)
  19283. */
  19284. type: number,
  19285. /**
  19286. * Defines the related dom event
  19287. */
  19288. event: KeyboardEvent);
  19289. }
  19290. /**
  19291. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19292. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19293. */
  19294. export class KeyboardInfoPre extends KeyboardInfo {
  19295. /**
  19296. * Defines the type of event (KeyboardEventTypes)
  19297. */
  19298. type: number;
  19299. /**
  19300. * Defines the related dom event
  19301. */
  19302. event: KeyboardEvent;
  19303. /**
  19304. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19305. */
  19306. skipOnPointerObservable: boolean;
  19307. /**
  19308. * Instantiates a new keyboard pre info.
  19309. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19310. * @param type Defines the type of event (KeyboardEventTypes)
  19311. * @param event Defines the related dom event
  19312. */
  19313. constructor(
  19314. /**
  19315. * Defines the type of event (KeyboardEventTypes)
  19316. */
  19317. type: number,
  19318. /**
  19319. * Defines the related dom event
  19320. */
  19321. event: KeyboardEvent);
  19322. }
  19323. }
  19324. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19325. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19326. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19327. /**
  19328. * Manage the keyboard inputs to control the movement of a free camera.
  19329. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19330. */
  19331. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19332. /**
  19333. * Defines the camera the input is attached to.
  19334. */
  19335. camera: FreeCamera;
  19336. /**
  19337. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19338. */
  19339. keysUp: number[];
  19340. /**
  19341. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19342. */
  19343. keysUpward: number[];
  19344. /**
  19345. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19346. */
  19347. keysDown: number[];
  19348. /**
  19349. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19350. */
  19351. keysDownward: number[];
  19352. /**
  19353. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19354. */
  19355. keysLeft: number[];
  19356. /**
  19357. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19358. */
  19359. keysRight: number[];
  19360. private _keys;
  19361. private _onCanvasBlurObserver;
  19362. private _onKeyboardObserver;
  19363. private _engine;
  19364. private _scene;
  19365. /**
  19366. * Attach the input controls to a specific dom element to get the input from.
  19367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19368. */
  19369. attachControl(noPreventDefault?: boolean): void;
  19370. /**
  19371. * Detach the current controls from the specified dom element.
  19372. */
  19373. detachControl(): void;
  19374. /**
  19375. * Update the current camera state depending on the inputs that have been used this frame.
  19376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19377. */
  19378. checkInputs(): void;
  19379. /**
  19380. * Gets the class name of the current intput.
  19381. * @returns the class name
  19382. */
  19383. getClassName(): string;
  19384. /** @hidden */
  19385. _onLostFocus(): void;
  19386. /**
  19387. * Get the friendly name associated with the input class.
  19388. * @returns the input friendly name
  19389. */
  19390. getSimpleName(): string;
  19391. }
  19392. }
  19393. declare module "babylonjs/Events/pointerEvents" {
  19394. import { Nullable } from "babylonjs/types";
  19395. import { Vector2 } from "babylonjs/Maths/math.vector";
  19396. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19397. import { Ray } from "babylonjs/Culling/ray";
  19398. /**
  19399. * Gather the list of pointer event types as constants.
  19400. */
  19401. export class PointerEventTypes {
  19402. /**
  19403. * 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.
  19404. */
  19405. static readonly POINTERDOWN: number;
  19406. /**
  19407. * The pointerup event is fired when a pointer is no longer active.
  19408. */
  19409. static readonly POINTERUP: number;
  19410. /**
  19411. * The pointermove event is fired when a pointer changes coordinates.
  19412. */
  19413. static readonly POINTERMOVE: number;
  19414. /**
  19415. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19416. */
  19417. static readonly POINTERWHEEL: number;
  19418. /**
  19419. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19420. */
  19421. static readonly POINTERPICK: number;
  19422. /**
  19423. * The pointertap event is fired when a the object has been touched and released without drag.
  19424. */
  19425. static readonly POINTERTAP: number;
  19426. /**
  19427. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19428. */
  19429. static readonly POINTERDOUBLETAP: number;
  19430. }
  19431. /**
  19432. * Base class of pointer info types.
  19433. */
  19434. export class PointerInfoBase {
  19435. /**
  19436. * Defines the type of event (PointerEventTypes)
  19437. */
  19438. type: number;
  19439. /**
  19440. * Defines the related dom event
  19441. */
  19442. event: PointerEvent | MouseWheelEvent;
  19443. /**
  19444. * Instantiates the base class of pointers info.
  19445. * @param type Defines the type of event (PointerEventTypes)
  19446. * @param event Defines the related dom event
  19447. */
  19448. constructor(
  19449. /**
  19450. * Defines the type of event (PointerEventTypes)
  19451. */
  19452. type: number,
  19453. /**
  19454. * Defines the related dom event
  19455. */
  19456. event: PointerEvent | MouseWheelEvent);
  19457. }
  19458. /**
  19459. * This class is used to store pointer related info for the onPrePointerObservable event.
  19460. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19461. */
  19462. export class PointerInfoPre extends PointerInfoBase {
  19463. /**
  19464. * Ray from a pointer if availible (eg. 6dof controller)
  19465. */
  19466. ray: Nullable<Ray>;
  19467. /**
  19468. * Defines the local position of the pointer on the canvas.
  19469. */
  19470. localPosition: Vector2;
  19471. /**
  19472. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19473. */
  19474. skipOnPointerObservable: boolean;
  19475. /**
  19476. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19477. * @param type Defines the type of event (PointerEventTypes)
  19478. * @param event Defines the related dom event
  19479. * @param localX Defines the local x coordinates of the pointer when the event occured
  19480. * @param localY Defines the local y coordinates of the pointer when the event occured
  19481. */
  19482. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19483. }
  19484. /**
  19485. * This type contains all the data related to a pointer event in Babylon.js.
  19486. * 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.
  19487. */
  19488. export class PointerInfo extends PointerInfoBase {
  19489. /**
  19490. * Defines the picking info associated to the info (if any)\
  19491. */
  19492. pickInfo: Nullable<PickingInfo>;
  19493. /**
  19494. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19495. * @param type Defines the type of event (PointerEventTypes)
  19496. * @param event Defines the related dom event
  19497. * @param pickInfo Defines the picking info associated to the info (if any)\
  19498. */
  19499. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19500. /**
  19501. * Defines the picking info associated to the info (if any)\
  19502. */
  19503. pickInfo: Nullable<PickingInfo>);
  19504. }
  19505. /**
  19506. * Data relating to a touch event on the screen.
  19507. */
  19508. export interface PointerTouch {
  19509. /**
  19510. * X coordinate of touch.
  19511. */
  19512. x: number;
  19513. /**
  19514. * Y coordinate of touch.
  19515. */
  19516. y: number;
  19517. /**
  19518. * Id of touch. Unique for each finger.
  19519. */
  19520. pointerId: number;
  19521. /**
  19522. * Event type passed from DOM.
  19523. */
  19524. type: any;
  19525. }
  19526. }
  19527. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19528. import { Observable } from "babylonjs/Misc/observable";
  19529. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19530. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19531. /**
  19532. * Manage the mouse inputs to control the movement of a free camera.
  19533. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19534. */
  19535. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19536. /**
  19537. * Define if touch is enabled in the mouse input
  19538. */
  19539. touchEnabled: boolean;
  19540. /**
  19541. * Defines the camera the input is attached to.
  19542. */
  19543. camera: FreeCamera;
  19544. /**
  19545. * Defines the buttons associated with the input to handle camera move.
  19546. */
  19547. buttons: number[];
  19548. /**
  19549. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19550. */
  19551. angularSensibility: number;
  19552. private _pointerInput;
  19553. private _onMouseMove;
  19554. private _observer;
  19555. private previousPosition;
  19556. /**
  19557. * Observable for when a pointer move event occurs containing the move offset
  19558. */
  19559. onPointerMovedObservable: Observable<{
  19560. offsetX: number;
  19561. offsetY: number;
  19562. }>;
  19563. /**
  19564. * @hidden
  19565. * If the camera should be rotated automatically based on pointer movement
  19566. */
  19567. _allowCameraRotation: boolean;
  19568. /**
  19569. * Manage the mouse inputs to control the movement of a free camera.
  19570. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19571. * @param touchEnabled Defines if touch is enabled or not
  19572. */
  19573. constructor(
  19574. /**
  19575. * Define if touch is enabled in the mouse input
  19576. */
  19577. touchEnabled?: boolean);
  19578. /**
  19579. * Attach the input controls to a specific dom element to get the input from.
  19580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19581. */
  19582. attachControl(noPreventDefault?: boolean): void;
  19583. /**
  19584. * Called on JS contextmenu event.
  19585. * Override this method to provide functionality.
  19586. */
  19587. protected onContextMenu(evt: PointerEvent): void;
  19588. /**
  19589. * Detach the current controls from the specified dom element.
  19590. */
  19591. detachControl(): void;
  19592. /**
  19593. * Gets the class name of the current intput.
  19594. * @returns the class name
  19595. */
  19596. getClassName(): string;
  19597. /**
  19598. * Get the friendly name associated with the input class.
  19599. * @returns the input friendly name
  19600. */
  19601. getSimpleName(): string;
  19602. }
  19603. }
  19604. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  19605. import { Observable } from "babylonjs/Misc/observable";
  19606. import { Camera } from "babylonjs/Cameras/camera";
  19607. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19608. /**
  19609. * Base class for mouse wheel input..
  19610. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  19611. * for example usage.
  19612. */
  19613. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  19614. /**
  19615. * Defines the camera the input is attached to.
  19616. */
  19617. abstract camera: Camera;
  19618. /**
  19619. * How fast is the camera moves in relation to X axis mouseWheel events.
  19620. * Use negative value to reverse direction.
  19621. */
  19622. wheelPrecisionX: number;
  19623. /**
  19624. * How fast is the camera moves in relation to Y axis mouseWheel events.
  19625. * Use negative value to reverse direction.
  19626. */
  19627. wheelPrecisionY: number;
  19628. /**
  19629. * How fast is the camera moves in relation to Z axis mouseWheel events.
  19630. * Use negative value to reverse direction.
  19631. */
  19632. wheelPrecisionZ: number;
  19633. /**
  19634. * Observable for when a mouse wheel move event occurs.
  19635. */
  19636. onChangedObservable: Observable<{
  19637. wheelDeltaX: number;
  19638. wheelDeltaY: number;
  19639. wheelDeltaZ: number;
  19640. }>;
  19641. private _wheel;
  19642. private _observer;
  19643. /**
  19644. * Attach the input controls to a specific dom element to get the input from.
  19645. * @param noPreventDefault Defines whether event caught by the controls
  19646. * should call preventdefault().
  19647. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19648. */
  19649. attachControl(noPreventDefault?: boolean): void;
  19650. /**
  19651. * Detach the current controls from the specified dom element.
  19652. */
  19653. detachControl(): void;
  19654. /**
  19655. * Called for each rendered frame.
  19656. */
  19657. checkInputs(): void;
  19658. /**
  19659. * Gets the class name of the current intput.
  19660. * @returns the class name
  19661. */
  19662. getClassName(): string;
  19663. /**
  19664. * Get the friendly name associated with the input class.
  19665. * @returns the input friendly name
  19666. */
  19667. getSimpleName(): string;
  19668. /**
  19669. * Incremental value of multiple mouse wheel movements of the X axis.
  19670. * Should be zero-ed when read.
  19671. */
  19672. protected _wheelDeltaX: number;
  19673. /**
  19674. * Incremental value of multiple mouse wheel movements of the Y axis.
  19675. * Should be zero-ed when read.
  19676. */
  19677. protected _wheelDeltaY: number;
  19678. /**
  19679. * Incremental value of multiple mouse wheel movements of the Z axis.
  19680. * Should be zero-ed when read.
  19681. */
  19682. protected _wheelDeltaZ: number;
  19683. /**
  19684. * Firefox uses a different scheme to report scroll distances to other
  19685. * browsers. Rather than use complicated methods to calculate the exact
  19686. * multiple we need to apply, let's just cheat and use a constant.
  19687. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  19688. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  19689. */
  19690. private readonly _ffMultiplier;
  19691. /**
  19692. * Different event attributes for wheel data fall into a few set ranges.
  19693. * Some relevant but dated date here:
  19694. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  19695. */
  19696. private readonly _normalize;
  19697. }
  19698. }
  19699. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  19700. import { Nullable } from "babylonjs/types";
  19701. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19702. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  19703. import { Coordinate } from "babylonjs/Maths/math.axis";
  19704. /**
  19705. * Manage the mouse wheel inputs to control a free camera.
  19706. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19707. */
  19708. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  19709. /**
  19710. * Defines the camera the input is attached to.
  19711. */
  19712. camera: FreeCamera;
  19713. /**
  19714. * Gets the class name of the current input.
  19715. * @returns the class name
  19716. */
  19717. getClassName(): string;
  19718. /**
  19719. * Set which movement axis (relative to camera's orientation) the mouse
  19720. * wheel's X axis controls.
  19721. * @param axis The axis to be moved. Set null to clear.
  19722. */
  19723. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  19724. /**
  19725. * Get the configured movement axis (relative to camera's orientation) the
  19726. * mouse wheel's X axis controls.
  19727. * @returns The configured axis or null if none.
  19728. */
  19729. get wheelXMoveRelative(): Nullable<Coordinate>;
  19730. /**
  19731. * Set which movement axis (relative to camera's orientation) the mouse
  19732. * wheel's Y axis controls.
  19733. * @param axis The axis to be moved. Set null to clear.
  19734. */
  19735. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  19736. /**
  19737. * Get the configured movement axis (relative to camera's orientation) the
  19738. * mouse wheel's Y axis controls.
  19739. * @returns The configured axis or null if none.
  19740. */
  19741. get wheelYMoveRelative(): Nullable<Coordinate>;
  19742. /**
  19743. * Set which movement axis (relative to camera's orientation) the mouse
  19744. * wheel's Z axis controls.
  19745. * @param axis The axis to be moved. Set null to clear.
  19746. */
  19747. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  19748. /**
  19749. * Get the configured movement axis (relative to camera's orientation) the
  19750. * mouse wheel's Z axis controls.
  19751. * @returns The configured axis or null if none.
  19752. */
  19753. get wheelZMoveRelative(): Nullable<Coordinate>;
  19754. /**
  19755. * Set which rotation axis (relative to camera's orientation) the mouse
  19756. * wheel's X axis controls.
  19757. * @param axis The axis to be moved. Set null to clear.
  19758. */
  19759. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  19760. /**
  19761. * Get the configured rotation axis (relative to camera's orientation) the
  19762. * mouse wheel's X axis controls.
  19763. * @returns The configured axis or null if none.
  19764. */
  19765. get wheelXRotateRelative(): Nullable<Coordinate>;
  19766. /**
  19767. * Set which rotation axis (relative to camera's orientation) the mouse
  19768. * wheel's Y axis controls.
  19769. * @param axis The axis to be moved. Set null to clear.
  19770. */
  19771. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  19772. /**
  19773. * Get the configured rotation axis (relative to camera's orientation) the
  19774. * mouse wheel's Y axis controls.
  19775. * @returns The configured axis or null if none.
  19776. */
  19777. get wheelYRotateRelative(): Nullable<Coordinate>;
  19778. /**
  19779. * Set which rotation axis (relative to camera's orientation) the mouse
  19780. * wheel's Z axis controls.
  19781. * @param axis The axis to be moved. Set null to clear.
  19782. */
  19783. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  19784. /**
  19785. * Get the configured rotation axis (relative to camera's orientation) the
  19786. * mouse wheel's Z axis controls.
  19787. * @returns The configured axis or null if none.
  19788. */
  19789. get wheelZRotateRelative(): Nullable<Coordinate>;
  19790. /**
  19791. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  19792. * controls.
  19793. * @param axis The axis to be moved. Set null to clear.
  19794. */
  19795. set wheelXMoveScene(axis: Nullable<Coordinate>);
  19796. /**
  19797. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19798. * X axis controls.
  19799. * @returns The configured axis or null if none.
  19800. */
  19801. get wheelXMoveScene(): Nullable<Coordinate>;
  19802. /**
  19803. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  19804. * controls.
  19805. * @param axis The axis to be moved. Set null to clear.
  19806. */
  19807. set wheelYMoveScene(axis: Nullable<Coordinate>);
  19808. /**
  19809. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19810. * Y axis controls.
  19811. * @returns The configured axis or null if none.
  19812. */
  19813. get wheelYMoveScene(): Nullable<Coordinate>;
  19814. /**
  19815. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  19816. * controls.
  19817. * @param axis The axis to be moved. Set null to clear.
  19818. */
  19819. set wheelZMoveScene(axis: Nullable<Coordinate>);
  19820. /**
  19821. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19822. * Z axis controls.
  19823. * @returns The configured axis or null if none.
  19824. */
  19825. get wheelZMoveScene(): Nullable<Coordinate>;
  19826. /**
  19827. * Called for each rendered frame.
  19828. */
  19829. checkInputs(): void;
  19830. private _moveRelative;
  19831. private _rotateRelative;
  19832. private _moveScene;
  19833. /**
  19834. * These are set to the desired default behaviour.
  19835. */
  19836. private _wheelXAction;
  19837. private _wheelXActionCoordinate;
  19838. private _wheelYAction;
  19839. private _wheelYActionCoordinate;
  19840. private _wheelZAction;
  19841. private _wheelZActionCoordinate;
  19842. /**
  19843. * Update the camera according to any configured properties for the 3
  19844. * mouse-wheel axis.
  19845. */
  19846. private _updateCamera;
  19847. }
  19848. }
  19849. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19850. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19851. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19852. /**
  19853. * Manage the touch inputs to control the movement of a free camera.
  19854. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19855. */
  19856. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19857. /**
  19858. * Define if mouse events can be treated as touch events
  19859. */
  19860. allowMouse: boolean;
  19861. /**
  19862. * Defines the camera the input is attached to.
  19863. */
  19864. camera: FreeCamera;
  19865. /**
  19866. * Defines the touch sensibility for rotation.
  19867. * The higher the faster.
  19868. */
  19869. touchAngularSensibility: number;
  19870. /**
  19871. * Defines the touch sensibility for move.
  19872. * The higher the faster.
  19873. */
  19874. touchMoveSensibility: number;
  19875. private _offsetX;
  19876. private _offsetY;
  19877. private _pointerPressed;
  19878. private _pointerInput?;
  19879. private _observer;
  19880. private _onLostFocus;
  19881. /**
  19882. * Manage the touch inputs to control the movement of a free camera.
  19883. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19884. * @param allowMouse Defines if mouse events can be treated as touch events
  19885. */
  19886. constructor(
  19887. /**
  19888. * Define if mouse events can be treated as touch events
  19889. */
  19890. allowMouse?: boolean);
  19891. /**
  19892. * Attach the input controls to a specific dom element to get the input from.
  19893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19894. */
  19895. attachControl(noPreventDefault?: boolean): void;
  19896. /**
  19897. * Detach the current controls from the specified dom element.
  19898. * @param element Defines the element to stop listening the inputs from
  19899. */
  19900. detachControl(): void;
  19901. /**
  19902. * Update the current camera state depending on the inputs that have been used this frame.
  19903. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19904. */
  19905. checkInputs(): void;
  19906. /**
  19907. * Gets the class name of the current intput.
  19908. * @returns the class name
  19909. */
  19910. getClassName(): string;
  19911. /**
  19912. * Get the friendly name associated with the input class.
  19913. * @returns the input friendly name
  19914. */
  19915. getSimpleName(): string;
  19916. }
  19917. }
  19918. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19919. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19920. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19921. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19922. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  19923. import { Nullable } from "babylonjs/types";
  19924. /**
  19925. * Default Inputs manager for the FreeCamera.
  19926. * It groups all the default supported inputs for ease of use.
  19927. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19928. */
  19929. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19930. /**
  19931. * @hidden
  19932. */
  19933. _mouseInput: Nullable<FreeCameraMouseInput>;
  19934. /**
  19935. * @hidden
  19936. */
  19937. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  19938. /**
  19939. * Instantiates a new FreeCameraInputsManager.
  19940. * @param camera Defines the camera the inputs belong to
  19941. */
  19942. constructor(camera: FreeCamera);
  19943. /**
  19944. * Add keyboard input support to the input manager.
  19945. * @returns the current input manager
  19946. */
  19947. addKeyboard(): FreeCameraInputsManager;
  19948. /**
  19949. * Add mouse input support to the input manager.
  19950. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19951. * @returns the current input manager
  19952. */
  19953. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19954. /**
  19955. * Removes the mouse input support from the manager
  19956. * @returns the current input manager
  19957. */
  19958. removeMouse(): FreeCameraInputsManager;
  19959. /**
  19960. * Add mouse wheel input support to the input manager.
  19961. * @returns the current input manager
  19962. */
  19963. addMouseWheel(): FreeCameraInputsManager;
  19964. /**
  19965. * Removes the mouse wheel input support from the manager
  19966. * @returns the current input manager
  19967. */
  19968. removeMouseWheel(): FreeCameraInputsManager;
  19969. /**
  19970. * Add touch input support to the input manager.
  19971. * @returns the current input manager
  19972. */
  19973. addTouch(): FreeCameraInputsManager;
  19974. /**
  19975. * Remove all attached input methods from a camera
  19976. */
  19977. clear(): void;
  19978. }
  19979. }
  19980. declare module "babylonjs/Cameras/freeCamera" {
  19981. import { Vector3 } from "babylonjs/Maths/math.vector";
  19982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19983. import { Scene } from "babylonjs/scene";
  19984. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19985. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19986. /**
  19987. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19988. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19989. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19990. */
  19991. export class FreeCamera extends TargetCamera {
  19992. /**
  19993. * Define the collision ellipsoid of the camera.
  19994. * This is helpful to simulate a camera body like the player body around the camera
  19995. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19996. */
  19997. ellipsoid: Vector3;
  19998. /**
  19999. * Define an offset for the position of the ellipsoid around the camera.
  20000. * This can be helpful to determine the center of the body near the gravity center of the body
  20001. * instead of its head.
  20002. */
  20003. ellipsoidOffset: Vector3;
  20004. /**
  20005. * Enable or disable collisions of the camera with the rest of the scene objects.
  20006. */
  20007. checkCollisions: boolean;
  20008. /**
  20009. * Enable or disable gravity on the camera.
  20010. */
  20011. applyGravity: boolean;
  20012. /**
  20013. * Define the input manager associated to the camera.
  20014. */
  20015. inputs: FreeCameraInputsManager;
  20016. /**
  20017. * Gets the input sensibility for a mouse input. (default is 2000.0)
  20018. * Higher values reduce sensitivity.
  20019. */
  20020. get angularSensibility(): number;
  20021. /**
  20022. * Sets the input sensibility for a mouse input. (default is 2000.0)
  20023. * Higher values reduce sensitivity.
  20024. */
  20025. set angularSensibility(value: number);
  20026. /**
  20027. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  20028. */
  20029. get keysUp(): number[];
  20030. set keysUp(value: number[]);
  20031. /**
  20032. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  20033. */
  20034. get keysUpward(): number[];
  20035. set keysUpward(value: number[]);
  20036. /**
  20037. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  20038. */
  20039. get keysDown(): number[];
  20040. set keysDown(value: number[]);
  20041. /**
  20042. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  20043. */
  20044. get keysDownward(): number[];
  20045. set keysDownward(value: number[]);
  20046. /**
  20047. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  20048. */
  20049. get keysLeft(): number[];
  20050. set keysLeft(value: number[]);
  20051. /**
  20052. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  20053. */
  20054. get keysRight(): number[];
  20055. set keysRight(value: number[]);
  20056. /**
  20057. * Event raised when the camera collide with a mesh in the scene.
  20058. */
  20059. onCollide: (collidedMesh: AbstractMesh) => void;
  20060. private _collider;
  20061. private _needMoveForGravity;
  20062. private _oldPosition;
  20063. private _diffPosition;
  20064. private _newPosition;
  20065. /** @hidden */
  20066. _localDirection: Vector3;
  20067. /** @hidden */
  20068. _transformedDirection: Vector3;
  20069. /**
  20070. * Instantiates a Free Camera.
  20071. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  20072. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  20073. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  20074. * @param name Define the name of the camera in the scene
  20075. * @param position Define the start position of the camera in the scene
  20076. * @param scene Define the scene the camera belongs to
  20077. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  20078. */
  20079. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  20080. /**
  20081. * Attached controls to the current camera.
  20082. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20083. */
  20084. attachControl(noPreventDefault?: boolean): void;
  20085. /**
  20086. * Detach the current controls from the camera.
  20087. * The camera will stop reacting to inputs.
  20088. */
  20089. detachControl(): void;
  20090. private _collisionMask;
  20091. /**
  20092. * Define a collision mask to limit the list of object the camera can collide with
  20093. */
  20094. get collisionMask(): number;
  20095. set collisionMask(mask: number);
  20096. /** @hidden */
  20097. _collideWithWorld(displacement: Vector3): void;
  20098. private _onCollisionPositionChange;
  20099. /** @hidden */
  20100. _checkInputs(): void;
  20101. /** @hidden */
  20102. _decideIfNeedsToMove(): boolean;
  20103. /** @hidden */
  20104. _updatePosition(): void;
  20105. /**
  20106. * Destroy the camera and release the current resources hold by it.
  20107. */
  20108. dispose(): void;
  20109. /**
  20110. * Gets the current object class name.
  20111. * @return the class name
  20112. */
  20113. getClassName(): string;
  20114. }
  20115. }
  20116. declare module "babylonjs/Gamepads/gamepad" {
  20117. import { Observable } from "babylonjs/Misc/observable";
  20118. /**
  20119. * Represents a gamepad control stick position
  20120. */
  20121. export class StickValues {
  20122. /**
  20123. * The x component of the control stick
  20124. */
  20125. x: number;
  20126. /**
  20127. * The y component of the control stick
  20128. */
  20129. y: number;
  20130. /**
  20131. * Initializes the gamepad x and y control stick values
  20132. * @param x The x component of the gamepad control stick value
  20133. * @param y The y component of the gamepad control stick value
  20134. */
  20135. constructor(
  20136. /**
  20137. * The x component of the control stick
  20138. */
  20139. x: number,
  20140. /**
  20141. * The y component of the control stick
  20142. */
  20143. y: number);
  20144. }
  20145. /**
  20146. * An interface which manages callbacks for gamepad button changes
  20147. */
  20148. export interface GamepadButtonChanges {
  20149. /**
  20150. * Called when a gamepad has been changed
  20151. */
  20152. changed: boolean;
  20153. /**
  20154. * Called when a gamepad press event has been triggered
  20155. */
  20156. pressChanged: boolean;
  20157. /**
  20158. * Called when a touch event has been triggered
  20159. */
  20160. touchChanged: boolean;
  20161. /**
  20162. * Called when a value has changed
  20163. */
  20164. valueChanged: boolean;
  20165. }
  20166. /**
  20167. * Represents a gamepad
  20168. */
  20169. export class Gamepad {
  20170. /**
  20171. * The id of the gamepad
  20172. */
  20173. id: string;
  20174. /**
  20175. * The index of the gamepad
  20176. */
  20177. index: number;
  20178. /**
  20179. * The browser gamepad
  20180. */
  20181. browserGamepad: any;
  20182. /**
  20183. * Specifies what type of gamepad this represents
  20184. */
  20185. type: number;
  20186. private _leftStick;
  20187. private _rightStick;
  20188. /** @hidden */
  20189. _isConnected: boolean;
  20190. private _leftStickAxisX;
  20191. private _leftStickAxisY;
  20192. private _rightStickAxisX;
  20193. private _rightStickAxisY;
  20194. /**
  20195. * Triggered when the left control stick has been changed
  20196. */
  20197. private _onleftstickchanged;
  20198. /**
  20199. * Triggered when the right control stick has been changed
  20200. */
  20201. private _onrightstickchanged;
  20202. /**
  20203. * Represents a gamepad controller
  20204. */
  20205. static GAMEPAD: number;
  20206. /**
  20207. * Represents a generic controller
  20208. */
  20209. static GENERIC: number;
  20210. /**
  20211. * Represents an XBox controller
  20212. */
  20213. static XBOX: number;
  20214. /**
  20215. * Represents a pose-enabled controller
  20216. */
  20217. static POSE_ENABLED: number;
  20218. /**
  20219. * Represents an Dual Shock controller
  20220. */
  20221. static DUALSHOCK: number;
  20222. /**
  20223. * Specifies whether the left control stick should be Y-inverted
  20224. */
  20225. protected _invertLeftStickY: boolean;
  20226. /**
  20227. * Specifies if the gamepad has been connected
  20228. */
  20229. get isConnected(): boolean;
  20230. /**
  20231. * Initializes the gamepad
  20232. * @param id The id of the gamepad
  20233. * @param index The index of the gamepad
  20234. * @param browserGamepad The browser gamepad
  20235. * @param leftStickX The x component of the left joystick
  20236. * @param leftStickY The y component of the left joystick
  20237. * @param rightStickX The x component of the right joystick
  20238. * @param rightStickY The y component of the right joystick
  20239. */
  20240. constructor(
  20241. /**
  20242. * The id of the gamepad
  20243. */
  20244. id: string,
  20245. /**
  20246. * The index of the gamepad
  20247. */
  20248. index: number,
  20249. /**
  20250. * The browser gamepad
  20251. */
  20252. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  20253. /**
  20254. * Callback triggered when the left joystick has changed
  20255. * @param callback
  20256. */
  20257. onleftstickchanged(callback: (values: StickValues) => void): void;
  20258. /**
  20259. * Callback triggered when the right joystick has changed
  20260. * @param callback
  20261. */
  20262. onrightstickchanged(callback: (values: StickValues) => void): void;
  20263. /**
  20264. * Gets the left joystick
  20265. */
  20266. get leftStick(): StickValues;
  20267. /**
  20268. * Sets the left joystick values
  20269. */
  20270. set leftStick(newValues: StickValues);
  20271. /**
  20272. * Gets the right joystick
  20273. */
  20274. get rightStick(): StickValues;
  20275. /**
  20276. * Sets the right joystick value
  20277. */
  20278. set rightStick(newValues: StickValues);
  20279. /**
  20280. * Updates the gamepad joystick positions
  20281. */
  20282. update(): void;
  20283. /**
  20284. * Disposes the gamepad
  20285. */
  20286. dispose(): void;
  20287. }
  20288. /**
  20289. * Represents a generic gamepad
  20290. */
  20291. export class GenericPad extends Gamepad {
  20292. private _buttons;
  20293. private _onbuttondown;
  20294. private _onbuttonup;
  20295. /**
  20296. * Observable triggered when a button has been pressed
  20297. */
  20298. onButtonDownObservable: Observable<number>;
  20299. /**
  20300. * Observable triggered when a button has been released
  20301. */
  20302. onButtonUpObservable: Observable<number>;
  20303. /**
  20304. * Callback triggered when a button has been pressed
  20305. * @param callback Called when a button has been pressed
  20306. */
  20307. onbuttondown(callback: (buttonPressed: number) => void): void;
  20308. /**
  20309. * Callback triggered when a button has been released
  20310. * @param callback Called when a button has been released
  20311. */
  20312. onbuttonup(callback: (buttonReleased: number) => void): void;
  20313. /**
  20314. * Initializes the generic gamepad
  20315. * @param id The id of the generic gamepad
  20316. * @param index The index of the generic gamepad
  20317. * @param browserGamepad The browser gamepad
  20318. */
  20319. constructor(id: string, index: number, browserGamepad: any);
  20320. private _setButtonValue;
  20321. /**
  20322. * Updates the generic gamepad
  20323. */
  20324. update(): void;
  20325. /**
  20326. * Disposes the generic gamepad
  20327. */
  20328. dispose(): void;
  20329. }
  20330. }
  20331. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20332. import { Observable } from "babylonjs/Misc/observable";
  20333. import { Nullable } from "babylonjs/types";
  20334. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20335. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20337. import { Ray } from "babylonjs/Culling/ray";
  20338. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20339. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20340. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20341. /**
  20342. * Defines the types of pose enabled controllers that are supported
  20343. */
  20344. export enum PoseEnabledControllerType {
  20345. /**
  20346. * HTC Vive
  20347. */
  20348. VIVE = 0,
  20349. /**
  20350. * Oculus Rift
  20351. */
  20352. OCULUS = 1,
  20353. /**
  20354. * Windows mixed reality
  20355. */
  20356. WINDOWS = 2,
  20357. /**
  20358. * Samsung gear VR
  20359. */
  20360. GEAR_VR = 3,
  20361. /**
  20362. * Google Daydream
  20363. */
  20364. DAYDREAM = 4,
  20365. /**
  20366. * Generic
  20367. */
  20368. GENERIC = 5
  20369. }
  20370. /**
  20371. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20372. */
  20373. export interface MutableGamepadButton {
  20374. /**
  20375. * Value of the button/trigger
  20376. */
  20377. value: number;
  20378. /**
  20379. * If the button/trigger is currently touched
  20380. */
  20381. touched: boolean;
  20382. /**
  20383. * If the button/trigger is currently pressed
  20384. */
  20385. pressed: boolean;
  20386. }
  20387. /**
  20388. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20389. * @hidden
  20390. */
  20391. export interface ExtendedGamepadButton extends GamepadButton {
  20392. /**
  20393. * If the button/trigger is currently pressed
  20394. */
  20395. readonly pressed: boolean;
  20396. /**
  20397. * If the button/trigger is currently touched
  20398. */
  20399. readonly touched: boolean;
  20400. /**
  20401. * Value of the button/trigger
  20402. */
  20403. readonly value: number;
  20404. }
  20405. /** @hidden */
  20406. export interface _GamePadFactory {
  20407. /**
  20408. * Returns whether or not the current gamepad can be created for this type of controller.
  20409. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20410. * @returns true if it can be created, otherwise false
  20411. */
  20412. canCreate(gamepadInfo: any): boolean;
  20413. /**
  20414. * Creates a new instance of the Gamepad.
  20415. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20416. * @returns the new gamepad instance
  20417. */
  20418. create(gamepadInfo: any): Gamepad;
  20419. }
  20420. /**
  20421. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20422. */
  20423. export class PoseEnabledControllerHelper {
  20424. /** @hidden */
  20425. static _ControllerFactories: _GamePadFactory[];
  20426. /** @hidden */
  20427. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20428. /**
  20429. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20430. * @param vrGamepad the gamepad to initialized
  20431. * @returns a vr controller of the type the gamepad identified as
  20432. */
  20433. static InitiateController(vrGamepad: any): Gamepad;
  20434. }
  20435. /**
  20436. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20437. */
  20438. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20439. /**
  20440. * If the controller is used in a webXR session
  20441. */
  20442. isXR: boolean;
  20443. private _deviceRoomPosition;
  20444. private _deviceRoomRotationQuaternion;
  20445. /**
  20446. * The device position in babylon space
  20447. */
  20448. devicePosition: Vector3;
  20449. /**
  20450. * The device rotation in babylon space
  20451. */
  20452. deviceRotationQuaternion: Quaternion;
  20453. /**
  20454. * The scale factor of the device in babylon space
  20455. */
  20456. deviceScaleFactor: number;
  20457. /**
  20458. * (Likely devicePosition should be used instead) The device position in its room space
  20459. */
  20460. position: Vector3;
  20461. /**
  20462. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20463. */
  20464. rotationQuaternion: Quaternion;
  20465. /**
  20466. * The type of controller (Eg. Windows mixed reality)
  20467. */
  20468. controllerType: PoseEnabledControllerType;
  20469. protected _calculatedPosition: Vector3;
  20470. private _calculatedRotation;
  20471. /**
  20472. * The raw pose from the device
  20473. */
  20474. rawPose: DevicePose;
  20475. private _trackPosition;
  20476. private _maxRotationDistFromHeadset;
  20477. private _draggedRoomRotation;
  20478. /**
  20479. * @hidden
  20480. */
  20481. _disableTrackPosition(fixedPosition: Vector3): void;
  20482. /**
  20483. * Internal, the mesh attached to the controller
  20484. * @hidden
  20485. */
  20486. _mesh: Nullable<AbstractMesh>;
  20487. private _poseControlledCamera;
  20488. private _leftHandSystemQuaternion;
  20489. /**
  20490. * Internal, matrix used to convert room space to babylon space
  20491. * @hidden
  20492. */
  20493. _deviceToWorld: Matrix;
  20494. /**
  20495. * Node to be used when casting a ray from the controller
  20496. * @hidden
  20497. */
  20498. _pointingPoseNode: Nullable<TransformNode>;
  20499. /**
  20500. * Name of the child mesh that can be used to cast a ray from the controller
  20501. */
  20502. static readonly POINTING_POSE: string;
  20503. /**
  20504. * Creates a new PoseEnabledController from a gamepad
  20505. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20506. */
  20507. constructor(browserGamepad: any);
  20508. private _workingMatrix;
  20509. /**
  20510. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20511. */
  20512. update(): void;
  20513. /**
  20514. * Updates only the pose device and mesh without doing any button event checking
  20515. */
  20516. protected _updatePoseAndMesh(): void;
  20517. /**
  20518. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20519. * @param poseData raw pose fromthe device
  20520. */
  20521. updateFromDevice(poseData: DevicePose): void;
  20522. /**
  20523. * @hidden
  20524. */
  20525. _meshAttachedObservable: Observable<AbstractMesh>;
  20526. /**
  20527. * Attaches a mesh to the controller
  20528. * @param mesh the mesh to be attached
  20529. */
  20530. attachToMesh(mesh: AbstractMesh): void;
  20531. /**
  20532. * Attaches the controllers mesh to a camera
  20533. * @param camera the camera the mesh should be attached to
  20534. */
  20535. attachToPoseControlledCamera(camera: TargetCamera): void;
  20536. /**
  20537. * Disposes of the controller
  20538. */
  20539. dispose(): void;
  20540. /**
  20541. * The mesh that is attached to the controller
  20542. */
  20543. get mesh(): Nullable<AbstractMesh>;
  20544. /**
  20545. * Gets the ray of the controller in the direction the controller is pointing
  20546. * @param length the length the resulting ray should be
  20547. * @returns a ray in the direction the controller is pointing
  20548. */
  20549. getForwardRay(length?: number): Ray;
  20550. }
  20551. }
  20552. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20553. import { Observable } from "babylonjs/Misc/observable";
  20554. import { Scene } from "babylonjs/scene";
  20555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20556. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20557. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20558. import { Nullable } from "babylonjs/types";
  20559. /**
  20560. * Defines the WebVRController object that represents controllers tracked in 3D space
  20561. */
  20562. export abstract class WebVRController extends PoseEnabledController {
  20563. /**
  20564. * Internal, the default controller model for the controller
  20565. */
  20566. protected _defaultModel: Nullable<AbstractMesh>;
  20567. /**
  20568. * Fired when the trigger state has changed
  20569. */
  20570. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20571. /**
  20572. * Fired when the main button state has changed
  20573. */
  20574. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20575. /**
  20576. * Fired when the secondary button state has changed
  20577. */
  20578. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20579. /**
  20580. * Fired when the pad state has changed
  20581. */
  20582. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20583. /**
  20584. * Fired when controllers stick values have changed
  20585. */
  20586. onPadValuesChangedObservable: Observable<StickValues>;
  20587. /**
  20588. * Array of button availible on the controller
  20589. */
  20590. protected _buttons: Array<MutableGamepadButton>;
  20591. private _onButtonStateChange;
  20592. /**
  20593. * Fired when a controller button's state has changed
  20594. * @param callback the callback containing the button that was modified
  20595. */
  20596. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20597. /**
  20598. * X and Y axis corresponding to the controllers joystick
  20599. */
  20600. pad: StickValues;
  20601. /**
  20602. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20603. */
  20604. hand: string;
  20605. /**
  20606. * The default controller model for the controller
  20607. */
  20608. get defaultModel(): Nullable<AbstractMesh>;
  20609. /**
  20610. * Creates a new WebVRController from a gamepad
  20611. * @param vrGamepad the gamepad that the WebVRController should be created from
  20612. */
  20613. constructor(vrGamepad: any);
  20614. /**
  20615. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20616. */
  20617. update(): void;
  20618. /**
  20619. * Function to be called when a button is modified
  20620. */
  20621. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20622. /**
  20623. * Loads a mesh and attaches it to the controller
  20624. * @param scene the scene the mesh should be added to
  20625. * @param meshLoaded callback for when the mesh has been loaded
  20626. */
  20627. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20628. private _setButtonValue;
  20629. private _changes;
  20630. private _checkChanges;
  20631. /**
  20632. * Disposes of th webVRCOntroller
  20633. */
  20634. dispose(): void;
  20635. }
  20636. }
  20637. declare module "babylonjs/Lights/hemisphericLight" {
  20638. import { Nullable } from "babylonjs/types";
  20639. import { Scene } from "babylonjs/scene";
  20640. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20641. import { Color3 } from "babylonjs/Maths/math.color";
  20642. import { Effect } from "babylonjs/Materials/effect";
  20643. import { Light } from "babylonjs/Lights/light";
  20644. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20645. /**
  20646. * The HemisphericLight simulates the ambient environment light,
  20647. * so the passed direction is the light reflection direction, not the incoming direction.
  20648. */
  20649. export class HemisphericLight extends Light {
  20650. /**
  20651. * The groundColor is the light in the opposite direction to the one specified during creation.
  20652. * 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.
  20653. */
  20654. groundColor: Color3;
  20655. /**
  20656. * The light reflection direction, not the incoming direction.
  20657. */
  20658. direction: Vector3;
  20659. /**
  20660. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20661. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20662. * The HemisphericLight can't cast shadows.
  20663. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20664. * @param name The friendly name of the light
  20665. * @param direction The direction of the light reflection
  20666. * @param scene The scene the light belongs to
  20667. */
  20668. constructor(name: string, direction: Vector3, scene: Scene);
  20669. protected _buildUniformLayout(): void;
  20670. /**
  20671. * Returns the string "HemisphericLight".
  20672. * @return The class name
  20673. */
  20674. getClassName(): string;
  20675. /**
  20676. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20677. * Returns the updated direction.
  20678. * @param target The target the direction should point to
  20679. * @return The computed direction
  20680. */
  20681. setDirectionToTarget(target: Vector3): Vector3;
  20682. /**
  20683. * Returns the shadow generator associated to the light.
  20684. * @returns Always null for hemispheric lights because it does not support shadows.
  20685. */
  20686. getShadowGenerator(): Nullable<IShadowGenerator>;
  20687. /**
  20688. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20689. * @param effect The effect to update
  20690. * @param lightIndex The index of the light in the effect to update
  20691. * @returns The hemispheric light
  20692. */
  20693. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20694. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20695. /**
  20696. * Computes the world matrix of the node
  20697. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20698. * @param useWasUpdatedFlag defines a reserved property
  20699. * @returns the world matrix
  20700. */
  20701. computeWorldMatrix(): Matrix;
  20702. /**
  20703. * Returns the integer 3.
  20704. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20705. */
  20706. getTypeID(): number;
  20707. /**
  20708. * Prepares the list of defines specific to the light type.
  20709. * @param defines the list of defines
  20710. * @param lightIndex defines the index of the light for the effect
  20711. */
  20712. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20713. }
  20714. }
  20715. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20716. /** @hidden */
  20717. export var vrMultiviewToSingleviewPixelShader: {
  20718. name: string;
  20719. shader: string;
  20720. };
  20721. }
  20722. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20723. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20724. import { Scene } from "babylonjs/scene";
  20725. /**
  20726. * Renders to multiple views with a single draw call
  20727. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20728. */
  20729. export class MultiviewRenderTarget extends RenderTargetTexture {
  20730. /**
  20731. * Creates a multiview render target
  20732. * @param scene scene used with the render target
  20733. * @param size the size of the render target (used for each view)
  20734. */
  20735. constructor(scene: Scene, size?: number | {
  20736. width: number;
  20737. height: number;
  20738. } | {
  20739. ratio: number;
  20740. });
  20741. /**
  20742. * @hidden
  20743. * @param faceIndex the face index, if its a cube texture
  20744. */
  20745. _bindFrameBuffer(faceIndex?: number): void;
  20746. /**
  20747. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20748. * @returns the view count
  20749. */
  20750. getViewCount(): number;
  20751. }
  20752. }
  20753. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20754. import { Camera } from "babylonjs/Cameras/camera";
  20755. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20756. import { Nullable } from "babylonjs/types";
  20757. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20758. import { Matrix } from "babylonjs/Maths/math.vector";
  20759. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20760. module "babylonjs/Engines/engine" {
  20761. interface Engine {
  20762. /**
  20763. * Creates a new multiview render target
  20764. * @param width defines the width of the texture
  20765. * @param height defines the height of the texture
  20766. * @returns the created multiview texture
  20767. */
  20768. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20769. /**
  20770. * Binds a multiview framebuffer to be drawn to
  20771. * @param multiviewTexture texture to bind
  20772. */
  20773. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20774. }
  20775. }
  20776. module "babylonjs/Cameras/camera" {
  20777. interface Camera {
  20778. /**
  20779. * @hidden
  20780. * 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)
  20781. */
  20782. _useMultiviewToSingleView: boolean;
  20783. /**
  20784. * @hidden
  20785. * 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)
  20786. */
  20787. _multiviewTexture: Nullable<RenderTargetTexture>;
  20788. /**
  20789. * @hidden
  20790. * ensures the multiview texture of the camera exists and has the specified width/height
  20791. * @param width height to set on the multiview texture
  20792. * @param height width to set on the multiview texture
  20793. */
  20794. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20795. }
  20796. }
  20797. module "babylonjs/scene" {
  20798. interface Scene {
  20799. /** @hidden */
  20800. _transformMatrixR: Matrix;
  20801. /** @hidden */
  20802. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20803. /** @hidden */
  20804. _createMultiviewUbo(): void;
  20805. /** @hidden */
  20806. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20807. /** @hidden */
  20808. _renderMultiviewToSingleView(camera: Camera): void;
  20809. }
  20810. }
  20811. }
  20812. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20813. import { Camera } from "babylonjs/Cameras/camera";
  20814. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20815. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20816. import "babylonjs/Engines/Extensions/engine.multiview";
  20817. /**
  20818. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20819. * This will not be used for webXR as it supports displaying texture arrays directly
  20820. */
  20821. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20822. /**
  20823. * Gets a string identifying the name of the class
  20824. * @returns "VRMultiviewToSingleviewPostProcess" string
  20825. */
  20826. getClassName(): string;
  20827. /**
  20828. * Initializes a VRMultiviewToSingleview
  20829. * @param name name of the post process
  20830. * @param camera camera to be applied to
  20831. * @param scaleFactor scaling factor to the size of the output texture
  20832. */
  20833. constructor(name: string, camera: Camera, scaleFactor: number);
  20834. }
  20835. }
  20836. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20837. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20838. import { Nullable } from "babylonjs/types";
  20839. import { Size } from "babylonjs/Maths/math.size";
  20840. import { Observable } from "babylonjs/Misc/observable";
  20841. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20842. /**
  20843. * Interface used to define additional presentation attributes
  20844. */
  20845. export interface IVRPresentationAttributes {
  20846. /**
  20847. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20848. */
  20849. highRefreshRate: boolean;
  20850. /**
  20851. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20852. */
  20853. foveationLevel: number;
  20854. }
  20855. module "babylonjs/Engines/engine" {
  20856. interface Engine {
  20857. /** @hidden */
  20858. _vrDisplay: any;
  20859. /** @hidden */
  20860. _vrSupported: boolean;
  20861. /** @hidden */
  20862. _oldSize: Size;
  20863. /** @hidden */
  20864. _oldHardwareScaleFactor: number;
  20865. /** @hidden */
  20866. _vrExclusivePointerMode: boolean;
  20867. /** @hidden */
  20868. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20869. /** @hidden */
  20870. _onVRDisplayPointerRestricted: () => void;
  20871. /** @hidden */
  20872. _onVRDisplayPointerUnrestricted: () => void;
  20873. /** @hidden */
  20874. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20875. /** @hidden */
  20876. _onVrDisplayDisconnect: Nullable<() => void>;
  20877. /** @hidden */
  20878. _onVrDisplayPresentChange: Nullable<() => void>;
  20879. /**
  20880. * Observable signaled when VR display mode changes
  20881. */
  20882. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20883. /**
  20884. * Observable signaled when VR request present is complete
  20885. */
  20886. onVRRequestPresentComplete: Observable<boolean>;
  20887. /**
  20888. * Observable signaled when VR request present starts
  20889. */
  20890. onVRRequestPresentStart: Observable<Engine>;
  20891. /**
  20892. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20893. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20894. */
  20895. isInVRExclusivePointerMode: boolean;
  20896. /**
  20897. * Gets a boolean indicating if a webVR device was detected
  20898. * @returns true if a webVR device was detected
  20899. */
  20900. isVRDevicePresent(): boolean;
  20901. /**
  20902. * Gets the current webVR device
  20903. * @returns the current webVR device (or null)
  20904. */
  20905. getVRDevice(): any;
  20906. /**
  20907. * Initializes a webVR display and starts listening to display change events
  20908. * The onVRDisplayChangedObservable will be notified upon these changes
  20909. * @returns A promise containing a VRDisplay and if vr is supported
  20910. */
  20911. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20912. /** @hidden */
  20913. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20914. /**
  20915. * Gets or sets the presentation attributes used to configure VR rendering
  20916. */
  20917. vrPresentationAttributes?: IVRPresentationAttributes;
  20918. /**
  20919. * Call this function to switch to webVR mode
  20920. * Will do nothing if webVR is not supported or if there is no webVR device
  20921. * @param options the webvr options provided to the camera. mainly used for multiview
  20922. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20923. */
  20924. enableVR(options: WebVROptions): void;
  20925. /** @hidden */
  20926. _onVRFullScreenTriggered(): void;
  20927. }
  20928. }
  20929. }
  20930. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20931. import { Nullable } from "babylonjs/types";
  20932. import { Observable } from "babylonjs/Misc/observable";
  20933. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20934. import { Scene } from "babylonjs/scene";
  20935. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20936. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20937. import { Node } from "babylonjs/node";
  20938. import { Ray } from "babylonjs/Culling/ray";
  20939. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20940. import "babylonjs/Engines/Extensions/engine.webVR";
  20941. /**
  20942. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20943. * IMPORTANT!! The data is right-hand data.
  20944. * @export
  20945. * @interface DevicePose
  20946. */
  20947. export interface DevicePose {
  20948. /**
  20949. * The position of the device, values in array are [x,y,z].
  20950. */
  20951. readonly position: Nullable<Float32Array>;
  20952. /**
  20953. * The linearVelocity of the device, values in array are [x,y,z].
  20954. */
  20955. readonly linearVelocity: Nullable<Float32Array>;
  20956. /**
  20957. * The linearAcceleration of the device, values in array are [x,y,z].
  20958. */
  20959. readonly linearAcceleration: Nullable<Float32Array>;
  20960. /**
  20961. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20962. */
  20963. readonly orientation: Nullable<Float32Array>;
  20964. /**
  20965. * The angularVelocity of the device, values in array are [x,y,z].
  20966. */
  20967. readonly angularVelocity: Nullable<Float32Array>;
  20968. /**
  20969. * The angularAcceleration of the device, values in array are [x,y,z].
  20970. */
  20971. readonly angularAcceleration: Nullable<Float32Array>;
  20972. }
  20973. /**
  20974. * Interface representing a pose controlled object in Babylon.
  20975. * A pose controlled object has both regular pose values as well as pose values
  20976. * from an external device such as a VR head mounted display
  20977. */
  20978. export interface PoseControlled {
  20979. /**
  20980. * The position of the object in babylon space.
  20981. */
  20982. position: Vector3;
  20983. /**
  20984. * The rotation quaternion of the object in babylon space.
  20985. */
  20986. rotationQuaternion: Quaternion;
  20987. /**
  20988. * The position of the device in babylon space.
  20989. */
  20990. devicePosition?: Vector3;
  20991. /**
  20992. * The rotation quaternion of the device in babylon space.
  20993. */
  20994. deviceRotationQuaternion: Quaternion;
  20995. /**
  20996. * The raw pose coming from the device.
  20997. */
  20998. rawPose: Nullable<DevicePose>;
  20999. /**
  21000. * The scale of the device to be used when translating from device space to babylon space.
  21001. */
  21002. deviceScaleFactor: number;
  21003. /**
  21004. * Updates the poseControlled values based on the input device pose.
  21005. * @param poseData the pose data to update the object with
  21006. */
  21007. updateFromDevice(poseData: DevicePose): void;
  21008. }
  21009. /**
  21010. * Set of options to customize the webVRCamera
  21011. */
  21012. export interface WebVROptions {
  21013. /**
  21014. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  21015. */
  21016. trackPosition?: boolean;
  21017. /**
  21018. * Sets the scale of the vrDevice in babylon space. (default: 1)
  21019. */
  21020. positionScale?: number;
  21021. /**
  21022. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  21023. */
  21024. displayName?: string;
  21025. /**
  21026. * Should the native controller meshes be initialized. (default: true)
  21027. */
  21028. controllerMeshes?: boolean;
  21029. /**
  21030. * Creating a default HemiLight only on controllers. (default: true)
  21031. */
  21032. defaultLightingOnControllers?: boolean;
  21033. /**
  21034. * If you don't want to use the default VR button of the helper. (default: false)
  21035. */
  21036. useCustomVRButton?: boolean;
  21037. /**
  21038. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  21039. */
  21040. customVRButton?: HTMLButtonElement;
  21041. /**
  21042. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  21043. */
  21044. rayLength?: number;
  21045. /**
  21046. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  21047. */
  21048. defaultHeight?: number;
  21049. /**
  21050. * If multiview should be used if availible (default: false)
  21051. */
  21052. useMultiview?: boolean;
  21053. }
  21054. /**
  21055. * This represents a WebVR camera.
  21056. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  21057. * @example https://doc.babylonjs.com/how_to/webvr_camera
  21058. */
  21059. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  21060. private webVROptions;
  21061. /**
  21062. * @hidden
  21063. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  21064. */
  21065. _vrDevice: any;
  21066. /**
  21067. * The rawPose of the vrDevice.
  21068. */
  21069. rawPose: Nullable<DevicePose>;
  21070. private _onVREnabled;
  21071. private _specsVersion;
  21072. private _attached;
  21073. private _frameData;
  21074. protected _descendants: Array<Node>;
  21075. private _deviceRoomPosition;
  21076. /** @hidden */
  21077. _deviceRoomRotationQuaternion: Quaternion;
  21078. private _standingMatrix;
  21079. /**
  21080. * Represents device position in babylon space.
  21081. */
  21082. devicePosition: Vector3;
  21083. /**
  21084. * Represents device rotation in babylon space.
  21085. */
  21086. deviceRotationQuaternion: Quaternion;
  21087. /**
  21088. * The scale of the device to be used when translating from device space to babylon space.
  21089. */
  21090. deviceScaleFactor: number;
  21091. private _deviceToWorld;
  21092. private _worldToDevice;
  21093. /**
  21094. * References to the webVR controllers for the vrDevice.
  21095. */
  21096. controllers: Array<WebVRController>;
  21097. /**
  21098. * Emits an event when a controller is attached.
  21099. */
  21100. onControllersAttachedObservable: Observable<WebVRController[]>;
  21101. /**
  21102. * Emits an event when a controller's mesh has been loaded;
  21103. */
  21104. onControllerMeshLoadedObservable: Observable<WebVRController>;
  21105. /**
  21106. * Emits an event when the HMD's pose has been updated.
  21107. */
  21108. onPoseUpdatedFromDeviceObservable: Observable<any>;
  21109. private _poseSet;
  21110. /**
  21111. * If the rig cameras be used as parent instead of this camera.
  21112. */
  21113. rigParenting: boolean;
  21114. private _lightOnControllers;
  21115. private _defaultHeight?;
  21116. /**
  21117. * Instantiates a WebVRFreeCamera.
  21118. * @param name The name of the WebVRFreeCamera
  21119. * @param position The starting anchor position for the camera
  21120. * @param scene The scene the camera belongs to
  21121. * @param webVROptions a set of customizable options for the webVRCamera
  21122. */
  21123. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  21124. /**
  21125. * Gets the device distance from the ground in meters.
  21126. * @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.
  21127. */
  21128. deviceDistanceToRoomGround(): number;
  21129. /**
  21130. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  21131. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  21132. */
  21133. useStandingMatrix(callback?: (bool: boolean) => void): void;
  21134. /**
  21135. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  21136. * @returns A promise with a boolean set to if the standing matrix is supported.
  21137. */
  21138. useStandingMatrixAsync(): Promise<boolean>;
  21139. /**
  21140. * Disposes the camera
  21141. */
  21142. dispose(): void;
  21143. /**
  21144. * Gets a vrController by name.
  21145. * @param name The name of the controller to retreive
  21146. * @returns the controller matching the name specified or null if not found
  21147. */
  21148. getControllerByName(name: string): Nullable<WebVRController>;
  21149. private _leftController;
  21150. /**
  21151. * The controller corresponding to the users left hand.
  21152. */
  21153. get leftController(): Nullable<WebVRController>;
  21154. private _rightController;
  21155. /**
  21156. * The controller corresponding to the users right hand.
  21157. */
  21158. get rightController(): Nullable<WebVRController>;
  21159. /**
  21160. * Casts a ray forward from the vrCamera's gaze.
  21161. * @param length Length of the ray (default: 100)
  21162. * @returns the ray corresponding to the gaze
  21163. */
  21164. getForwardRay(length?: number): Ray;
  21165. /**
  21166. * @hidden
  21167. * Updates the camera based on device's frame data
  21168. */
  21169. _checkInputs(): void;
  21170. /**
  21171. * Updates the poseControlled values based on the input device pose.
  21172. * @param poseData Pose coming from the device
  21173. */
  21174. updateFromDevice(poseData: DevicePose): void;
  21175. private _detachIfAttached;
  21176. /**
  21177. * WebVR's attach control will start broadcasting frames to the device.
  21178. * Note that in certain browsers (chrome for example) this function must be called
  21179. * within a user-interaction callback. Example:
  21180. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  21181. *
  21182. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  21183. */
  21184. attachControl(noPreventDefault?: boolean): void;
  21185. /**
  21186. * Detaches the camera from the html element and disables VR
  21187. */
  21188. detachControl(): void;
  21189. /**
  21190. * @returns the name of this class
  21191. */
  21192. getClassName(): string;
  21193. /**
  21194. * Calls resetPose on the vrDisplay
  21195. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  21196. */
  21197. resetToCurrentRotation(): void;
  21198. /**
  21199. * @hidden
  21200. * Updates the rig cameras (left and right eye)
  21201. */
  21202. _updateRigCameras(): void;
  21203. private _workingVector;
  21204. private _oneVector;
  21205. private _workingMatrix;
  21206. private updateCacheCalled;
  21207. private _correctPositionIfNotTrackPosition;
  21208. /**
  21209. * @hidden
  21210. * Updates the cached values of the camera
  21211. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  21212. */
  21213. _updateCache(ignoreParentClass?: boolean): void;
  21214. /**
  21215. * @hidden
  21216. * Get current device position in babylon world
  21217. */
  21218. _computeDevicePosition(): void;
  21219. /**
  21220. * Updates the current device position and rotation in the babylon world
  21221. */
  21222. update(): void;
  21223. /**
  21224. * @hidden
  21225. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  21226. * @returns an identity matrix
  21227. */
  21228. _getViewMatrix(): Matrix;
  21229. private _tmpMatrix;
  21230. /**
  21231. * This function is called by the two RIG cameras.
  21232. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  21233. * @hidden
  21234. */
  21235. _getWebVRViewMatrix(): Matrix;
  21236. /** @hidden */
  21237. _getWebVRProjectionMatrix(): Matrix;
  21238. private _onGamepadConnectedObserver;
  21239. private _onGamepadDisconnectedObserver;
  21240. private _updateCacheWhenTrackingDisabledObserver;
  21241. /**
  21242. * Initializes the controllers and their meshes
  21243. */
  21244. initControllers(): void;
  21245. }
  21246. }
  21247. declare module "babylonjs/Materials/materialHelper" {
  21248. import { Nullable } from "babylonjs/types";
  21249. import { Scene } from "babylonjs/scene";
  21250. import { Engine } from "babylonjs/Engines/engine";
  21251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21252. import { Light } from "babylonjs/Lights/light";
  21253. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  21254. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21255. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  21256. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21257. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21258. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21259. /**
  21260. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  21261. *
  21262. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  21263. *
  21264. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  21265. */
  21266. export class MaterialHelper {
  21267. /**
  21268. * Bind the current view position to an effect.
  21269. * @param effect The effect to be bound
  21270. * @param scene The scene the eyes position is used from
  21271. * @param variableName name of the shader variable that will hold the eye position
  21272. */
  21273. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  21274. /**
  21275. * Helps preparing the defines values about the UVs in used in the effect.
  21276. * UVs are shared as much as we can accross channels in the shaders.
  21277. * @param texture The texture we are preparing the UVs for
  21278. * @param defines The defines to update
  21279. * @param key The channel key "diffuse", "specular"... used in the shader
  21280. */
  21281. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  21282. /**
  21283. * Binds a texture matrix value to its corrsponding uniform
  21284. * @param texture The texture to bind the matrix for
  21285. * @param uniformBuffer The uniform buffer receivin the data
  21286. * @param key The channel key "diffuse", "specular"... used in the shader
  21287. */
  21288. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  21289. /**
  21290. * Gets the current status of the fog (should it be enabled?)
  21291. * @param mesh defines the mesh to evaluate for fog support
  21292. * @param scene defines the hosting scene
  21293. * @returns true if fog must be enabled
  21294. */
  21295. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  21296. /**
  21297. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  21298. * @param mesh defines the current mesh
  21299. * @param scene defines the current scene
  21300. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  21301. * @param pointsCloud defines if point cloud rendering has to be turned on
  21302. * @param fogEnabled defines if fog has to be turned on
  21303. * @param alphaTest defines if alpha testing has to be turned on
  21304. * @param defines defines the current list of defines
  21305. */
  21306. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  21307. /**
  21308. * Helper used to prepare the list of defines associated with frame values for shader compilation
  21309. * @param scene defines the current scene
  21310. * @param engine defines the current engine
  21311. * @param defines specifies the list of active defines
  21312. * @param useInstances defines if instances have to be turned on
  21313. * @param useClipPlane defines if clip plane have to be turned on
  21314. * @param useInstances defines if instances have to be turned on
  21315. * @param useThinInstances defines if thin instances have to be turned on
  21316. */
  21317. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21318. /**
  21319. * Prepares the defines for bones
  21320. * @param mesh The mesh containing the geometry data we will draw
  21321. * @param defines The defines to update
  21322. */
  21323. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21324. /**
  21325. * Prepares the defines for morph targets
  21326. * @param mesh The mesh containing the geometry data we will draw
  21327. * @param defines The defines to update
  21328. */
  21329. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21330. /**
  21331. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21332. * @param mesh The mesh containing the geometry data we will draw
  21333. * @param defines The defines to update
  21334. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21335. * @param useBones Precise whether bones should be used or not (override mesh info)
  21336. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21337. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21338. * @returns false if defines are considered not dirty and have not been checked
  21339. */
  21340. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21341. /**
  21342. * Prepares the defines related to multiview
  21343. * @param scene The scene we are intending to draw
  21344. * @param defines The defines to update
  21345. */
  21346. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21347. /**
  21348. * Prepares the defines related to the prepass
  21349. * @param scene The scene we are intending to draw
  21350. * @param defines The defines to update
  21351. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21352. */
  21353. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21354. /**
  21355. * Prepares the defines related to the light information passed in parameter
  21356. * @param scene The scene we are intending to draw
  21357. * @param mesh The mesh the effect is compiling for
  21358. * @param light The light the effect is compiling for
  21359. * @param lightIndex The index of the light
  21360. * @param defines The defines to update
  21361. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21362. * @param state Defines the current state regarding what is needed (normals, etc...)
  21363. */
  21364. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21365. needNormals: boolean;
  21366. needRebuild: boolean;
  21367. shadowEnabled: boolean;
  21368. specularEnabled: boolean;
  21369. lightmapMode: boolean;
  21370. }): void;
  21371. /**
  21372. * Prepares the defines related to the light information passed in parameter
  21373. * @param scene The scene we are intending to draw
  21374. * @param mesh The mesh the effect is compiling for
  21375. * @param defines The defines to update
  21376. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21377. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21378. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21379. * @returns true if normals will be required for the rest of the effect
  21380. */
  21381. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21382. /**
  21383. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21384. * @param lightIndex defines the light index
  21385. * @param uniformsList The uniform list
  21386. * @param samplersList The sampler list
  21387. * @param projectedLightTexture defines if projected texture must be used
  21388. * @param uniformBuffersList defines an optional list of uniform buffers
  21389. */
  21390. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21391. /**
  21392. * Prepares the uniforms and samplers list to be used in the effect
  21393. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21394. * @param samplersList The sampler list
  21395. * @param defines The defines helping in the list generation
  21396. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21397. */
  21398. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21399. /**
  21400. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21401. * @param defines The defines to update while falling back
  21402. * @param fallbacks The authorized effect fallbacks
  21403. * @param maxSimultaneousLights The maximum number of lights allowed
  21404. * @param rank the current rank of the Effect
  21405. * @returns The newly affected rank
  21406. */
  21407. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21408. private static _TmpMorphInfluencers;
  21409. /**
  21410. * Prepares the list of attributes required for morph targets according to the effect defines.
  21411. * @param attribs The current list of supported attribs
  21412. * @param mesh The mesh to prepare the morph targets attributes for
  21413. * @param influencers The number of influencers
  21414. */
  21415. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21416. /**
  21417. * Prepares the list of attributes required for morph targets according to the effect defines.
  21418. * @param attribs The current list of supported attribs
  21419. * @param mesh The mesh to prepare the morph targets attributes for
  21420. * @param defines The current Defines of the effect
  21421. */
  21422. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21423. /**
  21424. * Prepares the list of attributes required for bones according to the effect defines.
  21425. * @param attribs The current list of supported attribs
  21426. * @param mesh The mesh to prepare the bones attributes for
  21427. * @param defines The current Defines of the effect
  21428. * @param fallbacks The current efffect fallback strategy
  21429. */
  21430. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21431. /**
  21432. * Check and prepare the list of attributes required for instances according to the effect defines.
  21433. * @param attribs The current list of supported attribs
  21434. * @param defines The current MaterialDefines of the effect
  21435. */
  21436. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21437. /**
  21438. * Add the list of attributes required for instances to the attribs array.
  21439. * @param attribs The current list of supported attribs
  21440. */
  21441. static PushAttributesForInstances(attribs: string[]): void;
  21442. /**
  21443. * Binds the light information to the effect.
  21444. * @param light The light containing the generator
  21445. * @param effect The effect we are binding the data to
  21446. * @param lightIndex The light index in the effect used to render
  21447. */
  21448. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21449. /**
  21450. * Binds the lights information from the scene to the effect for the given mesh.
  21451. * @param light Light to bind
  21452. * @param lightIndex Light index
  21453. * @param scene The scene where the light belongs to
  21454. * @param effect The effect we are binding the data to
  21455. * @param useSpecular Defines if specular is supported
  21456. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21457. */
  21458. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21459. /**
  21460. * Binds the lights information from the scene to the effect for the given mesh.
  21461. * @param scene The scene the lights belongs to
  21462. * @param mesh The mesh we are binding the information to render
  21463. * @param effect The effect we are binding the data to
  21464. * @param defines The generated defines for the effect
  21465. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21466. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21467. */
  21468. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21469. private static _tempFogColor;
  21470. /**
  21471. * Binds the fog information from the scene to the effect for the given mesh.
  21472. * @param scene The scene the lights belongs to
  21473. * @param mesh The mesh we are binding the information to render
  21474. * @param effect The effect we are binding the data to
  21475. * @param linearSpace Defines if the fog effect is applied in linear space
  21476. */
  21477. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21478. /**
  21479. * Binds the bones information from the mesh to the effect.
  21480. * @param mesh The mesh we are binding the information to render
  21481. * @param effect The effect we are binding the data to
  21482. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21483. */
  21484. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21485. private static _CopyBonesTransformationMatrices;
  21486. /**
  21487. * Binds the morph targets information from the mesh to the effect.
  21488. * @param abstractMesh The mesh we are binding the information to render
  21489. * @param effect The effect we are binding the data to
  21490. */
  21491. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21492. /**
  21493. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21494. * @param defines The generated defines used in the effect
  21495. * @param effect The effect we are binding the data to
  21496. * @param scene The scene we are willing to render with logarithmic scale for
  21497. */
  21498. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21499. /**
  21500. * Binds the clip plane information from the scene to the effect.
  21501. * @param scene The scene the clip plane information are extracted from
  21502. * @param effect The effect we are binding the data to
  21503. */
  21504. static BindClipPlane(effect: Effect, scene: Scene): void;
  21505. }
  21506. }
  21507. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21508. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21509. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21510. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21511. import { Nullable } from "babylonjs/types";
  21512. import { Effect } from "babylonjs/Materials/effect";
  21513. import { Matrix } from "babylonjs/Maths/math.vector";
  21514. import { Scene } from "babylonjs/scene";
  21515. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21517. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21518. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21519. import { Observable } from "babylonjs/Misc/observable";
  21520. /**
  21521. * Block used to expose an input value
  21522. */
  21523. export class InputBlock extends NodeMaterialBlock {
  21524. private _mode;
  21525. private _associatedVariableName;
  21526. private _storedValue;
  21527. private _valueCallback;
  21528. private _type;
  21529. private _animationType;
  21530. /** Gets or set a value used to limit the range of float values */
  21531. min: number;
  21532. /** Gets or set a value used to limit the range of float values */
  21533. max: number;
  21534. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21535. isBoolean: boolean;
  21536. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21537. matrixMode: number;
  21538. /** @hidden */
  21539. _systemValue: Nullable<NodeMaterialSystemValues>;
  21540. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21541. isConstant: boolean;
  21542. /** Gets or sets the group to use to display this block in the Inspector */
  21543. groupInInspector: string;
  21544. /** Gets an observable raised when the value is changed */
  21545. onValueChangedObservable: Observable<InputBlock>;
  21546. /**
  21547. * Gets or sets the connection point type (default is float)
  21548. */
  21549. get type(): NodeMaterialBlockConnectionPointTypes;
  21550. /**
  21551. * Creates a new InputBlock
  21552. * @param name defines the block name
  21553. * @param target defines the target of that block (Vertex by default)
  21554. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21555. */
  21556. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21557. /**
  21558. * Validates if a name is a reserve word.
  21559. * @param newName the new name to be given to the node.
  21560. * @returns false if the name is a reserve word, else true.
  21561. */
  21562. validateBlockName(newName: string): boolean;
  21563. /**
  21564. * Gets the output component
  21565. */
  21566. get output(): NodeMaterialConnectionPoint;
  21567. /**
  21568. * Set the source of this connection point to a vertex attribute
  21569. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21570. * @returns the current connection point
  21571. */
  21572. setAsAttribute(attributeName?: string): InputBlock;
  21573. /**
  21574. * Set the source of this connection point to a system value
  21575. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21576. * @returns the current connection point
  21577. */
  21578. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21579. /**
  21580. * Gets or sets the value of that point.
  21581. * Please note that this value will be ignored if valueCallback is defined
  21582. */
  21583. get value(): any;
  21584. set value(value: any);
  21585. /**
  21586. * Gets or sets a callback used to get the value of that point.
  21587. * Please note that setting this value will force the connection point to ignore the value property
  21588. */
  21589. get valueCallback(): () => any;
  21590. set valueCallback(value: () => any);
  21591. /**
  21592. * Gets or sets the associated variable name in the shader
  21593. */
  21594. get associatedVariableName(): string;
  21595. set associatedVariableName(value: string);
  21596. /** Gets or sets the type of animation applied to the input */
  21597. get animationType(): AnimatedInputBlockTypes;
  21598. set animationType(value: AnimatedInputBlockTypes);
  21599. /**
  21600. * Gets a boolean indicating that this connection point not defined yet
  21601. */
  21602. get isUndefined(): boolean;
  21603. /**
  21604. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21605. * In this case the connection point name must be the name of the uniform to use.
  21606. * Can only be set on inputs
  21607. */
  21608. get isUniform(): boolean;
  21609. set isUniform(value: boolean);
  21610. /**
  21611. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21612. * In this case the connection point name must be the name of the attribute to use
  21613. * Can only be set on inputs
  21614. */
  21615. get isAttribute(): boolean;
  21616. set isAttribute(value: boolean);
  21617. /**
  21618. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21619. * Can only be set on exit points
  21620. */
  21621. get isVarying(): boolean;
  21622. set isVarying(value: boolean);
  21623. /**
  21624. * Gets a boolean indicating that the current connection point is a system value
  21625. */
  21626. get isSystemValue(): boolean;
  21627. /**
  21628. * Gets or sets the current well known value or null if not defined as a system value
  21629. */
  21630. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21631. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21632. /**
  21633. * Gets the current class name
  21634. * @returns the class name
  21635. */
  21636. getClassName(): string;
  21637. /**
  21638. * Animate the input if animationType !== None
  21639. * @param scene defines the rendering scene
  21640. */
  21641. animate(scene: Scene): void;
  21642. private _emitDefine;
  21643. initialize(state: NodeMaterialBuildState): void;
  21644. /**
  21645. * Set the input block to its default value (based on its type)
  21646. */
  21647. setDefaultValue(): void;
  21648. private _emitConstant;
  21649. /** @hidden */
  21650. get _noContextSwitch(): boolean;
  21651. private _emit;
  21652. /** @hidden */
  21653. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21654. /** @hidden */
  21655. _transmit(effect: Effect, scene: Scene): void;
  21656. protected _buildBlock(state: NodeMaterialBuildState): void;
  21657. protected _dumpPropertiesCode(): string;
  21658. dispose(): void;
  21659. serialize(): any;
  21660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21661. }
  21662. }
  21663. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21664. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21665. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21666. import { Nullable } from "babylonjs/types";
  21667. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21668. import { Observable } from "babylonjs/Misc/observable";
  21669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21670. /**
  21671. * Enum used to define the compatibility state between two connection points
  21672. */
  21673. export enum NodeMaterialConnectionPointCompatibilityStates {
  21674. /** Points are compatibles */
  21675. Compatible = 0,
  21676. /** Points are incompatible because of their types */
  21677. TypeIncompatible = 1,
  21678. /** Points are incompatible because of their targets (vertex vs fragment) */
  21679. TargetIncompatible = 2
  21680. }
  21681. /**
  21682. * Defines the direction of a connection point
  21683. */
  21684. export enum NodeMaterialConnectionPointDirection {
  21685. /** Input */
  21686. Input = 0,
  21687. /** Output */
  21688. Output = 1
  21689. }
  21690. /**
  21691. * Defines a connection point for a block
  21692. */
  21693. export class NodeMaterialConnectionPoint {
  21694. /** @hidden */
  21695. _ownerBlock: NodeMaterialBlock;
  21696. /** @hidden */
  21697. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21698. private _endpoints;
  21699. private _associatedVariableName;
  21700. private _direction;
  21701. /** @hidden */
  21702. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21703. /** @hidden */
  21704. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21705. private _type;
  21706. /** @hidden */
  21707. _enforceAssociatedVariableName: boolean;
  21708. /** Gets the direction of the point */
  21709. get direction(): NodeMaterialConnectionPointDirection;
  21710. /** Indicates that this connection point needs dual validation before being connected to another point */
  21711. needDualDirectionValidation: boolean;
  21712. /**
  21713. * Gets or sets the additional types supported by this connection point
  21714. */
  21715. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21716. /**
  21717. * Gets or sets the additional types excluded by this connection point
  21718. */
  21719. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21720. /**
  21721. * Observable triggered when this point is connected
  21722. */
  21723. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21724. /**
  21725. * Gets or sets the associated variable name in the shader
  21726. */
  21727. get associatedVariableName(): string;
  21728. set associatedVariableName(value: string);
  21729. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21730. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21731. /**
  21732. * Gets or sets the connection point type (default is float)
  21733. */
  21734. get type(): NodeMaterialBlockConnectionPointTypes;
  21735. set type(value: NodeMaterialBlockConnectionPointTypes);
  21736. /**
  21737. * Gets or sets the connection point name
  21738. */
  21739. name: string;
  21740. /**
  21741. * Gets or sets the connection point name
  21742. */
  21743. displayName: string;
  21744. /**
  21745. * Gets or sets a boolean indicating that this connection point can be omitted
  21746. */
  21747. isOptional: boolean;
  21748. /**
  21749. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21750. */
  21751. isExposedOnFrame: boolean;
  21752. /**
  21753. * Gets or sets number indicating the position that the port is exposed to on a frame
  21754. */
  21755. exposedPortPosition: number;
  21756. /**
  21757. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21758. */
  21759. define: string;
  21760. /** @hidden */
  21761. _prioritizeVertex: boolean;
  21762. private _target;
  21763. /** Gets or sets the target of that connection point */
  21764. get target(): NodeMaterialBlockTargets;
  21765. set target(value: NodeMaterialBlockTargets);
  21766. /**
  21767. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21768. */
  21769. get isConnected(): boolean;
  21770. /**
  21771. * Gets a boolean indicating that the current point is connected to an input block
  21772. */
  21773. get isConnectedToInputBlock(): boolean;
  21774. /**
  21775. * Gets a the connected input block (if any)
  21776. */
  21777. get connectInputBlock(): Nullable<InputBlock>;
  21778. /** Get the other side of the connection (if any) */
  21779. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21780. /** Get the block that owns this connection point */
  21781. get ownerBlock(): NodeMaterialBlock;
  21782. /** Get the block connected on the other side of this connection (if any) */
  21783. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21784. /** Get the block connected on the endpoints of this connection (if any) */
  21785. get connectedBlocks(): Array<NodeMaterialBlock>;
  21786. /** Gets the list of connected endpoints */
  21787. get endpoints(): NodeMaterialConnectionPoint[];
  21788. /** Gets a boolean indicating if that output point is connected to at least one input */
  21789. get hasEndpoints(): boolean;
  21790. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21791. get isConnectedInVertexShader(): boolean;
  21792. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21793. get isConnectedInFragmentShader(): boolean;
  21794. /**
  21795. * Creates a block suitable to be used as an input for this input point.
  21796. * If null is returned, a block based on the point type will be created.
  21797. * @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
  21798. */
  21799. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21800. /**
  21801. * Creates a new connection point
  21802. * @param name defines the connection point name
  21803. * @param ownerBlock defines the block hosting this connection point
  21804. * @param direction defines the direction of the connection point
  21805. */
  21806. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21807. /**
  21808. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21809. * @returns the class name
  21810. */
  21811. getClassName(): string;
  21812. /**
  21813. * Gets a boolean indicating if the current point can be connected to another point
  21814. * @param connectionPoint defines the other connection point
  21815. * @returns a boolean
  21816. */
  21817. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21818. /**
  21819. * Gets a number indicating if the current point can be connected to another point
  21820. * @param connectionPoint defines the other connection point
  21821. * @returns a number defining the compatibility state
  21822. */
  21823. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21824. /**
  21825. * Connect this point to another connection point
  21826. * @param connectionPoint defines the other connection point
  21827. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21828. * @returns the current connection point
  21829. */
  21830. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21831. /**
  21832. * Disconnect this point from one of his endpoint
  21833. * @param endpoint defines the other connection point
  21834. * @returns the current connection point
  21835. */
  21836. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21837. /**
  21838. * Serializes this point in a JSON representation
  21839. * @param isInput defines if the connection point is an input (default is true)
  21840. * @returns the serialized point object
  21841. */
  21842. serialize(isInput?: boolean): any;
  21843. /**
  21844. * Release resources
  21845. */
  21846. dispose(): void;
  21847. }
  21848. }
  21849. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21850. /**
  21851. * Enum used to define the material modes
  21852. */
  21853. export enum NodeMaterialModes {
  21854. /** Regular material */
  21855. Material = 0,
  21856. /** For post process */
  21857. PostProcess = 1,
  21858. /** For particle system */
  21859. Particle = 2,
  21860. /** For procedural texture */
  21861. ProceduralTexture = 3
  21862. }
  21863. }
  21864. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21865. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21867. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21870. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21871. import { Effect } from "babylonjs/Materials/effect";
  21872. import { Mesh } from "babylonjs/Meshes/mesh";
  21873. import { Nullable } from "babylonjs/types";
  21874. import { Texture } from "babylonjs/Materials/Textures/texture";
  21875. import { Scene } from "babylonjs/scene";
  21876. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21877. /**
  21878. * Block used to read a texture from a sampler
  21879. */
  21880. export class TextureBlock extends NodeMaterialBlock {
  21881. private _defineName;
  21882. private _linearDefineName;
  21883. private _gammaDefineName;
  21884. private _tempTextureRead;
  21885. private _samplerName;
  21886. private _transformedUVName;
  21887. private _textureTransformName;
  21888. private _textureInfoName;
  21889. private _mainUVName;
  21890. private _mainUVDefineName;
  21891. private _fragmentOnly;
  21892. /**
  21893. * Gets or sets the texture associated with the node
  21894. */
  21895. texture: Nullable<Texture>;
  21896. /**
  21897. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21898. */
  21899. convertToGammaSpace: boolean;
  21900. /**
  21901. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21902. */
  21903. convertToLinearSpace: boolean;
  21904. /**
  21905. * Create a new TextureBlock
  21906. * @param name defines the block name
  21907. */
  21908. constructor(name: string, fragmentOnly?: boolean);
  21909. /**
  21910. * Gets the current class name
  21911. * @returns the class name
  21912. */
  21913. getClassName(): string;
  21914. /**
  21915. * Gets the uv input component
  21916. */
  21917. get uv(): NodeMaterialConnectionPoint;
  21918. /**
  21919. * Gets the rgba output component
  21920. */
  21921. get rgba(): NodeMaterialConnectionPoint;
  21922. /**
  21923. * Gets the rgb output component
  21924. */
  21925. get rgb(): NodeMaterialConnectionPoint;
  21926. /**
  21927. * Gets the r output component
  21928. */
  21929. get r(): NodeMaterialConnectionPoint;
  21930. /**
  21931. * Gets the g output component
  21932. */
  21933. get g(): NodeMaterialConnectionPoint;
  21934. /**
  21935. * Gets the b output component
  21936. */
  21937. get b(): NodeMaterialConnectionPoint;
  21938. /**
  21939. * Gets the a output component
  21940. */
  21941. get a(): NodeMaterialConnectionPoint;
  21942. get target(): NodeMaterialBlockTargets;
  21943. autoConfigure(material: NodeMaterial): void;
  21944. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21945. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21946. isReady(): boolean;
  21947. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21948. private get _isMixed();
  21949. private _injectVertexCode;
  21950. private _writeTextureRead;
  21951. private _writeOutput;
  21952. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21953. protected _dumpPropertiesCode(): string;
  21954. serialize(): any;
  21955. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21956. }
  21957. }
  21958. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21959. /** @hidden */
  21960. export var reflectionFunction: {
  21961. name: string;
  21962. shader: string;
  21963. };
  21964. }
  21965. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21966. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21967. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21968. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21971. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21972. import { Effect } from "babylonjs/Materials/effect";
  21973. import { Mesh } from "babylonjs/Meshes/mesh";
  21974. import { Nullable } from "babylonjs/types";
  21975. import { Scene } from "babylonjs/scene";
  21976. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21977. /**
  21978. * Base block used to read a reflection texture from a sampler
  21979. */
  21980. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21981. /** @hidden */
  21982. _define3DName: string;
  21983. /** @hidden */
  21984. _defineCubicName: string;
  21985. /** @hidden */
  21986. _defineExplicitName: string;
  21987. /** @hidden */
  21988. _defineProjectionName: string;
  21989. /** @hidden */
  21990. _defineLocalCubicName: string;
  21991. /** @hidden */
  21992. _defineSphericalName: string;
  21993. /** @hidden */
  21994. _definePlanarName: string;
  21995. /** @hidden */
  21996. _defineEquirectangularName: string;
  21997. /** @hidden */
  21998. _defineMirroredEquirectangularFixedName: string;
  21999. /** @hidden */
  22000. _defineEquirectangularFixedName: string;
  22001. /** @hidden */
  22002. _defineSkyboxName: string;
  22003. /** @hidden */
  22004. _defineOppositeZ: string;
  22005. /** @hidden */
  22006. _cubeSamplerName: string;
  22007. /** @hidden */
  22008. _2DSamplerName: string;
  22009. protected _positionUVWName: string;
  22010. protected _directionWName: string;
  22011. protected _reflectionVectorName: string;
  22012. /** @hidden */
  22013. _reflectionCoordsName: string;
  22014. /** @hidden */
  22015. _reflectionMatrixName: string;
  22016. protected _reflectionColorName: string;
  22017. /**
  22018. * Gets or sets the texture associated with the node
  22019. */
  22020. texture: Nullable<BaseTexture>;
  22021. /**
  22022. * Create a new ReflectionTextureBaseBlock
  22023. * @param name defines the block name
  22024. */
  22025. constructor(name: string);
  22026. /**
  22027. * Gets the current class name
  22028. * @returns the class name
  22029. */
  22030. getClassName(): string;
  22031. /**
  22032. * Gets the world position input component
  22033. */
  22034. abstract get position(): NodeMaterialConnectionPoint;
  22035. /**
  22036. * Gets the world position input component
  22037. */
  22038. abstract get worldPosition(): NodeMaterialConnectionPoint;
  22039. /**
  22040. * Gets the world normal input component
  22041. */
  22042. abstract get worldNormal(): NodeMaterialConnectionPoint;
  22043. /**
  22044. * Gets the world input component
  22045. */
  22046. abstract get world(): NodeMaterialConnectionPoint;
  22047. /**
  22048. * Gets the camera (or eye) position component
  22049. */
  22050. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  22051. /**
  22052. * Gets the view input component
  22053. */
  22054. abstract get view(): NodeMaterialConnectionPoint;
  22055. protected _getTexture(): Nullable<BaseTexture>;
  22056. autoConfigure(material: NodeMaterial): void;
  22057. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22058. isReady(): boolean;
  22059. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  22060. /**
  22061. * Gets the code to inject in the vertex shader
  22062. * @param state current state of the node material building
  22063. * @returns the shader code
  22064. */
  22065. handleVertexSide(state: NodeMaterialBuildState): string;
  22066. /**
  22067. * Handles the inits for the fragment code path
  22068. * @param state node material build state
  22069. */
  22070. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  22071. /**
  22072. * Generates the reflection coords code for the fragment code path
  22073. * @param worldNormalVarName name of the world normal variable
  22074. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  22075. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  22076. * @returns the shader code
  22077. */
  22078. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  22079. /**
  22080. * Generates the reflection color code for the fragment code path
  22081. * @param lodVarName name of the lod variable
  22082. * @param swizzleLookupTexture swizzle to use for the final color variable
  22083. * @returns the shader code
  22084. */
  22085. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  22086. /**
  22087. * Generates the code corresponding to the connected output points
  22088. * @param state node material build state
  22089. * @param varName name of the variable to output
  22090. * @returns the shader code
  22091. */
  22092. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  22093. protected _buildBlock(state: NodeMaterialBuildState): this;
  22094. protected _dumpPropertiesCode(): string;
  22095. serialize(): any;
  22096. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22097. }
  22098. }
  22099. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  22100. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22101. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22102. import { Nullable } from "babylonjs/types";
  22103. /**
  22104. * Defines a connection point to be used for points with a custom object type
  22105. */
  22106. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  22107. private _blockType;
  22108. private _blockName;
  22109. private _nameForCheking?;
  22110. /**
  22111. * Creates a new connection point
  22112. * @param name defines the connection point name
  22113. * @param ownerBlock defines the block hosting this connection point
  22114. * @param direction defines the direction of the connection point
  22115. */
  22116. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  22117. /**
  22118. * Gets a number indicating if the current point can be connected to another point
  22119. * @param connectionPoint defines the other connection point
  22120. * @returns a number defining the compatibility state
  22121. */
  22122. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  22123. /**
  22124. * Creates a block suitable to be used as an input for this input point.
  22125. * If null is returned, a block based on the point type will be created.
  22126. * @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
  22127. */
  22128. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  22129. }
  22130. }
  22131. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  22132. /**
  22133. * Enum defining the type of properties that can be edited in the property pages in the NME
  22134. */
  22135. export enum PropertyTypeForEdition {
  22136. /** property is a boolean */
  22137. Boolean = 0,
  22138. /** property is a float */
  22139. Float = 1,
  22140. /** property is a Vector2 */
  22141. Vector2 = 2,
  22142. /** property is a list of values */
  22143. List = 3
  22144. }
  22145. /**
  22146. * Interface that defines an option in a variable of type list
  22147. */
  22148. export interface IEditablePropertyListOption {
  22149. /** label of the option */
  22150. "label": string;
  22151. /** value of the option */
  22152. "value": number;
  22153. }
  22154. /**
  22155. * Interface that defines the options available for an editable property
  22156. */
  22157. export interface IEditablePropertyOption {
  22158. /** min value */
  22159. "min"?: number;
  22160. /** max value */
  22161. "max"?: number;
  22162. /** notifiers: indicates which actions to take when the property is changed */
  22163. "notifiers"?: {
  22164. /** the material should be rebuilt */
  22165. "rebuild"?: boolean;
  22166. /** the preview should be updated */
  22167. "update"?: boolean;
  22168. };
  22169. /** list of the options for a variable of type list */
  22170. "options"?: IEditablePropertyListOption[];
  22171. }
  22172. /**
  22173. * Interface that describes an editable property
  22174. */
  22175. export interface IPropertyDescriptionForEdition {
  22176. /** name of the property */
  22177. "propertyName": string;
  22178. /** display name of the property */
  22179. "displayName": string;
  22180. /** type of the property */
  22181. "type": PropertyTypeForEdition;
  22182. /** group of the property - all properties with the same group value will be displayed in a specific section */
  22183. "groupName": string;
  22184. /** options for the property */
  22185. "options": IEditablePropertyOption;
  22186. }
  22187. /**
  22188. * Decorator that flags a property in a node material block as being editable
  22189. */
  22190. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  22191. }
  22192. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  22193. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22194. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22195. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22197. import { Nullable } from "babylonjs/types";
  22198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22199. import { Mesh } from "babylonjs/Meshes/mesh";
  22200. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22201. import { Effect } from "babylonjs/Materials/effect";
  22202. import { Scene } from "babylonjs/scene";
  22203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22204. /**
  22205. * Block used to implement the refraction part of the sub surface module of the PBR material
  22206. */
  22207. export class RefractionBlock extends NodeMaterialBlock {
  22208. /** @hidden */
  22209. _define3DName: string;
  22210. /** @hidden */
  22211. _refractionMatrixName: string;
  22212. /** @hidden */
  22213. _defineLODRefractionAlpha: string;
  22214. /** @hidden */
  22215. _defineLinearSpecularRefraction: string;
  22216. /** @hidden */
  22217. _defineOppositeZ: string;
  22218. /** @hidden */
  22219. _cubeSamplerName: string;
  22220. /** @hidden */
  22221. _2DSamplerName: string;
  22222. /** @hidden */
  22223. _vRefractionMicrosurfaceInfosName: string;
  22224. /** @hidden */
  22225. _vRefractionInfosName: string;
  22226. private _scene;
  22227. /**
  22228. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22229. * Materials half opaque for instance using refraction could benefit from this control.
  22230. */
  22231. linkRefractionWithTransparency: boolean;
  22232. /**
  22233. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22234. */
  22235. invertRefractionY: boolean;
  22236. /**
  22237. * Gets or sets the texture associated with the node
  22238. */
  22239. texture: Nullable<BaseTexture>;
  22240. /**
  22241. * Create a new RefractionBlock
  22242. * @param name defines the block name
  22243. */
  22244. constructor(name: string);
  22245. /**
  22246. * Gets the current class name
  22247. * @returns the class name
  22248. */
  22249. getClassName(): string;
  22250. /**
  22251. * Gets the intensity input component
  22252. */
  22253. get intensity(): NodeMaterialConnectionPoint;
  22254. /**
  22255. * Gets the index of refraction input component
  22256. */
  22257. get indexOfRefraction(): NodeMaterialConnectionPoint;
  22258. /**
  22259. * Gets the tint at distance input component
  22260. */
  22261. get tintAtDistance(): NodeMaterialConnectionPoint;
  22262. /**
  22263. * Gets the view input component
  22264. */
  22265. get view(): NodeMaterialConnectionPoint;
  22266. /**
  22267. * Gets the refraction object output component
  22268. */
  22269. get refraction(): NodeMaterialConnectionPoint;
  22270. /**
  22271. * Returns true if the block has a texture
  22272. */
  22273. get hasTexture(): boolean;
  22274. protected _getTexture(): Nullable<BaseTexture>;
  22275. autoConfigure(material: NodeMaterial): void;
  22276. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22277. isReady(): boolean;
  22278. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22279. /**
  22280. * Gets the main code of the block (fragment side)
  22281. * @param state current state of the node material building
  22282. * @returns the shader code
  22283. */
  22284. getCode(state: NodeMaterialBuildState): string;
  22285. protected _buildBlock(state: NodeMaterialBuildState): this;
  22286. protected _dumpPropertiesCode(): string;
  22287. serialize(): any;
  22288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22289. }
  22290. }
  22291. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  22292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22293. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22294. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22297. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22298. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22299. import { Nullable } from "babylonjs/types";
  22300. import { Scene } from "babylonjs/scene";
  22301. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22302. /**
  22303. * Base block used as input for post process
  22304. */
  22305. export class CurrentScreenBlock extends NodeMaterialBlock {
  22306. private _samplerName;
  22307. private _linearDefineName;
  22308. private _gammaDefineName;
  22309. private _mainUVName;
  22310. private _tempTextureRead;
  22311. /**
  22312. * Gets or sets the texture associated with the node
  22313. */
  22314. texture: Nullable<BaseTexture>;
  22315. /**
  22316. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22317. */
  22318. convertToGammaSpace: boolean;
  22319. /**
  22320. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22321. */
  22322. convertToLinearSpace: boolean;
  22323. /**
  22324. * Create a new CurrentScreenBlock
  22325. * @param name defines the block name
  22326. */
  22327. constructor(name: string);
  22328. /**
  22329. * Gets the current class name
  22330. * @returns the class name
  22331. */
  22332. getClassName(): string;
  22333. /**
  22334. * Gets the uv input component
  22335. */
  22336. get uv(): NodeMaterialConnectionPoint;
  22337. /**
  22338. * Gets the rgba output component
  22339. */
  22340. get rgba(): NodeMaterialConnectionPoint;
  22341. /**
  22342. * Gets the rgb output component
  22343. */
  22344. get rgb(): NodeMaterialConnectionPoint;
  22345. /**
  22346. * Gets the r output component
  22347. */
  22348. get r(): NodeMaterialConnectionPoint;
  22349. /**
  22350. * Gets the g output component
  22351. */
  22352. get g(): NodeMaterialConnectionPoint;
  22353. /**
  22354. * Gets the b output component
  22355. */
  22356. get b(): NodeMaterialConnectionPoint;
  22357. /**
  22358. * Gets the a output component
  22359. */
  22360. get a(): NodeMaterialConnectionPoint;
  22361. /**
  22362. * Initialize the block and prepare the context for build
  22363. * @param state defines the state that will be used for the build
  22364. */
  22365. initialize(state: NodeMaterialBuildState): void;
  22366. get target(): NodeMaterialBlockTargets;
  22367. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22368. isReady(): boolean;
  22369. private _injectVertexCode;
  22370. private _writeTextureRead;
  22371. private _writeOutput;
  22372. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22373. serialize(): any;
  22374. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22375. }
  22376. }
  22377. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22382. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22383. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22384. import { Nullable } from "babylonjs/types";
  22385. import { Scene } from "babylonjs/scene";
  22386. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22387. /**
  22388. * Base block used for the particle texture
  22389. */
  22390. export class ParticleTextureBlock extends NodeMaterialBlock {
  22391. private _samplerName;
  22392. private _linearDefineName;
  22393. private _gammaDefineName;
  22394. private _tempTextureRead;
  22395. /**
  22396. * Gets or sets the texture associated with the node
  22397. */
  22398. texture: Nullable<BaseTexture>;
  22399. /**
  22400. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22401. */
  22402. convertToGammaSpace: boolean;
  22403. /**
  22404. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22405. */
  22406. convertToLinearSpace: boolean;
  22407. /**
  22408. * Create a new ParticleTextureBlock
  22409. * @param name defines the block name
  22410. */
  22411. constructor(name: string);
  22412. /**
  22413. * Gets the current class name
  22414. * @returns the class name
  22415. */
  22416. getClassName(): string;
  22417. /**
  22418. * Gets the uv input component
  22419. */
  22420. get uv(): NodeMaterialConnectionPoint;
  22421. /**
  22422. * Gets the rgba output component
  22423. */
  22424. get rgba(): NodeMaterialConnectionPoint;
  22425. /**
  22426. * Gets the rgb output component
  22427. */
  22428. get rgb(): NodeMaterialConnectionPoint;
  22429. /**
  22430. * Gets the r output component
  22431. */
  22432. get r(): NodeMaterialConnectionPoint;
  22433. /**
  22434. * Gets the g output component
  22435. */
  22436. get g(): NodeMaterialConnectionPoint;
  22437. /**
  22438. * Gets the b output component
  22439. */
  22440. get b(): NodeMaterialConnectionPoint;
  22441. /**
  22442. * Gets the a output component
  22443. */
  22444. get a(): NodeMaterialConnectionPoint;
  22445. /**
  22446. * Initialize the block and prepare the context for build
  22447. * @param state defines the state that will be used for the build
  22448. */
  22449. initialize(state: NodeMaterialBuildState): void;
  22450. autoConfigure(material: NodeMaterial): void;
  22451. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22452. isReady(): boolean;
  22453. private _writeOutput;
  22454. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22455. serialize(): any;
  22456. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22457. }
  22458. }
  22459. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22460. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22461. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22462. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22463. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22464. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22465. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22466. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22467. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22468. import { Scene } from "babylonjs/scene";
  22469. /**
  22470. * Class used to store shared data between 2 NodeMaterialBuildState
  22471. */
  22472. export class NodeMaterialBuildStateSharedData {
  22473. /**
  22474. * Gets the list of emitted varyings
  22475. */
  22476. temps: string[];
  22477. /**
  22478. * Gets the list of emitted varyings
  22479. */
  22480. varyings: string[];
  22481. /**
  22482. * Gets the varying declaration string
  22483. */
  22484. varyingDeclaration: string;
  22485. /**
  22486. * Input blocks
  22487. */
  22488. inputBlocks: InputBlock[];
  22489. /**
  22490. * Input blocks
  22491. */
  22492. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22493. /**
  22494. * Bindable blocks (Blocks that need to set data to the effect)
  22495. */
  22496. bindableBlocks: NodeMaterialBlock[];
  22497. /**
  22498. * List of blocks that can provide a compilation fallback
  22499. */
  22500. blocksWithFallbacks: NodeMaterialBlock[];
  22501. /**
  22502. * List of blocks that can provide a define update
  22503. */
  22504. blocksWithDefines: NodeMaterialBlock[];
  22505. /**
  22506. * List of blocks that can provide a repeatable content
  22507. */
  22508. repeatableContentBlocks: NodeMaterialBlock[];
  22509. /**
  22510. * List of blocks that can provide a dynamic list of uniforms
  22511. */
  22512. dynamicUniformBlocks: NodeMaterialBlock[];
  22513. /**
  22514. * List of blocks that can block the isReady function for the material
  22515. */
  22516. blockingBlocks: NodeMaterialBlock[];
  22517. /**
  22518. * Gets the list of animated inputs
  22519. */
  22520. animatedInputs: InputBlock[];
  22521. /**
  22522. * Build Id used to avoid multiple recompilations
  22523. */
  22524. buildId: number;
  22525. /** List of emitted variables */
  22526. variableNames: {
  22527. [key: string]: number;
  22528. };
  22529. /** List of emitted defines */
  22530. defineNames: {
  22531. [key: string]: number;
  22532. };
  22533. /** Should emit comments? */
  22534. emitComments: boolean;
  22535. /** Emit build activity */
  22536. verbose: boolean;
  22537. /** Gets or sets the hosting scene */
  22538. scene: Scene;
  22539. /**
  22540. * Gets the compilation hints emitted at compilation time
  22541. */
  22542. hints: {
  22543. needWorldViewMatrix: boolean;
  22544. needWorldViewProjectionMatrix: boolean;
  22545. needAlphaBlending: boolean;
  22546. needAlphaTesting: boolean;
  22547. };
  22548. /**
  22549. * List of compilation checks
  22550. */
  22551. checks: {
  22552. emitVertex: boolean;
  22553. emitFragment: boolean;
  22554. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22555. };
  22556. /**
  22557. * Is vertex program allowed to be empty?
  22558. */
  22559. allowEmptyVertexProgram: boolean;
  22560. /** Creates a new shared data */
  22561. constructor();
  22562. /**
  22563. * Emits console errors and exceptions if there is a failing check
  22564. */
  22565. emitErrors(): void;
  22566. }
  22567. }
  22568. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22569. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22570. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22571. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22572. /**
  22573. * Class used to store node based material build state
  22574. */
  22575. export class NodeMaterialBuildState {
  22576. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22577. supportUniformBuffers: boolean;
  22578. /**
  22579. * Gets the list of emitted attributes
  22580. */
  22581. attributes: string[];
  22582. /**
  22583. * Gets the list of emitted uniforms
  22584. */
  22585. uniforms: string[];
  22586. /**
  22587. * Gets the list of emitted constants
  22588. */
  22589. constants: string[];
  22590. /**
  22591. * Gets the list of emitted samplers
  22592. */
  22593. samplers: string[];
  22594. /**
  22595. * Gets the list of emitted functions
  22596. */
  22597. functions: {
  22598. [key: string]: string;
  22599. };
  22600. /**
  22601. * Gets the list of emitted extensions
  22602. */
  22603. extensions: {
  22604. [key: string]: string;
  22605. };
  22606. /**
  22607. * Gets the target of the compilation state
  22608. */
  22609. target: NodeMaterialBlockTargets;
  22610. /**
  22611. * Gets the list of emitted counters
  22612. */
  22613. counters: {
  22614. [key: string]: number;
  22615. };
  22616. /**
  22617. * Shared data between multiple NodeMaterialBuildState instances
  22618. */
  22619. sharedData: NodeMaterialBuildStateSharedData;
  22620. /** @hidden */
  22621. _vertexState: NodeMaterialBuildState;
  22622. /** @hidden */
  22623. _attributeDeclaration: string;
  22624. /** @hidden */
  22625. _uniformDeclaration: string;
  22626. /** @hidden */
  22627. _constantDeclaration: string;
  22628. /** @hidden */
  22629. _samplerDeclaration: string;
  22630. /** @hidden */
  22631. _varyingTransfer: string;
  22632. /** @hidden */
  22633. _injectAtEnd: string;
  22634. private _repeatableContentAnchorIndex;
  22635. /** @hidden */
  22636. _builtCompilationString: string;
  22637. /**
  22638. * Gets the emitted compilation strings
  22639. */
  22640. compilationString: string;
  22641. /**
  22642. * Finalize the compilation strings
  22643. * @param state defines the current compilation state
  22644. */
  22645. finalize(state: NodeMaterialBuildState): void;
  22646. /** @hidden */
  22647. get _repeatableContentAnchor(): string;
  22648. /** @hidden */
  22649. _getFreeVariableName(prefix: string): string;
  22650. /** @hidden */
  22651. _getFreeDefineName(prefix: string): string;
  22652. /** @hidden */
  22653. _excludeVariableName(name: string): void;
  22654. /** @hidden */
  22655. _emit2DSampler(name: string): void;
  22656. /** @hidden */
  22657. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22658. /** @hidden */
  22659. _emitExtension(name: string, extension: string, define?: string): void;
  22660. /** @hidden */
  22661. _emitFunction(name: string, code: string, comments: string): void;
  22662. /** @hidden */
  22663. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22664. replaceStrings?: {
  22665. search: RegExp;
  22666. replace: string;
  22667. }[];
  22668. repeatKey?: string;
  22669. }): string;
  22670. /** @hidden */
  22671. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22672. repeatKey?: string;
  22673. removeAttributes?: boolean;
  22674. removeUniforms?: boolean;
  22675. removeVaryings?: boolean;
  22676. removeIfDef?: boolean;
  22677. replaceStrings?: {
  22678. search: RegExp;
  22679. replace: string;
  22680. }[];
  22681. }, storeKey?: string): void;
  22682. /** @hidden */
  22683. _registerTempVariable(name: string): boolean;
  22684. /** @hidden */
  22685. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22686. /** @hidden */
  22687. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22688. /** @hidden */
  22689. _emitFloat(value: number): string;
  22690. }
  22691. }
  22692. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22693. /**
  22694. * Helper class used to generate session unique ID
  22695. */
  22696. export class UniqueIdGenerator {
  22697. private static _UniqueIdCounter;
  22698. /**
  22699. * Gets an unique (relatively to the current scene) Id
  22700. */
  22701. static get UniqueId(): number;
  22702. }
  22703. }
  22704. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22705. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22707. import { Nullable } from "babylonjs/types";
  22708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22709. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22710. import { Effect } from "babylonjs/Materials/effect";
  22711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22712. import { Mesh } from "babylonjs/Meshes/mesh";
  22713. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22714. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22715. import { Scene } from "babylonjs/scene";
  22716. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22717. /**
  22718. * Defines a block that can be used inside a node based material
  22719. */
  22720. export class NodeMaterialBlock {
  22721. private _buildId;
  22722. private _buildTarget;
  22723. private _target;
  22724. private _isFinalMerger;
  22725. private _isInput;
  22726. private _name;
  22727. protected _isUnique: boolean;
  22728. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22729. inputsAreExclusive: boolean;
  22730. /** @hidden */
  22731. _codeVariableName: string;
  22732. /** @hidden */
  22733. _inputs: NodeMaterialConnectionPoint[];
  22734. /** @hidden */
  22735. _outputs: NodeMaterialConnectionPoint[];
  22736. /** @hidden */
  22737. _preparationId: number;
  22738. /**
  22739. * Gets the name of the block
  22740. */
  22741. get name(): string;
  22742. /**
  22743. * Sets the name of the block. Will check if the name is valid.
  22744. */
  22745. set name(newName: string);
  22746. /**
  22747. * Gets or sets the unique id of the node
  22748. */
  22749. uniqueId: number;
  22750. /**
  22751. * Gets or sets the comments associated with this block
  22752. */
  22753. comments: string;
  22754. /**
  22755. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22756. */
  22757. get isUnique(): boolean;
  22758. /**
  22759. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22760. */
  22761. get isFinalMerger(): boolean;
  22762. /**
  22763. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22764. */
  22765. get isInput(): boolean;
  22766. /**
  22767. * Gets or sets the build Id
  22768. */
  22769. get buildId(): number;
  22770. set buildId(value: number);
  22771. /**
  22772. * Gets or sets the target of the block
  22773. */
  22774. get target(): NodeMaterialBlockTargets;
  22775. set target(value: NodeMaterialBlockTargets);
  22776. /**
  22777. * Gets the list of input points
  22778. */
  22779. get inputs(): NodeMaterialConnectionPoint[];
  22780. /** Gets the list of output points */
  22781. get outputs(): NodeMaterialConnectionPoint[];
  22782. /**
  22783. * Find an input by its name
  22784. * @param name defines the name of the input to look for
  22785. * @returns the input or null if not found
  22786. */
  22787. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22788. /**
  22789. * Find an output by its name
  22790. * @param name defines the name of the outputto look for
  22791. * @returns the output or null if not found
  22792. */
  22793. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22794. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22795. visibleInInspector: boolean;
  22796. /**
  22797. * Creates a new NodeMaterialBlock
  22798. * @param name defines the block name
  22799. * @param target defines the target of that block (Vertex by default)
  22800. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22801. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22802. */
  22803. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22804. /**
  22805. * Initialize the block and prepare the context for build
  22806. * @param state defines the state that will be used for the build
  22807. */
  22808. initialize(state: NodeMaterialBuildState): void;
  22809. /**
  22810. * Bind data to effect. Will only be called for blocks with isBindable === true
  22811. * @param effect defines the effect to bind data to
  22812. * @param nodeMaterial defines the hosting NodeMaterial
  22813. * @param mesh defines the mesh that will be rendered
  22814. * @param subMesh defines the submesh that will be rendered
  22815. */
  22816. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22817. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22818. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22819. protected _writeFloat(value: number): string;
  22820. /**
  22821. * Gets the current class name e.g. "NodeMaterialBlock"
  22822. * @returns the class name
  22823. */
  22824. getClassName(): string;
  22825. /**
  22826. * Register a new input. Must be called inside a block constructor
  22827. * @param name defines the connection point name
  22828. * @param type defines the connection point type
  22829. * @param isOptional defines a boolean indicating that this input can be omitted
  22830. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22831. * @param point an already created connection point. If not provided, create a new one
  22832. * @returns the current block
  22833. */
  22834. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22835. /**
  22836. * Register a new output. Must be called inside a block constructor
  22837. * @param name defines the connection point name
  22838. * @param type defines the connection point type
  22839. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22840. * @param point an already created connection point. If not provided, create a new one
  22841. * @returns the current block
  22842. */
  22843. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22844. /**
  22845. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22846. * @param forOutput defines an optional connection point to check compatibility with
  22847. * @returns the first available input or null
  22848. */
  22849. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22850. /**
  22851. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22852. * @param forBlock defines an optional block to check compatibility with
  22853. * @returns the first available input or null
  22854. */
  22855. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22856. /**
  22857. * Gets the sibling of the given output
  22858. * @param current defines the current output
  22859. * @returns the next output in the list or null
  22860. */
  22861. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22862. /**
  22863. * Connect current block with another block
  22864. * @param other defines the block to connect with
  22865. * @param options define the various options to help pick the right connections
  22866. * @returns the current block
  22867. */
  22868. connectTo(other: NodeMaterialBlock, options?: {
  22869. input?: string;
  22870. output?: string;
  22871. outputSwizzle?: string;
  22872. }): this | undefined;
  22873. protected _buildBlock(state: NodeMaterialBuildState): void;
  22874. /**
  22875. * Add uniforms, samplers and uniform buffers at compilation time
  22876. * @param state defines the state to update
  22877. * @param nodeMaterial defines the node material requesting the update
  22878. * @param defines defines the material defines to update
  22879. * @param uniformBuffers defines the list of uniform buffer names
  22880. */
  22881. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22882. /**
  22883. * Add potential fallbacks if shader compilation fails
  22884. * @param mesh defines the mesh to be rendered
  22885. * @param fallbacks defines the current prioritized list of fallbacks
  22886. */
  22887. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22888. /**
  22889. * Initialize defines for shader compilation
  22890. * @param mesh defines the mesh to be rendered
  22891. * @param nodeMaterial defines the node material requesting the update
  22892. * @param defines defines the material defines to update
  22893. * @param useInstances specifies that instances should be used
  22894. */
  22895. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22896. /**
  22897. * Update defines for shader compilation
  22898. * @param mesh defines the mesh to be rendered
  22899. * @param nodeMaterial defines the node material requesting the update
  22900. * @param defines defines the material defines to update
  22901. * @param useInstances specifies that instances should be used
  22902. * @param subMesh defines which submesh to render
  22903. */
  22904. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22905. /**
  22906. * Lets the block try to connect some inputs automatically
  22907. * @param material defines the hosting NodeMaterial
  22908. */
  22909. autoConfigure(material: NodeMaterial): void;
  22910. /**
  22911. * Function called when a block is declared as repeatable content generator
  22912. * @param vertexShaderState defines the current compilation state for the vertex shader
  22913. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22914. * @param mesh defines the mesh to be rendered
  22915. * @param defines defines the material defines to update
  22916. */
  22917. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22918. /**
  22919. * Checks if the block is ready
  22920. * @param mesh defines the mesh to be rendered
  22921. * @param nodeMaterial defines the node material requesting the update
  22922. * @param defines defines the material defines to update
  22923. * @param useInstances specifies that instances should be used
  22924. * @returns true if the block is ready
  22925. */
  22926. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22927. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22928. private _processBuild;
  22929. /**
  22930. * Validates the new name for the block node.
  22931. * @param newName the new name to be given to the node.
  22932. * @returns false if the name is a reserve word, else true.
  22933. */
  22934. validateBlockName(newName: string): boolean;
  22935. /**
  22936. * Compile the current node and generate the shader code
  22937. * @param state defines the current compilation state (uniforms, samplers, current string)
  22938. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22939. * @returns true if already built
  22940. */
  22941. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22942. protected _inputRename(name: string): string;
  22943. protected _outputRename(name: string): string;
  22944. protected _dumpPropertiesCode(): string;
  22945. /** @hidden */
  22946. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22947. /** @hidden */
  22948. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22949. /**
  22950. * Clone the current block to a new identical block
  22951. * @param scene defines the hosting scene
  22952. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22953. * @returns a copy of the current block
  22954. */
  22955. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22956. /**
  22957. * Serializes this block in a JSON representation
  22958. * @returns the serialized block object
  22959. */
  22960. serialize(): any;
  22961. /** @hidden */
  22962. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22963. private _deserializePortDisplayNamesAndExposedOnFrame;
  22964. /**
  22965. * Release resources
  22966. */
  22967. dispose(): void;
  22968. }
  22969. }
  22970. declare module "babylonjs/Materials/pushMaterial" {
  22971. import { Nullable } from "babylonjs/types";
  22972. import { Scene } from "babylonjs/scene";
  22973. import { Matrix } from "babylonjs/Maths/math.vector";
  22974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22975. import { Mesh } from "babylonjs/Meshes/mesh";
  22976. import { Material } from "babylonjs/Materials/material";
  22977. import { Effect } from "babylonjs/Materials/effect";
  22978. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22979. /**
  22980. * Base class of materials working in push mode in babylon JS
  22981. * @hidden
  22982. */
  22983. export class PushMaterial extends Material {
  22984. protected _activeEffect: Effect;
  22985. protected _normalMatrix: Matrix;
  22986. constructor(name: string, scene: Scene);
  22987. getEffect(): Effect;
  22988. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22989. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22990. /**
  22991. * Binds the given world matrix to the active effect
  22992. *
  22993. * @param world the matrix to bind
  22994. */
  22995. bindOnlyWorldMatrix(world: Matrix): void;
  22996. /**
  22997. * Binds the given normal matrix to the active effect
  22998. *
  22999. * @param normalMatrix the matrix to bind
  23000. */
  23001. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  23002. bind(world: Matrix, mesh?: Mesh): void;
  23003. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  23004. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  23005. }
  23006. }
  23007. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  23008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23009. /**
  23010. * Root class for all node material optimizers
  23011. */
  23012. export class NodeMaterialOptimizer {
  23013. /**
  23014. * Function used to optimize a NodeMaterial graph
  23015. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  23016. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  23017. */
  23018. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  23019. }
  23020. }
  23021. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  23022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23023. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23025. import { Scene } from "babylonjs/scene";
  23026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23027. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  23028. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23029. /**
  23030. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  23031. */
  23032. export class TransformBlock extends NodeMaterialBlock {
  23033. /**
  23034. * Defines the value to use to complement W value to transform it to a Vector4
  23035. */
  23036. complementW: number;
  23037. /**
  23038. * Defines the value to use to complement z value to transform it to a Vector4
  23039. */
  23040. complementZ: number;
  23041. /**
  23042. * Creates a new TransformBlock
  23043. * @param name defines the block name
  23044. */
  23045. constructor(name: string);
  23046. /**
  23047. * Gets the current class name
  23048. * @returns the class name
  23049. */
  23050. getClassName(): string;
  23051. /**
  23052. * Gets the vector input
  23053. */
  23054. get vector(): NodeMaterialConnectionPoint;
  23055. /**
  23056. * Gets the output component
  23057. */
  23058. get output(): NodeMaterialConnectionPoint;
  23059. /**
  23060. * Gets the xyz output component
  23061. */
  23062. get xyz(): NodeMaterialConnectionPoint;
  23063. /**
  23064. * Gets the matrix transform input
  23065. */
  23066. get transform(): NodeMaterialConnectionPoint;
  23067. protected _buildBlock(state: NodeMaterialBuildState): this;
  23068. /**
  23069. * Update defines for shader compilation
  23070. * @param mesh defines the mesh to be rendered
  23071. * @param nodeMaterial defines the node material requesting the update
  23072. * @param defines defines the material defines to update
  23073. * @param useInstances specifies that instances should be used
  23074. * @param subMesh defines which submesh to render
  23075. */
  23076. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  23077. serialize(): any;
  23078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23079. protected _dumpPropertiesCode(): string;
  23080. }
  23081. }
  23082. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  23083. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23084. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23085. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23086. /**
  23087. * Block used to output the vertex position
  23088. */
  23089. export class VertexOutputBlock extends NodeMaterialBlock {
  23090. /**
  23091. * Creates a new VertexOutputBlock
  23092. * @param name defines the block name
  23093. */
  23094. constructor(name: string);
  23095. /**
  23096. * Gets the current class name
  23097. * @returns the class name
  23098. */
  23099. getClassName(): string;
  23100. /**
  23101. * Gets the vector input component
  23102. */
  23103. get vector(): NodeMaterialConnectionPoint;
  23104. protected _buildBlock(state: NodeMaterialBuildState): this;
  23105. }
  23106. }
  23107. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  23108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23111. /**
  23112. * Block used to output the final color
  23113. */
  23114. export class FragmentOutputBlock extends NodeMaterialBlock {
  23115. /**
  23116. * Create a new FragmentOutputBlock
  23117. * @param name defines the block name
  23118. */
  23119. constructor(name: string);
  23120. /**
  23121. * Gets the current class name
  23122. * @returns the class name
  23123. */
  23124. getClassName(): string;
  23125. /**
  23126. * Gets the rgba input component
  23127. */
  23128. get rgba(): NodeMaterialConnectionPoint;
  23129. /**
  23130. * Gets the rgb input component
  23131. */
  23132. get rgb(): NodeMaterialConnectionPoint;
  23133. /**
  23134. * Gets the a input component
  23135. */
  23136. get a(): NodeMaterialConnectionPoint;
  23137. protected _buildBlock(state: NodeMaterialBuildState): this;
  23138. }
  23139. }
  23140. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  23141. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23142. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23143. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23144. /**
  23145. * Block used for the particle ramp gradient section
  23146. */
  23147. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  23148. /**
  23149. * Create a new ParticleRampGradientBlock
  23150. * @param name defines the block name
  23151. */
  23152. constructor(name: string);
  23153. /**
  23154. * Gets the current class name
  23155. * @returns the class name
  23156. */
  23157. getClassName(): string;
  23158. /**
  23159. * Gets the color input component
  23160. */
  23161. get color(): NodeMaterialConnectionPoint;
  23162. /**
  23163. * Gets the rampColor output component
  23164. */
  23165. get rampColor(): NodeMaterialConnectionPoint;
  23166. /**
  23167. * Initialize the block and prepare the context for build
  23168. * @param state defines the state that will be used for the build
  23169. */
  23170. initialize(state: NodeMaterialBuildState): void;
  23171. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23172. }
  23173. }
  23174. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  23175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23178. /**
  23179. * Block used for the particle blend multiply section
  23180. */
  23181. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  23182. /**
  23183. * Create a new ParticleBlendMultiplyBlock
  23184. * @param name defines the block name
  23185. */
  23186. constructor(name: string);
  23187. /**
  23188. * Gets the current class name
  23189. * @returns the class name
  23190. */
  23191. getClassName(): string;
  23192. /**
  23193. * Gets the color input component
  23194. */
  23195. get color(): NodeMaterialConnectionPoint;
  23196. /**
  23197. * Gets the alphaTexture input component
  23198. */
  23199. get alphaTexture(): NodeMaterialConnectionPoint;
  23200. /**
  23201. * Gets the alphaColor input component
  23202. */
  23203. get alphaColor(): NodeMaterialConnectionPoint;
  23204. /**
  23205. * Gets the blendColor output component
  23206. */
  23207. get blendColor(): NodeMaterialConnectionPoint;
  23208. /**
  23209. * Initialize the block and prepare the context for build
  23210. * @param state defines the state that will be used for the build
  23211. */
  23212. initialize(state: NodeMaterialBuildState): void;
  23213. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23214. }
  23215. }
  23216. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  23217. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23218. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23219. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23220. /**
  23221. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  23222. */
  23223. export class VectorMergerBlock extends NodeMaterialBlock {
  23224. /**
  23225. * Create a new VectorMergerBlock
  23226. * @param name defines the block name
  23227. */
  23228. constructor(name: string);
  23229. /**
  23230. * Gets the current class name
  23231. * @returns the class name
  23232. */
  23233. getClassName(): string;
  23234. /**
  23235. * Gets the xyz component (input)
  23236. */
  23237. get xyzIn(): NodeMaterialConnectionPoint;
  23238. /**
  23239. * Gets the xy component (input)
  23240. */
  23241. get xyIn(): NodeMaterialConnectionPoint;
  23242. /**
  23243. * Gets the x component (input)
  23244. */
  23245. get x(): NodeMaterialConnectionPoint;
  23246. /**
  23247. * Gets the y component (input)
  23248. */
  23249. get y(): NodeMaterialConnectionPoint;
  23250. /**
  23251. * Gets the z component (input)
  23252. */
  23253. get z(): NodeMaterialConnectionPoint;
  23254. /**
  23255. * Gets the w component (input)
  23256. */
  23257. get w(): NodeMaterialConnectionPoint;
  23258. /**
  23259. * Gets the xyzw component (output)
  23260. */
  23261. get xyzw(): NodeMaterialConnectionPoint;
  23262. /**
  23263. * Gets the xyz component (output)
  23264. */
  23265. get xyzOut(): NodeMaterialConnectionPoint;
  23266. /**
  23267. * Gets the xy component (output)
  23268. */
  23269. get xyOut(): NodeMaterialConnectionPoint;
  23270. /**
  23271. * Gets the xy component (output)
  23272. * @deprecated Please use xyOut instead.
  23273. */
  23274. get xy(): NodeMaterialConnectionPoint;
  23275. /**
  23276. * Gets the xyz component (output)
  23277. * @deprecated Please use xyzOut instead.
  23278. */
  23279. get xyz(): NodeMaterialConnectionPoint;
  23280. protected _buildBlock(state: NodeMaterialBuildState): this;
  23281. }
  23282. }
  23283. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  23284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23287. import { Vector2 } from "babylonjs/Maths/math.vector";
  23288. import { Scene } from "babylonjs/scene";
  23289. /**
  23290. * Block used to remap a float from a range to a new one
  23291. */
  23292. export class RemapBlock extends NodeMaterialBlock {
  23293. /**
  23294. * Gets or sets the source range
  23295. */
  23296. sourceRange: Vector2;
  23297. /**
  23298. * Gets or sets the target range
  23299. */
  23300. targetRange: Vector2;
  23301. /**
  23302. * Creates a new RemapBlock
  23303. * @param name defines the block name
  23304. */
  23305. constructor(name: string);
  23306. /**
  23307. * Gets the current class name
  23308. * @returns the class name
  23309. */
  23310. getClassName(): string;
  23311. /**
  23312. * Gets the input component
  23313. */
  23314. get input(): NodeMaterialConnectionPoint;
  23315. /**
  23316. * Gets the source min input component
  23317. */
  23318. get sourceMin(): NodeMaterialConnectionPoint;
  23319. /**
  23320. * Gets the source max input component
  23321. */
  23322. get sourceMax(): NodeMaterialConnectionPoint;
  23323. /**
  23324. * Gets the target min input component
  23325. */
  23326. get targetMin(): NodeMaterialConnectionPoint;
  23327. /**
  23328. * Gets the target max input component
  23329. */
  23330. get targetMax(): NodeMaterialConnectionPoint;
  23331. /**
  23332. * Gets the output component
  23333. */
  23334. get output(): NodeMaterialConnectionPoint;
  23335. protected _buildBlock(state: NodeMaterialBuildState): this;
  23336. protected _dumpPropertiesCode(): string;
  23337. serialize(): any;
  23338. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23339. }
  23340. }
  23341. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23345. /**
  23346. * Block used to multiply 2 values
  23347. */
  23348. export class MultiplyBlock extends NodeMaterialBlock {
  23349. /**
  23350. * Creates a new MultiplyBlock
  23351. * @param name defines the block name
  23352. */
  23353. constructor(name: string);
  23354. /**
  23355. * Gets the current class name
  23356. * @returns the class name
  23357. */
  23358. getClassName(): string;
  23359. /**
  23360. * Gets the left operand input component
  23361. */
  23362. get left(): NodeMaterialConnectionPoint;
  23363. /**
  23364. * Gets the right operand input component
  23365. */
  23366. get right(): NodeMaterialConnectionPoint;
  23367. /**
  23368. * Gets the output component
  23369. */
  23370. get output(): NodeMaterialConnectionPoint;
  23371. protected _buildBlock(state: NodeMaterialBuildState): this;
  23372. }
  23373. }
  23374. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23375. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23376. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23378. /**
  23379. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23380. */
  23381. export class ColorSplitterBlock extends NodeMaterialBlock {
  23382. /**
  23383. * Create a new ColorSplitterBlock
  23384. * @param name defines the block name
  23385. */
  23386. constructor(name: string);
  23387. /**
  23388. * Gets the current class name
  23389. * @returns the class name
  23390. */
  23391. getClassName(): string;
  23392. /**
  23393. * Gets the rgba component (input)
  23394. */
  23395. get rgba(): NodeMaterialConnectionPoint;
  23396. /**
  23397. * Gets the rgb component (input)
  23398. */
  23399. get rgbIn(): NodeMaterialConnectionPoint;
  23400. /**
  23401. * Gets the rgb component (output)
  23402. */
  23403. get rgbOut(): NodeMaterialConnectionPoint;
  23404. /**
  23405. * Gets the r component (output)
  23406. */
  23407. get r(): NodeMaterialConnectionPoint;
  23408. /**
  23409. * Gets the g component (output)
  23410. */
  23411. get g(): NodeMaterialConnectionPoint;
  23412. /**
  23413. * Gets the b component (output)
  23414. */
  23415. get b(): NodeMaterialConnectionPoint;
  23416. /**
  23417. * Gets the a component (output)
  23418. */
  23419. get a(): NodeMaterialConnectionPoint;
  23420. protected _inputRename(name: string): string;
  23421. protected _outputRename(name: string): string;
  23422. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23423. }
  23424. }
  23425. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23427. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23428. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23429. import { Scene } from "babylonjs/scene";
  23430. /**
  23431. * Operations supported by the Trigonometry block
  23432. */
  23433. export enum TrigonometryBlockOperations {
  23434. /** Cos */
  23435. Cos = 0,
  23436. /** Sin */
  23437. Sin = 1,
  23438. /** Abs */
  23439. Abs = 2,
  23440. /** Exp */
  23441. Exp = 3,
  23442. /** Exp2 */
  23443. Exp2 = 4,
  23444. /** Round */
  23445. Round = 5,
  23446. /** Floor */
  23447. Floor = 6,
  23448. /** Ceiling */
  23449. Ceiling = 7,
  23450. /** Square root */
  23451. Sqrt = 8,
  23452. /** Log */
  23453. Log = 9,
  23454. /** Tangent */
  23455. Tan = 10,
  23456. /** Arc tangent */
  23457. ArcTan = 11,
  23458. /** Arc cosinus */
  23459. ArcCos = 12,
  23460. /** Arc sinus */
  23461. ArcSin = 13,
  23462. /** Fraction */
  23463. Fract = 14,
  23464. /** Sign */
  23465. Sign = 15,
  23466. /** To radians (from degrees) */
  23467. Radians = 16,
  23468. /** To degrees (from radians) */
  23469. Degrees = 17
  23470. }
  23471. /**
  23472. * Block used to apply trigonometry operation to floats
  23473. */
  23474. export class TrigonometryBlock extends NodeMaterialBlock {
  23475. /**
  23476. * Gets or sets the operation applied by the block
  23477. */
  23478. operation: TrigonometryBlockOperations;
  23479. /**
  23480. * Creates a new TrigonometryBlock
  23481. * @param name defines the block name
  23482. */
  23483. constructor(name: string);
  23484. /**
  23485. * Gets the current class name
  23486. * @returns the class name
  23487. */
  23488. getClassName(): string;
  23489. /**
  23490. * Gets the input component
  23491. */
  23492. get input(): NodeMaterialConnectionPoint;
  23493. /**
  23494. * Gets the output component
  23495. */
  23496. get output(): NodeMaterialConnectionPoint;
  23497. protected _buildBlock(state: NodeMaterialBuildState): this;
  23498. serialize(): any;
  23499. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23500. protected _dumpPropertiesCode(): string;
  23501. }
  23502. }
  23503. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23505. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23506. import { Scene } from "babylonjs/scene";
  23507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23508. import { Matrix } from "babylonjs/Maths/math.vector";
  23509. import { Mesh } from "babylonjs/Meshes/mesh";
  23510. import { Engine } from "babylonjs/Engines/engine";
  23511. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23512. import { Observable } from "babylonjs/Misc/observable";
  23513. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23514. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23515. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23516. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23517. import { Nullable } from "babylonjs/types";
  23518. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23519. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23520. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23521. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23522. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23523. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23524. import { Effect } from "babylonjs/Materials/effect";
  23525. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23526. import { Camera } from "babylonjs/Cameras/camera";
  23527. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23528. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23529. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23530. /**
  23531. * Interface used to configure the node material editor
  23532. */
  23533. export interface INodeMaterialEditorOptions {
  23534. /** Define the URl to load node editor script */
  23535. editorURL?: string;
  23536. }
  23537. /** @hidden */
  23538. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23539. NORMAL: boolean;
  23540. TANGENT: boolean;
  23541. UV1: boolean;
  23542. /** BONES */
  23543. NUM_BONE_INFLUENCERS: number;
  23544. BonesPerMesh: number;
  23545. BONETEXTURE: boolean;
  23546. /** MORPH TARGETS */
  23547. MORPHTARGETS: boolean;
  23548. MORPHTARGETS_NORMAL: boolean;
  23549. MORPHTARGETS_TANGENT: boolean;
  23550. MORPHTARGETS_UV: boolean;
  23551. NUM_MORPH_INFLUENCERS: number;
  23552. /** IMAGE PROCESSING */
  23553. IMAGEPROCESSING: boolean;
  23554. VIGNETTE: boolean;
  23555. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23556. VIGNETTEBLENDMODEOPAQUE: boolean;
  23557. TONEMAPPING: boolean;
  23558. TONEMAPPING_ACES: boolean;
  23559. CONTRAST: boolean;
  23560. EXPOSURE: boolean;
  23561. COLORCURVES: boolean;
  23562. COLORGRADING: boolean;
  23563. COLORGRADING3D: boolean;
  23564. SAMPLER3DGREENDEPTH: boolean;
  23565. SAMPLER3DBGRMAP: boolean;
  23566. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23567. /** MISC. */
  23568. BUMPDIRECTUV: number;
  23569. constructor();
  23570. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23571. }
  23572. /**
  23573. * Class used to configure NodeMaterial
  23574. */
  23575. export interface INodeMaterialOptions {
  23576. /**
  23577. * Defines if blocks should emit comments
  23578. */
  23579. emitComments: boolean;
  23580. }
  23581. /**
  23582. * Class used to create a node based material built by assembling shader blocks
  23583. */
  23584. export class NodeMaterial extends PushMaterial {
  23585. private static _BuildIdGenerator;
  23586. private _options;
  23587. private _vertexCompilationState;
  23588. private _fragmentCompilationState;
  23589. private _sharedData;
  23590. private _buildId;
  23591. private _buildWasSuccessful;
  23592. private _cachedWorldViewMatrix;
  23593. private _cachedWorldViewProjectionMatrix;
  23594. private _optimizers;
  23595. private _animationFrame;
  23596. /** Define the Url to load node editor script */
  23597. static EditorURL: string;
  23598. /** Define the Url to load snippets */
  23599. static SnippetUrl: string;
  23600. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23601. static IgnoreTexturesAtLoadTime: boolean;
  23602. private BJSNODEMATERIALEDITOR;
  23603. /** Get the inspector from bundle or global */
  23604. private _getGlobalNodeMaterialEditor;
  23605. /**
  23606. * Snippet ID if the material was created from the snippet server
  23607. */
  23608. snippetId: string;
  23609. /**
  23610. * Gets or sets data used by visual editor
  23611. * @see https://nme.babylonjs.com
  23612. */
  23613. editorData: any;
  23614. /**
  23615. * 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)
  23616. */
  23617. ignoreAlpha: boolean;
  23618. /**
  23619. * Defines the maximum number of lights that can be used in the material
  23620. */
  23621. maxSimultaneousLights: number;
  23622. /**
  23623. * Observable raised when the material is built
  23624. */
  23625. onBuildObservable: Observable<NodeMaterial>;
  23626. /**
  23627. * Gets or sets the root nodes of the material vertex shader
  23628. */
  23629. _vertexOutputNodes: NodeMaterialBlock[];
  23630. /**
  23631. * Gets or sets the root nodes of the material fragment (pixel) shader
  23632. */
  23633. _fragmentOutputNodes: NodeMaterialBlock[];
  23634. /** Gets or sets options to control the node material overall behavior */
  23635. get options(): INodeMaterialOptions;
  23636. set options(options: INodeMaterialOptions);
  23637. /**
  23638. * Default configuration related to image processing available in the standard Material.
  23639. */
  23640. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23641. /**
  23642. * Gets the image processing configuration used either in this material.
  23643. */
  23644. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23645. /**
  23646. * Sets the Default image processing configuration used either in the this material.
  23647. *
  23648. * If sets to null, the scene one is in use.
  23649. */
  23650. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23651. /**
  23652. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23653. */
  23654. attachedBlocks: NodeMaterialBlock[];
  23655. /**
  23656. * Specifies the mode of the node material
  23657. * @hidden
  23658. */
  23659. _mode: NodeMaterialModes;
  23660. /**
  23661. * Gets the mode property
  23662. */
  23663. get mode(): NodeMaterialModes;
  23664. /**
  23665. * A free comment about the material
  23666. */
  23667. comment: string;
  23668. /**
  23669. * Create a new node based material
  23670. * @param name defines the material name
  23671. * @param scene defines the hosting scene
  23672. * @param options defines creation option
  23673. */
  23674. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23675. /**
  23676. * Gets the current class name of the material e.g. "NodeMaterial"
  23677. * @returns the class name
  23678. */
  23679. getClassName(): string;
  23680. /**
  23681. * Keep track of the image processing observer to allow dispose and replace.
  23682. */
  23683. private _imageProcessingObserver;
  23684. /**
  23685. * Attaches a new image processing configuration to the Standard Material.
  23686. * @param configuration
  23687. */
  23688. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23689. /**
  23690. * Get a block by its name
  23691. * @param name defines the name of the block to retrieve
  23692. * @returns the required block or null if not found
  23693. */
  23694. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23695. /**
  23696. * Get a block by its name
  23697. * @param predicate defines the predicate used to find the good candidate
  23698. * @returns the required block or null if not found
  23699. */
  23700. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23701. /**
  23702. * Get an input block by its name
  23703. * @param predicate defines the predicate used to find the good candidate
  23704. * @returns the required input block or null if not found
  23705. */
  23706. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23707. /**
  23708. * Gets the list of input blocks attached to this material
  23709. * @returns an array of InputBlocks
  23710. */
  23711. getInputBlocks(): InputBlock[];
  23712. /**
  23713. * Adds a new optimizer to the list of optimizers
  23714. * @param optimizer defines the optimizers to add
  23715. * @returns the current material
  23716. */
  23717. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23718. /**
  23719. * Remove an optimizer from the list of optimizers
  23720. * @param optimizer defines the optimizers to remove
  23721. * @returns the current material
  23722. */
  23723. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23724. /**
  23725. * Add a new block to the list of output nodes
  23726. * @param node defines the node to add
  23727. * @returns the current material
  23728. */
  23729. addOutputNode(node: NodeMaterialBlock): this;
  23730. /**
  23731. * Remove a block from the list of root nodes
  23732. * @param node defines the node to remove
  23733. * @returns the current material
  23734. */
  23735. removeOutputNode(node: NodeMaterialBlock): this;
  23736. private _addVertexOutputNode;
  23737. private _removeVertexOutputNode;
  23738. private _addFragmentOutputNode;
  23739. private _removeFragmentOutputNode;
  23740. /**
  23741. * Specifies if the material will require alpha blending
  23742. * @returns a boolean specifying if alpha blending is needed
  23743. */
  23744. needAlphaBlending(): boolean;
  23745. /**
  23746. * Specifies if this material should be rendered in alpha test mode
  23747. * @returns a boolean specifying if an alpha test is needed.
  23748. */
  23749. needAlphaTesting(): boolean;
  23750. private _initializeBlock;
  23751. private _resetDualBlocks;
  23752. /**
  23753. * Remove a block from the current node material
  23754. * @param block defines the block to remove
  23755. */
  23756. removeBlock(block: NodeMaterialBlock): void;
  23757. /**
  23758. * Build the material and generates the inner effect
  23759. * @param verbose defines if the build should log activity
  23760. */
  23761. build(verbose?: boolean): void;
  23762. /**
  23763. * Runs an otpimization phase to try to improve the shader code
  23764. */
  23765. optimize(): void;
  23766. private _prepareDefinesForAttributes;
  23767. /**
  23768. * Create a post process from the material
  23769. * @param camera The camera to apply the render pass to.
  23770. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23772. * @param engine The engine which the post process will be applied. (default: current engine)
  23773. * @param reusable If the post process can be reused on the same frame. (default: false)
  23774. * @param textureType Type of textures used when performing the post process. (default: 0)
  23775. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23776. * @returns the post process created
  23777. */
  23778. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23779. /**
  23780. * Create the post process effect from the material
  23781. * @param postProcess The post process to create the effect for
  23782. */
  23783. createEffectForPostProcess(postProcess: PostProcess): void;
  23784. private _createEffectForPostProcess;
  23785. /**
  23786. * Create a new procedural texture based on this node material
  23787. * @param size defines the size of the texture
  23788. * @param scene defines the hosting scene
  23789. * @returns the new procedural texture attached to this node material
  23790. */
  23791. createProceduralTexture(size: number | {
  23792. width: number;
  23793. height: number;
  23794. layers?: number;
  23795. }, scene: Scene): Nullable<ProceduralTexture>;
  23796. private _createEffectForParticles;
  23797. private _checkInternals;
  23798. /**
  23799. * Create the effect to be used as the custom effect for a particle system
  23800. * @param particleSystem Particle system to create the effect for
  23801. * @param onCompiled defines a function to call when the effect creation is successful
  23802. * @param onError defines a function to call when the effect creation has failed
  23803. */
  23804. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23805. private _processDefines;
  23806. /**
  23807. * Get if the submesh is ready to be used and all its information available.
  23808. * Child classes can use it to update shaders
  23809. * @param mesh defines the mesh to check
  23810. * @param subMesh defines which submesh to check
  23811. * @param useInstances specifies that instances should be used
  23812. * @returns a boolean indicating that the submesh is ready or not
  23813. */
  23814. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23815. /**
  23816. * Get a string representing the shaders built by the current node graph
  23817. */
  23818. get compiledShaders(): string;
  23819. /**
  23820. * Binds the world matrix to the material
  23821. * @param world defines the world transformation matrix
  23822. */
  23823. bindOnlyWorldMatrix(world: Matrix): void;
  23824. /**
  23825. * Binds the submesh to this material by preparing the effect and shader to draw
  23826. * @param world defines the world transformation matrix
  23827. * @param mesh defines the mesh containing the submesh
  23828. * @param subMesh defines the submesh to bind the material to
  23829. */
  23830. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23831. /**
  23832. * Gets the active textures from the material
  23833. * @returns an array of textures
  23834. */
  23835. getActiveTextures(): BaseTexture[];
  23836. /**
  23837. * Gets the list of texture blocks
  23838. * @returns an array of texture blocks
  23839. */
  23840. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23841. /**
  23842. * Specifies if the material uses a texture
  23843. * @param texture defines the texture to check against the material
  23844. * @returns a boolean specifying if the material uses the texture
  23845. */
  23846. hasTexture(texture: BaseTexture): boolean;
  23847. /**
  23848. * Disposes the material
  23849. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23850. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23851. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23852. */
  23853. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23854. /** Creates the node editor window. */
  23855. private _createNodeEditor;
  23856. /**
  23857. * Launch the node material editor
  23858. * @param config Define the configuration of the editor
  23859. * @return a promise fulfilled when the node editor is visible
  23860. */
  23861. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23862. /**
  23863. * Clear the current material
  23864. */
  23865. clear(): void;
  23866. /**
  23867. * Clear the current material and set it to a default state
  23868. */
  23869. setToDefault(): void;
  23870. /**
  23871. * Clear the current material and set it to a default state for post process
  23872. */
  23873. setToDefaultPostProcess(): void;
  23874. /**
  23875. * Clear the current material and set it to a default state for procedural texture
  23876. */
  23877. setToDefaultProceduralTexture(): void;
  23878. /**
  23879. * Clear the current material and set it to a default state for particle
  23880. */
  23881. setToDefaultParticle(): void;
  23882. /**
  23883. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23884. * @param url defines the url to load from
  23885. * @returns a promise that will fullfil when the material is fully loaded
  23886. */
  23887. loadAsync(url: string): Promise<void>;
  23888. private _gatherBlocks;
  23889. /**
  23890. * Generate a string containing the code declaration required to create an equivalent of this material
  23891. * @returns a string
  23892. */
  23893. generateCode(): string;
  23894. /**
  23895. * Serializes this material in a JSON representation
  23896. * @returns the serialized material object
  23897. */
  23898. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23899. private _restoreConnections;
  23900. /**
  23901. * Clear the current graph and load a new one from a serialization object
  23902. * @param source defines the JSON representation of the material
  23903. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23904. * @param merge defines whether or not the source must be merged or replace the current content
  23905. */
  23906. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23907. /**
  23908. * Makes a duplicate of the current material.
  23909. * @param name - name to use for the new material.
  23910. */
  23911. clone(name: string): NodeMaterial;
  23912. /**
  23913. * Creates a node material from parsed material data
  23914. * @param source defines the JSON representation of the material
  23915. * @param scene defines the hosting scene
  23916. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23917. * @returns a new node material
  23918. */
  23919. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23920. /**
  23921. * Creates a node material from a snippet saved in a remote file
  23922. * @param name defines the name of the material to create
  23923. * @param url defines the url to load from
  23924. * @param scene defines the hosting scene
  23925. * @returns a promise that will resolve to the new node material
  23926. */
  23927. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23928. /**
  23929. * Creates a node material from a snippet saved by the node material editor
  23930. * @param snippetId defines the snippet to load
  23931. * @param scene defines the hosting scene
  23932. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23933. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23934. * @returns a promise that will resolve to the new node material
  23935. */
  23936. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23937. /**
  23938. * Creates a new node material set to default basic configuration
  23939. * @param name defines the name of the material
  23940. * @param scene defines the hosting scene
  23941. * @returns a new NodeMaterial
  23942. */
  23943. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23944. }
  23945. }
  23946. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23948. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23949. import { Nullable } from "babylonjs/types";
  23950. module "babylonjs/Engines/thinEngine" {
  23951. interface ThinEngine {
  23952. /**
  23953. * Unbind a list of render target textures from the webGL context
  23954. * This is used only when drawBuffer extension or webGL2 are active
  23955. * @param textures defines the render target textures to unbind
  23956. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23957. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23958. */
  23959. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23960. /**
  23961. * Create a multi render target texture
  23962. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23963. * @param size defines the size of the texture
  23964. * @param options defines the creation options
  23965. * @returns the cube texture as an InternalTexture
  23966. */
  23967. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23968. /**
  23969. * Update the sample count for a given multiple render target texture
  23970. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23971. * @param textures defines the textures to update
  23972. * @param samples defines the sample count to set
  23973. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23974. */
  23975. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23976. /**
  23977. * Select a subsets of attachments to draw to.
  23978. * @param attachments gl attachments
  23979. */
  23980. bindAttachments(attachments: number[]): void;
  23981. /**
  23982. * Creates a layout object to draw/clear on specific textures in a MRT
  23983. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23984. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23985. */
  23986. buildTextureLayout(textureStatus: boolean[]): number[];
  23987. /**
  23988. * Restores the webgl state to only draw on the main color attachment
  23989. */
  23990. restoreSingleAttachment(): void;
  23991. }
  23992. }
  23993. }
  23994. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23995. import { Scene } from "babylonjs/scene";
  23996. import { Engine } from "babylonjs/Engines/engine";
  23997. import { Texture } from "babylonjs/Materials/Textures/texture";
  23998. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23999. import "babylonjs/Engines/Extensions/engine.multiRender";
  24000. /**
  24001. * Creation options of the multi render target texture.
  24002. */
  24003. export interface IMultiRenderTargetOptions {
  24004. /**
  24005. * Define if the texture needs to create mip maps after render.
  24006. */
  24007. generateMipMaps?: boolean;
  24008. /**
  24009. * Define the types of all the draw buffers we want to create
  24010. */
  24011. types?: number[];
  24012. /**
  24013. * Define the sampling modes of all the draw buffers we want to create
  24014. */
  24015. samplingModes?: number[];
  24016. /**
  24017. * Define if a depth buffer is required
  24018. */
  24019. generateDepthBuffer?: boolean;
  24020. /**
  24021. * Define if a stencil buffer is required
  24022. */
  24023. generateStencilBuffer?: boolean;
  24024. /**
  24025. * Define if a depth texture is required instead of a depth buffer
  24026. */
  24027. generateDepthTexture?: boolean;
  24028. /**
  24029. * Define the number of desired draw buffers
  24030. */
  24031. textureCount?: number;
  24032. /**
  24033. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24034. */
  24035. doNotChangeAspectRatio?: boolean;
  24036. /**
  24037. * Define the default type of the buffers we are creating
  24038. */
  24039. defaultType?: number;
  24040. }
  24041. /**
  24042. * A multi render target, like a render target provides the ability to render to a texture.
  24043. * Unlike the render target, it can render to several draw buffers in one draw.
  24044. * This is specially interesting in deferred rendering or for any effects requiring more than
  24045. * just one color from a single pass.
  24046. */
  24047. export class MultiRenderTarget extends RenderTargetTexture {
  24048. private _internalTextures;
  24049. private _textures;
  24050. private _multiRenderTargetOptions;
  24051. private _count;
  24052. /**
  24053. * Get if draw buffers are currently supported by the used hardware and browser.
  24054. */
  24055. get isSupported(): boolean;
  24056. /**
  24057. * Get the list of textures generated by the multi render target.
  24058. */
  24059. get textures(): Texture[];
  24060. /**
  24061. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24062. */
  24063. get count(): number;
  24064. /**
  24065. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24066. */
  24067. get depthTexture(): Texture;
  24068. /**
  24069. * Set the wrapping mode on U of all the textures we are rendering to.
  24070. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24071. */
  24072. set wrapU(wrap: number);
  24073. /**
  24074. * Set the wrapping mode on V of all the textures we are rendering to.
  24075. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24076. */
  24077. set wrapV(wrap: number);
  24078. /**
  24079. * Instantiate a new multi render target texture.
  24080. * A multi render target, like a render target provides the ability to render to a texture.
  24081. * Unlike the render target, it can render to several draw buffers in one draw.
  24082. * This is specially interesting in deferred rendering or for any effects requiring more than
  24083. * just one color from a single pass.
  24084. * @param name Define the name of the texture
  24085. * @param size Define the size of the buffers to render to
  24086. * @param count Define the number of target we are rendering into
  24087. * @param scene Define the scene the texture belongs to
  24088. * @param options Define the options used to create the multi render target
  24089. */
  24090. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24091. private _initTypes;
  24092. /** @hidden */
  24093. _rebuild(forceFullRebuild?: boolean): void;
  24094. private _createInternalTextures;
  24095. private _createTextures;
  24096. /**
  24097. * Replaces a texture within the MRT.
  24098. * @param texture The new texture to insert in the MRT
  24099. * @param index The index of the texture to replace
  24100. */
  24101. replaceTexture(texture: Texture, index: number): void;
  24102. /**
  24103. * Define the number of samples used if MSAA is enabled.
  24104. */
  24105. get samples(): number;
  24106. set samples(value: number);
  24107. /**
  24108. * Resize all the textures in the multi render target.
  24109. * Be careful as it will recreate all the data in the new texture.
  24110. * @param size Define the new size
  24111. */
  24112. resize(size: any): void;
  24113. /**
  24114. * Changes the number of render targets in this MRT
  24115. * Be careful as it will recreate all the data in the new texture.
  24116. * @param count new texture count
  24117. * @param options Specifies texture types and sampling modes for new textures
  24118. */
  24119. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  24120. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24121. /**
  24122. * Dispose the render targets and their associated resources
  24123. */
  24124. dispose(): void;
  24125. /**
  24126. * Release all the underlying texture used as draw buffers.
  24127. */
  24128. releaseInternalTextures(): void;
  24129. }
  24130. }
  24131. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24132. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24133. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24134. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24135. /** @hidden */
  24136. export var imageProcessingPixelShader: {
  24137. name: string;
  24138. shader: string;
  24139. };
  24140. }
  24141. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24142. import { Nullable } from "babylonjs/types";
  24143. import { Color4 } from "babylonjs/Maths/math.color";
  24144. import { Camera } from "babylonjs/Cameras/camera";
  24145. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24146. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24147. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24148. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24149. import { Engine } from "babylonjs/Engines/engine";
  24150. import "babylonjs/Shaders/imageProcessing.fragment";
  24151. import "babylonjs/Shaders/postprocess.vertex";
  24152. /**
  24153. * ImageProcessingPostProcess
  24154. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24155. */
  24156. export class ImageProcessingPostProcess extends PostProcess {
  24157. /**
  24158. * Default configuration related to image processing available in the PBR Material.
  24159. */
  24160. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24161. /**
  24162. * Gets the image processing configuration used either in this material.
  24163. */
  24164. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24165. /**
  24166. * Sets the Default image processing configuration used either in the this material.
  24167. *
  24168. * If sets to null, the scene one is in use.
  24169. */
  24170. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24171. /**
  24172. * Keep track of the image processing observer to allow dispose and replace.
  24173. */
  24174. private _imageProcessingObserver;
  24175. /**
  24176. * Attaches a new image processing configuration to the PBR Material.
  24177. * @param configuration
  24178. */
  24179. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24180. /**
  24181. * If the post process is supported.
  24182. */
  24183. get isSupported(): boolean;
  24184. /**
  24185. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24186. */
  24187. get colorCurves(): Nullable<ColorCurves>;
  24188. /**
  24189. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24190. */
  24191. set colorCurves(value: Nullable<ColorCurves>);
  24192. /**
  24193. * Gets wether the color curves effect is enabled.
  24194. */
  24195. get colorCurvesEnabled(): boolean;
  24196. /**
  24197. * Sets wether the color curves effect is enabled.
  24198. */
  24199. set colorCurvesEnabled(value: boolean);
  24200. /**
  24201. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24202. */
  24203. get colorGradingTexture(): Nullable<BaseTexture>;
  24204. /**
  24205. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24206. */
  24207. set colorGradingTexture(value: Nullable<BaseTexture>);
  24208. /**
  24209. * Gets wether the color grading effect is enabled.
  24210. */
  24211. get colorGradingEnabled(): boolean;
  24212. /**
  24213. * Gets wether the color grading effect is enabled.
  24214. */
  24215. set colorGradingEnabled(value: boolean);
  24216. /**
  24217. * Gets exposure used in the effect.
  24218. */
  24219. get exposure(): number;
  24220. /**
  24221. * Sets exposure used in the effect.
  24222. */
  24223. set exposure(value: number);
  24224. /**
  24225. * Gets wether tonemapping is enabled or not.
  24226. */
  24227. get toneMappingEnabled(): boolean;
  24228. /**
  24229. * Sets wether tonemapping is enabled or not
  24230. */
  24231. set toneMappingEnabled(value: boolean);
  24232. /**
  24233. * Gets the type of tone mapping effect.
  24234. */
  24235. get toneMappingType(): number;
  24236. /**
  24237. * Sets the type of tone mapping effect.
  24238. */
  24239. set toneMappingType(value: number);
  24240. /**
  24241. * Gets contrast used in the effect.
  24242. */
  24243. get contrast(): number;
  24244. /**
  24245. * Sets contrast used in the effect.
  24246. */
  24247. set contrast(value: number);
  24248. /**
  24249. * Gets Vignette stretch size.
  24250. */
  24251. get vignetteStretch(): number;
  24252. /**
  24253. * Sets Vignette stretch size.
  24254. */
  24255. set vignetteStretch(value: number);
  24256. /**
  24257. * Gets Vignette centre X Offset.
  24258. */
  24259. get vignetteCentreX(): number;
  24260. /**
  24261. * Sets Vignette centre X Offset.
  24262. */
  24263. set vignetteCentreX(value: number);
  24264. /**
  24265. * Gets Vignette centre Y Offset.
  24266. */
  24267. get vignetteCentreY(): number;
  24268. /**
  24269. * Sets Vignette centre Y Offset.
  24270. */
  24271. set vignetteCentreY(value: number);
  24272. /**
  24273. * Gets Vignette weight or intensity of the vignette effect.
  24274. */
  24275. get vignetteWeight(): number;
  24276. /**
  24277. * Sets Vignette weight or intensity of the vignette effect.
  24278. */
  24279. set vignetteWeight(value: number);
  24280. /**
  24281. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24282. * if vignetteEnabled is set to true.
  24283. */
  24284. get vignetteColor(): Color4;
  24285. /**
  24286. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24287. * if vignetteEnabled is set to true.
  24288. */
  24289. set vignetteColor(value: Color4);
  24290. /**
  24291. * Gets Camera field of view used by the Vignette effect.
  24292. */
  24293. get vignetteCameraFov(): number;
  24294. /**
  24295. * Sets Camera field of view used by the Vignette effect.
  24296. */
  24297. set vignetteCameraFov(value: number);
  24298. /**
  24299. * Gets the vignette blend mode allowing different kind of effect.
  24300. */
  24301. get vignetteBlendMode(): number;
  24302. /**
  24303. * Sets the vignette blend mode allowing different kind of effect.
  24304. */
  24305. set vignetteBlendMode(value: number);
  24306. /**
  24307. * Gets wether the vignette effect is enabled.
  24308. */
  24309. get vignetteEnabled(): boolean;
  24310. /**
  24311. * Sets wether the vignette effect is enabled.
  24312. */
  24313. set vignetteEnabled(value: boolean);
  24314. private _fromLinearSpace;
  24315. /**
  24316. * Gets wether the input of the processing is in Gamma or Linear Space.
  24317. */
  24318. get fromLinearSpace(): boolean;
  24319. /**
  24320. * Sets wether the input of the processing is in Gamma or Linear Space.
  24321. */
  24322. set fromLinearSpace(value: boolean);
  24323. /**
  24324. * Defines cache preventing GC.
  24325. */
  24326. private _defines;
  24327. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24328. /**
  24329. * "ImageProcessingPostProcess"
  24330. * @returns "ImageProcessingPostProcess"
  24331. */
  24332. getClassName(): string;
  24333. /**
  24334. * @hidden
  24335. */
  24336. _updateParameters(): void;
  24337. dispose(camera?: Camera): void;
  24338. }
  24339. }
  24340. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24341. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24342. /**
  24343. * Interface for defining prepass effects in the prepass post-process pipeline
  24344. */
  24345. export interface PrePassEffectConfiguration {
  24346. /**
  24347. * Name of the effect
  24348. */
  24349. name: string;
  24350. /**
  24351. * Post process to attach for this effect
  24352. */
  24353. postProcess?: PostProcess;
  24354. /**
  24355. * Textures required in the MRT
  24356. */
  24357. texturesRequired: number[];
  24358. /**
  24359. * Is the effect enabled
  24360. */
  24361. enabled: boolean;
  24362. /**
  24363. * Disposes the effect configuration
  24364. */
  24365. dispose?: () => void;
  24366. /**
  24367. * Creates the associated post process
  24368. */
  24369. createPostProcess?: () => PostProcess;
  24370. }
  24371. }
  24372. declare module "babylonjs/Materials/fresnelParameters" {
  24373. import { DeepImmutable } from "babylonjs/types";
  24374. import { Color3 } from "babylonjs/Maths/math.color";
  24375. /**
  24376. * Options to be used when creating a FresnelParameters.
  24377. */
  24378. export type IFresnelParametersCreationOptions = {
  24379. /**
  24380. * Define the color used on edges (grazing angle)
  24381. */
  24382. leftColor?: Color3;
  24383. /**
  24384. * Define the color used on center
  24385. */
  24386. rightColor?: Color3;
  24387. /**
  24388. * Define bias applied to computed fresnel term
  24389. */
  24390. bias?: number;
  24391. /**
  24392. * Defined the power exponent applied to fresnel term
  24393. */
  24394. power?: number;
  24395. /**
  24396. * Define if the fresnel effect is enable or not.
  24397. */
  24398. isEnabled?: boolean;
  24399. };
  24400. /**
  24401. * Serialized format for FresnelParameters.
  24402. */
  24403. export type IFresnelParametersSerialized = {
  24404. /**
  24405. * Define the color used on edges (grazing angle) [as an array]
  24406. */
  24407. leftColor: number[];
  24408. /**
  24409. * Define the color used on center [as an array]
  24410. */
  24411. rightColor: number[];
  24412. /**
  24413. * Define bias applied to computed fresnel term
  24414. */
  24415. bias: number;
  24416. /**
  24417. * Defined the power exponent applied to fresnel term
  24418. */
  24419. power?: number;
  24420. /**
  24421. * Define if the fresnel effect is enable or not.
  24422. */
  24423. isEnabled: boolean;
  24424. };
  24425. /**
  24426. * This represents all the required information to add a fresnel effect on a material:
  24427. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24428. */
  24429. export class FresnelParameters {
  24430. private _isEnabled;
  24431. /**
  24432. * Define if the fresnel effect is enable or not.
  24433. */
  24434. get isEnabled(): boolean;
  24435. set isEnabled(value: boolean);
  24436. /**
  24437. * Define the color used on edges (grazing angle)
  24438. */
  24439. leftColor: Color3;
  24440. /**
  24441. * Define the color used on center
  24442. */
  24443. rightColor: Color3;
  24444. /**
  24445. * Define bias applied to computed fresnel term
  24446. */
  24447. bias: number;
  24448. /**
  24449. * Defined the power exponent applied to fresnel term
  24450. */
  24451. power: number;
  24452. /**
  24453. * Creates a new FresnelParameters object.
  24454. *
  24455. * @param options provide your own settings to optionally to override defaults
  24456. */
  24457. constructor(options?: IFresnelParametersCreationOptions);
  24458. /**
  24459. * Clones the current fresnel and its valuues
  24460. * @returns a clone fresnel configuration
  24461. */
  24462. clone(): FresnelParameters;
  24463. /**
  24464. * Determines equality between FresnelParameters objects
  24465. * @param otherFresnelParameters defines the second operand
  24466. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  24467. */
  24468. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  24469. /**
  24470. * Serializes the current fresnel parameters to a JSON representation.
  24471. * @return the JSON serialization
  24472. */
  24473. serialize(): IFresnelParametersSerialized;
  24474. /**
  24475. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  24476. * @param parsedFresnelParameters Define the JSON representation
  24477. * @returns the parsed parameters
  24478. */
  24479. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  24480. }
  24481. }
  24482. declare module "babylonjs/Materials/materialFlags" {
  24483. /**
  24484. * This groups all the flags used to control the materials channel.
  24485. */
  24486. export class MaterialFlags {
  24487. private static _DiffuseTextureEnabled;
  24488. /**
  24489. * Are diffuse textures enabled in the application.
  24490. */
  24491. static get DiffuseTextureEnabled(): boolean;
  24492. static set DiffuseTextureEnabled(value: boolean);
  24493. private static _DetailTextureEnabled;
  24494. /**
  24495. * Are detail textures enabled in the application.
  24496. */
  24497. static get DetailTextureEnabled(): boolean;
  24498. static set DetailTextureEnabled(value: boolean);
  24499. private static _AmbientTextureEnabled;
  24500. /**
  24501. * Are ambient textures enabled in the application.
  24502. */
  24503. static get AmbientTextureEnabled(): boolean;
  24504. static set AmbientTextureEnabled(value: boolean);
  24505. private static _OpacityTextureEnabled;
  24506. /**
  24507. * Are opacity textures enabled in the application.
  24508. */
  24509. static get OpacityTextureEnabled(): boolean;
  24510. static set OpacityTextureEnabled(value: boolean);
  24511. private static _ReflectionTextureEnabled;
  24512. /**
  24513. * Are reflection textures enabled in the application.
  24514. */
  24515. static get ReflectionTextureEnabled(): boolean;
  24516. static set ReflectionTextureEnabled(value: boolean);
  24517. private static _EmissiveTextureEnabled;
  24518. /**
  24519. * Are emissive textures enabled in the application.
  24520. */
  24521. static get EmissiveTextureEnabled(): boolean;
  24522. static set EmissiveTextureEnabled(value: boolean);
  24523. private static _SpecularTextureEnabled;
  24524. /**
  24525. * Are specular textures enabled in the application.
  24526. */
  24527. static get SpecularTextureEnabled(): boolean;
  24528. static set SpecularTextureEnabled(value: boolean);
  24529. private static _BumpTextureEnabled;
  24530. /**
  24531. * Are bump textures enabled in the application.
  24532. */
  24533. static get BumpTextureEnabled(): boolean;
  24534. static set BumpTextureEnabled(value: boolean);
  24535. private static _LightmapTextureEnabled;
  24536. /**
  24537. * Are lightmap textures enabled in the application.
  24538. */
  24539. static get LightmapTextureEnabled(): boolean;
  24540. static set LightmapTextureEnabled(value: boolean);
  24541. private static _RefractionTextureEnabled;
  24542. /**
  24543. * Are refraction textures enabled in the application.
  24544. */
  24545. static get RefractionTextureEnabled(): boolean;
  24546. static set RefractionTextureEnabled(value: boolean);
  24547. private static _ColorGradingTextureEnabled;
  24548. /**
  24549. * Are color grading textures enabled in the application.
  24550. */
  24551. static get ColorGradingTextureEnabled(): boolean;
  24552. static set ColorGradingTextureEnabled(value: boolean);
  24553. private static _FresnelEnabled;
  24554. /**
  24555. * Are fresnels enabled in the application.
  24556. */
  24557. static get FresnelEnabled(): boolean;
  24558. static set FresnelEnabled(value: boolean);
  24559. private static _ClearCoatTextureEnabled;
  24560. /**
  24561. * Are clear coat textures enabled in the application.
  24562. */
  24563. static get ClearCoatTextureEnabled(): boolean;
  24564. static set ClearCoatTextureEnabled(value: boolean);
  24565. private static _ClearCoatBumpTextureEnabled;
  24566. /**
  24567. * Are clear coat bump textures enabled in the application.
  24568. */
  24569. static get ClearCoatBumpTextureEnabled(): boolean;
  24570. static set ClearCoatBumpTextureEnabled(value: boolean);
  24571. private static _ClearCoatTintTextureEnabled;
  24572. /**
  24573. * Are clear coat tint textures enabled in the application.
  24574. */
  24575. static get ClearCoatTintTextureEnabled(): boolean;
  24576. static set ClearCoatTintTextureEnabled(value: boolean);
  24577. private static _SheenTextureEnabled;
  24578. /**
  24579. * Are sheen textures enabled in the application.
  24580. */
  24581. static get SheenTextureEnabled(): boolean;
  24582. static set SheenTextureEnabled(value: boolean);
  24583. private static _AnisotropicTextureEnabled;
  24584. /**
  24585. * Are anisotropic textures enabled in the application.
  24586. */
  24587. static get AnisotropicTextureEnabled(): boolean;
  24588. static set AnisotropicTextureEnabled(value: boolean);
  24589. private static _ThicknessTextureEnabled;
  24590. /**
  24591. * Are thickness textures enabled in the application.
  24592. */
  24593. static get ThicknessTextureEnabled(): boolean;
  24594. static set ThicknessTextureEnabled(value: boolean);
  24595. }
  24596. }
  24597. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  24598. /** @hidden */
  24599. export var defaultFragmentDeclaration: {
  24600. name: string;
  24601. shader: string;
  24602. };
  24603. }
  24604. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  24605. /** @hidden */
  24606. export var defaultUboDeclaration: {
  24607. name: string;
  24608. shader: string;
  24609. };
  24610. }
  24611. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  24612. /** @hidden */
  24613. export var prePassDeclaration: {
  24614. name: string;
  24615. shader: string;
  24616. };
  24617. }
  24618. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  24619. /** @hidden */
  24620. export var lightFragmentDeclaration: {
  24621. name: string;
  24622. shader: string;
  24623. };
  24624. }
  24625. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  24626. /** @hidden */
  24627. export var lightUboDeclaration: {
  24628. name: string;
  24629. shader: string;
  24630. };
  24631. }
  24632. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  24633. /** @hidden */
  24634. export var lightsFragmentFunctions: {
  24635. name: string;
  24636. shader: string;
  24637. };
  24638. }
  24639. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  24640. /** @hidden */
  24641. export var shadowsFragmentFunctions: {
  24642. name: string;
  24643. shader: string;
  24644. };
  24645. }
  24646. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  24647. /** @hidden */
  24648. export var fresnelFunction: {
  24649. name: string;
  24650. shader: string;
  24651. };
  24652. }
  24653. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  24654. /** @hidden */
  24655. export var bumpFragmentMainFunctions: {
  24656. name: string;
  24657. shader: string;
  24658. };
  24659. }
  24660. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  24661. /** @hidden */
  24662. export var bumpFragmentFunctions: {
  24663. name: string;
  24664. shader: string;
  24665. };
  24666. }
  24667. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  24668. /** @hidden */
  24669. export var logDepthDeclaration: {
  24670. name: string;
  24671. shader: string;
  24672. };
  24673. }
  24674. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  24675. /** @hidden */
  24676. export var bumpFragment: {
  24677. name: string;
  24678. shader: string;
  24679. };
  24680. }
  24681. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  24682. /** @hidden */
  24683. export var depthPrePass: {
  24684. name: string;
  24685. shader: string;
  24686. };
  24687. }
  24688. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  24689. /** @hidden */
  24690. export var lightFragment: {
  24691. name: string;
  24692. shader: string;
  24693. };
  24694. }
  24695. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  24696. /** @hidden */
  24697. export var logDepthFragment: {
  24698. name: string;
  24699. shader: string;
  24700. };
  24701. }
  24702. declare module "babylonjs/Shaders/default.fragment" {
  24703. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  24704. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24705. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  24706. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24707. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24708. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24709. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  24710. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  24711. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  24712. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  24713. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24714. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24715. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  24716. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  24717. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  24718. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24719. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24720. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  24721. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  24722. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  24723. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  24724. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  24725. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24726. /** @hidden */
  24727. export var defaultPixelShader: {
  24728. name: string;
  24729. shader: string;
  24730. };
  24731. }
  24732. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  24733. /** @hidden */
  24734. export var defaultVertexDeclaration: {
  24735. name: string;
  24736. shader: string;
  24737. };
  24738. }
  24739. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  24740. /** @hidden */
  24741. export var prePassVertexDeclaration: {
  24742. name: string;
  24743. shader: string;
  24744. };
  24745. }
  24746. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  24747. /** @hidden */
  24748. export var bumpVertexDeclaration: {
  24749. name: string;
  24750. shader: string;
  24751. };
  24752. }
  24753. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  24754. /** @hidden */
  24755. export var prePassVertex: {
  24756. name: string;
  24757. shader: string;
  24758. };
  24759. }
  24760. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  24761. /** @hidden */
  24762. export var bumpVertex: {
  24763. name: string;
  24764. shader: string;
  24765. };
  24766. }
  24767. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  24768. /** @hidden */
  24769. export var fogVertex: {
  24770. name: string;
  24771. shader: string;
  24772. };
  24773. }
  24774. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  24775. /** @hidden */
  24776. export var shadowsVertex: {
  24777. name: string;
  24778. shader: string;
  24779. };
  24780. }
  24781. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  24782. /** @hidden */
  24783. export var pointCloudVertex: {
  24784. name: string;
  24785. shader: string;
  24786. };
  24787. }
  24788. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  24789. /** @hidden */
  24790. export var logDepthVertex: {
  24791. name: string;
  24792. shader: string;
  24793. };
  24794. }
  24795. declare module "babylonjs/Shaders/default.vertex" {
  24796. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  24797. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24798. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24799. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  24800. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  24801. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  24802. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  24803. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  24804. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24805. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24806. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24807. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  24808. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  24809. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24810. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  24811. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  24812. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  24813. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  24814. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  24815. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  24816. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  24817. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  24818. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  24819. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  24820. /** @hidden */
  24821. export var defaultVertexShader: {
  24822. name: string;
  24823. shader: string;
  24824. };
  24825. }
  24826. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  24827. import { Nullable } from "babylonjs/types";
  24828. import { Scene } from "babylonjs/scene";
  24829. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24830. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24831. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24832. /**
  24833. * @hidden
  24834. */
  24835. export interface IMaterialDetailMapDefines {
  24836. DETAIL: boolean;
  24837. DETAILDIRECTUV: number;
  24838. DETAIL_NORMALBLENDMETHOD: number;
  24839. /** @hidden */
  24840. _areTexturesDirty: boolean;
  24841. }
  24842. /**
  24843. * Define the code related to the detail map parameters of a material
  24844. *
  24845. * Inspired from:
  24846. * 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
  24847. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  24848. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  24849. */
  24850. export class DetailMapConfiguration {
  24851. private _texture;
  24852. /**
  24853. * The detail texture of the material.
  24854. */
  24855. texture: Nullable<BaseTexture>;
  24856. /**
  24857. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  24858. * Bigger values mean stronger blending
  24859. */
  24860. diffuseBlendLevel: number;
  24861. /**
  24862. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  24863. * Bigger values mean stronger blending. Only used with PBR materials
  24864. */
  24865. roughnessBlendLevel: number;
  24866. /**
  24867. * Defines how strong the bump effect from the detail map is
  24868. * Bigger values mean stronger effect
  24869. */
  24870. bumpLevel: number;
  24871. private _normalBlendMethod;
  24872. /**
  24873. * The method used to blend the bump and detail normals together
  24874. */
  24875. normalBlendMethod: number;
  24876. private _isEnabled;
  24877. /**
  24878. * Enable or disable the detail map on this material
  24879. */
  24880. isEnabled: boolean;
  24881. /** @hidden */
  24882. private _internalMarkAllSubMeshesAsTexturesDirty;
  24883. /** @hidden */
  24884. _markAllSubMeshesAsTexturesDirty(): void;
  24885. /**
  24886. * Instantiate a new detail map
  24887. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24888. */
  24889. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24890. /**
  24891. * Gets whether the submesh is ready to be used or not.
  24892. * @param defines the list of "defines" to update.
  24893. * @param scene defines the scene the material belongs to.
  24894. * @returns - boolean indicating that the submesh is ready or not.
  24895. */
  24896. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24897. /**
  24898. * Update the defines for detail map usage
  24899. * @param defines the list of "defines" to update.
  24900. * @param scene defines the scene the material belongs to.
  24901. */
  24902. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24903. /**
  24904. * Binds the material data.
  24905. * @param uniformBuffer defines the Uniform buffer to fill in.
  24906. * @param scene defines the scene the material belongs to.
  24907. * @param isFrozen defines whether the material is frozen or not.
  24908. */
  24909. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24910. /**
  24911. * Checks to see if a texture is used in the material.
  24912. * @param texture - Base texture to use.
  24913. * @returns - Boolean specifying if a texture is used in the material.
  24914. */
  24915. hasTexture(texture: BaseTexture): boolean;
  24916. /**
  24917. * Returns an array of the actively used textures.
  24918. * @param activeTextures Array of BaseTextures
  24919. */
  24920. getActiveTextures(activeTextures: BaseTexture[]): void;
  24921. /**
  24922. * Returns the animatable textures.
  24923. * @param animatables Array of animatable textures.
  24924. */
  24925. getAnimatables(animatables: IAnimatable[]): void;
  24926. /**
  24927. * Disposes the resources of the material.
  24928. * @param forceDisposeTextures - Forces the disposal of all textures.
  24929. */
  24930. dispose(forceDisposeTextures?: boolean): void;
  24931. /**
  24932. * Get the current class name useful for serialization or dynamic coding.
  24933. * @returns "DetailMap"
  24934. */
  24935. getClassName(): string;
  24936. /**
  24937. * Add the required uniforms to the current list.
  24938. * @param uniforms defines the current uniform list.
  24939. */
  24940. static AddUniforms(uniforms: string[]): void;
  24941. /**
  24942. * Add the required samplers to the current list.
  24943. * @param samplers defines the current sampler list.
  24944. */
  24945. static AddSamplers(samplers: string[]): void;
  24946. /**
  24947. * Add the required uniforms to the current buffer.
  24948. * @param uniformBuffer defines the current uniform buffer.
  24949. */
  24950. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24951. /**
  24952. * Makes a duplicate of the current instance into another one.
  24953. * @param detailMap define the instance where to copy the info
  24954. */
  24955. copyTo(detailMap: DetailMapConfiguration): void;
  24956. /**
  24957. * Serializes this detail map instance
  24958. * @returns - An object with the serialized instance.
  24959. */
  24960. serialize(): any;
  24961. /**
  24962. * Parses a detail map setting from a serialized object.
  24963. * @param source - Serialized object.
  24964. * @param scene Defines the scene we are parsing for
  24965. * @param rootUrl Defines the rootUrl to load from
  24966. */
  24967. parse(source: any, scene: Scene, rootUrl: string): void;
  24968. }
  24969. }
  24970. declare module "babylonjs/Materials/standardMaterial" {
  24971. import { SmartArray } from "babylonjs/Misc/smartArray";
  24972. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24973. import { Nullable } from "babylonjs/types";
  24974. import { Scene } from "babylonjs/scene";
  24975. import { Matrix } from "babylonjs/Maths/math.vector";
  24976. import { Color3 } from "babylonjs/Maths/math.color";
  24977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24979. import { Mesh } from "babylonjs/Meshes/mesh";
  24980. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  24981. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  24982. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24983. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  24984. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24985. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  24986. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24987. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24988. import "babylonjs/Shaders/default.fragment";
  24989. import "babylonjs/Shaders/default.vertex";
  24990. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  24991. /** @hidden */
  24992. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24993. MAINUV1: boolean;
  24994. MAINUV2: boolean;
  24995. DIFFUSE: boolean;
  24996. DIFFUSEDIRECTUV: number;
  24997. DETAIL: boolean;
  24998. DETAILDIRECTUV: number;
  24999. DETAIL_NORMALBLENDMETHOD: number;
  25000. AMBIENT: boolean;
  25001. AMBIENTDIRECTUV: number;
  25002. OPACITY: boolean;
  25003. OPACITYDIRECTUV: number;
  25004. OPACITYRGB: boolean;
  25005. REFLECTION: boolean;
  25006. EMISSIVE: boolean;
  25007. EMISSIVEDIRECTUV: number;
  25008. SPECULAR: boolean;
  25009. SPECULARDIRECTUV: number;
  25010. BUMP: boolean;
  25011. BUMPDIRECTUV: number;
  25012. PARALLAX: boolean;
  25013. PARALLAXOCCLUSION: boolean;
  25014. SPECULAROVERALPHA: boolean;
  25015. CLIPPLANE: boolean;
  25016. CLIPPLANE2: boolean;
  25017. CLIPPLANE3: boolean;
  25018. CLIPPLANE4: boolean;
  25019. CLIPPLANE5: boolean;
  25020. CLIPPLANE6: boolean;
  25021. ALPHATEST: boolean;
  25022. DEPTHPREPASS: boolean;
  25023. ALPHAFROMDIFFUSE: boolean;
  25024. POINTSIZE: boolean;
  25025. FOG: boolean;
  25026. SPECULARTERM: boolean;
  25027. DIFFUSEFRESNEL: boolean;
  25028. OPACITYFRESNEL: boolean;
  25029. REFLECTIONFRESNEL: boolean;
  25030. REFRACTIONFRESNEL: boolean;
  25031. EMISSIVEFRESNEL: boolean;
  25032. FRESNEL: boolean;
  25033. NORMAL: boolean;
  25034. UV1: boolean;
  25035. UV2: boolean;
  25036. VERTEXCOLOR: boolean;
  25037. VERTEXALPHA: boolean;
  25038. NUM_BONE_INFLUENCERS: number;
  25039. BonesPerMesh: number;
  25040. BONETEXTURE: boolean;
  25041. BONES_VELOCITY_ENABLED: boolean;
  25042. INSTANCES: boolean;
  25043. THIN_INSTANCES: boolean;
  25044. GLOSSINESS: boolean;
  25045. ROUGHNESS: boolean;
  25046. EMISSIVEASILLUMINATION: boolean;
  25047. LINKEMISSIVEWITHDIFFUSE: boolean;
  25048. REFLECTIONFRESNELFROMSPECULAR: boolean;
  25049. LIGHTMAP: boolean;
  25050. LIGHTMAPDIRECTUV: number;
  25051. OBJECTSPACE_NORMALMAP: boolean;
  25052. USELIGHTMAPASSHADOWMAP: boolean;
  25053. REFLECTIONMAP_3D: boolean;
  25054. REFLECTIONMAP_SPHERICAL: boolean;
  25055. REFLECTIONMAP_PLANAR: boolean;
  25056. REFLECTIONMAP_CUBIC: boolean;
  25057. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  25058. REFLECTIONMAP_PROJECTION: boolean;
  25059. REFLECTIONMAP_SKYBOX: boolean;
  25060. REFLECTIONMAP_EXPLICIT: boolean;
  25061. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  25062. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  25063. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  25064. INVERTCUBICMAP: boolean;
  25065. LOGARITHMICDEPTH: boolean;
  25066. REFRACTION: boolean;
  25067. REFRACTIONMAP_3D: boolean;
  25068. REFLECTIONOVERALPHA: boolean;
  25069. TWOSIDEDLIGHTING: boolean;
  25070. SHADOWFLOAT: boolean;
  25071. MORPHTARGETS: boolean;
  25072. MORPHTARGETS_NORMAL: boolean;
  25073. MORPHTARGETS_TANGENT: boolean;
  25074. MORPHTARGETS_UV: boolean;
  25075. NUM_MORPH_INFLUENCERS: number;
  25076. NONUNIFORMSCALING: boolean;
  25077. PREMULTIPLYALPHA: boolean;
  25078. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  25079. ALPHABLEND: boolean;
  25080. PREPASS: boolean;
  25081. PREPASS_IRRADIANCE: boolean;
  25082. PREPASS_IRRADIANCE_INDEX: number;
  25083. PREPASS_ALBEDO: boolean;
  25084. PREPASS_ALBEDO_INDEX: number;
  25085. PREPASS_DEPTHNORMAL: boolean;
  25086. PREPASS_DEPTHNORMAL_INDEX: number;
  25087. PREPASS_POSITION: boolean;
  25088. PREPASS_POSITION_INDEX: number;
  25089. PREPASS_VELOCITY: boolean;
  25090. PREPASS_VELOCITY_INDEX: number;
  25091. PREPASS_REFLECTIVITY: boolean;
  25092. PREPASS_REFLECTIVITY_INDEX: number;
  25093. SCENE_MRT_COUNT: number;
  25094. RGBDLIGHTMAP: boolean;
  25095. RGBDREFLECTION: boolean;
  25096. RGBDREFRACTION: boolean;
  25097. IMAGEPROCESSING: boolean;
  25098. VIGNETTE: boolean;
  25099. VIGNETTEBLENDMODEMULTIPLY: boolean;
  25100. VIGNETTEBLENDMODEOPAQUE: boolean;
  25101. TONEMAPPING: boolean;
  25102. TONEMAPPING_ACES: boolean;
  25103. CONTRAST: boolean;
  25104. COLORCURVES: boolean;
  25105. COLORGRADING: boolean;
  25106. COLORGRADING3D: boolean;
  25107. SAMPLER3DGREENDEPTH: boolean;
  25108. SAMPLER3DBGRMAP: boolean;
  25109. IMAGEPROCESSINGPOSTPROCESS: boolean;
  25110. MULTIVIEW: boolean;
  25111. /**
  25112. * If the reflection texture on this material is in linear color space
  25113. * @hidden
  25114. */
  25115. IS_REFLECTION_LINEAR: boolean;
  25116. /**
  25117. * If the refraction texture on this material is in linear color space
  25118. * @hidden
  25119. */
  25120. IS_REFRACTION_LINEAR: boolean;
  25121. EXPOSURE: boolean;
  25122. constructor();
  25123. setReflectionMode(modeToEnable: string): void;
  25124. }
  25125. /**
  25126. * This is the default material used in Babylon. It is the best trade off between quality
  25127. * and performances.
  25128. * @see https://doc.babylonjs.com/babylon101/materials
  25129. */
  25130. export class StandardMaterial extends PushMaterial {
  25131. private _diffuseTexture;
  25132. /**
  25133. * The basic texture of the material as viewed under a light.
  25134. */
  25135. diffuseTexture: Nullable<BaseTexture>;
  25136. private _ambientTexture;
  25137. /**
  25138. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  25139. */
  25140. ambientTexture: Nullable<BaseTexture>;
  25141. private _opacityTexture;
  25142. /**
  25143. * Define the transparency of the material from a texture.
  25144. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  25145. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  25146. */
  25147. opacityTexture: Nullable<BaseTexture>;
  25148. private _reflectionTexture;
  25149. /**
  25150. * Define the texture used to display the reflection.
  25151. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25152. */
  25153. reflectionTexture: Nullable<BaseTexture>;
  25154. private _emissiveTexture;
  25155. /**
  25156. * Define texture of the material as if self lit.
  25157. * This will be mixed in the final result even in the absence of light.
  25158. */
  25159. emissiveTexture: Nullable<BaseTexture>;
  25160. private _specularTexture;
  25161. /**
  25162. * Define how the color and intensity of the highlight given by the light in the material.
  25163. */
  25164. specularTexture: Nullable<BaseTexture>;
  25165. private _bumpTexture;
  25166. /**
  25167. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  25168. * 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.
  25169. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  25170. */
  25171. bumpTexture: Nullable<BaseTexture>;
  25172. private _lightmapTexture;
  25173. /**
  25174. * Complex lighting can be computationally expensive to compute at runtime.
  25175. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  25176. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  25177. */
  25178. lightmapTexture: Nullable<BaseTexture>;
  25179. private _refractionTexture;
  25180. /**
  25181. * Define the texture used to display the refraction.
  25182. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25183. */
  25184. refractionTexture: Nullable<BaseTexture>;
  25185. /**
  25186. * The color of the material lit by the environmental background lighting.
  25187. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  25188. */
  25189. ambientColor: Color3;
  25190. /**
  25191. * The basic color of the material as viewed under a light.
  25192. */
  25193. diffuseColor: Color3;
  25194. /**
  25195. * Define how the color and intensity of the highlight given by the light in the material.
  25196. */
  25197. specularColor: Color3;
  25198. /**
  25199. * Define the color of the material as if self lit.
  25200. * This will be mixed in the final result even in the absence of light.
  25201. */
  25202. emissiveColor: Color3;
  25203. /**
  25204. * Defines how sharp are the highlights in the material.
  25205. * The bigger the value the sharper giving a more glossy feeling to the result.
  25206. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  25207. */
  25208. specularPower: number;
  25209. private _useAlphaFromDiffuseTexture;
  25210. /**
  25211. * Does the transparency come from the diffuse texture alpha channel.
  25212. */
  25213. useAlphaFromDiffuseTexture: boolean;
  25214. private _useEmissiveAsIllumination;
  25215. /**
  25216. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  25217. */
  25218. useEmissiveAsIllumination: boolean;
  25219. private _linkEmissiveWithDiffuse;
  25220. /**
  25221. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  25222. * the emissive level when the final color is close to one.
  25223. */
  25224. linkEmissiveWithDiffuse: boolean;
  25225. private _useSpecularOverAlpha;
  25226. /**
  25227. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  25228. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  25229. */
  25230. useSpecularOverAlpha: boolean;
  25231. private _useReflectionOverAlpha;
  25232. /**
  25233. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  25234. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  25235. */
  25236. useReflectionOverAlpha: boolean;
  25237. private _disableLighting;
  25238. /**
  25239. * Does lights from the scene impacts this material.
  25240. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  25241. */
  25242. disableLighting: boolean;
  25243. private _useObjectSpaceNormalMap;
  25244. /**
  25245. * Allows using an object space normal map (instead of tangent space).
  25246. */
  25247. useObjectSpaceNormalMap: boolean;
  25248. private _useParallax;
  25249. /**
  25250. * Is parallax enabled or not.
  25251. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  25252. */
  25253. useParallax: boolean;
  25254. private _useParallaxOcclusion;
  25255. /**
  25256. * Is parallax occlusion enabled or not.
  25257. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  25258. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  25259. */
  25260. useParallaxOcclusion: boolean;
  25261. /**
  25262. * 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.
  25263. */
  25264. parallaxScaleBias: number;
  25265. private _roughness;
  25266. /**
  25267. * Helps to define how blurry the reflections should appears in the material.
  25268. */
  25269. roughness: number;
  25270. /**
  25271. * In case of refraction, define the value of the index of refraction.
  25272. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25273. */
  25274. indexOfRefraction: number;
  25275. /**
  25276. * Invert the refraction texture alongside the y axis.
  25277. * It can be useful with procedural textures or probe for instance.
  25278. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25279. */
  25280. invertRefractionY: boolean;
  25281. /**
  25282. * Defines the alpha limits in alpha test mode.
  25283. */
  25284. alphaCutOff: number;
  25285. private _useLightmapAsShadowmap;
  25286. /**
  25287. * In case of light mapping, define whether the map contains light or shadow informations.
  25288. */
  25289. useLightmapAsShadowmap: boolean;
  25290. private _diffuseFresnelParameters;
  25291. /**
  25292. * Define the diffuse fresnel parameters of the material.
  25293. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25294. */
  25295. diffuseFresnelParameters: FresnelParameters;
  25296. private _opacityFresnelParameters;
  25297. /**
  25298. * Define the opacity fresnel parameters of the material.
  25299. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25300. */
  25301. opacityFresnelParameters: FresnelParameters;
  25302. private _reflectionFresnelParameters;
  25303. /**
  25304. * Define the reflection fresnel parameters of the material.
  25305. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25306. */
  25307. reflectionFresnelParameters: FresnelParameters;
  25308. private _refractionFresnelParameters;
  25309. /**
  25310. * Define the refraction fresnel parameters of the material.
  25311. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25312. */
  25313. refractionFresnelParameters: FresnelParameters;
  25314. private _emissiveFresnelParameters;
  25315. /**
  25316. * Define the emissive fresnel parameters of the material.
  25317. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25318. */
  25319. emissiveFresnelParameters: FresnelParameters;
  25320. private _useReflectionFresnelFromSpecular;
  25321. /**
  25322. * If true automatically deducts the fresnels values from the material specularity.
  25323. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25324. */
  25325. useReflectionFresnelFromSpecular: boolean;
  25326. private _useGlossinessFromSpecularMapAlpha;
  25327. /**
  25328. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  25329. */
  25330. useGlossinessFromSpecularMapAlpha: boolean;
  25331. private _maxSimultaneousLights;
  25332. /**
  25333. * Defines the maximum number of lights that can be used in the material
  25334. */
  25335. maxSimultaneousLights: number;
  25336. private _invertNormalMapX;
  25337. /**
  25338. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25339. */
  25340. invertNormalMapX: boolean;
  25341. private _invertNormalMapY;
  25342. /**
  25343. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25344. */
  25345. invertNormalMapY: boolean;
  25346. private _twoSidedLighting;
  25347. /**
  25348. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25349. */
  25350. twoSidedLighting: boolean;
  25351. /**
  25352. * Default configuration related to image processing available in the standard Material.
  25353. */
  25354. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25355. /**
  25356. * Gets the image processing configuration used either in this material.
  25357. */
  25358. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25359. /**
  25360. * Sets the Default image processing configuration used either in the this material.
  25361. *
  25362. * If sets to null, the scene one is in use.
  25363. */
  25364. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25365. /**
  25366. * Keep track of the image processing observer to allow dispose and replace.
  25367. */
  25368. private _imageProcessingObserver;
  25369. /**
  25370. * Attaches a new image processing configuration to the Standard Material.
  25371. * @param configuration
  25372. */
  25373. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25374. /**
  25375. * Defines additionnal PrePass parameters for the material.
  25376. */
  25377. readonly prePassConfiguration: PrePassConfiguration;
  25378. /**
  25379. * Gets wether the color curves effect is enabled.
  25380. */
  25381. get cameraColorCurvesEnabled(): boolean;
  25382. /**
  25383. * Sets wether the color curves effect is enabled.
  25384. */
  25385. set cameraColorCurvesEnabled(value: boolean);
  25386. /**
  25387. * Gets wether the color grading effect is enabled.
  25388. */
  25389. get cameraColorGradingEnabled(): boolean;
  25390. /**
  25391. * Gets wether the color grading effect is enabled.
  25392. */
  25393. set cameraColorGradingEnabled(value: boolean);
  25394. /**
  25395. * Gets wether tonemapping is enabled or not.
  25396. */
  25397. get cameraToneMappingEnabled(): boolean;
  25398. /**
  25399. * Sets wether tonemapping is enabled or not
  25400. */
  25401. set cameraToneMappingEnabled(value: boolean);
  25402. /**
  25403. * The camera exposure used on this material.
  25404. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25405. * This corresponds to a photographic exposure.
  25406. */
  25407. get cameraExposure(): number;
  25408. /**
  25409. * The camera exposure used on this material.
  25410. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25411. * This corresponds to a photographic exposure.
  25412. */
  25413. set cameraExposure(value: number);
  25414. /**
  25415. * Gets The camera contrast used on this material.
  25416. */
  25417. get cameraContrast(): number;
  25418. /**
  25419. * Sets The camera contrast used on this material.
  25420. */
  25421. set cameraContrast(value: number);
  25422. /**
  25423. * Gets the Color Grading 2D Lookup Texture.
  25424. */
  25425. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  25426. /**
  25427. * Sets the Color Grading 2D Lookup Texture.
  25428. */
  25429. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  25430. /**
  25431. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25432. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25433. * 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;
  25434. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25435. */
  25436. get cameraColorCurves(): Nullable<ColorCurves>;
  25437. /**
  25438. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25439. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25440. * 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;
  25441. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25442. */
  25443. set cameraColorCurves(value: Nullable<ColorCurves>);
  25444. /**
  25445. * Can this material render to several textures at once
  25446. */
  25447. get canRenderToMRT(): boolean;
  25448. /**
  25449. * Defines the detail map parameters for the material.
  25450. */
  25451. readonly detailMap: DetailMapConfiguration;
  25452. protected _renderTargets: SmartArray<RenderTargetTexture>;
  25453. protected _worldViewProjectionMatrix: Matrix;
  25454. protected _globalAmbientColor: Color3;
  25455. protected _useLogarithmicDepth: boolean;
  25456. protected _rebuildInParallel: boolean;
  25457. /**
  25458. * Instantiates a new standard material.
  25459. * This is the default material used in Babylon. It is the best trade off between quality
  25460. * and performances.
  25461. * @see https://doc.babylonjs.com/babylon101/materials
  25462. * @param name Define the name of the material in the scene
  25463. * @param scene Define the scene the material belong to
  25464. */
  25465. constructor(name: string, scene: Scene);
  25466. /**
  25467. * Gets a boolean indicating that current material needs to register RTT
  25468. */
  25469. get hasRenderTargetTextures(): boolean;
  25470. /**
  25471. * Gets the current class name of the material e.g. "StandardMaterial"
  25472. * Mainly use in serialization.
  25473. * @returns the class name
  25474. */
  25475. getClassName(): string;
  25476. /**
  25477. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  25478. * You can try switching to logarithmic depth.
  25479. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  25480. */
  25481. get useLogarithmicDepth(): boolean;
  25482. set useLogarithmicDepth(value: boolean);
  25483. /**
  25484. * Specifies if the material will require alpha blending
  25485. * @returns a boolean specifying if alpha blending is needed
  25486. */
  25487. needAlphaBlending(): boolean;
  25488. /**
  25489. * Specifies if this material should be rendered in alpha test mode
  25490. * @returns a boolean specifying if an alpha test is needed.
  25491. */
  25492. needAlphaTesting(): boolean;
  25493. /**
  25494. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  25495. */
  25496. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  25497. /**
  25498. * Specifies whether or not there is a usable alpha channel for transparency.
  25499. */
  25500. protected _hasAlphaChannel(): boolean;
  25501. /**
  25502. * Get the texture used for alpha test purpose.
  25503. * @returns the diffuse texture in case of the standard material.
  25504. */
  25505. getAlphaTestTexture(): Nullable<BaseTexture>;
  25506. /**
  25507. * Get if the submesh is ready to be used and all its information available.
  25508. * Child classes can use it to update shaders
  25509. * @param mesh defines the mesh to check
  25510. * @param subMesh defines which submesh to check
  25511. * @param useInstances specifies that instances should be used
  25512. * @returns a boolean indicating that the submesh is ready or not
  25513. */
  25514. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25515. /**
  25516. * Builds the material UBO layouts.
  25517. * Used internally during the effect preparation.
  25518. */
  25519. buildUniformLayout(): void;
  25520. /**
  25521. * Unbinds the material from the mesh
  25522. */
  25523. unbind(): void;
  25524. /**
  25525. * Binds the submesh to this material by preparing the effect and shader to draw
  25526. * @param world defines the world transformation matrix
  25527. * @param mesh defines the mesh containing the submesh
  25528. * @param subMesh defines the submesh to bind the material to
  25529. */
  25530. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25531. /**
  25532. * Get the list of animatables in the material.
  25533. * @returns the list of animatables object used in the material
  25534. */
  25535. getAnimatables(): IAnimatable[];
  25536. /**
  25537. * Gets the active textures from the material
  25538. * @returns an array of textures
  25539. */
  25540. getActiveTextures(): BaseTexture[];
  25541. /**
  25542. * Specifies if the material uses a texture
  25543. * @param texture defines the texture to check against the material
  25544. * @returns a boolean specifying if the material uses the texture
  25545. */
  25546. hasTexture(texture: BaseTexture): boolean;
  25547. /**
  25548. * Disposes the material
  25549. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25550. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25551. */
  25552. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25553. /**
  25554. * Makes a duplicate of the material, and gives it a new name
  25555. * @param name defines the new name for the duplicated material
  25556. * @returns the cloned material
  25557. */
  25558. clone(name: string): StandardMaterial;
  25559. /**
  25560. * Serializes this material in a JSON representation
  25561. * @returns the serialized material object
  25562. */
  25563. serialize(): any;
  25564. /**
  25565. * Creates a standard material from parsed material data
  25566. * @param source defines the JSON representation of the material
  25567. * @param scene defines the hosting scene
  25568. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25569. * @returns a new standard material
  25570. */
  25571. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  25572. /**
  25573. * Are diffuse textures enabled in the application.
  25574. */
  25575. static get DiffuseTextureEnabled(): boolean;
  25576. static set DiffuseTextureEnabled(value: boolean);
  25577. /**
  25578. * Are detail textures enabled in the application.
  25579. */
  25580. static get DetailTextureEnabled(): boolean;
  25581. static set DetailTextureEnabled(value: boolean);
  25582. /**
  25583. * Are ambient textures enabled in the application.
  25584. */
  25585. static get AmbientTextureEnabled(): boolean;
  25586. static set AmbientTextureEnabled(value: boolean);
  25587. /**
  25588. * Are opacity textures enabled in the application.
  25589. */
  25590. static get OpacityTextureEnabled(): boolean;
  25591. static set OpacityTextureEnabled(value: boolean);
  25592. /**
  25593. * Are reflection textures enabled in the application.
  25594. */
  25595. static get ReflectionTextureEnabled(): boolean;
  25596. static set ReflectionTextureEnabled(value: boolean);
  25597. /**
  25598. * Are emissive textures enabled in the application.
  25599. */
  25600. static get EmissiveTextureEnabled(): boolean;
  25601. static set EmissiveTextureEnabled(value: boolean);
  25602. /**
  25603. * Are specular textures enabled in the application.
  25604. */
  25605. static get SpecularTextureEnabled(): boolean;
  25606. static set SpecularTextureEnabled(value: boolean);
  25607. /**
  25608. * Are bump textures enabled in the application.
  25609. */
  25610. static get BumpTextureEnabled(): boolean;
  25611. static set BumpTextureEnabled(value: boolean);
  25612. /**
  25613. * Are lightmap textures enabled in the application.
  25614. */
  25615. static get LightmapTextureEnabled(): boolean;
  25616. static set LightmapTextureEnabled(value: boolean);
  25617. /**
  25618. * Are refraction textures enabled in the application.
  25619. */
  25620. static get RefractionTextureEnabled(): boolean;
  25621. static set RefractionTextureEnabled(value: boolean);
  25622. /**
  25623. * Are color grading textures enabled in the application.
  25624. */
  25625. static get ColorGradingTextureEnabled(): boolean;
  25626. static set ColorGradingTextureEnabled(value: boolean);
  25627. /**
  25628. * Are fresnels enabled in the application.
  25629. */
  25630. static get FresnelEnabled(): boolean;
  25631. static set FresnelEnabled(value: boolean);
  25632. }
  25633. }
  25634. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  25635. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25636. /** @hidden */
  25637. export var rgbdDecodePixelShader: {
  25638. name: string;
  25639. shader: string;
  25640. };
  25641. }
  25642. declare module "babylonjs/Misc/rgbdTextureTools" {
  25643. import "babylonjs/Shaders/rgbdDecode.fragment";
  25644. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25645. import { Texture } from "babylonjs/Materials/Textures/texture";
  25646. /**
  25647. * Class used to host RGBD texture specific utilities
  25648. */
  25649. export class RGBDTextureTools {
  25650. /**
  25651. * Expand the RGBD Texture from RGBD to Half Float if possible.
  25652. * @param texture the texture to expand.
  25653. */
  25654. static ExpandRGBDTexture(texture: Texture): void;
  25655. }
  25656. }
  25657. declare module "babylonjs/Misc/brdfTextureTools" {
  25658. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25659. import { Scene } from "babylonjs/scene";
  25660. /**
  25661. * Class used to host texture specific utilities
  25662. */
  25663. export class BRDFTextureTools {
  25664. /**
  25665. * Prevents texture cache collision
  25666. */
  25667. private static _instanceNumber;
  25668. /**
  25669. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  25670. * @param scene defines the hosting scene
  25671. * @returns the environment BRDF texture
  25672. */
  25673. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25674. private static _environmentBRDFBase64Texture;
  25675. }
  25676. }
  25677. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  25678. import { Nullable } from "babylonjs/types";
  25679. import { Color3 } from "babylonjs/Maths/math.color";
  25680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25681. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25682. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25683. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25684. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25685. import { Engine } from "babylonjs/Engines/engine";
  25686. import { Scene } from "babylonjs/scene";
  25687. /**
  25688. * @hidden
  25689. */
  25690. export interface IMaterialClearCoatDefines {
  25691. CLEARCOAT: boolean;
  25692. CLEARCOAT_DEFAULTIOR: boolean;
  25693. CLEARCOAT_TEXTURE: boolean;
  25694. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  25695. CLEARCOAT_TEXTUREDIRECTUV: number;
  25696. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  25697. CLEARCOAT_BUMP: boolean;
  25698. CLEARCOAT_BUMPDIRECTUV: number;
  25699. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25700. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25701. CLEARCOAT_REMAP_F0: boolean;
  25702. CLEARCOAT_TINT: boolean;
  25703. CLEARCOAT_TINT_TEXTURE: boolean;
  25704. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  25705. /** @hidden */
  25706. _areTexturesDirty: boolean;
  25707. }
  25708. /**
  25709. * Define the code related to the clear coat parameters of the pbr material.
  25710. */
  25711. export class PBRClearCoatConfiguration {
  25712. /**
  25713. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25714. * The default fits with a polyurethane material.
  25715. */
  25716. private static readonly _DefaultIndexOfRefraction;
  25717. private _isEnabled;
  25718. /**
  25719. * Defines if the clear coat is enabled in the material.
  25720. */
  25721. isEnabled: boolean;
  25722. /**
  25723. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  25724. */
  25725. intensity: number;
  25726. /**
  25727. * Defines the clear coat layer roughness.
  25728. */
  25729. roughness: number;
  25730. private _indexOfRefraction;
  25731. /**
  25732. * Defines the index of refraction of the clear coat.
  25733. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25734. * The default fits with a polyurethane material.
  25735. * Changing the default value is more performance intensive.
  25736. */
  25737. indexOfRefraction: number;
  25738. private _texture;
  25739. /**
  25740. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  25741. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  25742. * if textureRoughness is not empty, else no texture roughness is used
  25743. */
  25744. texture: Nullable<BaseTexture>;
  25745. private _useRoughnessFromMainTexture;
  25746. /**
  25747. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  25748. * If false, the green channel from textureRoughness is used for roughness
  25749. */
  25750. useRoughnessFromMainTexture: boolean;
  25751. private _textureRoughness;
  25752. /**
  25753. * Stores the clear coat roughness in a texture (green channel)
  25754. * Not used if useRoughnessFromMainTexture is true
  25755. */
  25756. textureRoughness: Nullable<BaseTexture>;
  25757. private _remapF0OnInterfaceChange;
  25758. /**
  25759. * Defines if the F0 value should be remapped to account for the interface change in the material.
  25760. */
  25761. remapF0OnInterfaceChange: boolean;
  25762. private _bumpTexture;
  25763. /**
  25764. * Define the clear coat specific bump texture.
  25765. */
  25766. bumpTexture: Nullable<BaseTexture>;
  25767. private _isTintEnabled;
  25768. /**
  25769. * Defines if the clear coat tint is enabled in the material.
  25770. */
  25771. isTintEnabled: boolean;
  25772. /**
  25773. * Defines the clear coat tint of the material.
  25774. * This is only use if tint is enabled
  25775. */
  25776. tintColor: Color3;
  25777. /**
  25778. * Defines the distance at which the tint color should be found in the
  25779. * clear coat media.
  25780. * This is only use if tint is enabled
  25781. */
  25782. tintColorAtDistance: number;
  25783. /**
  25784. * Defines the clear coat layer thickness.
  25785. * This is only use if tint is enabled
  25786. */
  25787. tintThickness: number;
  25788. private _tintTexture;
  25789. /**
  25790. * Stores the clear tint values in a texture.
  25791. * rgb is tint
  25792. * a is a thickness factor
  25793. */
  25794. tintTexture: Nullable<BaseTexture>;
  25795. /** @hidden */
  25796. private _internalMarkAllSubMeshesAsTexturesDirty;
  25797. /** @hidden */
  25798. _markAllSubMeshesAsTexturesDirty(): void;
  25799. /**
  25800. * Instantiate a new istance of clear coat configuration.
  25801. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25802. */
  25803. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25804. /**
  25805. * Gets wehter the submesh is ready to be used or not.
  25806. * @param defines the list of "defines" to update.
  25807. * @param scene defines the scene the material belongs to.
  25808. * @param engine defines the engine the material belongs to.
  25809. * @param disableBumpMap defines wether the material disables bump or not.
  25810. * @returns - boolean indicating that the submesh is ready or not.
  25811. */
  25812. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  25813. /**
  25814. * Checks to see if a texture is used in the material.
  25815. * @param defines the list of "defines" to update.
  25816. * @param scene defines the scene to the material belongs to.
  25817. */
  25818. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  25819. /**
  25820. * Binds the material data.
  25821. * @param uniformBuffer defines the Uniform buffer to fill in.
  25822. * @param scene defines the scene the material belongs to.
  25823. * @param engine defines the engine the material belongs to.
  25824. * @param disableBumpMap defines wether the material disables bump or not.
  25825. * @param isFrozen defines wether the material is frozen or not.
  25826. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25827. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25828. * @param subMesh the submesh to bind data for
  25829. */
  25830. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  25831. /**
  25832. * Checks to see if a texture is used in the material.
  25833. * @param texture - Base texture to use.
  25834. * @returns - Boolean specifying if a texture is used in the material.
  25835. */
  25836. hasTexture(texture: BaseTexture): boolean;
  25837. /**
  25838. * Returns an array of the actively used textures.
  25839. * @param activeTextures Array of BaseTextures
  25840. */
  25841. getActiveTextures(activeTextures: BaseTexture[]): void;
  25842. /**
  25843. * Returns the animatable textures.
  25844. * @param animatables Array of animatable textures.
  25845. */
  25846. getAnimatables(animatables: IAnimatable[]): void;
  25847. /**
  25848. * Disposes the resources of the material.
  25849. * @param forceDisposeTextures - Forces the disposal of all textures.
  25850. */
  25851. dispose(forceDisposeTextures?: boolean): void;
  25852. /**
  25853. * Get the current class name of the texture useful for serialization or dynamic coding.
  25854. * @returns "PBRClearCoatConfiguration"
  25855. */
  25856. getClassName(): string;
  25857. /**
  25858. * Add fallbacks to the effect fallbacks list.
  25859. * @param defines defines the Base texture to use.
  25860. * @param fallbacks defines the current fallback list.
  25861. * @param currentRank defines the current fallback rank.
  25862. * @returns the new fallback rank.
  25863. */
  25864. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25865. /**
  25866. * Add the required uniforms to the current list.
  25867. * @param uniforms defines the current uniform list.
  25868. */
  25869. static AddUniforms(uniforms: string[]): void;
  25870. /**
  25871. * Add the required samplers to the current list.
  25872. * @param samplers defines the current sampler list.
  25873. */
  25874. static AddSamplers(samplers: string[]): void;
  25875. /**
  25876. * Add the required uniforms to the current buffer.
  25877. * @param uniformBuffer defines the current uniform buffer.
  25878. */
  25879. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25880. /**
  25881. * Makes a duplicate of the current configuration into another one.
  25882. * @param clearCoatConfiguration define the config where to copy the info
  25883. */
  25884. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  25885. /**
  25886. * Serializes this clear coat configuration.
  25887. * @returns - An object with the serialized config.
  25888. */
  25889. serialize(): any;
  25890. /**
  25891. * Parses a anisotropy Configuration from a serialized object.
  25892. * @param source - Serialized object.
  25893. * @param scene Defines the scene we are parsing for
  25894. * @param rootUrl Defines the rootUrl to load from
  25895. */
  25896. parse(source: any, scene: Scene, rootUrl: string): void;
  25897. }
  25898. }
  25899. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  25900. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25902. import { Vector2 } from "babylonjs/Maths/math.vector";
  25903. import { Scene } from "babylonjs/scene";
  25904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25905. import { Nullable } from "babylonjs/types";
  25906. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25907. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25908. /**
  25909. * @hidden
  25910. */
  25911. export interface IMaterialAnisotropicDefines {
  25912. ANISOTROPIC: boolean;
  25913. ANISOTROPIC_TEXTURE: boolean;
  25914. ANISOTROPIC_TEXTUREDIRECTUV: number;
  25915. MAINUV1: boolean;
  25916. _areTexturesDirty: boolean;
  25917. _needUVs: boolean;
  25918. }
  25919. /**
  25920. * Define the code related to the anisotropic parameters of the pbr material.
  25921. */
  25922. export class PBRAnisotropicConfiguration {
  25923. private _isEnabled;
  25924. /**
  25925. * Defines if the anisotropy is enabled in the material.
  25926. */
  25927. isEnabled: boolean;
  25928. /**
  25929. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25930. */
  25931. intensity: number;
  25932. /**
  25933. * Defines if the effect is along the tangents, bitangents or in between.
  25934. * By default, the effect is "strectching" the highlights along the tangents.
  25935. */
  25936. direction: Vector2;
  25937. private _texture;
  25938. /**
  25939. * Stores the anisotropy values in a texture.
  25940. * rg is direction (like normal from -1 to 1)
  25941. * b is a intensity
  25942. */
  25943. texture: Nullable<BaseTexture>;
  25944. /** @hidden */
  25945. private _internalMarkAllSubMeshesAsTexturesDirty;
  25946. /** @hidden */
  25947. _markAllSubMeshesAsTexturesDirty(): void;
  25948. /**
  25949. * Instantiate a new istance of anisotropy configuration.
  25950. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25951. */
  25952. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25953. /**
  25954. * Specifies that the submesh is ready to be used.
  25955. * @param defines the list of "defines" to update.
  25956. * @param scene defines the scene the material belongs to.
  25957. * @returns - boolean indicating that the submesh is ready or not.
  25958. */
  25959. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25960. /**
  25961. * Checks to see if a texture is used in the material.
  25962. * @param defines the list of "defines" to update.
  25963. * @param mesh the mesh we are preparing the defines for.
  25964. * @param scene defines the scene the material belongs to.
  25965. */
  25966. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25967. /**
  25968. * Binds the material data.
  25969. * @param uniformBuffer defines the Uniform buffer to fill in.
  25970. * @param scene defines the scene the material belongs to.
  25971. * @param isFrozen defines wether the material is frozen or not.
  25972. */
  25973. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25974. /**
  25975. * Checks to see if a texture is used in the material.
  25976. * @param texture - Base texture to use.
  25977. * @returns - Boolean specifying if a texture is used in the material.
  25978. */
  25979. hasTexture(texture: BaseTexture): boolean;
  25980. /**
  25981. * Returns an array of the actively used textures.
  25982. * @param activeTextures Array of BaseTextures
  25983. */
  25984. getActiveTextures(activeTextures: BaseTexture[]): void;
  25985. /**
  25986. * Returns the animatable textures.
  25987. * @param animatables Array of animatable textures.
  25988. */
  25989. getAnimatables(animatables: IAnimatable[]): void;
  25990. /**
  25991. * Disposes the resources of the material.
  25992. * @param forceDisposeTextures - Forces the disposal of all textures.
  25993. */
  25994. dispose(forceDisposeTextures?: boolean): void;
  25995. /**
  25996. * Get the current class name of the texture useful for serialization or dynamic coding.
  25997. * @returns "PBRAnisotropicConfiguration"
  25998. */
  25999. getClassName(): string;
  26000. /**
  26001. * Add fallbacks to the effect fallbacks list.
  26002. * @param defines defines the Base texture to use.
  26003. * @param fallbacks defines the current fallback list.
  26004. * @param currentRank defines the current fallback rank.
  26005. * @returns the new fallback rank.
  26006. */
  26007. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26008. /**
  26009. * Add the required uniforms to the current list.
  26010. * @param uniforms defines the current uniform list.
  26011. */
  26012. static AddUniforms(uniforms: string[]): void;
  26013. /**
  26014. * Add the required uniforms to the current buffer.
  26015. * @param uniformBuffer defines the current uniform buffer.
  26016. */
  26017. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26018. /**
  26019. * Add the required samplers to the current list.
  26020. * @param samplers defines the current sampler list.
  26021. */
  26022. static AddSamplers(samplers: string[]): void;
  26023. /**
  26024. * Makes a duplicate of the current configuration into another one.
  26025. * @param anisotropicConfiguration define the config where to copy the info
  26026. */
  26027. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  26028. /**
  26029. * Serializes this anisotropy configuration.
  26030. * @returns - An object with the serialized config.
  26031. */
  26032. serialize(): any;
  26033. /**
  26034. * Parses a anisotropy Configuration from a serialized object.
  26035. * @param source - Serialized object.
  26036. * @param scene Defines the scene we are parsing for
  26037. * @param rootUrl Defines the rootUrl to load from
  26038. */
  26039. parse(source: any, scene: Scene, rootUrl: string): void;
  26040. }
  26041. }
  26042. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  26043. import { Scene } from "babylonjs/scene";
  26044. /**
  26045. * @hidden
  26046. */
  26047. export interface IMaterialBRDFDefines {
  26048. BRDF_V_HEIGHT_CORRELATED: boolean;
  26049. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26050. SPHERICAL_HARMONICS: boolean;
  26051. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26052. /** @hidden */
  26053. _areMiscDirty: boolean;
  26054. }
  26055. /**
  26056. * Define the code related to the BRDF parameters of the pbr material.
  26057. */
  26058. export class PBRBRDFConfiguration {
  26059. /**
  26060. * Default value used for the energy conservation.
  26061. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  26062. */
  26063. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  26064. /**
  26065. * Default value used for the Smith Visibility Height Correlated mode.
  26066. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  26067. */
  26068. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  26069. /**
  26070. * Default value used for the IBL diffuse part.
  26071. * This can help switching back to the polynomials mode globally which is a tiny bit
  26072. * less GPU intensive at the drawback of a lower quality.
  26073. */
  26074. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  26075. /**
  26076. * Default value used for activating energy conservation for the specular workflow.
  26077. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  26078. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  26079. */
  26080. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  26081. private _useEnergyConservation;
  26082. /**
  26083. * Defines if the material uses energy conservation.
  26084. */
  26085. useEnergyConservation: boolean;
  26086. private _useSmithVisibilityHeightCorrelated;
  26087. /**
  26088. * LEGACY Mode set to false
  26089. * Defines if the material uses height smith correlated visibility term.
  26090. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  26091. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  26092. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  26093. * Not relying on height correlated will also disable energy conservation.
  26094. */
  26095. useSmithVisibilityHeightCorrelated: boolean;
  26096. private _useSphericalHarmonics;
  26097. /**
  26098. * LEGACY Mode set to false
  26099. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  26100. * diffuse part of the IBL.
  26101. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  26102. * to the ground truth.
  26103. */
  26104. useSphericalHarmonics: boolean;
  26105. private _useSpecularGlossinessInputEnergyConservation;
  26106. /**
  26107. * Defines if the material uses energy conservation, when the specular workflow is active.
  26108. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  26109. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  26110. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  26111. */
  26112. useSpecularGlossinessInputEnergyConservation: boolean;
  26113. /** @hidden */
  26114. private _internalMarkAllSubMeshesAsMiscDirty;
  26115. /** @hidden */
  26116. _markAllSubMeshesAsMiscDirty(): void;
  26117. /**
  26118. * Instantiate a new istance of clear coat configuration.
  26119. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  26120. */
  26121. constructor(markAllSubMeshesAsMiscDirty: () => void);
  26122. /**
  26123. * Checks to see if a texture is used in the material.
  26124. * @param defines the list of "defines" to update.
  26125. */
  26126. prepareDefines(defines: IMaterialBRDFDefines): void;
  26127. /**
  26128. * Get the current class name of the texture useful for serialization or dynamic coding.
  26129. * @returns "PBRClearCoatConfiguration"
  26130. */
  26131. getClassName(): string;
  26132. /**
  26133. * Makes a duplicate of the current configuration into another one.
  26134. * @param brdfConfiguration define the config where to copy the info
  26135. */
  26136. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  26137. /**
  26138. * Serializes this BRDF configuration.
  26139. * @returns - An object with the serialized config.
  26140. */
  26141. serialize(): any;
  26142. /**
  26143. * Parses a anisotropy Configuration from a serialized object.
  26144. * @param source - Serialized object.
  26145. * @param scene Defines the scene we are parsing for
  26146. * @param rootUrl Defines the rootUrl to load from
  26147. */
  26148. parse(source: any, scene: Scene, rootUrl: string): void;
  26149. }
  26150. }
  26151. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  26152. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26153. import { Color3 } from "babylonjs/Maths/math.color";
  26154. import { Scene } from "babylonjs/scene";
  26155. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26156. import { Nullable } from "babylonjs/types";
  26157. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26158. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26159. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26160. /**
  26161. * @hidden
  26162. */
  26163. export interface IMaterialSheenDefines {
  26164. SHEEN: boolean;
  26165. SHEEN_TEXTURE: boolean;
  26166. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26167. SHEEN_TEXTUREDIRECTUV: number;
  26168. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26169. SHEEN_LINKWITHALBEDO: boolean;
  26170. SHEEN_ROUGHNESS: boolean;
  26171. SHEEN_ALBEDOSCALING: boolean;
  26172. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26173. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26174. /** @hidden */
  26175. _areTexturesDirty: boolean;
  26176. }
  26177. /**
  26178. * Define the code related to the Sheen parameters of the pbr material.
  26179. */
  26180. export class PBRSheenConfiguration {
  26181. private _isEnabled;
  26182. /**
  26183. * Defines if the material uses sheen.
  26184. */
  26185. isEnabled: boolean;
  26186. private _linkSheenWithAlbedo;
  26187. /**
  26188. * Defines if the sheen is linked to the sheen color.
  26189. */
  26190. linkSheenWithAlbedo: boolean;
  26191. /**
  26192. * Defines the sheen intensity.
  26193. */
  26194. intensity: number;
  26195. /**
  26196. * Defines the sheen color.
  26197. */
  26198. color: Color3;
  26199. private _texture;
  26200. /**
  26201. * Stores the sheen tint values in a texture.
  26202. * rgb is tint
  26203. * 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)
  26204. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  26205. */
  26206. texture: Nullable<BaseTexture>;
  26207. private _useRoughnessFromMainTexture;
  26208. /**
  26209. * Indicates that the alpha channel of the texture property will be used for roughness.
  26210. * Has no effect if the roughness (and texture!) property is not defined
  26211. */
  26212. useRoughnessFromMainTexture: boolean;
  26213. private _roughness;
  26214. /**
  26215. * Defines the sheen roughness.
  26216. * It is not taken into account if linkSheenWithAlbedo is true.
  26217. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  26218. */
  26219. roughness: Nullable<number>;
  26220. private _textureRoughness;
  26221. /**
  26222. * Stores the sheen roughness in a texture.
  26223. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  26224. */
  26225. textureRoughness: Nullable<BaseTexture>;
  26226. private _albedoScaling;
  26227. /**
  26228. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  26229. * It allows the strength of the sheen effect to not depend on the base color of the material,
  26230. * making it easier to setup and tweak the effect
  26231. */
  26232. albedoScaling: boolean;
  26233. /** @hidden */
  26234. private _internalMarkAllSubMeshesAsTexturesDirty;
  26235. /** @hidden */
  26236. _markAllSubMeshesAsTexturesDirty(): void;
  26237. /**
  26238. * Instantiate a new istance of clear coat configuration.
  26239. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26240. */
  26241. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  26242. /**
  26243. * Specifies that the submesh is ready to be used.
  26244. * @param defines the list of "defines" to update.
  26245. * @param scene defines the scene the material belongs to.
  26246. * @returns - boolean indicating that the submesh is ready or not.
  26247. */
  26248. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  26249. /**
  26250. * Checks to see if a texture is used in the material.
  26251. * @param defines the list of "defines" to update.
  26252. * @param scene defines the scene the material belongs to.
  26253. */
  26254. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  26255. /**
  26256. * Binds the material data.
  26257. * @param uniformBuffer defines the Uniform buffer to fill in.
  26258. * @param scene defines the scene the material belongs to.
  26259. * @param isFrozen defines wether the material is frozen or not.
  26260. * @param subMesh the submesh to bind data for
  26261. */
  26262. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  26263. /**
  26264. * Checks to see if a texture is used in the material.
  26265. * @param texture - Base texture to use.
  26266. * @returns - Boolean specifying if a texture is used in the material.
  26267. */
  26268. hasTexture(texture: BaseTexture): boolean;
  26269. /**
  26270. * Returns an array of the actively used textures.
  26271. * @param activeTextures Array of BaseTextures
  26272. */
  26273. getActiveTextures(activeTextures: BaseTexture[]): void;
  26274. /**
  26275. * Returns the animatable textures.
  26276. * @param animatables Array of animatable textures.
  26277. */
  26278. getAnimatables(animatables: IAnimatable[]): void;
  26279. /**
  26280. * Disposes the resources of the material.
  26281. * @param forceDisposeTextures - Forces the disposal of all textures.
  26282. */
  26283. dispose(forceDisposeTextures?: boolean): void;
  26284. /**
  26285. * Get the current class name of the texture useful for serialization or dynamic coding.
  26286. * @returns "PBRSheenConfiguration"
  26287. */
  26288. getClassName(): string;
  26289. /**
  26290. * Add fallbacks to the effect fallbacks list.
  26291. * @param defines defines the Base texture to use.
  26292. * @param fallbacks defines the current fallback list.
  26293. * @param currentRank defines the current fallback rank.
  26294. * @returns the new fallback rank.
  26295. */
  26296. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26297. /**
  26298. * Add the required uniforms to the current list.
  26299. * @param uniforms defines the current uniform list.
  26300. */
  26301. static AddUniforms(uniforms: string[]): void;
  26302. /**
  26303. * Add the required uniforms to the current buffer.
  26304. * @param uniformBuffer defines the current uniform buffer.
  26305. */
  26306. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26307. /**
  26308. * Add the required samplers to the current list.
  26309. * @param samplers defines the current sampler list.
  26310. */
  26311. static AddSamplers(samplers: string[]): void;
  26312. /**
  26313. * Makes a duplicate of the current configuration into another one.
  26314. * @param sheenConfiguration define the config where to copy the info
  26315. */
  26316. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  26317. /**
  26318. * Serializes this BRDF configuration.
  26319. * @returns - An object with the serialized config.
  26320. */
  26321. serialize(): any;
  26322. /**
  26323. * Parses a anisotropy Configuration from a serialized object.
  26324. * @param source - Serialized object.
  26325. * @param scene Defines the scene we are parsing for
  26326. * @param rootUrl Defines the rootUrl to load from
  26327. */
  26328. parse(source: any, scene: Scene, rootUrl: string): void;
  26329. }
  26330. }
  26331. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  26332. import { Nullable } from "babylonjs/types";
  26333. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26334. import { Color3 } from "babylonjs/Maths/math.color";
  26335. import { SmartArray } from "babylonjs/Misc/smartArray";
  26336. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26337. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26338. import { Effect } from "babylonjs/Materials/effect";
  26339. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26340. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26341. import { Engine } from "babylonjs/Engines/engine";
  26342. import { Scene } from "babylonjs/scene";
  26343. /**
  26344. * @hidden
  26345. */
  26346. export interface IMaterialSubSurfaceDefines {
  26347. SUBSURFACE: boolean;
  26348. SS_REFRACTION: boolean;
  26349. SS_TRANSLUCENCY: boolean;
  26350. SS_SCATTERING: boolean;
  26351. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26352. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26353. SS_REFRACTIONMAP_3D: boolean;
  26354. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26355. SS_LODINREFRACTIONALPHA: boolean;
  26356. SS_GAMMAREFRACTION: boolean;
  26357. SS_RGBDREFRACTION: boolean;
  26358. SS_LINEARSPECULARREFRACTION: boolean;
  26359. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26360. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26361. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26362. /** @hidden */
  26363. _areTexturesDirty: boolean;
  26364. }
  26365. /**
  26366. * Define the code related to the sub surface parameters of the pbr material.
  26367. */
  26368. export class PBRSubSurfaceConfiguration {
  26369. private _isRefractionEnabled;
  26370. /**
  26371. * Defines if the refraction is enabled in the material.
  26372. */
  26373. isRefractionEnabled: boolean;
  26374. private _isTranslucencyEnabled;
  26375. /**
  26376. * Defines if the translucency is enabled in the material.
  26377. */
  26378. isTranslucencyEnabled: boolean;
  26379. private _isScatteringEnabled;
  26380. /**
  26381. * Defines if the sub surface scattering is enabled in the material.
  26382. */
  26383. isScatteringEnabled: boolean;
  26384. private _scatteringDiffusionProfileIndex;
  26385. /**
  26386. * Diffusion profile for subsurface scattering.
  26387. * Useful for better scattering in the skins or foliages.
  26388. */
  26389. get scatteringDiffusionProfile(): Nullable<Color3>;
  26390. set scatteringDiffusionProfile(c: Nullable<Color3>);
  26391. /**
  26392. * Defines the refraction intensity of the material.
  26393. * The refraction when enabled replaces the Diffuse part of the material.
  26394. * The intensity helps transitionning between diffuse and refraction.
  26395. */
  26396. refractionIntensity: number;
  26397. /**
  26398. * Defines the translucency intensity of the material.
  26399. * When translucency has been enabled, this defines how much of the "translucency"
  26400. * is addded to the diffuse part of the material.
  26401. */
  26402. translucencyIntensity: number;
  26403. /**
  26404. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  26405. */
  26406. useAlbedoToTintRefraction: boolean;
  26407. private _thicknessTexture;
  26408. /**
  26409. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  26410. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  26411. * 0 would mean minimumThickness
  26412. * 1 would mean maximumThickness
  26413. * The other channels might be use as a mask to vary the different effects intensity.
  26414. */
  26415. thicknessTexture: Nullable<BaseTexture>;
  26416. private _refractionTexture;
  26417. /**
  26418. * Defines the texture to use for refraction.
  26419. */
  26420. refractionTexture: Nullable<BaseTexture>;
  26421. private _indexOfRefraction;
  26422. /**
  26423. * Index of refraction of the material base layer.
  26424. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26425. *
  26426. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26427. *
  26428. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26429. */
  26430. indexOfRefraction: number;
  26431. private _volumeIndexOfRefraction;
  26432. /**
  26433. * Index of refraction of the material's volume.
  26434. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26435. *
  26436. * This ONLY impacts refraction. If not provided or given a non-valid value,
  26437. * the volume will use the same IOR as the surface.
  26438. */
  26439. get volumeIndexOfRefraction(): number;
  26440. set volumeIndexOfRefraction(value: number);
  26441. private _invertRefractionY;
  26442. /**
  26443. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26444. */
  26445. invertRefractionY: boolean;
  26446. private _linkRefractionWithTransparency;
  26447. /**
  26448. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26449. * Materials half opaque for instance using refraction could benefit from this control.
  26450. */
  26451. linkRefractionWithTransparency: boolean;
  26452. /**
  26453. * Defines the minimum thickness stored in the thickness map.
  26454. * If no thickness map is defined, this value will be used to simulate thickness.
  26455. */
  26456. minimumThickness: number;
  26457. /**
  26458. * Defines the maximum thickness stored in the thickness map.
  26459. */
  26460. maximumThickness: number;
  26461. /**
  26462. * Defines the volume tint of the material.
  26463. * This is used for both translucency and scattering.
  26464. */
  26465. tintColor: Color3;
  26466. /**
  26467. * Defines the distance at which the tint color should be found in the media.
  26468. * This is used for refraction only.
  26469. */
  26470. tintColorAtDistance: number;
  26471. /**
  26472. * Defines how far each channel transmit through the media.
  26473. * It is defined as a color to simplify it selection.
  26474. */
  26475. diffusionDistance: Color3;
  26476. private _useMaskFromThicknessTexture;
  26477. /**
  26478. * Stores the intensity of the different subsurface effects in the thickness texture.
  26479. * * the green channel is the translucency intensity.
  26480. * * the blue channel is the scattering intensity.
  26481. * * the alpha channel is the refraction intensity.
  26482. */
  26483. useMaskFromThicknessTexture: boolean;
  26484. private _scene;
  26485. /** @hidden */
  26486. private _internalMarkAllSubMeshesAsTexturesDirty;
  26487. private _internalMarkScenePrePassDirty;
  26488. /** @hidden */
  26489. _markAllSubMeshesAsTexturesDirty(): void;
  26490. /** @hidden */
  26491. _markScenePrePassDirty(): void;
  26492. /**
  26493. * Instantiate a new istance of sub surface configuration.
  26494. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26495. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  26496. * @param scene The scene
  26497. */
  26498. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  26499. /**
  26500. * Gets wehter the submesh is ready to be used or not.
  26501. * @param defines the list of "defines" to update.
  26502. * @param scene defines the scene the material belongs to.
  26503. * @returns - boolean indicating that the submesh is ready or not.
  26504. */
  26505. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  26506. /**
  26507. * Checks to see if a texture is used in the material.
  26508. * @param defines the list of "defines" to update.
  26509. * @param scene defines the scene to the material belongs to.
  26510. */
  26511. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  26512. /**
  26513. * Binds the material data.
  26514. * @param uniformBuffer defines the Uniform buffer to fill in.
  26515. * @param scene defines the scene the material belongs to.
  26516. * @param engine defines the engine the material belongs to.
  26517. * @param isFrozen defines whether the material is frozen or not.
  26518. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  26519. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  26520. */
  26521. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  26522. /**
  26523. * Unbinds the material from the mesh.
  26524. * @param activeEffect defines the effect that should be unbound from.
  26525. * @returns true if unbound, otherwise false
  26526. */
  26527. unbind(activeEffect: Effect): boolean;
  26528. /**
  26529. * Returns the texture used for refraction or null if none is used.
  26530. * @param scene defines the scene the material belongs to.
  26531. * @returns - Refraction texture if present. If no refraction texture and refraction
  26532. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26533. */
  26534. private _getRefractionTexture;
  26535. /**
  26536. * Returns true if alpha blending should be disabled.
  26537. */
  26538. get disableAlphaBlending(): boolean;
  26539. /**
  26540. * Fills the list of render target textures.
  26541. * @param renderTargets the list of render targets to update
  26542. */
  26543. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  26544. /**
  26545. * Checks to see if a texture is used in the material.
  26546. * @param texture - Base texture to use.
  26547. * @returns - Boolean specifying if a texture is used in the material.
  26548. */
  26549. hasTexture(texture: BaseTexture): boolean;
  26550. /**
  26551. * Gets a boolean indicating that current material needs to register RTT
  26552. * @returns true if this uses a render target otherwise false.
  26553. */
  26554. hasRenderTargetTextures(): boolean;
  26555. /**
  26556. * Returns an array of the actively used textures.
  26557. * @param activeTextures Array of BaseTextures
  26558. */
  26559. getActiveTextures(activeTextures: BaseTexture[]): void;
  26560. /**
  26561. * Returns the animatable textures.
  26562. * @param animatables Array of animatable textures.
  26563. */
  26564. getAnimatables(animatables: IAnimatable[]): void;
  26565. /**
  26566. * Disposes the resources of the material.
  26567. * @param forceDisposeTextures - Forces the disposal of all textures.
  26568. */
  26569. dispose(forceDisposeTextures?: boolean): void;
  26570. /**
  26571. * Get the current class name of the texture useful for serialization or dynamic coding.
  26572. * @returns "PBRSubSurfaceConfiguration"
  26573. */
  26574. getClassName(): string;
  26575. /**
  26576. * Add fallbacks to the effect fallbacks list.
  26577. * @param defines defines the Base texture to use.
  26578. * @param fallbacks defines the current fallback list.
  26579. * @param currentRank defines the current fallback rank.
  26580. * @returns the new fallback rank.
  26581. */
  26582. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26583. /**
  26584. * Add the required uniforms to the current list.
  26585. * @param uniforms defines the current uniform list.
  26586. */
  26587. static AddUniforms(uniforms: string[]): void;
  26588. /**
  26589. * Add the required samplers to the current list.
  26590. * @param samplers defines the current sampler list.
  26591. */
  26592. static AddSamplers(samplers: string[]): void;
  26593. /**
  26594. * Add the required uniforms to the current buffer.
  26595. * @param uniformBuffer defines the current uniform buffer.
  26596. */
  26597. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26598. /**
  26599. * Makes a duplicate of the current configuration into another one.
  26600. * @param configuration define the config where to copy the info
  26601. */
  26602. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  26603. /**
  26604. * Serializes this Sub Surface configuration.
  26605. * @returns - An object with the serialized config.
  26606. */
  26607. serialize(): any;
  26608. /**
  26609. * Parses a anisotropy Configuration from a serialized object.
  26610. * @param source - Serialized object.
  26611. * @param scene Defines the scene we are parsing for
  26612. * @param rootUrl Defines the rootUrl to load from
  26613. */
  26614. parse(source: any, scene: Scene, rootUrl: string): void;
  26615. }
  26616. }
  26617. declare module "babylonjs/Maths/sphericalPolynomial" {
  26618. import { Vector3 } from "babylonjs/Maths/math.vector";
  26619. import { Color3 } from "babylonjs/Maths/math.color";
  26620. /**
  26621. * Class representing spherical harmonics coefficients to the 3rd degree
  26622. */
  26623. export class SphericalHarmonics {
  26624. /**
  26625. * Defines whether or not the harmonics have been prescaled for rendering.
  26626. */
  26627. preScaled: boolean;
  26628. /**
  26629. * The l0,0 coefficients of the spherical harmonics
  26630. */
  26631. l00: Vector3;
  26632. /**
  26633. * The l1,-1 coefficients of the spherical harmonics
  26634. */
  26635. l1_1: Vector3;
  26636. /**
  26637. * The l1,0 coefficients of the spherical harmonics
  26638. */
  26639. l10: Vector3;
  26640. /**
  26641. * The l1,1 coefficients of the spherical harmonics
  26642. */
  26643. l11: Vector3;
  26644. /**
  26645. * The l2,-2 coefficients of the spherical harmonics
  26646. */
  26647. l2_2: Vector3;
  26648. /**
  26649. * The l2,-1 coefficients of the spherical harmonics
  26650. */
  26651. l2_1: Vector3;
  26652. /**
  26653. * The l2,0 coefficients of the spherical harmonics
  26654. */
  26655. l20: Vector3;
  26656. /**
  26657. * The l2,1 coefficients of the spherical harmonics
  26658. */
  26659. l21: Vector3;
  26660. /**
  26661. * The l2,2 coefficients of the spherical harmonics
  26662. */
  26663. l22: Vector3;
  26664. /**
  26665. * Adds a light to the spherical harmonics
  26666. * @param direction the direction of the light
  26667. * @param color the color of the light
  26668. * @param deltaSolidAngle the delta solid angle of the light
  26669. */
  26670. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  26671. /**
  26672. * Scales the spherical harmonics by the given amount
  26673. * @param scale the amount to scale
  26674. */
  26675. scaleInPlace(scale: number): void;
  26676. /**
  26677. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  26678. *
  26679. * ```
  26680. * E_lm = A_l * L_lm
  26681. * ```
  26682. *
  26683. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  26684. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  26685. * the scaling factors are given in equation 9.
  26686. */
  26687. convertIncidentRadianceToIrradiance(): void;
  26688. /**
  26689. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  26690. *
  26691. * ```
  26692. * L = (1/pi) * E * rho
  26693. * ```
  26694. *
  26695. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  26696. */
  26697. convertIrradianceToLambertianRadiance(): void;
  26698. /**
  26699. * Integrates the reconstruction coefficients directly in to the SH preventing further
  26700. * required operations at run time.
  26701. *
  26702. * This is simply done by scaling back the SH with Ylm constants parameter.
  26703. * The trigonometric part being applied by the shader at run time.
  26704. */
  26705. preScaleForRendering(): void;
  26706. /**
  26707. * Constructs a spherical harmonics from an array.
  26708. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  26709. * @returns the spherical harmonics
  26710. */
  26711. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  26712. /**
  26713. * Gets the spherical harmonics from polynomial
  26714. * @param polynomial the spherical polynomial
  26715. * @returns the spherical harmonics
  26716. */
  26717. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  26718. }
  26719. /**
  26720. * Class representing spherical polynomial coefficients to the 3rd degree
  26721. */
  26722. export class SphericalPolynomial {
  26723. private _harmonics;
  26724. /**
  26725. * The spherical harmonics used to create the polynomials.
  26726. */
  26727. get preScaledHarmonics(): SphericalHarmonics;
  26728. /**
  26729. * The x coefficients of the spherical polynomial
  26730. */
  26731. x: Vector3;
  26732. /**
  26733. * The y coefficients of the spherical polynomial
  26734. */
  26735. y: Vector3;
  26736. /**
  26737. * The z coefficients of the spherical polynomial
  26738. */
  26739. z: Vector3;
  26740. /**
  26741. * The xx coefficients of the spherical polynomial
  26742. */
  26743. xx: Vector3;
  26744. /**
  26745. * The yy coefficients of the spherical polynomial
  26746. */
  26747. yy: Vector3;
  26748. /**
  26749. * The zz coefficients of the spherical polynomial
  26750. */
  26751. zz: Vector3;
  26752. /**
  26753. * The xy coefficients of the spherical polynomial
  26754. */
  26755. xy: Vector3;
  26756. /**
  26757. * The yz coefficients of the spherical polynomial
  26758. */
  26759. yz: Vector3;
  26760. /**
  26761. * The zx coefficients of the spherical polynomial
  26762. */
  26763. zx: Vector3;
  26764. /**
  26765. * Adds an ambient color to the spherical polynomial
  26766. * @param color the color to add
  26767. */
  26768. addAmbient(color: Color3): void;
  26769. /**
  26770. * Scales the spherical polynomial by the given amount
  26771. * @param scale the amount to scale
  26772. */
  26773. scaleInPlace(scale: number): void;
  26774. /**
  26775. * Gets the spherical polynomial from harmonics
  26776. * @param harmonics the spherical harmonics
  26777. * @returns the spherical polynomial
  26778. */
  26779. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  26780. /**
  26781. * Constructs a spherical polynomial from an array.
  26782. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  26783. * @returns the spherical polynomial
  26784. */
  26785. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  26786. }
  26787. }
  26788. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  26789. import { Nullable } from "babylonjs/types";
  26790. /**
  26791. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26792. */
  26793. export interface CubeMapInfo {
  26794. /**
  26795. * The pixel array for the front face.
  26796. * This is stored in format, left to right, up to down format.
  26797. */
  26798. front: Nullable<ArrayBufferView>;
  26799. /**
  26800. * The pixel array for the back face.
  26801. * This is stored in format, left to right, up to down format.
  26802. */
  26803. back: Nullable<ArrayBufferView>;
  26804. /**
  26805. * The pixel array for the left face.
  26806. * This is stored in format, left to right, up to down format.
  26807. */
  26808. left: Nullable<ArrayBufferView>;
  26809. /**
  26810. * The pixel array for the right face.
  26811. * This is stored in format, left to right, up to down format.
  26812. */
  26813. right: Nullable<ArrayBufferView>;
  26814. /**
  26815. * The pixel array for the up face.
  26816. * This is stored in format, left to right, up to down format.
  26817. */
  26818. up: Nullable<ArrayBufferView>;
  26819. /**
  26820. * The pixel array for the down face.
  26821. * This is stored in format, left to right, up to down format.
  26822. */
  26823. down: Nullable<ArrayBufferView>;
  26824. /**
  26825. * The size of the cubemap stored.
  26826. *
  26827. * Each faces will be size * size pixels.
  26828. */
  26829. size: number;
  26830. /**
  26831. * The format of the texture.
  26832. *
  26833. * RGBA, RGB.
  26834. */
  26835. format: number;
  26836. /**
  26837. * The type of the texture data.
  26838. *
  26839. * UNSIGNED_INT, FLOAT.
  26840. */
  26841. type: number;
  26842. /**
  26843. * Specifies whether the texture is in gamma space.
  26844. */
  26845. gammaSpace: boolean;
  26846. }
  26847. /**
  26848. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26849. */
  26850. export class PanoramaToCubeMapTools {
  26851. private static FACE_LEFT;
  26852. private static FACE_RIGHT;
  26853. private static FACE_FRONT;
  26854. private static FACE_BACK;
  26855. private static FACE_DOWN;
  26856. private static FACE_UP;
  26857. /**
  26858. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26859. *
  26860. * @param float32Array The source data.
  26861. * @param inputWidth The width of the input panorama.
  26862. * @param inputHeight The height of the input panorama.
  26863. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26864. * @return The cubemap data
  26865. */
  26866. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26867. private static CreateCubemapTexture;
  26868. private static CalcProjectionSpherical;
  26869. }
  26870. }
  26871. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  26872. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26874. import { Nullable } from "babylonjs/types";
  26875. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  26876. /**
  26877. * Helper class dealing with the extraction of spherical polynomial dataArray
  26878. * from a cube map.
  26879. */
  26880. export class CubeMapToSphericalPolynomialTools {
  26881. private static FileFaces;
  26882. /**
  26883. * Converts a texture to the according Spherical Polynomial data.
  26884. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26885. *
  26886. * @param texture The texture to extract the information from.
  26887. * @return The Spherical Polynomial data.
  26888. */
  26889. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26890. /**
  26891. * Converts a cubemap to the according Spherical Polynomial data.
  26892. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26893. *
  26894. * @param cubeInfo The Cube map to extract the information from.
  26895. * @return The Spherical Polynomial data.
  26896. */
  26897. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26898. }
  26899. }
  26900. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  26901. import { Nullable } from "babylonjs/types";
  26902. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26903. module "babylonjs/Materials/Textures/baseTexture" {
  26904. interface BaseTexture {
  26905. /**
  26906. * Get the polynomial representation of the texture data.
  26907. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26908. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26909. */
  26910. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26911. }
  26912. }
  26913. }
  26914. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  26915. /** @hidden */
  26916. export var pbrFragmentDeclaration: {
  26917. name: string;
  26918. shader: string;
  26919. };
  26920. }
  26921. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  26922. /** @hidden */
  26923. export var pbrUboDeclaration: {
  26924. name: string;
  26925. shader: string;
  26926. };
  26927. }
  26928. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  26929. /** @hidden */
  26930. export var pbrFragmentExtraDeclaration: {
  26931. name: string;
  26932. shader: string;
  26933. };
  26934. }
  26935. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  26936. /** @hidden */
  26937. export var pbrFragmentSamplersDeclaration: {
  26938. name: string;
  26939. shader: string;
  26940. };
  26941. }
  26942. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  26943. /** @hidden */
  26944. export var subSurfaceScatteringFunctions: {
  26945. name: string;
  26946. shader: string;
  26947. };
  26948. }
  26949. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  26950. /** @hidden */
  26951. export var importanceSampling: {
  26952. name: string;
  26953. shader: string;
  26954. };
  26955. }
  26956. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  26957. /** @hidden */
  26958. export var pbrHelperFunctions: {
  26959. name: string;
  26960. shader: string;
  26961. };
  26962. }
  26963. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  26964. /** @hidden */
  26965. export var harmonicsFunctions: {
  26966. name: string;
  26967. shader: string;
  26968. };
  26969. }
  26970. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  26971. /** @hidden */
  26972. export var pbrDirectLightingSetupFunctions: {
  26973. name: string;
  26974. shader: string;
  26975. };
  26976. }
  26977. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  26978. /** @hidden */
  26979. export var pbrDirectLightingFalloffFunctions: {
  26980. name: string;
  26981. shader: string;
  26982. };
  26983. }
  26984. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  26985. /** @hidden */
  26986. export var pbrBRDFFunctions: {
  26987. name: string;
  26988. shader: string;
  26989. };
  26990. }
  26991. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  26992. /** @hidden */
  26993. export var hdrFilteringFunctions: {
  26994. name: string;
  26995. shader: string;
  26996. };
  26997. }
  26998. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  26999. /** @hidden */
  27000. export var pbrDirectLightingFunctions: {
  27001. name: string;
  27002. shader: string;
  27003. };
  27004. }
  27005. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  27006. /** @hidden */
  27007. export var pbrIBLFunctions: {
  27008. name: string;
  27009. shader: string;
  27010. };
  27011. }
  27012. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  27013. /** @hidden */
  27014. export var pbrBlockAlbedoOpacity: {
  27015. name: string;
  27016. shader: string;
  27017. };
  27018. }
  27019. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  27020. /** @hidden */
  27021. export var pbrBlockReflectivity: {
  27022. name: string;
  27023. shader: string;
  27024. };
  27025. }
  27026. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  27027. /** @hidden */
  27028. export var pbrBlockAmbientOcclusion: {
  27029. name: string;
  27030. shader: string;
  27031. };
  27032. }
  27033. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  27034. /** @hidden */
  27035. export var pbrBlockAlphaFresnel: {
  27036. name: string;
  27037. shader: string;
  27038. };
  27039. }
  27040. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  27041. /** @hidden */
  27042. export var pbrBlockAnisotropic: {
  27043. name: string;
  27044. shader: string;
  27045. };
  27046. }
  27047. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  27048. /** @hidden */
  27049. export var pbrBlockReflection: {
  27050. name: string;
  27051. shader: string;
  27052. };
  27053. }
  27054. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  27055. /** @hidden */
  27056. export var pbrBlockSheen: {
  27057. name: string;
  27058. shader: string;
  27059. };
  27060. }
  27061. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  27062. /** @hidden */
  27063. export var pbrBlockClearcoat: {
  27064. name: string;
  27065. shader: string;
  27066. };
  27067. }
  27068. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  27069. /** @hidden */
  27070. export var pbrBlockSubSurface: {
  27071. name: string;
  27072. shader: string;
  27073. };
  27074. }
  27075. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  27076. /** @hidden */
  27077. export var pbrBlockNormalGeometric: {
  27078. name: string;
  27079. shader: string;
  27080. };
  27081. }
  27082. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  27083. /** @hidden */
  27084. export var pbrBlockNormalFinal: {
  27085. name: string;
  27086. shader: string;
  27087. };
  27088. }
  27089. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  27090. /** @hidden */
  27091. export var pbrBlockLightmapInit: {
  27092. name: string;
  27093. shader: string;
  27094. };
  27095. }
  27096. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  27097. /** @hidden */
  27098. export var pbrBlockGeometryInfo: {
  27099. name: string;
  27100. shader: string;
  27101. };
  27102. }
  27103. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  27104. /** @hidden */
  27105. export var pbrBlockReflectance0: {
  27106. name: string;
  27107. shader: string;
  27108. };
  27109. }
  27110. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  27111. /** @hidden */
  27112. export var pbrBlockReflectance: {
  27113. name: string;
  27114. shader: string;
  27115. };
  27116. }
  27117. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  27118. /** @hidden */
  27119. export var pbrBlockDirectLighting: {
  27120. name: string;
  27121. shader: string;
  27122. };
  27123. }
  27124. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  27125. /** @hidden */
  27126. export var pbrBlockFinalLitComponents: {
  27127. name: string;
  27128. shader: string;
  27129. };
  27130. }
  27131. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  27132. /** @hidden */
  27133. export var pbrBlockFinalUnlitComponents: {
  27134. name: string;
  27135. shader: string;
  27136. };
  27137. }
  27138. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  27139. /** @hidden */
  27140. export var pbrBlockFinalColorComposition: {
  27141. name: string;
  27142. shader: string;
  27143. };
  27144. }
  27145. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  27146. /** @hidden */
  27147. export var pbrBlockImageProcessing: {
  27148. name: string;
  27149. shader: string;
  27150. };
  27151. }
  27152. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  27153. /** @hidden */
  27154. export var pbrDebug: {
  27155. name: string;
  27156. shader: string;
  27157. };
  27158. }
  27159. declare module "babylonjs/Shaders/pbr.fragment" {
  27160. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  27161. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  27162. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  27163. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  27164. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27165. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27166. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  27167. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27168. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27169. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27170. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27171. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27172. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  27173. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  27174. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  27175. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27176. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27177. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  27178. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  27179. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  27180. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  27181. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  27182. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  27183. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  27184. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  27185. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27186. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27187. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  27188. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  27189. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  27190. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  27191. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  27192. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  27193. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  27194. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  27195. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  27196. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27197. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  27198. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27199. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  27200. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27201. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  27202. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  27203. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  27204. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  27205. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  27206. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27207. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  27208. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  27209. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  27210. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27211. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27212. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  27213. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  27214. /** @hidden */
  27215. export var pbrPixelShader: {
  27216. name: string;
  27217. shader: string;
  27218. };
  27219. }
  27220. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  27221. /** @hidden */
  27222. export var pbrVertexDeclaration: {
  27223. name: string;
  27224. shader: string;
  27225. };
  27226. }
  27227. declare module "babylonjs/Shaders/pbr.vertex" {
  27228. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  27229. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  27230. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27231. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27232. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27233. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  27234. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  27235. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27236. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27237. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27238. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27239. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27240. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27241. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27242. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27243. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27244. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27245. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27246. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  27247. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27248. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27249. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27250. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27251. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27252. /** @hidden */
  27253. export var pbrVertexShader: {
  27254. name: string;
  27255. shader: string;
  27256. };
  27257. }
  27258. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  27259. import { Nullable } from "babylonjs/types";
  27260. import { Scene } from "babylonjs/scene";
  27261. import { Matrix } from "babylonjs/Maths/math.vector";
  27262. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27264. import { Mesh } from "babylonjs/Meshes/mesh";
  27265. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  27266. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  27267. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  27268. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  27269. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  27270. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  27271. import { Color3 } from "babylonjs/Maths/math.color";
  27272. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27273. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  27274. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27275. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27277. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27278. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  27279. import "babylonjs/Shaders/pbr.fragment";
  27280. import "babylonjs/Shaders/pbr.vertex";
  27281. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  27282. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  27283. /**
  27284. * Manages the defines for the PBR Material.
  27285. * @hidden
  27286. */
  27287. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  27288. PBR: boolean;
  27289. NUM_SAMPLES: string;
  27290. REALTIME_FILTERING: boolean;
  27291. MAINUV1: boolean;
  27292. MAINUV2: boolean;
  27293. UV1: boolean;
  27294. UV2: boolean;
  27295. ALBEDO: boolean;
  27296. GAMMAALBEDO: boolean;
  27297. ALBEDODIRECTUV: number;
  27298. VERTEXCOLOR: boolean;
  27299. DETAIL: boolean;
  27300. DETAILDIRECTUV: number;
  27301. DETAIL_NORMALBLENDMETHOD: number;
  27302. AMBIENT: boolean;
  27303. AMBIENTDIRECTUV: number;
  27304. AMBIENTINGRAYSCALE: boolean;
  27305. OPACITY: boolean;
  27306. VERTEXALPHA: boolean;
  27307. OPACITYDIRECTUV: number;
  27308. OPACITYRGB: boolean;
  27309. ALPHATEST: boolean;
  27310. DEPTHPREPASS: boolean;
  27311. ALPHABLEND: boolean;
  27312. ALPHAFROMALBEDO: boolean;
  27313. ALPHATESTVALUE: string;
  27314. SPECULAROVERALPHA: boolean;
  27315. RADIANCEOVERALPHA: boolean;
  27316. ALPHAFRESNEL: boolean;
  27317. LINEARALPHAFRESNEL: boolean;
  27318. PREMULTIPLYALPHA: boolean;
  27319. EMISSIVE: boolean;
  27320. EMISSIVEDIRECTUV: number;
  27321. REFLECTIVITY: boolean;
  27322. REFLECTIVITYDIRECTUV: number;
  27323. SPECULARTERM: boolean;
  27324. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  27325. MICROSURFACEAUTOMATIC: boolean;
  27326. LODBASEDMICROSFURACE: boolean;
  27327. MICROSURFACEMAP: boolean;
  27328. MICROSURFACEMAPDIRECTUV: number;
  27329. METALLICWORKFLOW: boolean;
  27330. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  27331. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  27332. METALLNESSSTOREINMETALMAPBLUE: boolean;
  27333. AOSTOREINMETALMAPRED: boolean;
  27334. METALLIC_REFLECTANCE: boolean;
  27335. METALLIC_REFLECTANCEDIRECTUV: number;
  27336. ENVIRONMENTBRDF: boolean;
  27337. ENVIRONMENTBRDF_RGBD: boolean;
  27338. NORMAL: boolean;
  27339. TANGENT: boolean;
  27340. BUMP: boolean;
  27341. BUMPDIRECTUV: number;
  27342. OBJECTSPACE_NORMALMAP: boolean;
  27343. PARALLAX: boolean;
  27344. PARALLAXOCCLUSION: boolean;
  27345. NORMALXYSCALE: boolean;
  27346. LIGHTMAP: boolean;
  27347. LIGHTMAPDIRECTUV: number;
  27348. USELIGHTMAPASSHADOWMAP: boolean;
  27349. GAMMALIGHTMAP: boolean;
  27350. RGBDLIGHTMAP: boolean;
  27351. REFLECTION: boolean;
  27352. REFLECTIONMAP_3D: boolean;
  27353. REFLECTIONMAP_SPHERICAL: boolean;
  27354. REFLECTIONMAP_PLANAR: boolean;
  27355. REFLECTIONMAP_CUBIC: boolean;
  27356. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27357. REFLECTIONMAP_PROJECTION: boolean;
  27358. REFLECTIONMAP_SKYBOX: boolean;
  27359. REFLECTIONMAP_EXPLICIT: boolean;
  27360. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27361. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27362. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27363. INVERTCUBICMAP: boolean;
  27364. USESPHERICALFROMREFLECTIONMAP: boolean;
  27365. USEIRRADIANCEMAP: boolean;
  27366. SPHERICAL_HARMONICS: boolean;
  27367. USESPHERICALINVERTEX: boolean;
  27368. REFLECTIONMAP_OPPOSITEZ: boolean;
  27369. LODINREFLECTIONALPHA: boolean;
  27370. GAMMAREFLECTION: boolean;
  27371. RGBDREFLECTION: boolean;
  27372. LINEARSPECULARREFLECTION: boolean;
  27373. RADIANCEOCCLUSION: boolean;
  27374. HORIZONOCCLUSION: boolean;
  27375. INSTANCES: boolean;
  27376. THIN_INSTANCES: boolean;
  27377. PREPASS: boolean;
  27378. PREPASS_IRRADIANCE: boolean;
  27379. PREPASS_IRRADIANCE_INDEX: number;
  27380. PREPASS_ALBEDO: boolean;
  27381. PREPASS_ALBEDO_INDEX: number;
  27382. PREPASS_DEPTHNORMAL: boolean;
  27383. PREPASS_DEPTHNORMAL_INDEX: number;
  27384. PREPASS_POSITION: boolean;
  27385. PREPASS_POSITION_INDEX: number;
  27386. PREPASS_VELOCITY: boolean;
  27387. PREPASS_VELOCITY_INDEX: number;
  27388. PREPASS_REFLECTIVITY: boolean;
  27389. PREPASS_REFLECTIVITY_INDEX: number;
  27390. SCENE_MRT_COUNT: number;
  27391. NUM_BONE_INFLUENCERS: number;
  27392. BonesPerMesh: number;
  27393. BONETEXTURE: boolean;
  27394. BONES_VELOCITY_ENABLED: boolean;
  27395. NONUNIFORMSCALING: boolean;
  27396. MORPHTARGETS: boolean;
  27397. MORPHTARGETS_NORMAL: boolean;
  27398. MORPHTARGETS_TANGENT: boolean;
  27399. MORPHTARGETS_UV: boolean;
  27400. NUM_MORPH_INFLUENCERS: number;
  27401. IMAGEPROCESSING: boolean;
  27402. VIGNETTE: boolean;
  27403. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27404. VIGNETTEBLENDMODEOPAQUE: boolean;
  27405. TONEMAPPING: boolean;
  27406. TONEMAPPING_ACES: boolean;
  27407. CONTRAST: boolean;
  27408. COLORCURVES: boolean;
  27409. COLORGRADING: boolean;
  27410. COLORGRADING3D: boolean;
  27411. SAMPLER3DGREENDEPTH: boolean;
  27412. SAMPLER3DBGRMAP: boolean;
  27413. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27414. EXPOSURE: boolean;
  27415. MULTIVIEW: boolean;
  27416. USEPHYSICALLIGHTFALLOFF: boolean;
  27417. USEGLTFLIGHTFALLOFF: boolean;
  27418. TWOSIDEDLIGHTING: boolean;
  27419. SHADOWFLOAT: boolean;
  27420. CLIPPLANE: boolean;
  27421. CLIPPLANE2: boolean;
  27422. CLIPPLANE3: boolean;
  27423. CLIPPLANE4: boolean;
  27424. CLIPPLANE5: boolean;
  27425. CLIPPLANE6: boolean;
  27426. POINTSIZE: boolean;
  27427. FOG: boolean;
  27428. LOGARITHMICDEPTH: boolean;
  27429. FORCENORMALFORWARD: boolean;
  27430. SPECULARAA: boolean;
  27431. CLEARCOAT: boolean;
  27432. CLEARCOAT_DEFAULTIOR: boolean;
  27433. CLEARCOAT_TEXTURE: boolean;
  27434. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  27435. CLEARCOAT_TEXTUREDIRECTUV: number;
  27436. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  27437. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27438. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27439. CLEARCOAT_BUMP: boolean;
  27440. CLEARCOAT_BUMPDIRECTUV: number;
  27441. CLEARCOAT_REMAP_F0: boolean;
  27442. CLEARCOAT_TINT: boolean;
  27443. CLEARCOAT_TINT_TEXTURE: boolean;
  27444. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  27445. ANISOTROPIC: boolean;
  27446. ANISOTROPIC_TEXTURE: boolean;
  27447. ANISOTROPIC_TEXTUREDIRECTUV: number;
  27448. BRDF_V_HEIGHT_CORRELATED: boolean;
  27449. MS_BRDF_ENERGY_CONSERVATION: boolean;
  27450. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  27451. SHEEN: boolean;
  27452. SHEEN_TEXTURE: boolean;
  27453. SHEEN_TEXTURE_ROUGHNESS: boolean;
  27454. SHEEN_TEXTUREDIRECTUV: number;
  27455. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  27456. SHEEN_LINKWITHALBEDO: boolean;
  27457. SHEEN_ROUGHNESS: boolean;
  27458. SHEEN_ALBEDOSCALING: boolean;
  27459. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27460. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27461. SUBSURFACE: boolean;
  27462. SS_REFRACTION: boolean;
  27463. SS_TRANSLUCENCY: boolean;
  27464. SS_SCATTERING: boolean;
  27465. SS_THICKNESSANDMASK_TEXTURE: boolean;
  27466. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  27467. SS_REFRACTIONMAP_3D: boolean;
  27468. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  27469. SS_LODINREFRACTIONALPHA: boolean;
  27470. SS_GAMMAREFRACTION: boolean;
  27471. SS_RGBDREFRACTION: boolean;
  27472. SS_LINEARSPECULARREFRACTION: boolean;
  27473. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  27474. SS_ALBEDOFORREFRACTIONTINT: boolean;
  27475. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  27476. UNLIT: boolean;
  27477. DEBUGMODE: number;
  27478. /**
  27479. * Initializes the PBR Material defines.
  27480. */
  27481. constructor();
  27482. /**
  27483. * Resets the PBR Material defines.
  27484. */
  27485. reset(): void;
  27486. }
  27487. /**
  27488. * The Physically based material base class of BJS.
  27489. *
  27490. * This offers the main features of a standard PBR material.
  27491. * For more information, please refer to the documentation :
  27492. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27493. */
  27494. export abstract class PBRBaseMaterial extends PushMaterial {
  27495. /**
  27496. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27497. */
  27498. static readonly PBRMATERIAL_OPAQUE: number;
  27499. /**
  27500. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27501. */
  27502. static readonly PBRMATERIAL_ALPHATEST: number;
  27503. /**
  27504. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27505. */
  27506. static readonly PBRMATERIAL_ALPHABLEND: number;
  27507. /**
  27508. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27509. * They are also discarded below the alpha cutoff threshold to improve performances.
  27510. */
  27511. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27512. /**
  27513. * Defines the default value of how much AO map is occluding the analytical lights
  27514. * (point spot...).
  27515. */
  27516. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27517. /**
  27518. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  27519. */
  27520. static readonly LIGHTFALLOFF_PHYSICAL: number;
  27521. /**
  27522. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  27523. * to enhance interoperability with other engines.
  27524. */
  27525. static readonly LIGHTFALLOFF_GLTF: number;
  27526. /**
  27527. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  27528. * to enhance interoperability with other materials.
  27529. */
  27530. static readonly LIGHTFALLOFF_STANDARD: number;
  27531. /**
  27532. * Intensity of the direct lights e.g. the four lights available in your scene.
  27533. * This impacts both the direct diffuse and specular highlights.
  27534. */
  27535. protected _directIntensity: number;
  27536. /**
  27537. * Intensity of the emissive part of the material.
  27538. * This helps controlling the emissive effect without modifying the emissive color.
  27539. */
  27540. protected _emissiveIntensity: number;
  27541. /**
  27542. * Intensity of the environment e.g. how much the environment will light the object
  27543. * either through harmonics for rough material or through the refelction for shiny ones.
  27544. */
  27545. protected _environmentIntensity: number;
  27546. /**
  27547. * This is a special control allowing the reduction of the specular highlights coming from the
  27548. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27549. */
  27550. protected _specularIntensity: number;
  27551. /**
  27552. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27553. */
  27554. private _lightingInfos;
  27555. /**
  27556. * Debug Control allowing disabling the bump map on this material.
  27557. */
  27558. protected _disableBumpMap: boolean;
  27559. /**
  27560. * AKA Diffuse Texture in standard nomenclature.
  27561. */
  27562. protected _albedoTexture: Nullable<BaseTexture>;
  27563. /**
  27564. * AKA Occlusion Texture in other nomenclature.
  27565. */
  27566. protected _ambientTexture: Nullable<BaseTexture>;
  27567. /**
  27568. * AKA Occlusion Texture Intensity in other nomenclature.
  27569. */
  27570. protected _ambientTextureStrength: number;
  27571. /**
  27572. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27573. * 1 means it completely occludes it
  27574. * 0 mean it has no impact
  27575. */
  27576. protected _ambientTextureImpactOnAnalyticalLights: number;
  27577. /**
  27578. * Stores the alpha values in a texture.
  27579. */
  27580. protected _opacityTexture: Nullable<BaseTexture>;
  27581. /**
  27582. * Stores the reflection values in a texture.
  27583. */
  27584. protected _reflectionTexture: Nullable<BaseTexture>;
  27585. /**
  27586. * Stores the emissive values in a texture.
  27587. */
  27588. protected _emissiveTexture: Nullable<BaseTexture>;
  27589. /**
  27590. * AKA Specular texture in other nomenclature.
  27591. */
  27592. protected _reflectivityTexture: Nullable<BaseTexture>;
  27593. /**
  27594. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27595. */
  27596. protected _metallicTexture: Nullable<BaseTexture>;
  27597. /**
  27598. * Specifies the metallic scalar of the metallic/roughness workflow.
  27599. * Can also be used to scale the metalness values of the metallic texture.
  27600. */
  27601. protected _metallic: Nullable<number>;
  27602. /**
  27603. * Specifies the roughness scalar of the metallic/roughness workflow.
  27604. * Can also be used to scale the roughness values of the metallic texture.
  27605. */
  27606. protected _roughness: Nullable<number>;
  27607. /**
  27608. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27609. * By default the indexOfrefraction is used to compute F0;
  27610. *
  27611. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27612. *
  27613. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27614. * F90 = metallicReflectanceColor;
  27615. */
  27616. protected _metallicF0Factor: number;
  27617. /**
  27618. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27619. * By default the F90 is always 1;
  27620. *
  27621. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27622. *
  27623. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27624. * F90 = metallicReflectanceColor;
  27625. */
  27626. protected _metallicReflectanceColor: Color3;
  27627. /**
  27628. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27629. * This is multiply against the scalar values defined in the material.
  27630. */
  27631. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  27632. /**
  27633. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27634. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27635. */
  27636. protected _microSurfaceTexture: Nullable<BaseTexture>;
  27637. /**
  27638. * Stores surface normal data used to displace a mesh in a texture.
  27639. */
  27640. protected _bumpTexture: Nullable<BaseTexture>;
  27641. /**
  27642. * Stores the pre-calculated light information of a mesh in a texture.
  27643. */
  27644. protected _lightmapTexture: Nullable<BaseTexture>;
  27645. /**
  27646. * The color of a material in ambient lighting.
  27647. */
  27648. protected _ambientColor: Color3;
  27649. /**
  27650. * AKA Diffuse Color in other nomenclature.
  27651. */
  27652. protected _albedoColor: Color3;
  27653. /**
  27654. * AKA Specular Color in other nomenclature.
  27655. */
  27656. protected _reflectivityColor: Color3;
  27657. /**
  27658. * The color applied when light is reflected from a material.
  27659. */
  27660. protected _reflectionColor: Color3;
  27661. /**
  27662. * The color applied when light is emitted from a material.
  27663. */
  27664. protected _emissiveColor: Color3;
  27665. /**
  27666. * AKA Glossiness in other nomenclature.
  27667. */
  27668. protected _microSurface: number;
  27669. /**
  27670. * Specifies that the material will use the light map as a show map.
  27671. */
  27672. protected _useLightmapAsShadowmap: boolean;
  27673. /**
  27674. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27675. * makes the reflect vector face the model (under horizon).
  27676. */
  27677. protected _useHorizonOcclusion: boolean;
  27678. /**
  27679. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27680. * too much the area relying on ambient texture to define their ambient occlusion.
  27681. */
  27682. protected _useRadianceOcclusion: boolean;
  27683. /**
  27684. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27685. */
  27686. protected _useAlphaFromAlbedoTexture: boolean;
  27687. /**
  27688. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27689. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27690. */
  27691. protected _useSpecularOverAlpha: boolean;
  27692. /**
  27693. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27694. */
  27695. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27696. /**
  27697. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27698. */
  27699. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27700. /**
  27701. * Specifies if the metallic texture contains the roughness information in its green channel.
  27702. */
  27703. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27704. /**
  27705. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27706. */
  27707. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27708. /**
  27709. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27710. */
  27711. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27712. /**
  27713. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27714. */
  27715. protected _useAmbientInGrayScale: boolean;
  27716. /**
  27717. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27718. * The material will try to infer what glossiness each pixel should be.
  27719. */
  27720. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27721. /**
  27722. * Defines the falloff type used in this material.
  27723. * It by default is Physical.
  27724. */
  27725. protected _lightFalloff: number;
  27726. /**
  27727. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27728. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27729. */
  27730. protected _useRadianceOverAlpha: boolean;
  27731. /**
  27732. * Allows using an object space normal map (instead of tangent space).
  27733. */
  27734. protected _useObjectSpaceNormalMap: boolean;
  27735. /**
  27736. * Allows using the bump map in parallax mode.
  27737. */
  27738. protected _useParallax: boolean;
  27739. /**
  27740. * Allows using the bump map in parallax occlusion mode.
  27741. */
  27742. protected _useParallaxOcclusion: boolean;
  27743. /**
  27744. * Controls the scale bias of the parallax mode.
  27745. */
  27746. protected _parallaxScaleBias: number;
  27747. /**
  27748. * If sets to true, disables all the lights affecting the material.
  27749. */
  27750. protected _disableLighting: boolean;
  27751. /**
  27752. * Number of Simultaneous lights allowed on the material.
  27753. */
  27754. protected _maxSimultaneousLights: number;
  27755. /**
  27756. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27757. */
  27758. protected _invertNormalMapX: boolean;
  27759. /**
  27760. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27761. */
  27762. protected _invertNormalMapY: boolean;
  27763. /**
  27764. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27765. */
  27766. protected _twoSidedLighting: boolean;
  27767. /**
  27768. * Defines the alpha limits in alpha test mode.
  27769. */
  27770. protected _alphaCutOff: number;
  27771. /**
  27772. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27773. */
  27774. protected _forceAlphaTest: boolean;
  27775. /**
  27776. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27777. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27778. */
  27779. protected _useAlphaFresnel: boolean;
  27780. /**
  27781. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27782. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27783. */
  27784. protected _useLinearAlphaFresnel: boolean;
  27785. /**
  27786. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27787. * from cos thetav and roughness:
  27788. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27789. */
  27790. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27791. /**
  27792. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27793. */
  27794. protected _forceIrradianceInFragment: boolean;
  27795. private _realTimeFiltering;
  27796. /**
  27797. * Enables realtime filtering on the texture.
  27798. */
  27799. get realTimeFiltering(): boolean;
  27800. set realTimeFiltering(b: boolean);
  27801. private _realTimeFilteringQuality;
  27802. /**
  27803. * Quality switch for realtime filtering
  27804. */
  27805. get realTimeFilteringQuality(): number;
  27806. set realTimeFilteringQuality(n: number);
  27807. /**
  27808. * Can this material render to several textures at once
  27809. */
  27810. get canRenderToMRT(): boolean;
  27811. /**
  27812. * Force normal to face away from face.
  27813. */
  27814. protected _forceNormalForward: boolean;
  27815. /**
  27816. * Enables specular anti aliasing in the PBR shader.
  27817. * It will both interacts on the Geometry for analytical and IBL lighting.
  27818. * It also prefilter the roughness map based on the bump values.
  27819. */
  27820. protected _enableSpecularAntiAliasing: boolean;
  27821. /**
  27822. * Default configuration related to image processing available in the PBR Material.
  27823. */
  27824. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27825. /**
  27826. * Keep track of the image processing observer to allow dispose and replace.
  27827. */
  27828. private _imageProcessingObserver;
  27829. /**
  27830. * Attaches a new image processing configuration to the PBR Material.
  27831. * @param configuration
  27832. */
  27833. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27834. /**
  27835. * Stores the available render targets.
  27836. */
  27837. private _renderTargets;
  27838. /**
  27839. * Sets the global ambient color for the material used in lighting calculations.
  27840. */
  27841. private _globalAmbientColor;
  27842. /**
  27843. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27844. */
  27845. private _useLogarithmicDepth;
  27846. /**
  27847. * If set to true, no lighting calculations will be applied.
  27848. */
  27849. private _unlit;
  27850. private _debugMode;
  27851. /**
  27852. * @hidden
  27853. * This is reserved for the inspector.
  27854. * Defines the material debug mode.
  27855. * It helps seeing only some components of the material while troubleshooting.
  27856. */
  27857. debugMode: number;
  27858. /**
  27859. * @hidden
  27860. * This is reserved for the inspector.
  27861. * Specify from where on screen the debug mode should start.
  27862. * The value goes from -1 (full screen) to 1 (not visible)
  27863. * It helps with side by side comparison against the final render
  27864. * This defaults to -1
  27865. */
  27866. private debugLimit;
  27867. /**
  27868. * @hidden
  27869. * This is reserved for the inspector.
  27870. * As the default viewing range might not be enough (if the ambient is really small for instance)
  27871. * You can use the factor to better multiply the final value.
  27872. */
  27873. private debugFactor;
  27874. /**
  27875. * Defines the clear coat layer parameters for the material.
  27876. */
  27877. readonly clearCoat: PBRClearCoatConfiguration;
  27878. /**
  27879. * Defines the anisotropic parameters for the material.
  27880. */
  27881. readonly anisotropy: PBRAnisotropicConfiguration;
  27882. /**
  27883. * Defines the BRDF parameters for the material.
  27884. */
  27885. readonly brdf: PBRBRDFConfiguration;
  27886. /**
  27887. * Defines the Sheen parameters for the material.
  27888. */
  27889. readonly sheen: PBRSheenConfiguration;
  27890. /**
  27891. * Defines the SubSurface parameters for the material.
  27892. */
  27893. readonly subSurface: PBRSubSurfaceConfiguration;
  27894. /**
  27895. * Defines additionnal PrePass parameters for the material.
  27896. */
  27897. readonly prePassConfiguration: PrePassConfiguration;
  27898. /**
  27899. * Defines the detail map parameters for the material.
  27900. */
  27901. readonly detailMap: DetailMapConfiguration;
  27902. protected _rebuildInParallel: boolean;
  27903. /**
  27904. * Instantiates a new PBRMaterial instance.
  27905. *
  27906. * @param name The material name
  27907. * @param scene The scene the material will be use in.
  27908. */
  27909. constructor(name: string, scene: Scene);
  27910. /**
  27911. * Gets a boolean indicating that current material needs to register RTT
  27912. */
  27913. get hasRenderTargetTextures(): boolean;
  27914. /**
  27915. * Gets the name of the material class.
  27916. */
  27917. getClassName(): string;
  27918. /**
  27919. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27920. */
  27921. get useLogarithmicDepth(): boolean;
  27922. /**
  27923. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27924. */
  27925. set useLogarithmicDepth(value: boolean);
  27926. /**
  27927. * Returns true if alpha blending should be disabled.
  27928. */
  27929. protected get _disableAlphaBlending(): boolean;
  27930. /**
  27931. * Specifies whether or not this material should be rendered in alpha blend mode.
  27932. */
  27933. needAlphaBlending(): boolean;
  27934. /**
  27935. * Specifies whether or not this material should be rendered in alpha test mode.
  27936. */
  27937. needAlphaTesting(): boolean;
  27938. /**
  27939. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27940. */
  27941. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27942. /**
  27943. * Specifies whether or not there is a usable alpha channel for transparency.
  27944. */
  27945. protected _hasAlphaChannel(): boolean;
  27946. /**
  27947. * Gets the texture used for the alpha test.
  27948. */
  27949. getAlphaTestTexture(): Nullable<BaseTexture>;
  27950. /**
  27951. * Specifies that the submesh is ready to be used.
  27952. * @param mesh - BJS mesh.
  27953. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27954. * @param useInstances - Specifies that instances should be used.
  27955. * @returns - boolean indicating that the submesh is ready or not.
  27956. */
  27957. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27958. /**
  27959. * Specifies if the material uses metallic roughness workflow.
  27960. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27961. */
  27962. isMetallicWorkflow(): boolean;
  27963. private _prepareEffect;
  27964. private _prepareDefines;
  27965. /**
  27966. * Force shader compilation
  27967. */
  27968. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  27969. /**
  27970. * Initializes the uniform buffer layout for the shader.
  27971. */
  27972. buildUniformLayout(): void;
  27973. /**
  27974. * Unbinds the material from the mesh
  27975. */
  27976. unbind(): void;
  27977. /**
  27978. * Binds the submesh data.
  27979. * @param world - The world matrix.
  27980. * @param mesh - The BJS mesh.
  27981. * @param subMesh - A submesh of the BJS mesh.
  27982. */
  27983. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27984. /**
  27985. * Returns the animatable textures.
  27986. * @returns - Array of animatable textures.
  27987. */
  27988. getAnimatables(): IAnimatable[];
  27989. /**
  27990. * Returns the texture used for reflections.
  27991. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27992. */
  27993. private _getReflectionTexture;
  27994. /**
  27995. * Returns an array of the actively used textures.
  27996. * @returns - Array of BaseTextures
  27997. */
  27998. getActiveTextures(): BaseTexture[];
  27999. /**
  28000. * Checks to see if a texture is used in the material.
  28001. * @param texture - Base texture to use.
  28002. * @returns - Boolean specifying if a texture is used in the material.
  28003. */
  28004. hasTexture(texture: BaseTexture): boolean;
  28005. /**
  28006. * Sets the required values to the prepass renderer.
  28007. * @param prePassRenderer defines the prepass renderer to setup
  28008. */
  28009. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28010. /**
  28011. * Disposes the resources of the material.
  28012. * @param forceDisposeEffect - Forces the disposal of effects.
  28013. * @param forceDisposeTextures - Forces the disposal of all textures.
  28014. */
  28015. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  28016. }
  28017. }
  28018. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  28019. import { Nullable } from "babylonjs/types";
  28020. import { Scene } from "babylonjs/scene";
  28021. import { Color3 } from "babylonjs/Maths/math.color";
  28022. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  28023. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  28024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28025. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  28026. /**
  28027. * The Physically based material of BJS.
  28028. *
  28029. * This offers the main features of a standard PBR material.
  28030. * For more information, please refer to the documentation :
  28031. * https://doc.babylonjs.com/how_to/physically_based_rendering
  28032. */
  28033. export class PBRMaterial extends PBRBaseMaterial {
  28034. /**
  28035. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  28036. */
  28037. static readonly PBRMATERIAL_OPAQUE: number;
  28038. /**
  28039. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  28040. */
  28041. static readonly PBRMATERIAL_ALPHATEST: number;
  28042. /**
  28043. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28044. */
  28045. static readonly PBRMATERIAL_ALPHABLEND: number;
  28046. /**
  28047. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28048. * They are also discarded below the alpha cutoff threshold to improve performances.
  28049. */
  28050. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  28051. /**
  28052. * Defines the default value of how much AO map is occluding the analytical lights
  28053. * (point spot...).
  28054. */
  28055. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  28056. /**
  28057. * Intensity of the direct lights e.g. the four lights available in your scene.
  28058. * This impacts both the direct diffuse and specular highlights.
  28059. */
  28060. directIntensity: number;
  28061. /**
  28062. * Intensity of the emissive part of the material.
  28063. * This helps controlling the emissive effect without modifying the emissive color.
  28064. */
  28065. emissiveIntensity: number;
  28066. /**
  28067. * Intensity of the environment e.g. how much the environment will light the object
  28068. * either through harmonics for rough material or through the refelction for shiny ones.
  28069. */
  28070. environmentIntensity: number;
  28071. /**
  28072. * This is a special control allowing the reduction of the specular highlights coming from the
  28073. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  28074. */
  28075. specularIntensity: number;
  28076. /**
  28077. * Debug Control allowing disabling the bump map on this material.
  28078. */
  28079. disableBumpMap: boolean;
  28080. /**
  28081. * AKA Diffuse Texture in standard nomenclature.
  28082. */
  28083. albedoTexture: BaseTexture;
  28084. /**
  28085. * AKA Occlusion Texture in other nomenclature.
  28086. */
  28087. ambientTexture: BaseTexture;
  28088. /**
  28089. * AKA Occlusion Texture Intensity in other nomenclature.
  28090. */
  28091. ambientTextureStrength: number;
  28092. /**
  28093. * Defines how much the AO map is occluding the analytical lights (point spot...).
  28094. * 1 means it completely occludes it
  28095. * 0 mean it has no impact
  28096. */
  28097. ambientTextureImpactOnAnalyticalLights: number;
  28098. /**
  28099. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  28100. */
  28101. opacityTexture: BaseTexture;
  28102. /**
  28103. * Stores the reflection values in a texture.
  28104. */
  28105. reflectionTexture: Nullable<BaseTexture>;
  28106. /**
  28107. * Stores the emissive values in a texture.
  28108. */
  28109. emissiveTexture: BaseTexture;
  28110. /**
  28111. * AKA Specular texture in other nomenclature.
  28112. */
  28113. reflectivityTexture: BaseTexture;
  28114. /**
  28115. * Used to switch from specular/glossiness to metallic/roughness workflow.
  28116. */
  28117. metallicTexture: BaseTexture;
  28118. /**
  28119. * Specifies the metallic scalar of the metallic/roughness workflow.
  28120. * Can also be used to scale the metalness values of the metallic texture.
  28121. */
  28122. metallic: Nullable<number>;
  28123. /**
  28124. * Specifies the roughness scalar of the metallic/roughness workflow.
  28125. * Can also be used to scale the roughness values of the metallic texture.
  28126. */
  28127. roughness: Nullable<number>;
  28128. /**
  28129. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  28130. * By default the indexOfrefraction is used to compute F0;
  28131. *
  28132. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  28133. *
  28134. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  28135. * F90 = metallicReflectanceColor;
  28136. */
  28137. metallicF0Factor: number;
  28138. /**
  28139. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  28140. * By default the F90 is always 1;
  28141. *
  28142. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  28143. *
  28144. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  28145. * F90 = metallicReflectanceColor;
  28146. */
  28147. metallicReflectanceColor: Color3;
  28148. /**
  28149. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  28150. * This is multiply against the scalar values defined in the material.
  28151. */
  28152. metallicReflectanceTexture: Nullable<BaseTexture>;
  28153. /**
  28154. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  28155. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  28156. */
  28157. microSurfaceTexture: BaseTexture;
  28158. /**
  28159. * Stores surface normal data used to displace a mesh in a texture.
  28160. */
  28161. bumpTexture: BaseTexture;
  28162. /**
  28163. * Stores the pre-calculated light information of a mesh in a texture.
  28164. */
  28165. lightmapTexture: BaseTexture;
  28166. /**
  28167. * Stores the refracted light information in a texture.
  28168. */
  28169. get refractionTexture(): Nullable<BaseTexture>;
  28170. set refractionTexture(value: Nullable<BaseTexture>);
  28171. /**
  28172. * The color of a material in ambient lighting.
  28173. */
  28174. ambientColor: Color3;
  28175. /**
  28176. * AKA Diffuse Color in other nomenclature.
  28177. */
  28178. albedoColor: Color3;
  28179. /**
  28180. * AKA Specular Color in other nomenclature.
  28181. */
  28182. reflectivityColor: Color3;
  28183. /**
  28184. * The color reflected from the material.
  28185. */
  28186. reflectionColor: Color3;
  28187. /**
  28188. * The color emitted from the material.
  28189. */
  28190. emissiveColor: Color3;
  28191. /**
  28192. * AKA Glossiness in other nomenclature.
  28193. */
  28194. microSurface: number;
  28195. /**
  28196. * Index of refraction of the material base layer.
  28197. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  28198. *
  28199. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  28200. *
  28201. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  28202. */
  28203. get indexOfRefraction(): number;
  28204. set indexOfRefraction(value: number);
  28205. /**
  28206. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  28207. */
  28208. get invertRefractionY(): boolean;
  28209. set invertRefractionY(value: boolean);
  28210. /**
  28211. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  28212. * Materials half opaque for instance using refraction could benefit from this control.
  28213. */
  28214. get linkRefractionWithTransparency(): boolean;
  28215. set linkRefractionWithTransparency(value: boolean);
  28216. /**
  28217. * If true, the light map contains occlusion information instead of lighting info.
  28218. */
  28219. useLightmapAsShadowmap: boolean;
  28220. /**
  28221. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  28222. */
  28223. useAlphaFromAlbedoTexture: boolean;
  28224. /**
  28225. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  28226. */
  28227. forceAlphaTest: boolean;
  28228. /**
  28229. * Defines the alpha limits in alpha test mode.
  28230. */
  28231. alphaCutOff: number;
  28232. /**
  28233. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  28234. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  28235. */
  28236. useSpecularOverAlpha: boolean;
  28237. /**
  28238. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  28239. */
  28240. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  28241. /**
  28242. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  28243. */
  28244. useRoughnessFromMetallicTextureAlpha: boolean;
  28245. /**
  28246. * Specifies if the metallic texture contains the roughness information in its green channel.
  28247. */
  28248. useRoughnessFromMetallicTextureGreen: boolean;
  28249. /**
  28250. * Specifies if the metallic texture contains the metallness information in its blue channel.
  28251. */
  28252. useMetallnessFromMetallicTextureBlue: boolean;
  28253. /**
  28254. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  28255. */
  28256. useAmbientOcclusionFromMetallicTextureRed: boolean;
  28257. /**
  28258. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  28259. */
  28260. useAmbientInGrayScale: boolean;
  28261. /**
  28262. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  28263. * The material will try to infer what glossiness each pixel should be.
  28264. */
  28265. useAutoMicroSurfaceFromReflectivityMap: boolean;
  28266. /**
  28267. * BJS is using an harcoded light falloff based on a manually sets up range.
  28268. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  28269. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  28270. */
  28271. get usePhysicalLightFalloff(): boolean;
  28272. /**
  28273. * BJS is using an harcoded light falloff based on a manually sets up range.
  28274. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  28275. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  28276. */
  28277. set usePhysicalLightFalloff(value: boolean);
  28278. /**
  28279. * In order to support the falloff compatibility with gltf, a special mode has been added
  28280. * to reproduce the gltf light falloff.
  28281. */
  28282. get useGLTFLightFalloff(): boolean;
  28283. /**
  28284. * In order to support the falloff compatibility with gltf, a special mode has been added
  28285. * to reproduce the gltf light falloff.
  28286. */
  28287. set useGLTFLightFalloff(value: boolean);
  28288. /**
  28289. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  28290. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  28291. */
  28292. useRadianceOverAlpha: boolean;
  28293. /**
  28294. * Allows using an object space normal map (instead of tangent space).
  28295. */
  28296. useObjectSpaceNormalMap: boolean;
  28297. /**
  28298. * Allows using the bump map in parallax mode.
  28299. */
  28300. useParallax: boolean;
  28301. /**
  28302. * Allows using the bump map in parallax occlusion mode.
  28303. */
  28304. useParallaxOcclusion: boolean;
  28305. /**
  28306. * Controls the scale bias of the parallax mode.
  28307. */
  28308. parallaxScaleBias: number;
  28309. /**
  28310. * If sets to true, disables all the lights affecting the material.
  28311. */
  28312. disableLighting: boolean;
  28313. /**
  28314. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  28315. */
  28316. forceIrradianceInFragment: boolean;
  28317. /**
  28318. * Number of Simultaneous lights allowed on the material.
  28319. */
  28320. maxSimultaneousLights: number;
  28321. /**
  28322. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  28323. */
  28324. invertNormalMapX: boolean;
  28325. /**
  28326. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  28327. */
  28328. invertNormalMapY: boolean;
  28329. /**
  28330. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28331. */
  28332. twoSidedLighting: boolean;
  28333. /**
  28334. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28335. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  28336. */
  28337. useAlphaFresnel: boolean;
  28338. /**
  28339. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28340. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  28341. */
  28342. useLinearAlphaFresnel: boolean;
  28343. /**
  28344. * Let user defines the brdf lookup texture used for IBL.
  28345. * A default 8bit version is embedded but you could point at :
  28346. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  28347. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  28348. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  28349. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  28350. */
  28351. environmentBRDFTexture: Nullable<BaseTexture>;
  28352. /**
  28353. * Force normal to face away from face.
  28354. */
  28355. forceNormalForward: boolean;
  28356. /**
  28357. * Enables specular anti aliasing in the PBR shader.
  28358. * It will both interacts on the Geometry for analytical and IBL lighting.
  28359. * It also prefilter the roughness map based on the bump values.
  28360. */
  28361. enableSpecularAntiAliasing: boolean;
  28362. /**
  28363. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28364. * makes the reflect vector face the model (under horizon).
  28365. */
  28366. useHorizonOcclusion: boolean;
  28367. /**
  28368. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28369. * too much the area relying on ambient texture to define their ambient occlusion.
  28370. */
  28371. useRadianceOcclusion: boolean;
  28372. /**
  28373. * If set to true, no lighting calculations will be applied.
  28374. */
  28375. unlit: boolean;
  28376. /**
  28377. * Gets the image processing configuration used either in this material.
  28378. */
  28379. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28380. /**
  28381. * Sets the Default image processing configuration used either in the this material.
  28382. *
  28383. * If sets to null, the scene one is in use.
  28384. */
  28385. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28386. /**
  28387. * Gets wether the color curves effect is enabled.
  28388. */
  28389. get cameraColorCurvesEnabled(): boolean;
  28390. /**
  28391. * Sets wether the color curves effect is enabled.
  28392. */
  28393. set cameraColorCurvesEnabled(value: boolean);
  28394. /**
  28395. * Gets wether the color grading effect is enabled.
  28396. */
  28397. get cameraColorGradingEnabled(): boolean;
  28398. /**
  28399. * Gets wether the color grading effect is enabled.
  28400. */
  28401. set cameraColorGradingEnabled(value: boolean);
  28402. /**
  28403. * Gets wether tonemapping is enabled or not.
  28404. */
  28405. get cameraToneMappingEnabled(): boolean;
  28406. /**
  28407. * Sets wether tonemapping is enabled or not
  28408. */
  28409. set cameraToneMappingEnabled(value: boolean);
  28410. /**
  28411. * The camera exposure used on this material.
  28412. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28413. * This corresponds to a photographic exposure.
  28414. */
  28415. get cameraExposure(): number;
  28416. /**
  28417. * The camera exposure used on this material.
  28418. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28419. * This corresponds to a photographic exposure.
  28420. */
  28421. set cameraExposure(value: number);
  28422. /**
  28423. * Gets The camera contrast used on this material.
  28424. */
  28425. get cameraContrast(): number;
  28426. /**
  28427. * Sets The camera contrast used on this material.
  28428. */
  28429. set cameraContrast(value: number);
  28430. /**
  28431. * Gets the Color Grading 2D Lookup Texture.
  28432. */
  28433. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28434. /**
  28435. * Sets the Color Grading 2D Lookup Texture.
  28436. */
  28437. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28438. /**
  28439. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28440. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28441. * 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;
  28442. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28443. */
  28444. get cameraColorCurves(): Nullable<ColorCurves>;
  28445. /**
  28446. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28447. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28448. * 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;
  28449. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28450. */
  28451. set cameraColorCurves(value: Nullable<ColorCurves>);
  28452. /**
  28453. * Instantiates a new PBRMaterial instance.
  28454. *
  28455. * @param name The material name
  28456. * @param scene The scene the material will be use in.
  28457. */
  28458. constructor(name: string, scene: Scene);
  28459. /**
  28460. * Returns the name of this material class.
  28461. */
  28462. getClassName(): string;
  28463. /**
  28464. * Makes a duplicate of the current material.
  28465. * @param name - name to use for the new material.
  28466. */
  28467. clone(name: string): PBRMaterial;
  28468. /**
  28469. * Serializes this PBR Material.
  28470. * @returns - An object with the serialized material.
  28471. */
  28472. serialize(): any;
  28473. /**
  28474. * Parses a PBR Material from a serialized object.
  28475. * @param source - Serialized object.
  28476. * @param scene - BJS scene instance.
  28477. * @param rootUrl - url for the scene object
  28478. * @returns - PBRMaterial
  28479. */
  28480. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28481. }
  28482. }
  28483. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  28484. /** @hidden */
  28485. export var mrtFragmentDeclaration: {
  28486. name: string;
  28487. shader: string;
  28488. };
  28489. }
  28490. declare module "babylonjs/Shaders/geometry.fragment" {
  28491. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  28492. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  28493. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  28494. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  28495. /** @hidden */
  28496. export var geometryPixelShader: {
  28497. name: string;
  28498. shader: string;
  28499. };
  28500. }
  28501. declare module "babylonjs/Shaders/geometry.vertex" {
  28502. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28503. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28504. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28505. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28506. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28507. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28508. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28509. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  28510. /** @hidden */
  28511. export var geometryVertexShader: {
  28512. name: string;
  28513. shader: string;
  28514. };
  28515. }
  28516. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  28517. import { Matrix } from "babylonjs/Maths/math.vector";
  28518. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28520. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28521. import { Effect } from "babylonjs/Materials/effect";
  28522. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28523. import { Scene } from "babylonjs/scene";
  28524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28525. import { Nullable } from "babylonjs/types";
  28526. import "babylonjs/Shaders/geometry.fragment";
  28527. import "babylonjs/Shaders/geometry.vertex";
  28528. /** @hidden */
  28529. interface ISavedTransformationMatrix {
  28530. world: Matrix;
  28531. viewProjection: Matrix;
  28532. }
  28533. /**
  28534. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28535. */
  28536. export class GeometryBufferRenderer {
  28537. /**
  28538. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  28539. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  28540. */
  28541. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  28542. /**
  28543. * Constant used to retrieve the position texture index in the G-Buffer textures array
  28544. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  28545. */
  28546. static readonly POSITION_TEXTURE_TYPE: number;
  28547. /**
  28548. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  28549. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  28550. */
  28551. static readonly VELOCITY_TEXTURE_TYPE: number;
  28552. /**
  28553. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  28554. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  28555. */
  28556. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  28557. /**
  28558. * Dictionary used to store the previous transformation matrices of each rendered mesh
  28559. * in order to compute objects velocities when enableVelocity is set to "true"
  28560. * @hidden
  28561. */
  28562. _previousTransformationMatrices: {
  28563. [index: number]: ISavedTransformationMatrix;
  28564. };
  28565. /**
  28566. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  28567. * in order to compute objects velocities when enableVelocity is set to "true"
  28568. * @hidden
  28569. */
  28570. _previousBonesTransformationMatrices: {
  28571. [index: number]: Float32Array;
  28572. };
  28573. /**
  28574. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  28575. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  28576. */
  28577. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  28578. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  28579. renderTransparentMeshes: boolean;
  28580. private _scene;
  28581. private _resizeObserver;
  28582. private _multiRenderTarget;
  28583. private _ratio;
  28584. private _enablePosition;
  28585. private _enableVelocity;
  28586. private _enableReflectivity;
  28587. private _positionIndex;
  28588. private _velocityIndex;
  28589. private _reflectivityIndex;
  28590. private _depthNormalIndex;
  28591. private _linkedWithPrePass;
  28592. private _prePassRenderer;
  28593. private _attachments;
  28594. protected _effect: Effect;
  28595. protected _cachedDefines: string;
  28596. /**
  28597. * @hidden
  28598. * Sets up internal structures to share outputs with PrePassRenderer
  28599. * This method should only be called by the PrePassRenderer itself
  28600. */
  28601. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  28602. /**
  28603. * @hidden
  28604. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  28605. * This method should only be called by the PrePassRenderer itself
  28606. */
  28607. _unlinkPrePassRenderer(): void;
  28608. /**
  28609. * @hidden
  28610. * Resets the geometry buffer layout
  28611. */
  28612. _resetLayout(): void;
  28613. /**
  28614. * @hidden
  28615. * Replaces a texture in the geometry buffer renderer
  28616. * Useful when linking textures of the prepass renderer
  28617. */
  28618. _forceTextureType(geometryBufferType: number, index: number): void;
  28619. /**
  28620. * @hidden
  28621. * Sets texture attachments
  28622. * Useful when linking textures of the prepass renderer
  28623. */
  28624. _setAttachments(attachments: number[]): void;
  28625. /**
  28626. * @hidden
  28627. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  28628. * Useful when linking textures of the prepass renderer
  28629. */
  28630. _linkInternalTexture(internalTexture: InternalTexture): void;
  28631. /**
  28632. * Gets the render list (meshes to be rendered) used in the G buffer.
  28633. */
  28634. get renderList(): Nullable<AbstractMesh[]>;
  28635. /**
  28636. * Set the render list (meshes to be rendered) used in the G buffer.
  28637. */
  28638. set renderList(meshes: Nullable<AbstractMesh[]>);
  28639. /**
  28640. * Gets wether or not G buffer are supported by the running hardware.
  28641. * This requires draw buffer supports
  28642. */
  28643. get isSupported(): boolean;
  28644. /**
  28645. * Returns the index of the given texture type in the G-Buffer textures array
  28646. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  28647. * @returns the index of the given texture type in the G-Buffer textures array
  28648. */
  28649. getTextureIndex(textureType: number): number;
  28650. /**
  28651. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  28652. */
  28653. get enablePosition(): boolean;
  28654. /**
  28655. * Sets whether or not objects positions are enabled for the G buffer.
  28656. */
  28657. set enablePosition(enable: boolean);
  28658. /**
  28659. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  28660. */
  28661. get enableVelocity(): boolean;
  28662. /**
  28663. * Sets wether or not objects velocities are enabled for the G buffer.
  28664. */
  28665. set enableVelocity(enable: boolean);
  28666. /**
  28667. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  28668. */
  28669. get enableReflectivity(): boolean;
  28670. /**
  28671. * Sets wether or not objects roughness are enabled for the G buffer.
  28672. */
  28673. set enableReflectivity(enable: boolean);
  28674. /**
  28675. * Gets the scene associated with the buffer.
  28676. */
  28677. get scene(): Scene;
  28678. /**
  28679. * Gets the ratio used by the buffer during its creation.
  28680. * How big is the buffer related to the main canvas.
  28681. */
  28682. get ratio(): number;
  28683. /** @hidden */
  28684. static _SceneComponentInitialization: (scene: Scene) => void;
  28685. /**
  28686. * Creates a new G Buffer for the scene
  28687. * @param scene The scene the buffer belongs to
  28688. * @param ratio How big is the buffer related to the main canvas.
  28689. */
  28690. constructor(scene: Scene, ratio?: number);
  28691. /**
  28692. * Checks wether everything is ready to render a submesh to the G buffer.
  28693. * @param subMesh the submesh to check readiness for
  28694. * @param useInstances is the mesh drawn using instance or not
  28695. * @returns true if ready otherwise false
  28696. */
  28697. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28698. /**
  28699. * Gets the current underlying G Buffer.
  28700. * @returns the buffer
  28701. */
  28702. getGBuffer(): MultiRenderTarget;
  28703. /**
  28704. * Gets the number of samples used to render the buffer (anti aliasing).
  28705. */
  28706. get samples(): number;
  28707. /**
  28708. * Sets the number of samples used to render the buffer (anti aliasing).
  28709. */
  28710. set samples(value: number);
  28711. /**
  28712. * Disposes the renderer and frees up associated resources.
  28713. */
  28714. dispose(): void;
  28715. private _assignRenderTargetIndices;
  28716. protected _createRenderTargets(): void;
  28717. private _copyBonesTransformationMatrices;
  28718. }
  28719. }
  28720. declare module "babylonjs/Rendering/prePassRenderer" {
  28721. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28722. import { Scene } from "babylonjs/scene";
  28723. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  28724. import { Effect } from "babylonjs/Materials/effect";
  28725. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28727. import { Material } from "babylonjs/Materials/material";
  28728. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28729. /**
  28730. * Renders a pre pass of the scene
  28731. * This means every mesh in the scene will be rendered to a render target texture
  28732. * And then this texture will be composited to the rendering canvas with post processes
  28733. * It is necessary for effects like subsurface scattering or deferred shading
  28734. */
  28735. export class PrePassRenderer {
  28736. /** @hidden */
  28737. static _SceneComponentInitialization: (scene: Scene) => void;
  28738. private _textureFormats;
  28739. /**
  28740. * To save performance, we can excluded skinned meshes from the prepass
  28741. */
  28742. excludedSkinnedMesh: AbstractMesh[];
  28743. /**
  28744. * Force material to be excluded from the prepass
  28745. * Can be useful when `useGeometryBufferFallback` is set to `true`
  28746. * and you don't want a material to show in the effect.
  28747. */
  28748. excludedMaterials: Material[];
  28749. private _textureIndices;
  28750. private _scene;
  28751. private _engine;
  28752. private _isDirty;
  28753. /**
  28754. * Number of textures in the multi render target texture where the scene is directly rendered
  28755. */
  28756. mrtCount: number;
  28757. /**
  28758. * The render target where the scene is directly rendered
  28759. */
  28760. prePassRT: MultiRenderTarget;
  28761. private _multiRenderAttachments;
  28762. private _defaultAttachments;
  28763. private _clearAttachments;
  28764. private _postProcesses;
  28765. private readonly _clearColor;
  28766. /**
  28767. * Image processing post process for composition
  28768. */
  28769. imageProcessingPostProcess: ImageProcessingPostProcess;
  28770. /**
  28771. * Configuration for prepass effects
  28772. */
  28773. private _effectConfigurations;
  28774. private _mrtFormats;
  28775. private _mrtLayout;
  28776. private _enabled;
  28777. /**
  28778. * Indicates if the prepass is enabled
  28779. */
  28780. get enabled(): boolean;
  28781. /**
  28782. * How many samples are used for MSAA of the scene render target
  28783. */
  28784. get samples(): number;
  28785. set samples(n: number);
  28786. private _geometryBuffer;
  28787. private _useGeometryBufferFallback;
  28788. /**
  28789. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  28790. */
  28791. get useGeometryBufferFallback(): boolean;
  28792. set useGeometryBufferFallback(value: boolean);
  28793. /**
  28794. * Instanciates a prepass renderer
  28795. * @param scene The scene
  28796. */
  28797. constructor(scene: Scene);
  28798. private _initializeAttachments;
  28799. private _createCompositionEffect;
  28800. /**
  28801. * Indicates if rendering a prepass is supported
  28802. */
  28803. get isSupported(): boolean;
  28804. /**
  28805. * Sets the proper output textures to draw in the engine.
  28806. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  28807. * @param subMesh Submesh on which the effect is applied
  28808. */
  28809. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  28810. /**
  28811. * @hidden
  28812. */
  28813. _beforeCameraDraw(): void;
  28814. /**
  28815. * @hidden
  28816. */
  28817. _afterCameraDraw(): void;
  28818. private _checkRTSize;
  28819. private _bindFrameBuffer;
  28820. /**
  28821. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  28822. */
  28823. clear(): void;
  28824. private _setState;
  28825. private _updateGeometryBufferLayout;
  28826. /**
  28827. * Adds an effect configuration to the prepass.
  28828. * If an effect has already been added, it won't add it twice and will return the configuration
  28829. * already present.
  28830. * @param cfg the effect configuration
  28831. * @return the effect configuration now used by the prepass
  28832. */
  28833. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  28834. /**
  28835. * Returns the index of a texture in the multi render target texture array.
  28836. * @param type Texture type
  28837. * @return The index
  28838. */
  28839. getIndex(type: number): number;
  28840. private _enable;
  28841. private _disable;
  28842. private _resetLayout;
  28843. private _resetPostProcessChain;
  28844. private _bindPostProcessChain;
  28845. /**
  28846. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  28847. */
  28848. markAsDirty(): void;
  28849. /**
  28850. * Enables a texture on the MultiRenderTarget for prepass
  28851. */
  28852. private _enableTextures;
  28853. private _update;
  28854. private _markAllMaterialsAsPrePassDirty;
  28855. /**
  28856. * Disposes the prepass renderer.
  28857. */
  28858. dispose(): void;
  28859. }
  28860. }
  28861. declare module "babylonjs/PostProcesses/postProcess" {
  28862. import { Nullable } from "babylonjs/types";
  28863. import { SmartArray } from "babylonjs/Misc/smartArray";
  28864. import { Observable } from "babylonjs/Misc/observable";
  28865. import { Vector2 } from "babylonjs/Maths/math.vector";
  28866. import { Camera } from "babylonjs/Cameras/camera";
  28867. import { Effect } from "babylonjs/Materials/effect";
  28868. import "babylonjs/Shaders/postprocess.vertex";
  28869. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28870. import { Engine } from "babylonjs/Engines/engine";
  28871. import { Color4 } from "babylonjs/Maths/math.color";
  28872. import "babylonjs/Engines/Extensions/engine.renderTarget";
  28873. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  28874. import { Scene } from "babylonjs/scene";
  28875. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28876. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28877. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28878. /**
  28879. * Size options for a post process
  28880. */
  28881. export type PostProcessOptions = {
  28882. width: number;
  28883. height: number;
  28884. };
  28885. /**
  28886. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28887. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28888. */
  28889. export class PostProcess {
  28890. /**
  28891. * Gets or sets the unique id of the post process
  28892. */
  28893. uniqueId: number;
  28894. /** Name of the PostProcess. */
  28895. name: string;
  28896. /**
  28897. * Width of the texture to apply the post process on
  28898. */
  28899. width: number;
  28900. /**
  28901. * Height of the texture to apply the post process on
  28902. */
  28903. height: number;
  28904. /**
  28905. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  28906. */
  28907. nodeMaterialSource: Nullable<NodeMaterial>;
  28908. /**
  28909. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28910. * @hidden
  28911. */
  28912. _outputTexture: Nullable<InternalTexture>;
  28913. /**
  28914. * Sampling mode used by the shader
  28915. * See https://doc.babylonjs.com/classes/3.1/texture
  28916. */
  28917. renderTargetSamplingMode: number;
  28918. /**
  28919. * Clear color to use when screen clearing
  28920. */
  28921. clearColor: Color4;
  28922. /**
  28923. * If the buffer needs to be cleared before applying the post process. (default: true)
  28924. * Should be set to false if shader will overwrite all previous pixels.
  28925. */
  28926. autoClear: boolean;
  28927. /**
  28928. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28929. */
  28930. alphaMode: number;
  28931. /**
  28932. * Sets the setAlphaBlendConstants of the babylon engine
  28933. */
  28934. alphaConstants: Color4;
  28935. /**
  28936. * Animations to be used for the post processing
  28937. */
  28938. animations: import("babylonjs/Animations/animation").Animation[];
  28939. /**
  28940. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28941. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28942. */
  28943. enablePixelPerfectMode: boolean;
  28944. /**
  28945. * Force the postprocess to be applied without taking in account viewport
  28946. */
  28947. forceFullscreenViewport: boolean;
  28948. /**
  28949. * List of inspectable custom properties (used by the Inspector)
  28950. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28951. */
  28952. inspectableCustomProperties: IInspectable[];
  28953. /**
  28954. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28955. *
  28956. * | Value | Type | Description |
  28957. * | ----- | ----------------------------------- | ----------- |
  28958. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28959. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28960. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28961. *
  28962. */
  28963. scaleMode: number;
  28964. /**
  28965. * Force textures to be a power of two (default: false)
  28966. */
  28967. alwaysForcePOT: boolean;
  28968. private _samples;
  28969. /**
  28970. * Number of sample textures (default: 1)
  28971. */
  28972. get samples(): number;
  28973. set samples(n: number);
  28974. /**
  28975. * Modify the scale of the post process to be the same as the viewport (default: false)
  28976. */
  28977. adaptScaleToCurrentViewport: boolean;
  28978. private _camera;
  28979. protected _scene: Scene;
  28980. private _engine;
  28981. private _options;
  28982. private _reusable;
  28983. private _textureType;
  28984. private _textureFormat;
  28985. /**
  28986. * Smart array of input and output textures for the post process.
  28987. * @hidden
  28988. */
  28989. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  28990. /**
  28991. * The index in _textures that corresponds to the output texture.
  28992. * @hidden
  28993. */
  28994. _currentRenderTextureInd: number;
  28995. private _effect;
  28996. private _samplers;
  28997. private _fragmentUrl;
  28998. private _vertexUrl;
  28999. private _parameters;
  29000. private _scaleRatio;
  29001. protected _indexParameters: any;
  29002. private _shareOutputWithPostProcess;
  29003. private _texelSize;
  29004. private _forcedOutputTexture;
  29005. /**
  29006. * Prepass configuration in case this post process needs a texture from prepass
  29007. * @hidden
  29008. */
  29009. _prePassEffectConfiguration: PrePassEffectConfiguration;
  29010. /**
  29011. * Returns the fragment url or shader name used in the post process.
  29012. * @returns the fragment url or name in the shader store.
  29013. */
  29014. getEffectName(): string;
  29015. /**
  29016. * An event triggered when the postprocess is activated.
  29017. */
  29018. onActivateObservable: Observable<Camera>;
  29019. private _onActivateObserver;
  29020. /**
  29021. * A function that is added to the onActivateObservable
  29022. */
  29023. set onActivate(callback: Nullable<(camera: Camera) => void>);
  29024. /**
  29025. * An event triggered when the postprocess changes its size.
  29026. */
  29027. onSizeChangedObservable: Observable<PostProcess>;
  29028. private _onSizeChangedObserver;
  29029. /**
  29030. * A function that is added to the onSizeChangedObservable
  29031. */
  29032. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  29033. /**
  29034. * An event triggered when the postprocess applies its effect.
  29035. */
  29036. onApplyObservable: Observable<Effect>;
  29037. private _onApplyObserver;
  29038. /**
  29039. * A function that is added to the onApplyObservable
  29040. */
  29041. set onApply(callback: (effect: Effect) => void);
  29042. /**
  29043. * An event triggered before rendering the postprocess
  29044. */
  29045. onBeforeRenderObservable: Observable<Effect>;
  29046. private _onBeforeRenderObserver;
  29047. /**
  29048. * A function that is added to the onBeforeRenderObservable
  29049. */
  29050. set onBeforeRender(callback: (effect: Effect) => void);
  29051. /**
  29052. * An event triggered after rendering the postprocess
  29053. */
  29054. onAfterRenderObservable: Observable<Effect>;
  29055. private _onAfterRenderObserver;
  29056. /**
  29057. * A function that is added to the onAfterRenderObservable
  29058. */
  29059. set onAfterRender(callback: (efect: Effect) => void);
  29060. /**
  29061. * 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
  29062. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  29063. */
  29064. get inputTexture(): InternalTexture;
  29065. set inputTexture(value: InternalTexture);
  29066. /**
  29067. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  29068. * the only way to unset it is to use this function to restore its internal state
  29069. */
  29070. restoreDefaultInputTexture(): void;
  29071. /**
  29072. * Gets the camera which post process is applied to.
  29073. * @returns The camera the post process is applied to.
  29074. */
  29075. getCamera(): Camera;
  29076. /**
  29077. * Gets the texel size of the postprocess.
  29078. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  29079. */
  29080. get texelSize(): Vector2;
  29081. /**
  29082. * Creates a new instance PostProcess
  29083. * @param name The name of the PostProcess.
  29084. * @param fragmentUrl The url of the fragment shader to be used.
  29085. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  29086. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  29087. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  29088. * @param camera The camera to apply the render pass to.
  29089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29090. * @param engine The engine which the post process will be applied. (default: current engine)
  29091. * @param reusable If the post process can be reused on the same frame. (default: false)
  29092. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  29093. * @param textureType Type of textures used when performing the post process. (default: 0)
  29094. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  29095. * @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
  29096. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  29097. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  29098. */
  29099. 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);
  29100. /**
  29101. * Gets a string identifying the name of the class
  29102. * @returns "PostProcess" string
  29103. */
  29104. getClassName(): string;
  29105. /**
  29106. * Gets the engine which this post process belongs to.
  29107. * @returns The engine the post process was enabled with.
  29108. */
  29109. getEngine(): Engine;
  29110. /**
  29111. * The effect that is created when initializing the post process.
  29112. * @returns The created effect corresponding the the postprocess.
  29113. */
  29114. getEffect(): Effect;
  29115. /**
  29116. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  29117. * @param postProcess The post process to share the output with.
  29118. * @returns This post process.
  29119. */
  29120. shareOutputWith(postProcess: PostProcess): PostProcess;
  29121. /**
  29122. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  29123. * This should be called if the post process that shares output with this post process is disabled/disposed.
  29124. */
  29125. useOwnOutput(): void;
  29126. /**
  29127. * Updates the effect with the current post process compile time values and recompiles the shader.
  29128. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29129. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29130. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29131. * @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
  29132. * @param onCompiled Called when the shader has been compiled.
  29133. * @param onError Called if there is an error when compiling a shader.
  29134. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  29135. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  29136. */
  29137. 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;
  29138. /**
  29139. * The post process is reusable if it can be used multiple times within one frame.
  29140. * @returns If the post process is reusable
  29141. */
  29142. isReusable(): boolean;
  29143. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  29144. markTextureDirty(): void;
  29145. /**
  29146. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  29147. * 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.
  29148. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  29149. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  29150. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  29151. * @returns The target texture that was bound to be written to.
  29152. */
  29153. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  29154. /**
  29155. * If the post process is supported.
  29156. */
  29157. get isSupported(): boolean;
  29158. /**
  29159. * The aspect ratio of the output texture.
  29160. */
  29161. get aspectRatio(): number;
  29162. /**
  29163. * Get a value indicating if the post-process is ready to be used
  29164. * @returns true if the post-process is ready (shader is compiled)
  29165. */
  29166. isReady(): boolean;
  29167. /**
  29168. * Binds all textures and uniforms to the shader, this will be run on every pass.
  29169. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  29170. */
  29171. apply(): Nullable<Effect>;
  29172. private _disposeTextures;
  29173. /**
  29174. * Sets the required values to the prepass renderer.
  29175. * @param prePassRenderer defines the prepass renderer to setup.
  29176. * @returns true if the pre pass is needed.
  29177. */
  29178. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29179. /**
  29180. * Disposes the post process.
  29181. * @param camera The camera to dispose the post process on.
  29182. */
  29183. dispose(camera?: Camera): void;
  29184. /**
  29185. * Serializes the particle system to a JSON object
  29186. * @returns the JSON object
  29187. */
  29188. serialize(): any;
  29189. /**
  29190. * Creates a material from parsed material data
  29191. * @param parsedPostProcess defines parsed post process data
  29192. * @param scene defines the hosting scene
  29193. * @param rootUrl defines the root URL to use to load textures
  29194. * @returns a new post process
  29195. */
  29196. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  29197. }
  29198. }
  29199. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  29200. /** @hidden */
  29201. export var kernelBlurVaryingDeclaration: {
  29202. name: string;
  29203. shader: string;
  29204. };
  29205. }
  29206. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  29207. /** @hidden */
  29208. export var kernelBlurFragment: {
  29209. name: string;
  29210. shader: string;
  29211. };
  29212. }
  29213. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  29214. /** @hidden */
  29215. export var kernelBlurFragment2: {
  29216. name: string;
  29217. shader: string;
  29218. };
  29219. }
  29220. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  29221. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  29222. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  29223. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  29224. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  29225. /** @hidden */
  29226. export var kernelBlurPixelShader: {
  29227. name: string;
  29228. shader: string;
  29229. };
  29230. }
  29231. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  29232. /** @hidden */
  29233. export var kernelBlurVertex: {
  29234. name: string;
  29235. shader: string;
  29236. };
  29237. }
  29238. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  29239. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  29240. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  29241. /** @hidden */
  29242. export var kernelBlurVertexShader: {
  29243. name: string;
  29244. shader: string;
  29245. };
  29246. }
  29247. declare module "babylonjs/PostProcesses/blurPostProcess" {
  29248. import { Vector2 } from "babylonjs/Maths/math.vector";
  29249. import { Nullable } from "babylonjs/types";
  29250. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  29251. import { Camera } from "babylonjs/Cameras/camera";
  29252. import { Effect } from "babylonjs/Materials/effect";
  29253. import { Engine } from "babylonjs/Engines/engine";
  29254. import "babylonjs/Shaders/kernelBlur.fragment";
  29255. import "babylonjs/Shaders/kernelBlur.vertex";
  29256. import { Scene } from "babylonjs/scene";
  29257. /**
  29258. * The Blur Post Process which blurs an image based on a kernel and direction.
  29259. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  29260. */
  29261. export class BlurPostProcess extends PostProcess {
  29262. private blockCompilation;
  29263. protected _kernel: number;
  29264. protected _idealKernel: number;
  29265. protected _packedFloat: boolean;
  29266. private _staticDefines;
  29267. /** The direction in which to blur the image. */
  29268. direction: Vector2;
  29269. /**
  29270. * Sets the length in pixels of the blur sample region
  29271. */
  29272. set kernel(v: number);
  29273. /**
  29274. * Gets the length in pixels of the blur sample region
  29275. */
  29276. get kernel(): number;
  29277. /**
  29278. * Sets wether or not the blur needs to unpack/repack floats
  29279. */
  29280. set packedFloat(v: boolean);
  29281. /**
  29282. * Gets wether or not the blur is unpacking/repacking floats
  29283. */
  29284. get packedFloat(): boolean;
  29285. /**
  29286. * Gets a string identifying the name of the class
  29287. * @returns "BlurPostProcess" string
  29288. */
  29289. getClassName(): string;
  29290. /**
  29291. * Creates a new instance BlurPostProcess
  29292. * @param name The name of the effect.
  29293. * @param direction The direction in which to blur the image.
  29294. * @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.
  29295. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  29296. * @param camera The camera to apply the render pass to.
  29297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29298. * @param engine The engine which the post process will be applied. (default: current engine)
  29299. * @param reusable If the post process can be reused on the same frame. (default: false)
  29300. * @param textureType Type of textures used when performing the post process. (default: 0)
  29301. * @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)
  29302. */
  29303. 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);
  29304. /**
  29305. * Updates the effect with the current post process compile time values and recompiles the shader.
  29306. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29307. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29308. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29309. * @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
  29310. * @param onCompiled Called when the shader has been compiled.
  29311. * @param onError Called if there is an error when compiling a shader.
  29312. */
  29313. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29314. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29315. /**
  29316. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  29317. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  29318. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  29319. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  29320. * The gaps between physical kernels are compensated for in the weighting of the samples
  29321. * @param idealKernel Ideal blur kernel.
  29322. * @return Nearest best kernel.
  29323. */
  29324. protected _nearestBestKernel(idealKernel: number): number;
  29325. /**
  29326. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  29327. * @param x The point on the Gaussian distribution to sample.
  29328. * @return the value of the Gaussian function at x.
  29329. */
  29330. protected _gaussianWeight(x: number): number;
  29331. /**
  29332. * Generates a string that can be used as a floating point number in GLSL.
  29333. * @param x Value to print.
  29334. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  29335. * @return GLSL float string.
  29336. */
  29337. protected _glslFloat(x: number, decimalFigures?: number): string;
  29338. /** @hidden */
  29339. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  29340. }
  29341. }
  29342. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  29343. import { Scene } from "babylonjs/scene";
  29344. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29345. import { Plane } from "babylonjs/Maths/math.plane";
  29346. /**
  29347. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29348. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29349. * You can then easily use it as a reflectionTexture on a flat surface.
  29350. * In case the surface is not a plane, please consider relying on reflection probes.
  29351. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29352. */
  29353. export class MirrorTexture extends RenderTargetTexture {
  29354. private scene;
  29355. /**
  29356. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  29357. * 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.
  29358. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29359. */
  29360. mirrorPlane: Plane;
  29361. /**
  29362. * Define the blur ratio used to blur the reflection if needed.
  29363. */
  29364. set blurRatio(value: number);
  29365. get blurRatio(): number;
  29366. /**
  29367. * Define the adaptive blur kernel used to blur the reflection if needed.
  29368. * This will autocompute the closest best match for the `blurKernel`
  29369. */
  29370. set adaptiveBlurKernel(value: number);
  29371. /**
  29372. * Define the blur kernel used to blur the reflection if needed.
  29373. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29374. */
  29375. set blurKernel(value: number);
  29376. /**
  29377. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  29378. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29379. */
  29380. set blurKernelX(value: number);
  29381. get blurKernelX(): number;
  29382. /**
  29383. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  29384. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29385. */
  29386. set blurKernelY(value: number);
  29387. get blurKernelY(): number;
  29388. private _autoComputeBlurKernel;
  29389. protected _onRatioRescale(): void;
  29390. private _updateGammaSpace;
  29391. private _imageProcessingConfigChangeObserver;
  29392. private _transformMatrix;
  29393. private _mirrorMatrix;
  29394. private _savedViewMatrix;
  29395. private _blurX;
  29396. private _blurY;
  29397. private _adaptiveBlurKernel;
  29398. private _blurKernelX;
  29399. private _blurKernelY;
  29400. private _blurRatio;
  29401. /**
  29402. * Instantiates a Mirror Texture.
  29403. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29404. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29405. * You can then easily use it as a reflectionTexture on a flat surface.
  29406. * In case the surface is not a plane, please consider relying on reflection probes.
  29407. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29408. * @param name
  29409. * @param size
  29410. * @param scene
  29411. * @param generateMipMaps
  29412. * @param type
  29413. * @param samplingMode
  29414. * @param generateDepthBuffer
  29415. */
  29416. constructor(name: string, size: number | {
  29417. width: number;
  29418. height: number;
  29419. } | {
  29420. ratio: number;
  29421. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29422. private _preparePostProcesses;
  29423. /**
  29424. * Clone the mirror texture.
  29425. * @returns the cloned texture
  29426. */
  29427. clone(): MirrorTexture;
  29428. /**
  29429. * Serialize the texture to a JSON representation you could use in Parse later on
  29430. * @returns the serialized JSON representation
  29431. */
  29432. serialize(): any;
  29433. /**
  29434. * Dispose the texture and release its associated resources.
  29435. */
  29436. dispose(): void;
  29437. }
  29438. }
  29439. declare module "babylonjs/Materials/Textures/texture" {
  29440. import { Observable } from "babylonjs/Misc/observable";
  29441. import { Nullable } from "babylonjs/types";
  29442. import { Matrix } from "babylonjs/Maths/math.vector";
  29443. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29444. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29445. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29446. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  29447. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  29448. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29449. import { Scene } from "babylonjs/scene";
  29450. /**
  29451. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29452. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29453. */
  29454. export class Texture extends BaseTexture {
  29455. /**
  29456. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  29457. */
  29458. static SerializeBuffers: boolean;
  29459. /**
  29460. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  29461. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  29462. */
  29463. static ForceSerializeBuffers: boolean;
  29464. /** @hidden */
  29465. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  29466. /** @hidden */
  29467. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  29468. /** @hidden */
  29469. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  29470. /** nearest is mag = nearest and min = nearest and mip = linear */
  29471. static readonly NEAREST_SAMPLINGMODE: number;
  29472. /** nearest is mag = nearest and min = nearest and mip = linear */
  29473. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  29474. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29475. static readonly BILINEAR_SAMPLINGMODE: number;
  29476. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29477. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  29478. /** Trilinear is mag = linear and min = linear and mip = linear */
  29479. static readonly TRILINEAR_SAMPLINGMODE: number;
  29480. /** Trilinear is mag = linear and min = linear and mip = linear */
  29481. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  29482. /** mag = nearest and min = nearest and mip = nearest */
  29483. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  29484. /** mag = nearest and min = linear and mip = nearest */
  29485. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  29486. /** mag = nearest and min = linear and mip = linear */
  29487. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  29488. /** mag = nearest and min = linear and mip = none */
  29489. static readonly NEAREST_LINEAR: number;
  29490. /** mag = nearest and min = nearest and mip = none */
  29491. static readonly NEAREST_NEAREST: number;
  29492. /** mag = linear and min = nearest and mip = nearest */
  29493. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  29494. /** mag = linear and min = nearest and mip = linear */
  29495. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  29496. /** mag = linear and min = linear and mip = none */
  29497. static readonly LINEAR_LINEAR: number;
  29498. /** mag = linear and min = nearest and mip = none */
  29499. static readonly LINEAR_NEAREST: number;
  29500. /** Explicit coordinates mode */
  29501. static readonly EXPLICIT_MODE: number;
  29502. /** Spherical coordinates mode */
  29503. static readonly SPHERICAL_MODE: number;
  29504. /** Planar coordinates mode */
  29505. static readonly PLANAR_MODE: number;
  29506. /** Cubic coordinates mode */
  29507. static readonly CUBIC_MODE: number;
  29508. /** Projection coordinates mode */
  29509. static readonly PROJECTION_MODE: number;
  29510. /** Inverse Cubic coordinates mode */
  29511. static readonly SKYBOX_MODE: number;
  29512. /** Inverse Cubic coordinates mode */
  29513. static readonly INVCUBIC_MODE: number;
  29514. /** Equirectangular coordinates mode */
  29515. static readonly EQUIRECTANGULAR_MODE: number;
  29516. /** Equirectangular Fixed coordinates mode */
  29517. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  29518. /** Equirectangular Fixed Mirrored coordinates mode */
  29519. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29520. /** Texture is not repeating outside of 0..1 UVs */
  29521. static readonly CLAMP_ADDRESSMODE: number;
  29522. /** Texture is repeating outside of 0..1 UVs */
  29523. static readonly WRAP_ADDRESSMODE: number;
  29524. /** Texture is repeating and mirrored */
  29525. static readonly MIRROR_ADDRESSMODE: number;
  29526. /**
  29527. * 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
  29528. */
  29529. static UseSerializedUrlIfAny: boolean;
  29530. /**
  29531. * Define the url of the texture.
  29532. */
  29533. url: Nullable<string>;
  29534. /**
  29535. * Define an offset on the texture to offset the u coordinates of the UVs
  29536. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29537. */
  29538. uOffset: number;
  29539. /**
  29540. * Define an offset on the texture to offset the v coordinates of the UVs
  29541. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29542. */
  29543. vOffset: number;
  29544. /**
  29545. * Define an offset on the texture to scale the u coordinates of the UVs
  29546. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29547. */
  29548. uScale: number;
  29549. /**
  29550. * Define an offset on the texture to scale the v coordinates of the UVs
  29551. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29552. */
  29553. vScale: number;
  29554. /**
  29555. * Define an offset on the texture to rotate around the u coordinates of the UVs
  29556. * @see https://doc.babylonjs.com/how_to/more_materials
  29557. */
  29558. uAng: number;
  29559. /**
  29560. * Define an offset on the texture to rotate around the v coordinates of the UVs
  29561. * @see https://doc.babylonjs.com/how_to/more_materials
  29562. */
  29563. vAng: number;
  29564. /**
  29565. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  29566. * @see https://doc.babylonjs.com/how_to/more_materials
  29567. */
  29568. wAng: number;
  29569. /**
  29570. * Defines the center of rotation (U)
  29571. */
  29572. uRotationCenter: number;
  29573. /**
  29574. * Defines the center of rotation (V)
  29575. */
  29576. vRotationCenter: number;
  29577. /**
  29578. * Defines the center of rotation (W)
  29579. */
  29580. wRotationCenter: number;
  29581. /**
  29582. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  29583. */
  29584. homogeneousRotationInUVTransform: boolean;
  29585. /**
  29586. * Are mip maps generated for this texture or not.
  29587. */
  29588. get noMipmap(): boolean;
  29589. /**
  29590. * List of inspectable custom properties (used by the Inspector)
  29591. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29592. */
  29593. inspectableCustomProperties: Nullable<IInspectable[]>;
  29594. private _noMipmap;
  29595. /** @hidden */
  29596. _invertY: boolean;
  29597. private _rowGenerationMatrix;
  29598. private _cachedTextureMatrix;
  29599. private _projectionModeMatrix;
  29600. private _t0;
  29601. private _t1;
  29602. private _t2;
  29603. private _cachedUOffset;
  29604. private _cachedVOffset;
  29605. private _cachedUScale;
  29606. private _cachedVScale;
  29607. private _cachedUAng;
  29608. private _cachedVAng;
  29609. private _cachedWAng;
  29610. private _cachedProjectionMatrixId;
  29611. private _cachedURotationCenter;
  29612. private _cachedVRotationCenter;
  29613. private _cachedWRotationCenter;
  29614. private _cachedHomogeneousRotationInUVTransform;
  29615. private _cachedCoordinatesMode;
  29616. /** @hidden */
  29617. protected _initialSamplingMode: number;
  29618. /** @hidden */
  29619. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29620. private _deleteBuffer;
  29621. protected _format: Nullable<number>;
  29622. private _delayedOnLoad;
  29623. private _delayedOnError;
  29624. private _mimeType?;
  29625. private _loaderOptions?;
  29626. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  29627. get mimeType(): string | undefined;
  29628. /**
  29629. * Observable triggered once the texture has been loaded.
  29630. */
  29631. onLoadObservable: Observable<Texture>;
  29632. protected _isBlocking: boolean;
  29633. /**
  29634. * Is the texture preventing material to render while loading.
  29635. * If false, a default texture will be used instead of the loading one during the preparation step.
  29636. */
  29637. set isBlocking(value: boolean);
  29638. get isBlocking(): boolean;
  29639. /**
  29640. * Get the current sampling mode associated with the texture.
  29641. */
  29642. get samplingMode(): number;
  29643. /**
  29644. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  29645. */
  29646. get invertY(): boolean;
  29647. /**
  29648. * Instantiates a new texture.
  29649. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29650. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29651. * @param url defines the url of the picture to load as a texture
  29652. * @param sceneOrEngine defines the scene or engine the texture will belong to
  29653. * @param noMipmap defines if the texture will require mip maps or not
  29654. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  29655. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29656. * @param onLoad defines a callback triggered when the texture has been loaded
  29657. * @param onError defines a callback triggered when an error occurred during the loading session
  29658. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  29659. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  29660. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29661. * @param mimeType defines an optional mime type information
  29662. * @param loaderOptions options to be passed to the loader
  29663. */
  29664. 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);
  29665. /**
  29666. * Update the url (and optional buffer) of this texture if url was null during construction.
  29667. * @param url the url of the texture
  29668. * @param buffer the buffer of the texture (defaults to null)
  29669. * @param onLoad callback called when the texture is loaded (defaults to null)
  29670. */
  29671. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  29672. /**
  29673. * Finish the loading sequence of a texture flagged as delayed load.
  29674. * @hidden
  29675. */
  29676. delayLoad(): void;
  29677. private _prepareRowForTextureGeneration;
  29678. /**
  29679. * Checks if the texture has the same transform matrix than another texture
  29680. * @param texture texture to check against
  29681. * @returns true if the transforms are the same, else false
  29682. */
  29683. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  29684. /**
  29685. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  29686. * @returns the transform matrix of the texture.
  29687. */
  29688. getTextureMatrix(uBase?: number): Matrix;
  29689. /**
  29690. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  29691. * @returns The reflection texture transform
  29692. */
  29693. getReflectionTextureMatrix(): Matrix;
  29694. /**
  29695. * Clones the texture.
  29696. * @returns the cloned texture
  29697. */
  29698. clone(): Texture;
  29699. /**
  29700. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29701. * @returns The JSON representation of the texture
  29702. */
  29703. serialize(): any;
  29704. /**
  29705. * Get the current class name of the texture useful for serialization or dynamic coding.
  29706. * @returns "Texture"
  29707. */
  29708. getClassName(): string;
  29709. /**
  29710. * Dispose the texture and release its associated resources.
  29711. */
  29712. dispose(): void;
  29713. /**
  29714. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  29715. * @param parsedTexture Define the JSON representation of the texture
  29716. * @param scene Define the scene the parsed texture should be instantiated in
  29717. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  29718. * @returns The parsed texture if successful
  29719. */
  29720. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29721. /**
  29722. * Creates a texture from its base 64 representation.
  29723. * @param data Define the base64 payload without the data: prefix
  29724. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29725. * @param scene Define the scene the texture should belong to
  29726. * @param noMipmap Forces the texture to not create mip map information if true
  29727. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29728. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29729. * @param onLoad define a callback triggered when the texture has been loaded
  29730. * @param onError define a callback triggered when an error occurred during the loading session
  29731. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29732. * @returns the created texture
  29733. */
  29734. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29735. /**
  29736. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  29737. * @param data Define the base64 payload without the data: prefix
  29738. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29739. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  29740. * @param scene Define the scene the texture should belong to
  29741. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  29742. * @param noMipmap Forces the texture to not create mip map information if true
  29743. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29744. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29745. * @param onLoad define a callback triggered when the texture has been loaded
  29746. * @param onError define a callback triggered when an error occurred during the loading session
  29747. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29748. * @returns the created texture
  29749. */
  29750. 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;
  29751. }
  29752. }
  29753. declare module "babylonjs/PostProcesses/postProcessManager" {
  29754. import { Nullable } from "babylonjs/types";
  29755. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29756. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29757. import { Scene } from "babylonjs/scene";
  29758. /**
  29759. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29760. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29761. */
  29762. export class PostProcessManager {
  29763. private _scene;
  29764. private _indexBuffer;
  29765. private _vertexBuffers;
  29766. /**
  29767. * Creates a new instance PostProcess
  29768. * @param scene The scene that the post process is associated with.
  29769. */
  29770. constructor(scene: Scene);
  29771. private _prepareBuffers;
  29772. private _buildIndexBuffer;
  29773. /**
  29774. * Rebuilds the vertex buffers of the manager.
  29775. * @hidden
  29776. */
  29777. _rebuild(): void;
  29778. /**
  29779. * Prepares a frame to be run through a post process.
  29780. * @param sourceTexture The input texture to the post procesess. (default: null)
  29781. * @param postProcesses An array of post processes to be run. (default: null)
  29782. * @returns True if the post processes were able to be run.
  29783. * @hidden
  29784. */
  29785. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29786. /**
  29787. * Manually render a set of post processes to a texture.
  29788. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  29789. * @param postProcesses An array of post processes to be run.
  29790. * @param targetTexture The target texture to render to.
  29791. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29792. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  29793. * @param lodLevel defines which lod of the texture to render to
  29794. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  29795. */
  29796. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  29797. /**
  29798. * Finalize the result of the output of the postprocesses.
  29799. * @param doNotPresent If true the result will not be displayed to the screen.
  29800. * @param targetTexture The target texture to render to.
  29801. * @param faceIndex The index of the face to bind the target texture to.
  29802. * @param postProcesses The array of post processes to render.
  29803. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29804. * @hidden
  29805. */
  29806. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29807. /**
  29808. * Disposes of the post process manager.
  29809. */
  29810. dispose(): void;
  29811. }
  29812. }
  29813. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  29814. import { Observable } from "babylonjs/Misc/observable";
  29815. import { SmartArray } from "babylonjs/Misc/smartArray";
  29816. import { Nullable, Immutable } from "babylonjs/types";
  29817. import { Camera } from "babylonjs/Cameras/camera";
  29818. import { Scene } from "babylonjs/scene";
  29819. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29820. import { Color4 } from "babylonjs/Maths/math.color";
  29821. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29823. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29824. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29825. import { Texture } from "babylonjs/Materials/Textures/texture";
  29826. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29827. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  29828. import "babylonjs/Engines/Extensions/engine.renderTarget";
  29829. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  29830. import { Engine } from "babylonjs/Engines/engine";
  29831. /**
  29832. * This Helps creating a texture that will be created from a camera in your scene.
  29833. * It is basically a dynamic texture that could be used to create special effects for instance.
  29834. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  29835. */
  29836. export class RenderTargetTexture extends Texture {
  29837. /**
  29838. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  29839. */
  29840. static readonly REFRESHRATE_RENDER_ONCE: number;
  29841. /**
  29842. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  29843. */
  29844. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29845. /**
  29846. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  29847. * the central point of your effect and can save a lot of performances.
  29848. */
  29849. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29850. /**
  29851. * Use this predicate to dynamically define the list of mesh you want to render.
  29852. * If set, the renderList property will be overwritten.
  29853. */
  29854. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29855. private _renderList;
  29856. /**
  29857. * Use this list to define the list of mesh you want to render.
  29858. */
  29859. get renderList(): Nullable<Array<AbstractMesh>>;
  29860. set renderList(value: Nullable<Array<AbstractMesh>>);
  29861. /**
  29862. * Use this function to overload the renderList array at rendering time.
  29863. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  29864. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  29865. * the cube (if the RTT is a cube, else layerOrFace=0).
  29866. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  29867. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  29868. * hold dummy elements!
  29869. */
  29870. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  29871. private _hookArray;
  29872. /**
  29873. * Define if particles should be rendered in your texture.
  29874. */
  29875. renderParticles: boolean;
  29876. /**
  29877. * Define if sprites should be rendered in your texture.
  29878. */
  29879. renderSprites: boolean;
  29880. /**
  29881. * Define the camera used to render the texture.
  29882. */
  29883. activeCamera: Nullable<Camera>;
  29884. /**
  29885. * Override the mesh isReady function with your own one.
  29886. */
  29887. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  29888. /**
  29889. * Override the render function of the texture with your own one.
  29890. */
  29891. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29892. /**
  29893. * Define if camera post processes should be use while rendering the texture.
  29894. */
  29895. useCameraPostProcesses: boolean;
  29896. /**
  29897. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  29898. */
  29899. ignoreCameraViewport: boolean;
  29900. private _postProcessManager;
  29901. private _postProcesses;
  29902. private _resizeObserver;
  29903. /**
  29904. * An event triggered when the texture is unbind.
  29905. */
  29906. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29907. /**
  29908. * An event triggered when the texture is unbind.
  29909. */
  29910. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29911. private _onAfterUnbindObserver;
  29912. /**
  29913. * Set a after unbind callback in the texture.
  29914. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  29915. */
  29916. set onAfterUnbind(callback: () => void);
  29917. /**
  29918. * An event triggered before rendering the texture
  29919. */
  29920. onBeforeRenderObservable: Observable<number>;
  29921. private _onBeforeRenderObserver;
  29922. /**
  29923. * Set a before render callback in the texture.
  29924. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  29925. */
  29926. set onBeforeRender(callback: (faceIndex: number) => void);
  29927. /**
  29928. * An event triggered after rendering the texture
  29929. */
  29930. onAfterRenderObservable: Observable<number>;
  29931. private _onAfterRenderObserver;
  29932. /**
  29933. * Set a after render callback in the texture.
  29934. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  29935. */
  29936. set onAfterRender(callback: (faceIndex: number) => void);
  29937. /**
  29938. * An event triggered after the texture clear
  29939. */
  29940. onClearObservable: Observable<Engine>;
  29941. private _onClearObserver;
  29942. /**
  29943. * Set a clear callback in the texture.
  29944. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  29945. */
  29946. set onClear(callback: (Engine: Engine) => void);
  29947. /**
  29948. * An event triggered when the texture is resized.
  29949. */
  29950. onResizeObservable: Observable<RenderTargetTexture>;
  29951. /**
  29952. * Define the clear color of the Render Target if it should be different from the scene.
  29953. */
  29954. clearColor: Color4;
  29955. protected _size: number | {
  29956. width: number;
  29957. height: number;
  29958. layers?: number;
  29959. };
  29960. protected _initialSizeParameter: number | {
  29961. width: number;
  29962. height: number;
  29963. } | {
  29964. ratio: number;
  29965. };
  29966. protected _sizeRatio: Nullable<number>;
  29967. /** @hidden */
  29968. _generateMipMaps: boolean;
  29969. protected _renderingManager: RenderingManager;
  29970. /** @hidden */
  29971. _waitingRenderList?: string[];
  29972. protected _doNotChangeAspectRatio: boolean;
  29973. protected _currentRefreshId: number;
  29974. protected _refreshRate: number;
  29975. protected _textureMatrix: Matrix;
  29976. protected _samples: number;
  29977. protected _renderTargetOptions: RenderTargetCreationOptions;
  29978. /**
  29979. * Gets render target creation options that were used.
  29980. */
  29981. get renderTargetOptions(): RenderTargetCreationOptions;
  29982. protected _onRatioRescale(): void;
  29983. /**
  29984. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29985. * It must define where the camera used to render the texture is set
  29986. */
  29987. boundingBoxPosition: Vector3;
  29988. private _boundingBoxSize;
  29989. /**
  29990. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29991. * When defined, the cubemap will switch to local mode
  29992. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29993. * @example https://www.babylonjs-playground.com/#RNASML
  29994. */
  29995. set boundingBoxSize(value: Vector3);
  29996. get boundingBoxSize(): Vector3;
  29997. /**
  29998. * In case the RTT has been created with a depth texture, get the associated
  29999. * depth texture.
  30000. * Otherwise, return null.
  30001. */
  30002. get depthStencilTexture(): Nullable<InternalTexture>;
  30003. /**
  30004. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  30005. * or used a shadow, depth texture...
  30006. * @param name The friendly name of the texture
  30007. * @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)
  30008. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  30009. * @param generateMipMaps True if mip maps need to be generated after render.
  30010. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  30011. * @param type The type of the buffer in the RTT (int, half float, float...)
  30012. * @param isCube True if a cube texture needs to be created
  30013. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  30014. * @param generateDepthBuffer True to generate a depth buffer
  30015. * @param generateStencilBuffer True to generate a stencil buffer
  30016. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  30017. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  30018. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30019. */
  30020. constructor(name: string, size: number | {
  30021. width: number;
  30022. height: number;
  30023. layers?: number;
  30024. } | {
  30025. ratio: number;
  30026. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  30027. /**
  30028. * Creates a depth stencil texture.
  30029. * This is only available in WebGL 2 or with the depth texture extension available.
  30030. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  30031. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  30032. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  30033. */
  30034. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  30035. private _processSizeParameter;
  30036. /**
  30037. * Define the number of samples to use in case of MSAA.
  30038. * It defaults to one meaning no MSAA has been enabled.
  30039. */
  30040. get samples(): number;
  30041. set samples(value: number);
  30042. /**
  30043. * Resets the refresh counter of the texture and start bak from scratch.
  30044. * Could be useful to regenerate the texture if it is setup to render only once.
  30045. */
  30046. resetRefreshCounter(): void;
  30047. /**
  30048. * Define the refresh rate of the texture or the rendering frequency.
  30049. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  30050. */
  30051. get refreshRate(): number;
  30052. set refreshRate(value: number);
  30053. /**
  30054. * Adds a post process to the render target rendering passes.
  30055. * @param postProcess define the post process to add
  30056. */
  30057. addPostProcess(postProcess: PostProcess): void;
  30058. /**
  30059. * Clear all the post processes attached to the render target
  30060. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  30061. */
  30062. clearPostProcesses(dispose?: boolean): void;
  30063. /**
  30064. * Remove one of the post process from the list of attached post processes to the texture
  30065. * @param postProcess define the post process to remove from the list
  30066. */
  30067. removePostProcess(postProcess: PostProcess): void;
  30068. /** @hidden */
  30069. _shouldRender(): boolean;
  30070. /**
  30071. * Gets the actual render size of the texture.
  30072. * @returns the width of the render size
  30073. */
  30074. getRenderSize(): number;
  30075. /**
  30076. * Gets the actual render width of the texture.
  30077. * @returns the width of the render size
  30078. */
  30079. getRenderWidth(): number;
  30080. /**
  30081. * Gets the actual render height of the texture.
  30082. * @returns the height of the render size
  30083. */
  30084. getRenderHeight(): number;
  30085. /**
  30086. * Gets the actual number of layers of the texture.
  30087. * @returns the number of layers
  30088. */
  30089. getRenderLayers(): number;
  30090. /**
  30091. * Get if the texture can be rescaled or not.
  30092. */
  30093. get canRescale(): boolean;
  30094. /**
  30095. * Resize the texture using a ratio.
  30096. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  30097. */
  30098. scale(ratio: number): void;
  30099. /**
  30100. * Get the texture reflection matrix used to rotate/transform the reflection.
  30101. * @returns the reflection matrix
  30102. */
  30103. getReflectionTextureMatrix(): Matrix;
  30104. /**
  30105. * Resize the texture to a new desired size.
  30106. * Be carrefull as it will recreate all the data in the new texture.
  30107. * @param size Define the new size. It can be:
  30108. * - a number for squared texture,
  30109. * - an object containing { width: number, height: number }
  30110. * - or an object containing a ratio { ratio: number }
  30111. */
  30112. resize(size: number | {
  30113. width: number;
  30114. height: number;
  30115. } | {
  30116. ratio: number;
  30117. }): void;
  30118. private _defaultRenderListPrepared;
  30119. /**
  30120. * Renders all the objects from the render list into the texture.
  30121. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  30122. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  30123. */
  30124. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  30125. private _bestReflectionRenderTargetDimension;
  30126. private _prepareRenderingManager;
  30127. /**
  30128. * @hidden
  30129. * @param faceIndex face index to bind to if this is a cubetexture
  30130. * @param layer defines the index of the texture to bind in the array
  30131. */
  30132. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  30133. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  30134. private renderToTarget;
  30135. /**
  30136. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  30137. * This allowed control for front to back rendering or reversly depending of the special needs.
  30138. *
  30139. * @param renderingGroupId The rendering group id corresponding to its index
  30140. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  30141. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  30142. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  30143. */
  30144. 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;
  30145. /**
  30146. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  30147. *
  30148. * @param renderingGroupId The rendering group id corresponding to its index
  30149. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  30150. */
  30151. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  30152. /**
  30153. * Clones the texture.
  30154. * @returns the cloned texture
  30155. */
  30156. clone(): RenderTargetTexture;
  30157. /**
  30158. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  30159. * @returns The JSON representation of the texture
  30160. */
  30161. serialize(): any;
  30162. /**
  30163. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  30164. */
  30165. disposeFramebufferObjects(): void;
  30166. /**
  30167. * Dispose the texture and release its associated resources.
  30168. */
  30169. dispose(): void;
  30170. /** @hidden */
  30171. _rebuild(): void;
  30172. /**
  30173. * Clear the info related to rendering groups preventing retention point in material dispose.
  30174. */
  30175. freeRenderingGroups(): void;
  30176. /**
  30177. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  30178. * @returns the view count
  30179. */
  30180. getViewCount(): number;
  30181. }
  30182. }
  30183. declare module "babylonjs/Misc/guid" {
  30184. /**
  30185. * Class used to manipulate GUIDs
  30186. */
  30187. export class GUID {
  30188. /**
  30189. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30190. * Be aware Math.random() could cause collisions, but:
  30191. * "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"
  30192. * @returns a pseudo random id
  30193. */
  30194. static RandomId(): string;
  30195. }
  30196. }
  30197. declare module "babylonjs/Materials/shadowDepthWrapper" {
  30198. import { Nullable } from "babylonjs/types";
  30199. import { Scene } from "babylonjs/scene";
  30200. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30201. import { Material } from "babylonjs/Materials/material";
  30202. import { Effect } from "babylonjs/Materials/effect";
  30203. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  30204. /**
  30205. * Options to be used when creating a shadow depth material
  30206. */
  30207. export interface IIOptionShadowDepthMaterial {
  30208. /** Variables in the vertex shader code that need to have their names remapped.
  30209. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30210. * "var_name" should be either: worldPos or vNormalW
  30211. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30212. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30213. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30214. */
  30215. remappedVariables?: string[];
  30216. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30217. standalone?: boolean;
  30218. }
  30219. /**
  30220. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30221. */
  30222. export class ShadowDepthWrapper {
  30223. private _scene;
  30224. private _options?;
  30225. private _baseMaterial;
  30226. private _onEffectCreatedObserver;
  30227. private _subMeshToEffect;
  30228. private _subMeshToDepthEffect;
  30229. private _meshes;
  30230. /** @hidden */
  30231. _matriceNames: any;
  30232. /** Gets the standalone status of the wrapper */
  30233. get standalone(): boolean;
  30234. /** Gets the base material the wrapper is built upon */
  30235. get baseMaterial(): Material;
  30236. /**
  30237. * Instantiate a new shadow depth wrapper.
  30238. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30239. * generate the shadow depth map. For more information, please refer to the documentation:
  30240. * https://doc.babylonjs.com/babylon101/shadows
  30241. * @param baseMaterial Material to wrap
  30242. * @param scene Define the scene the material belongs to
  30243. * @param options Options used to create the wrapper
  30244. */
  30245. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30246. /**
  30247. * Gets the effect to use to generate the depth map
  30248. * @param subMesh subMesh to get the effect for
  30249. * @param shadowGenerator shadow generator to get the effect for
  30250. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30251. */
  30252. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30253. /**
  30254. * Specifies that the submesh is ready to be used for depth rendering
  30255. * @param subMesh submesh to check
  30256. * @param defines the list of defines to take into account when checking the effect
  30257. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30258. * @param useInstances specifies that instances should be used
  30259. * @returns a boolean indicating that the submesh is ready or not
  30260. */
  30261. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30262. /**
  30263. * Disposes the resources
  30264. */
  30265. dispose(): void;
  30266. private _makeEffect;
  30267. }
  30268. }
  30269. declare module "babylonjs/Materials/material" {
  30270. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30271. import { SmartArray } from "babylonjs/Misc/smartArray";
  30272. import { Observable } from "babylonjs/Misc/observable";
  30273. import { Nullable } from "babylonjs/types";
  30274. import { Scene } from "babylonjs/scene";
  30275. import { Matrix } from "babylonjs/Maths/math.vector";
  30276. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30278. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30279. import { Effect } from "babylonjs/Materials/effect";
  30280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30281. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30282. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30283. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30284. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  30285. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  30286. import { Mesh } from "babylonjs/Meshes/mesh";
  30287. import { Animation } from "babylonjs/Animations/animation";
  30288. /**
  30289. * Options for compiling materials.
  30290. */
  30291. export interface IMaterialCompilationOptions {
  30292. /**
  30293. * Defines whether clip planes are enabled.
  30294. */
  30295. clipPlane: boolean;
  30296. /**
  30297. * Defines whether instances are enabled.
  30298. */
  30299. useInstances: boolean;
  30300. }
  30301. /**
  30302. * Options passed when calling customShaderNameResolve
  30303. */
  30304. export interface ICustomShaderNameResolveOptions {
  30305. /**
  30306. * 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
  30307. */
  30308. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30309. }
  30310. /**
  30311. * Base class for the main features of a material in Babylon.js
  30312. */
  30313. export class Material implements IAnimatable {
  30314. /**
  30315. * Returns the triangle fill mode
  30316. */
  30317. static readonly TriangleFillMode: number;
  30318. /**
  30319. * Returns the wireframe mode
  30320. */
  30321. static readonly WireFrameFillMode: number;
  30322. /**
  30323. * Returns the point fill mode
  30324. */
  30325. static readonly PointFillMode: number;
  30326. /**
  30327. * Returns the point list draw mode
  30328. */
  30329. static readonly PointListDrawMode: number;
  30330. /**
  30331. * Returns the line list draw mode
  30332. */
  30333. static readonly LineListDrawMode: number;
  30334. /**
  30335. * Returns the line loop draw mode
  30336. */
  30337. static readonly LineLoopDrawMode: number;
  30338. /**
  30339. * Returns the line strip draw mode
  30340. */
  30341. static readonly LineStripDrawMode: number;
  30342. /**
  30343. * Returns the triangle strip draw mode
  30344. */
  30345. static readonly TriangleStripDrawMode: number;
  30346. /**
  30347. * Returns the triangle fan draw mode
  30348. */
  30349. static readonly TriangleFanDrawMode: number;
  30350. /**
  30351. * Stores the clock-wise side orientation
  30352. */
  30353. static readonly ClockWiseSideOrientation: number;
  30354. /**
  30355. * Stores the counter clock-wise side orientation
  30356. */
  30357. static readonly CounterClockWiseSideOrientation: number;
  30358. /**
  30359. * The dirty texture flag value
  30360. */
  30361. static readonly TextureDirtyFlag: number;
  30362. /**
  30363. * The dirty light flag value
  30364. */
  30365. static readonly LightDirtyFlag: number;
  30366. /**
  30367. * The dirty fresnel flag value
  30368. */
  30369. static readonly FresnelDirtyFlag: number;
  30370. /**
  30371. * The dirty attribute flag value
  30372. */
  30373. static readonly AttributesDirtyFlag: number;
  30374. /**
  30375. * The dirty misc flag value
  30376. */
  30377. static readonly MiscDirtyFlag: number;
  30378. /**
  30379. * The dirty prepass flag value
  30380. */
  30381. static readonly PrePassDirtyFlag: number;
  30382. /**
  30383. * The all dirty flag value
  30384. */
  30385. static readonly AllDirtyFlag: number;
  30386. /**
  30387. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30388. */
  30389. static readonly MATERIAL_OPAQUE: number;
  30390. /**
  30391. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30392. */
  30393. static readonly MATERIAL_ALPHATEST: number;
  30394. /**
  30395. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30396. */
  30397. static readonly MATERIAL_ALPHABLEND: number;
  30398. /**
  30399. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30400. * They are also discarded below the alpha cutoff threshold to improve performances.
  30401. */
  30402. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30403. /**
  30404. * The Whiteout method is used to blend normals.
  30405. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30406. */
  30407. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30408. /**
  30409. * The Reoriented Normal Mapping method is used to blend normals.
  30410. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30411. */
  30412. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30413. /**
  30414. * Custom callback helping to override the default shader used in the material.
  30415. */
  30416. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30417. /**
  30418. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30419. */
  30420. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30421. /**
  30422. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30423. * This means that the material can keep using a previous shader while a new one is being compiled.
  30424. * This is mostly used when shader parallel compilation is supported (true by default)
  30425. */
  30426. allowShaderHotSwapping: boolean;
  30427. /**
  30428. * The ID of the material
  30429. */
  30430. id: string;
  30431. /**
  30432. * Gets or sets the unique id of the material
  30433. */
  30434. uniqueId: number;
  30435. /**
  30436. * The name of the material
  30437. */
  30438. name: string;
  30439. /**
  30440. * Gets or sets user defined metadata
  30441. */
  30442. metadata: any;
  30443. /**
  30444. * For internal use only. Please do not use.
  30445. */
  30446. reservedDataStore: any;
  30447. /**
  30448. * Specifies if the ready state should be checked on each call
  30449. */
  30450. checkReadyOnEveryCall: boolean;
  30451. /**
  30452. * Specifies if the ready state should be checked once
  30453. */
  30454. checkReadyOnlyOnce: boolean;
  30455. /**
  30456. * The state of the material
  30457. */
  30458. state: string;
  30459. /**
  30460. * If the material can be rendered to several textures with MRT extension
  30461. */
  30462. get canRenderToMRT(): boolean;
  30463. /**
  30464. * The alpha value of the material
  30465. */
  30466. protected _alpha: number;
  30467. /**
  30468. * List of inspectable custom properties (used by the Inspector)
  30469. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30470. */
  30471. inspectableCustomProperties: IInspectable[];
  30472. /**
  30473. * Sets the alpha value of the material
  30474. */
  30475. set alpha(value: number);
  30476. /**
  30477. * Gets the alpha value of the material
  30478. */
  30479. get alpha(): number;
  30480. /**
  30481. * Specifies if back face culling is enabled
  30482. */
  30483. protected _backFaceCulling: boolean;
  30484. /**
  30485. * Sets the back-face culling state
  30486. */
  30487. set backFaceCulling(value: boolean);
  30488. /**
  30489. * Gets the back-face culling state
  30490. */
  30491. get backFaceCulling(): boolean;
  30492. /**
  30493. * Stores the value for side orientation
  30494. */
  30495. sideOrientation: number;
  30496. /**
  30497. * Callback triggered when the material is compiled
  30498. */
  30499. onCompiled: Nullable<(effect: Effect) => void>;
  30500. /**
  30501. * Callback triggered when an error occurs
  30502. */
  30503. onError: Nullable<(effect: Effect, errors: string) => void>;
  30504. /**
  30505. * Callback triggered to get the render target textures
  30506. */
  30507. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30508. /**
  30509. * Gets a boolean indicating that current material needs to register RTT
  30510. */
  30511. get hasRenderTargetTextures(): boolean;
  30512. /**
  30513. * Specifies if the material should be serialized
  30514. */
  30515. doNotSerialize: boolean;
  30516. /**
  30517. * @hidden
  30518. */
  30519. _storeEffectOnSubMeshes: boolean;
  30520. /**
  30521. * Stores the animations for the material
  30522. */
  30523. animations: Nullable<Array<Animation>>;
  30524. /**
  30525. * An event triggered when the material is disposed
  30526. */
  30527. onDisposeObservable: Observable<Material>;
  30528. /**
  30529. * An observer which watches for dispose events
  30530. */
  30531. private _onDisposeObserver;
  30532. private _onUnBindObservable;
  30533. /**
  30534. * Called during a dispose event
  30535. */
  30536. set onDispose(callback: () => void);
  30537. private _onBindObservable;
  30538. /**
  30539. * An event triggered when the material is bound
  30540. */
  30541. get onBindObservable(): Observable<AbstractMesh>;
  30542. /**
  30543. * An observer which watches for bind events
  30544. */
  30545. private _onBindObserver;
  30546. /**
  30547. * Called during a bind event
  30548. */
  30549. set onBind(callback: (Mesh: AbstractMesh) => void);
  30550. /**
  30551. * An event triggered when the material is unbound
  30552. */
  30553. get onUnBindObservable(): Observable<Material>;
  30554. protected _onEffectCreatedObservable: Nullable<Observable<{
  30555. effect: Effect;
  30556. subMesh: Nullable<SubMesh>;
  30557. }>>;
  30558. /**
  30559. * An event triggered when the effect is (re)created
  30560. */
  30561. get onEffectCreatedObservable(): Observable<{
  30562. effect: Effect;
  30563. subMesh: Nullable<SubMesh>;
  30564. }>;
  30565. /**
  30566. * Stores the value of the alpha mode
  30567. */
  30568. private _alphaMode;
  30569. /**
  30570. * Sets the value of the alpha mode.
  30571. *
  30572. * | Value | Type | Description |
  30573. * | --- | --- | --- |
  30574. * | 0 | ALPHA_DISABLE | |
  30575. * | 1 | ALPHA_ADD | |
  30576. * | 2 | ALPHA_COMBINE | |
  30577. * | 3 | ALPHA_SUBTRACT | |
  30578. * | 4 | ALPHA_MULTIPLY | |
  30579. * | 5 | ALPHA_MAXIMIZED | |
  30580. * | 6 | ALPHA_ONEONE | |
  30581. * | 7 | ALPHA_PREMULTIPLIED | |
  30582. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30583. * | 9 | ALPHA_INTERPOLATE | |
  30584. * | 10 | ALPHA_SCREENMODE | |
  30585. *
  30586. */
  30587. set alphaMode(value: number);
  30588. /**
  30589. * Gets the value of the alpha mode
  30590. */
  30591. get alphaMode(): number;
  30592. /**
  30593. * Stores the state of the need depth pre-pass value
  30594. */
  30595. private _needDepthPrePass;
  30596. /**
  30597. * Sets the need depth pre-pass value
  30598. */
  30599. set needDepthPrePass(value: boolean);
  30600. /**
  30601. * Gets the depth pre-pass value
  30602. */
  30603. get needDepthPrePass(): boolean;
  30604. /**
  30605. * Specifies if depth writing should be disabled
  30606. */
  30607. disableDepthWrite: boolean;
  30608. /**
  30609. * Specifies if color writing should be disabled
  30610. */
  30611. disableColorWrite: boolean;
  30612. /**
  30613. * Specifies if depth writing should be forced
  30614. */
  30615. forceDepthWrite: boolean;
  30616. /**
  30617. * Specifies the depth function that should be used. 0 means the default engine function
  30618. */
  30619. depthFunction: number;
  30620. /**
  30621. * Specifies if there should be a separate pass for culling
  30622. */
  30623. separateCullingPass: boolean;
  30624. /**
  30625. * Stores the state specifing if fog should be enabled
  30626. */
  30627. private _fogEnabled;
  30628. /**
  30629. * Sets the state for enabling fog
  30630. */
  30631. set fogEnabled(value: boolean);
  30632. /**
  30633. * Gets the value of the fog enabled state
  30634. */
  30635. get fogEnabled(): boolean;
  30636. /**
  30637. * Stores the size of points
  30638. */
  30639. pointSize: number;
  30640. /**
  30641. * Stores the z offset value
  30642. */
  30643. zOffset: number;
  30644. get wireframe(): boolean;
  30645. /**
  30646. * Sets the state of wireframe mode
  30647. */
  30648. set wireframe(value: boolean);
  30649. /**
  30650. * Gets the value specifying if point clouds are enabled
  30651. */
  30652. get pointsCloud(): boolean;
  30653. /**
  30654. * Sets the state of point cloud mode
  30655. */
  30656. set pointsCloud(value: boolean);
  30657. /**
  30658. * Gets the material fill mode
  30659. */
  30660. get fillMode(): number;
  30661. /**
  30662. * Sets the material fill mode
  30663. */
  30664. set fillMode(value: number);
  30665. /**
  30666. * @hidden
  30667. * Stores the effects for the material
  30668. */
  30669. _effect: Nullable<Effect>;
  30670. /**
  30671. * Specifies if uniform buffers should be used
  30672. */
  30673. private _useUBO;
  30674. /**
  30675. * Stores a reference to the scene
  30676. */
  30677. private _scene;
  30678. /**
  30679. * Stores the fill mode state
  30680. */
  30681. private _fillMode;
  30682. /**
  30683. * Specifies if the depth write state should be cached
  30684. */
  30685. private _cachedDepthWriteState;
  30686. /**
  30687. * Specifies if the color write state should be cached
  30688. */
  30689. private _cachedColorWriteState;
  30690. /**
  30691. * Specifies if the depth function state should be cached
  30692. */
  30693. private _cachedDepthFunctionState;
  30694. /**
  30695. * Stores the uniform buffer
  30696. */
  30697. protected _uniformBuffer: UniformBuffer;
  30698. /** @hidden */
  30699. _indexInSceneMaterialArray: number;
  30700. /** @hidden */
  30701. meshMap: Nullable<{
  30702. [id: string]: AbstractMesh | undefined;
  30703. }>;
  30704. /**
  30705. * Creates a material instance
  30706. * @param name defines the name of the material
  30707. * @param scene defines the scene to reference
  30708. * @param doNotAdd specifies if the material should be added to the scene
  30709. */
  30710. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30711. /**
  30712. * Returns a string representation of the current material
  30713. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30714. * @returns a string with material information
  30715. */
  30716. toString(fullDetails?: boolean): string;
  30717. /**
  30718. * Gets the class name of the material
  30719. * @returns a string with the class name of the material
  30720. */
  30721. getClassName(): string;
  30722. /**
  30723. * Specifies if updates for the material been locked
  30724. */
  30725. get isFrozen(): boolean;
  30726. /**
  30727. * Locks updates for the material
  30728. */
  30729. freeze(): void;
  30730. /**
  30731. * Unlocks updates for the material
  30732. */
  30733. unfreeze(): void;
  30734. /**
  30735. * Specifies if the material is ready to be used
  30736. * @param mesh defines the mesh to check
  30737. * @param useInstances specifies if instances should be used
  30738. * @returns a boolean indicating if the material is ready to be used
  30739. */
  30740. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30741. /**
  30742. * Specifies that the submesh is ready to be used
  30743. * @param mesh defines the mesh to check
  30744. * @param subMesh defines which submesh to check
  30745. * @param useInstances specifies that instances should be used
  30746. * @returns a boolean indicating that the submesh is ready or not
  30747. */
  30748. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30749. /**
  30750. * Returns the material effect
  30751. * @returns the effect associated with the material
  30752. */
  30753. getEffect(): Nullable<Effect>;
  30754. /**
  30755. * Returns the current scene
  30756. * @returns a Scene
  30757. */
  30758. getScene(): Scene;
  30759. /**
  30760. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30761. */
  30762. protected _forceAlphaTest: boolean;
  30763. /**
  30764. * The transparency mode of the material.
  30765. */
  30766. protected _transparencyMode: Nullable<number>;
  30767. /**
  30768. * Gets the current transparency mode.
  30769. */
  30770. get transparencyMode(): Nullable<number>;
  30771. /**
  30772. * Sets the transparency mode of the material.
  30773. *
  30774. * | Value | Type | Description |
  30775. * | ----- | ----------------------------------- | ----------- |
  30776. * | 0 | OPAQUE | |
  30777. * | 1 | ALPHATEST | |
  30778. * | 2 | ALPHABLEND | |
  30779. * | 3 | ALPHATESTANDBLEND | |
  30780. *
  30781. */
  30782. set transparencyMode(value: Nullable<number>);
  30783. /**
  30784. * Returns true if alpha blending should be disabled.
  30785. */
  30786. protected get _disableAlphaBlending(): boolean;
  30787. /**
  30788. * Specifies whether or not this material should be rendered in alpha blend mode.
  30789. * @returns a boolean specifying if alpha blending is needed
  30790. */
  30791. needAlphaBlending(): boolean;
  30792. /**
  30793. * Specifies if the mesh will require alpha blending
  30794. * @param mesh defines the mesh to check
  30795. * @returns a boolean specifying if alpha blending is needed for the mesh
  30796. */
  30797. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30798. /**
  30799. * Specifies whether or not this material should be rendered in alpha test mode.
  30800. * @returns a boolean specifying if an alpha test is needed.
  30801. */
  30802. needAlphaTesting(): boolean;
  30803. /**
  30804. * Specifies if material alpha testing should be turned on for the mesh
  30805. * @param mesh defines the mesh to check
  30806. */
  30807. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30808. /**
  30809. * Gets the texture used for the alpha test
  30810. * @returns the texture to use for alpha testing
  30811. */
  30812. getAlphaTestTexture(): Nullable<BaseTexture>;
  30813. /**
  30814. * Marks the material to indicate that it needs to be re-calculated
  30815. */
  30816. markDirty(): void;
  30817. /** @hidden */
  30818. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30819. /**
  30820. * Binds the material to the mesh
  30821. * @param world defines the world transformation matrix
  30822. * @param mesh defines the mesh to bind the material to
  30823. */
  30824. bind(world: Matrix, mesh?: Mesh): void;
  30825. /**
  30826. * Binds the submesh to the material
  30827. * @param world defines the world transformation matrix
  30828. * @param mesh defines the mesh containing the submesh
  30829. * @param subMesh defines the submesh to bind the material to
  30830. */
  30831. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30832. /**
  30833. * Binds the world matrix to the material
  30834. * @param world defines the world transformation matrix
  30835. */
  30836. bindOnlyWorldMatrix(world: Matrix): void;
  30837. /**
  30838. * Binds the scene's uniform buffer to the effect.
  30839. * @param effect defines the effect to bind to the scene uniform buffer
  30840. * @param sceneUbo defines the uniform buffer storing scene data
  30841. */
  30842. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30843. /**
  30844. * Binds the view matrix to the effect
  30845. * @param effect defines the effect to bind the view matrix to
  30846. */
  30847. bindView(effect: Effect): void;
  30848. /**
  30849. * Binds the view projection matrix to the effect
  30850. * @param effect defines the effect to bind the view projection matrix to
  30851. */
  30852. bindViewProjection(effect: Effect): void;
  30853. /**
  30854. * Processes to execute after binding the material to a mesh
  30855. * @param mesh defines the rendered mesh
  30856. */
  30857. protected _afterBind(mesh?: Mesh): void;
  30858. /**
  30859. * Unbinds the material from the mesh
  30860. */
  30861. unbind(): void;
  30862. /**
  30863. * Gets the active textures from the material
  30864. * @returns an array of textures
  30865. */
  30866. getActiveTextures(): BaseTexture[];
  30867. /**
  30868. * Specifies if the material uses a texture
  30869. * @param texture defines the texture to check against the material
  30870. * @returns a boolean specifying if the material uses the texture
  30871. */
  30872. hasTexture(texture: BaseTexture): boolean;
  30873. /**
  30874. * Makes a duplicate of the material, and gives it a new name
  30875. * @param name defines the new name for the duplicated material
  30876. * @returns the cloned material
  30877. */
  30878. clone(name: string): Nullable<Material>;
  30879. /**
  30880. * Gets the meshes bound to the material
  30881. * @returns an array of meshes bound to the material
  30882. */
  30883. getBindedMeshes(): AbstractMesh[];
  30884. /**
  30885. * Force shader compilation
  30886. * @param mesh defines the mesh associated with this material
  30887. * @param onCompiled defines a function to execute once the material is compiled
  30888. * @param options defines the options to configure the compilation
  30889. * @param onError defines a function to execute if the material fails compiling
  30890. */
  30891. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30892. /**
  30893. * Force shader compilation
  30894. * @param mesh defines the mesh that will use this material
  30895. * @param options defines additional options for compiling the shaders
  30896. * @returns a promise that resolves when the compilation completes
  30897. */
  30898. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30899. private static readonly _AllDirtyCallBack;
  30900. private static readonly _ImageProcessingDirtyCallBack;
  30901. private static readonly _TextureDirtyCallBack;
  30902. private static readonly _FresnelDirtyCallBack;
  30903. private static readonly _MiscDirtyCallBack;
  30904. private static readonly _PrePassDirtyCallBack;
  30905. private static readonly _LightsDirtyCallBack;
  30906. private static readonly _AttributeDirtyCallBack;
  30907. private static _FresnelAndMiscDirtyCallBack;
  30908. private static _TextureAndMiscDirtyCallBack;
  30909. private static readonly _DirtyCallbackArray;
  30910. private static readonly _RunDirtyCallBacks;
  30911. /**
  30912. * Marks a define in the material to indicate that it needs to be re-computed
  30913. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30914. */
  30915. markAsDirty(flag: number): void;
  30916. /**
  30917. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30918. * @param func defines a function which checks material defines against the submeshes
  30919. */
  30920. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30921. /**
  30922. * Indicates that the scene should check if the rendering now needs a prepass
  30923. */
  30924. protected _markScenePrePassDirty(): void;
  30925. /**
  30926. * Indicates that we need to re-calculated for all submeshes
  30927. */
  30928. protected _markAllSubMeshesAsAllDirty(): void;
  30929. /**
  30930. * Indicates that image processing needs to be re-calculated for all submeshes
  30931. */
  30932. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30933. /**
  30934. * Indicates that textures need to be re-calculated for all submeshes
  30935. */
  30936. protected _markAllSubMeshesAsTexturesDirty(): void;
  30937. /**
  30938. * Indicates that fresnel needs to be re-calculated for all submeshes
  30939. */
  30940. protected _markAllSubMeshesAsFresnelDirty(): void;
  30941. /**
  30942. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30943. */
  30944. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30945. /**
  30946. * Indicates that lights need to be re-calculated for all submeshes
  30947. */
  30948. protected _markAllSubMeshesAsLightsDirty(): void;
  30949. /**
  30950. * Indicates that attributes need to be re-calculated for all submeshes
  30951. */
  30952. protected _markAllSubMeshesAsAttributesDirty(): void;
  30953. /**
  30954. * Indicates that misc needs to be re-calculated for all submeshes
  30955. */
  30956. protected _markAllSubMeshesAsMiscDirty(): void;
  30957. /**
  30958. * Indicates that prepass needs to be re-calculated for all submeshes
  30959. */
  30960. protected _markAllSubMeshesAsPrePassDirty(): void;
  30961. /**
  30962. * Indicates that textures and misc need to be re-calculated for all submeshes
  30963. */
  30964. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30965. /**
  30966. * Sets the required values to the prepass renderer.
  30967. * @param prePassRenderer defines the prepass renderer to setup.
  30968. * @returns true if the pre pass is needed.
  30969. */
  30970. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30971. /**
  30972. * Disposes the material
  30973. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30974. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30975. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30976. */
  30977. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30978. /** @hidden */
  30979. private releaseVertexArrayObject;
  30980. /**
  30981. * Serializes this material
  30982. * @returns the serialized material object
  30983. */
  30984. serialize(): any;
  30985. /**
  30986. * Creates a material from parsed material data
  30987. * @param parsedMaterial defines parsed material data
  30988. * @param scene defines the hosting scene
  30989. * @param rootUrl defines the root URL to use to load textures
  30990. * @returns a new material
  30991. */
  30992. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30993. }
  30994. }
  30995. declare module "babylonjs/Materials/multiMaterial" {
  30996. import { Nullable } from "babylonjs/types";
  30997. import { Scene } from "babylonjs/scene";
  30998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30999. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31000. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31001. import { Material } from "babylonjs/Materials/material";
  31002. /**
  31003. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31004. * separate meshes. This can be use to improve performances.
  31005. * @see https://doc.babylonjs.com/how_to/multi_materials
  31006. */
  31007. export class MultiMaterial extends Material {
  31008. private _subMaterials;
  31009. /**
  31010. * Gets or Sets the list of Materials used within the multi material.
  31011. * They need to be ordered according to the submeshes order in the associated mesh
  31012. */
  31013. get subMaterials(): Nullable<Material>[];
  31014. set subMaterials(value: Nullable<Material>[]);
  31015. /**
  31016. * Function used to align with Node.getChildren()
  31017. * @returns the list of Materials used within the multi material
  31018. */
  31019. getChildren(): Nullable<Material>[];
  31020. /**
  31021. * Instantiates a new Multi Material
  31022. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31023. * separate meshes. This can be use to improve performances.
  31024. * @see https://doc.babylonjs.com/how_to/multi_materials
  31025. * @param name Define the name in the scene
  31026. * @param scene Define the scene the material belongs to
  31027. */
  31028. constructor(name: string, scene: Scene);
  31029. private _hookArray;
  31030. /**
  31031. * Get one of the submaterial by its index in the submaterials array
  31032. * @param index The index to look the sub material at
  31033. * @returns The Material if the index has been defined
  31034. */
  31035. getSubMaterial(index: number): Nullable<Material>;
  31036. /**
  31037. * Get the list of active textures for the whole sub materials list.
  31038. * @returns All the textures that will be used during the rendering
  31039. */
  31040. getActiveTextures(): BaseTexture[];
  31041. /**
  31042. * Gets the current class name of the material e.g. "MultiMaterial"
  31043. * Mainly use in serialization.
  31044. * @returns the class name
  31045. */
  31046. getClassName(): string;
  31047. /**
  31048. * Checks if the material is ready to render the requested sub mesh
  31049. * @param mesh Define the mesh the submesh belongs to
  31050. * @param subMesh Define the sub mesh to look readyness for
  31051. * @param useInstances Define whether or not the material is used with instances
  31052. * @returns true if ready, otherwise false
  31053. */
  31054. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31055. /**
  31056. * Clones the current material and its related sub materials
  31057. * @param name Define the name of the newly cloned material
  31058. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31059. * @returns the cloned material
  31060. */
  31061. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31062. /**
  31063. * Serializes the materials into a JSON representation.
  31064. * @returns the JSON representation
  31065. */
  31066. serialize(): any;
  31067. /**
  31068. * Dispose the material and release its associated resources
  31069. * @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)
  31070. * @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)
  31071. * @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)
  31072. */
  31073. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31074. /**
  31075. * Creates a MultiMaterial from parsed MultiMaterial data.
  31076. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31077. * @param scene defines the hosting scene
  31078. * @returns a new MultiMaterial
  31079. */
  31080. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31081. }
  31082. }
  31083. declare module "babylonjs/Meshes/subMesh" {
  31084. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  31085. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  31086. import { Engine } from "babylonjs/Engines/engine";
  31087. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  31088. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31089. import { Effect } from "babylonjs/Materials/effect";
  31090. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31091. import { Plane } from "babylonjs/Maths/math.plane";
  31092. import { Collider } from "babylonjs/Collisions/collider";
  31093. import { Material } from "babylonjs/Materials/material";
  31094. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31096. import { Mesh } from "babylonjs/Meshes/mesh";
  31097. import { Ray } from "babylonjs/Culling/ray";
  31098. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31099. /**
  31100. * Defines a subdivision inside a mesh
  31101. */
  31102. export class SubMesh implements ICullable {
  31103. /** the material index to use */
  31104. materialIndex: number;
  31105. /** vertex index start */
  31106. verticesStart: number;
  31107. /** vertices count */
  31108. verticesCount: number;
  31109. /** index start */
  31110. indexStart: number;
  31111. /** indices count */
  31112. indexCount: number;
  31113. /** @hidden */
  31114. _materialDefines: Nullable<MaterialDefines>;
  31115. /** @hidden */
  31116. _materialEffect: Nullable<Effect>;
  31117. /** @hidden */
  31118. _effectOverride: Nullable<Effect>;
  31119. /**
  31120. * Gets material defines used by the effect associated to the sub mesh
  31121. */
  31122. get materialDefines(): Nullable<MaterialDefines>;
  31123. /**
  31124. * Sets material defines used by the effect associated to the sub mesh
  31125. */
  31126. set materialDefines(defines: Nullable<MaterialDefines>);
  31127. /**
  31128. * Gets associated effect
  31129. */
  31130. get effect(): Nullable<Effect>;
  31131. /**
  31132. * Sets associated effect (effect used to render this submesh)
  31133. * @param effect defines the effect to associate with
  31134. * @param defines defines the set of defines used to compile this effect
  31135. */
  31136. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31137. /** @hidden */
  31138. _linesIndexCount: number;
  31139. private _mesh;
  31140. private _renderingMesh;
  31141. private _boundingInfo;
  31142. private _linesIndexBuffer;
  31143. /** @hidden */
  31144. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31145. /** @hidden */
  31146. _trianglePlanes: Plane[];
  31147. /** @hidden */
  31148. _lastColliderTransformMatrix: Nullable<Matrix>;
  31149. /** @hidden */
  31150. _renderId: number;
  31151. /** @hidden */
  31152. _alphaIndex: number;
  31153. /** @hidden */
  31154. _distanceToCamera: number;
  31155. /** @hidden */
  31156. _id: number;
  31157. private _currentMaterial;
  31158. /**
  31159. * Add a new submesh to a mesh
  31160. * @param materialIndex defines the material index to use
  31161. * @param verticesStart defines vertex index start
  31162. * @param verticesCount defines vertices count
  31163. * @param indexStart defines index start
  31164. * @param indexCount defines indices count
  31165. * @param mesh defines the parent mesh
  31166. * @param renderingMesh defines an optional rendering mesh
  31167. * @param createBoundingBox defines if bounding box should be created for this submesh
  31168. * @returns the new submesh
  31169. */
  31170. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31171. /**
  31172. * Creates a new submesh
  31173. * @param materialIndex defines the material index to use
  31174. * @param verticesStart defines vertex index start
  31175. * @param verticesCount defines vertices count
  31176. * @param indexStart defines index start
  31177. * @param indexCount defines indices count
  31178. * @param mesh defines the parent mesh
  31179. * @param renderingMesh defines an optional rendering mesh
  31180. * @param createBoundingBox defines if bounding box should be created for this submesh
  31181. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31182. */
  31183. constructor(
  31184. /** the material index to use */
  31185. materialIndex: number,
  31186. /** vertex index start */
  31187. verticesStart: number,
  31188. /** vertices count */
  31189. verticesCount: number,
  31190. /** index start */
  31191. indexStart: number,
  31192. /** indices count */
  31193. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31194. /**
  31195. * Returns true if this submesh covers the entire parent mesh
  31196. * @ignorenaming
  31197. */
  31198. get IsGlobal(): boolean;
  31199. /**
  31200. * Returns the submesh BoudingInfo object
  31201. * @returns current bounding info (or mesh's one if the submesh is global)
  31202. */
  31203. getBoundingInfo(): BoundingInfo;
  31204. /**
  31205. * Sets the submesh BoundingInfo
  31206. * @param boundingInfo defines the new bounding info to use
  31207. * @returns the SubMesh
  31208. */
  31209. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31210. /**
  31211. * Returns the mesh of the current submesh
  31212. * @return the parent mesh
  31213. */
  31214. getMesh(): AbstractMesh;
  31215. /**
  31216. * Returns the rendering mesh of the submesh
  31217. * @returns the rendering mesh (could be different from parent mesh)
  31218. */
  31219. getRenderingMesh(): Mesh;
  31220. /**
  31221. * Returns the replacement mesh of the submesh
  31222. * @returns the replacement mesh (could be different from parent mesh)
  31223. */
  31224. getReplacementMesh(): Nullable<AbstractMesh>;
  31225. /**
  31226. * Returns the effective mesh of the submesh
  31227. * @returns the effective mesh (could be different from parent mesh)
  31228. */
  31229. getEffectiveMesh(): AbstractMesh;
  31230. /**
  31231. * Returns the submesh material
  31232. * @returns null or the current material
  31233. */
  31234. getMaterial(): Nullable<Material>;
  31235. private _IsMultiMaterial;
  31236. /**
  31237. * Sets a new updated BoundingInfo object to the submesh
  31238. * @param data defines an optional position array to use to determine the bounding info
  31239. * @returns the SubMesh
  31240. */
  31241. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31242. /** @hidden */
  31243. _checkCollision(collider: Collider): boolean;
  31244. /**
  31245. * Updates the submesh BoundingInfo
  31246. * @param world defines the world matrix to use to update the bounding info
  31247. * @returns the submesh
  31248. */
  31249. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31250. /**
  31251. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31252. * @param frustumPlanes defines the frustum planes
  31253. * @returns true if the submesh is intersecting with the frustum
  31254. */
  31255. isInFrustum(frustumPlanes: Plane[]): boolean;
  31256. /**
  31257. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31258. * @param frustumPlanes defines the frustum planes
  31259. * @returns true if the submesh is inside the frustum
  31260. */
  31261. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31262. /**
  31263. * Renders the submesh
  31264. * @param enableAlphaMode defines if alpha needs to be used
  31265. * @returns the submesh
  31266. */
  31267. render(enableAlphaMode: boolean): SubMesh;
  31268. /**
  31269. * @hidden
  31270. */
  31271. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31272. /**
  31273. * Checks if the submesh intersects with a ray
  31274. * @param ray defines the ray to test
  31275. * @returns true is the passed ray intersects the submesh bounding box
  31276. */
  31277. canIntersects(ray: Ray): boolean;
  31278. /**
  31279. * Intersects current submesh with a ray
  31280. * @param ray defines the ray to test
  31281. * @param positions defines mesh's positions array
  31282. * @param indices defines mesh's indices array
  31283. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31284. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31285. * @returns intersection info or null if no intersection
  31286. */
  31287. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31288. /** @hidden */
  31289. private _intersectLines;
  31290. /** @hidden */
  31291. private _intersectUnIndexedLines;
  31292. /** @hidden */
  31293. private _intersectTriangles;
  31294. /** @hidden */
  31295. private _intersectUnIndexedTriangles;
  31296. /** @hidden */
  31297. _rebuild(): void;
  31298. /**
  31299. * Creates a new submesh from the passed mesh
  31300. * @param newMesh defines the new hosting mesh
  31301. * @param newRenderingMesh defines an optional rendering mesh
  31302. * @returns the new submesh
  31303. */
  31304. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31305. /**
  31306. * Release associated resources
  31307. */
  31308. dispose(): void;
  31309. /**
  31310. * Gets the class name
  31311. * @returns the string "SubMesh".
  31312. */
  31313. getClassName(): string;
  31314. /**
  31315. * Creates a new submesh from indices data
  31316. * @param materialIndex the index of the main mesh material
  31317. * @param startIndex the index where to start the copy in the mesh indices array
  31318. * @param indexCount the number of indices to copy then from the startIndex
  31319. * @param mesh the main mesh to create the submesh from
  31320. * @param renderingMesh the optional rendering mesh
  31321. * @returns a new submesh
  31322. */
  31323. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31324. }
  31325. }
  31326. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31327. /**
  31328. * Class used to represent data loading progression
  31329. */
  31330. export class SceneLoaderFlags {
  31331. private static _ForceFullSceneLoadingForIncremental;
  31332. private static _ShowLoadingScreen;
  31333. private static _CleanBoneMatrixWeights;
  31334. private static _loggingLevel;
  31335. /**
  31336. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31337. */
  31338. static get ForceFullSceneLoadingForIncremental(): boolean;
  31339. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31340. /**
  31341. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31342. */
  31343. static get ShowLoadingScreen(): boolean;
  31344. static set ShowLoadingScreen(value: boolean);
  31345. /**
  31346. * Defines the current logging level (while loading the scene)
  31347. * @ignorenaming
  31348. */
  31349. static get loggingLevel(): number;
  31350. static set loggingLevel(value: number);
  31351. /**
  31352. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31353. */
  31354. static get CleanBoneMatrixWeights(): boolean;
  31355. static set CleanBoneMatrixWeights(value: boolean);
  31356. }
  31357. }
  31358. declare module "babylonjs/Meshes/geometry" {
  31359. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31360. import { Scene } from "babylonjs/scene";
  31361. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31362. import { Engine } from "babylonjs/Engines/engine";
  31363. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31364. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31365. import { Effect } from "babylonjs/Materials/effect";
  31366. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31367. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31368. import { Mesh } from "babylonjs/Meshes/mesh";
  31369. /**
  31370. * Class used to store geometry data (vertex buffers + index buffer)
  31371. */
  31372. export class Geometry implements IGetSetVerticesData {
  31373. /**
  31374. * Gets or sets the ID of the geometry
  31375. */
  31376. id: string;
  31377. /**
  31378. * Gets or sets the unique ID of the geometry
  31379. */
  31380. uniqueId: number;
  31381. /**
  31382. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31383. */
  31384. delayLoadState: number;
  31385. /**
  31386. * Gets the file containing the data to load when running in delay load state
  31387. */
  31388. delayLoadingFile: Nullable<string>;
  31389. /**
  31390. * Callback called when the geometry is updated
  31391. */
  31392. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31393. private _scene;
  31394. private _engine;
  31395. private _meshes;
  31396. private _totalVertices;
  31397. /** @hidden */
  31398. _indices: IndicesArray;
  31399. /** @hidden */
  31400. _vertexBuffers: {
  31401. [key: string]: VertexBuffer;
  31402. };
  31403. private _isDisposed;
  31404. private _extend;
  31405. private _boundingBias;
  31406. /** @hidden */
  31407. _delayInfo: Array<string>;
  31408. private _indexBuffer;
  31409. private _indexBufferIsUpdatable;
  31410. /** @hidden */
  31411. _boundingInfo: Nullable<BoundingInfo>;
  31412. /** @hidden */
  31413. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31414. /** @hidden */
  31415. _softwareSkinningFrameId: number;
  31416. private _vertexArrayObjects;
  31417. private _updatable;
  31418. /** @hidden */
  31419. _positions: Nullable<Vector3[]>;
  31420. private _positionsCache;
  31421. /**
  31422. * 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
  31423. */
  31424. get boundingBias(): Vector2;
  31425. /**
  31426. * 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
  31427. */
  31428. set boundingBias(value: Vector2);
  31429. /**
  31430. * Static function used to attach a new empty geometry to a mesh
  31431. * @param mesh defines the mesh to attach the geometry to
  31432. * @returns the new Geometry
  31433. */
  31434. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31435. /** Get the list of meshes using this geometry */
  31436. get meshes(): Mesh[];
  31437. /**
  31438. * 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
  31439. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31440. */
  31441. useBoundingInfoFromGeometry: boolean;
  31442. /**
  31443. * Creates a new geometry
  31444. * @param id defines the unique ID
  31445. * @param scene defines the hosting scene
  31446. * @param vertexData defines the VertexData used to get geometry data
  31447. * @param updatable defines if geometry must be updatable (false by default)
  31448. * @param mesh defines the mesh that will be associated with the geometry
  31449. */
  31450. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31451. /**
  31452. * Gets the current extend of the geometry
  31453. */
  31454. get extend(): {
  31455. minimum: Vector3;
  31456. maximum: Vector3;
  31457. };
  31458. /**
  31459. * Gets the hosting scene
  31460. * @returns the hosting Scene
  31461. */
  31462. getScene(): Scene;
  31463. /**
  31464. * Gets the hosting engine
  31465. * @returns the hosting Engine
  31466. */
  31467. getEngine(): Engine;
  31468. /**
  31469. * Defines if the geometry is ready to use
  31470. * @returns true if the geometry is ready to be used
  31471. */
  31472. isReady(): boolean;
  31473. /**
  31474. * Gets a value indicating that the geometry should not be serialized
  31475. */
  31476. get doNotSerialize(): boolean;
  31477. /** @hidden */
  31478. _rebuild(): void;
  31479. /**
  31480. * Affects all geometry data in one call
  31481. * @param vertexData defines the geometry data
  31482. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31483. */
  31484. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31485. /**
  31486. * Set specific vertex data
  31487. * @param kind defines the data kind (Position, normal, etc...)
  31488. * @param data defines the vertex data to use
  31489. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31490. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31491. */
  31492. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31493. /**
  31494. * Removes a specific vertex data
  31495. * @param kind defines the data kind (Position, normal, etc...)
  31496. */
  31497. removeVerticesData(kind: string): void;
  31498. /**
  31499. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31500. * @param buffer defines the vertex buffer to use
  31501. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31502. */
  31503. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31504. /**
  31505. * Update a specific vertex buffer
  31506. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31507. * It will do nothing if the buffer is not updatable
  31508. * @param kind defines the data kind (Position, normal, etc...)
  31509. * @param data defines the data to use
  31510. * @param offset defines the offset in the target buffer where to store the data
  31511. * @param useBytes set to true if the offset is in bytes
  31512. */
  31513. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31514. /**
  31515. * Update a specific vertex buffer
  31516. * This function will create a new buffer if the current one is not updatable
  31517. * @param kind defines the data kind (Position, normal, etc...)
  31518. * @param data defines the data to use
  31519. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31520. */
  31521. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31522. private _updateBoundingInfo;
  31523. /** @hidden */
  31524. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31525. /**
  31526. * Gets total number of vertices
  31527. * @returns the total number of vertices
  31528. */
  31529. getTotalVertices(): number;
  31530. /**
  31531. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31532. * @param kind defines the data kind (Position, normal, etc...)
  31533. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31534. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31535. * @returns a float array containing vertex data
  31536. */
  31537. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31538. /**
  31539. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31540. * @param kind defines the data kind (Position, normal, etc...)
  31541. * @returns true if the vertex buffer with the specified kind is updatable
  31542. */
  31543. isVertexBufferUpdatable(kind: string): boolean;
  31544. /**
  31545. * Gets a specific vertex buffer
  31546. * @param kind defines the data kind (Position, normal, etc...)
  31547. * @returns a VertexBuffer
  31548. */
  31549. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31550. /**
  31551. * Returns all vertex buffers
  31552. * @return an object holding all vertex buffers indexed by kind
  31553. */
  31554. getVertexBuffers(): Nullable<{
  31555. [key: string]: VertexBuffer;
  31556. }>;
  31557. /**
  31558. * Gets a boolean indicating if specific vertex buffer is present
  31559. * @param kind defines the data kind (Position, normal, etc...)
  31560. * @returns true if data is present
  31561. */
  31562. isVerticesDataPresent(kind: string): boolean;
  31563. /**
  31564. * Gets a list of all attached data kinds (Position, normal, etc...)
  31565. * @returns a list of string containing all kinds
  31566. */
  31567. getVerticesDataKinds(): string[];
  31568. /**
  31569. * Update index buffer
  31570. * @param indices defines the indices to store in the index buffer
  31571. * @param offset defines the offset in the target buffer where to store the data
  31572. * @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)
  31573. */
  31574. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31575. /**
  31576. * Creates a new index buffer
  31577. * @param indices defines the indices to store in the index buffer
  31578. * @param totalVertices defines the total number of vertices (could be null)
  31579. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31580. */
  31581. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31582. /**
  31583. * Return the total number of indices
  31584. * @returns the total number of indices
  31585. */
  31586. getTotalIndices(): number;
  31587. /**
  31588. * Gets the index buffer array
  31589. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31590. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31591. * @returns the index buffer array
  31592. */
  31593. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31594. /**
  31595. * Gets the index buffer
  31596. * @return the index buffer
  31597. */
  31598. getIndexBuffer(): Nullable<DataBuffer>;
  31599. /** @hidden */
  31600. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31601. /**
  31602. * Release the associated resources for a specific mesh
  31603. * @param mesh defines the source mesh
  31604. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31605. */
  31606. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31607. /**
  31608. * Apply current geometry to a given mesh
  31609. * @param mesh defines the mesh to apply geometry to
  31610. */
  31611. applyToMesh(mesh: Mesh): void;
  31612. private _updateExtend;
  31613. private _applyToMesh;
  31614. private notifyUpdate;
  31615. /**
  31616. * Load the geometry if it was flagged as delay loaded
  31617. * @param scene defines the hosting scene
  31618. * @param onLoaded defines a callback called when the geometry is loaded
  31619. */
  31620. load(scene: Scene, onLoaded?: () => void): void;
  31621. private _queueLoad;
  31622. /**
  31623. * Invert the geometry to move from a right handed system to a left handed one.
  31624. */
  31625. toLeftHanded(): void;
  31626. /** @hidden */
  31627. _resetPointsArrayCache(): void;
  31628. /** @hidden */
  31629. _generatePointsArray(): boolean;
  31630. /**
  31631. * Gets a value indicating if the geometry is disposed
  31632. * @returns true if the geometry was disposed
  31633. */
  31634. isDisposed(): boolean;
  31635. private _disposeVertexArrayObjects;
  31636. /**
  31637. * Free all associated resources
  31638. */
  31639. dispose(): void;
  31640. /**
  31641. * Clone the current geometry into a new geometry
  31642. * @param id defines the unique ID of the new geometry
  31643. * @returns a new geometry object
  31644. */
  31645. copy(id: string): Geometry;
  31646. /**
  31647. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31648. * @return a JSON representation of the current geometry data (without the vertices data)
  31649. */
  31650. serialize(): any;
  31651. private toNumberArray;
  31652. /**
  31653. * Serialize all vertices data into a JSON oject
  31654. * @returns a JSON representation of the current geometry data
  31655. */
  31656. serializeVerticeData(): any;
  31657. /**
  31658. * Extracts a clone of a mesh geometry
  31659. * @param mesh defines the source mesh
  31660. * @param id defines the unique ID of the new geometry object
  31661. * @returns the new geometry object
  31662. */
  31663. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31664. /**
  31665. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31666. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31667. * Be aware Math.random() could cause collisions, but:
  31668. * "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"
  31669. * @returns a string containing a new GUID
  31670. */
  31671. static RandomId(): string;
  31672. /** @hidden */
  31673. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31674. private static _CleanMatricesWeights;
  31675. /**
  31676. * Create a new geometry from persisted data (Using .babylon file format)
  31677. * @param parsedVertexData defines the persisted data
  31678. * @param scene defines the hosting scene
  31679. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31680. * @returns the new geometry object
  31681. */
  31682. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31683. }
  31684. }
  31685. declare module "babylonjs/Meshes/mesh.vertexData" {
  31686. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  31687. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  31688. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  31689. import { Geometry } from "babylonjs/Meshes/geometry";
  31690. import { Mesh } from "babylonjs/Meshes/mesh";
  31691. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  31692. /**
  31693. * Define an interface for all classes that will get and set the data on vertices
  31694. */
  31695. export interface IGetSetVerticesData {
  31696. /**
  31697. * Gets a boolean indicating if specific vertex data is present
  31698. * @param kind defines the vertex data kind to use
  31699. * @returns true is data kind is present
  31700. */
  31701. isVerticesDataPresent(kind: string): boolean;
  31702. /**
  31703. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31704. * @param kind defines the data kind (Position, normal, etc...)
  31705. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31706. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31707. * @returns a float array containing vertex data
  31708. */
  31709. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31710. /**
  31711. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  31712. * @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.
  31713. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31714. * @returns the indices array or an empty array if the mesh has no geometry
  31715. */
  31716. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31717. /**
  31718. * Set specific vertex data
  31719. * @param kind defines the data kind (Position, normal, etc...)
  31720. * @param data defines the vertex data to use
  31721. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31722. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31723. */
  31724. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  31725. /**
  31726. * Update a specific associated vertex buffer
  31727. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  31728. * - VertexBuffer.PositionKind
  31729. * - VertexBuffer.UVKind
  31730. * - VertexBuffer.UV2Kind
  31731. * - VertexBuffer.UV3Kind
  31732. * - VertexBuffer.UV4Kind
  31733. * - VertexBuffer.UV5Kind
  31734. * - VertexBuffer.UV6Kind
  31735. * - VertexBuffer.ColorKind
  31736. * - VertexBuffer.MatricesIndicesKind
  31737. * - VertexBuffer.MatricesIndicesExtraKind
  31738. * - VertexBuffer.MatricesWeightsKind
  31739. * - VertexBuffer.MatricesWeightsExtraKind
  31740. * @param data defines the data source
  31741. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  31742. * @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)
  31743. */
  31744. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  31745. /**
  31746. * Creates a new index buffer
  31747. * @param indices defines the indices to store in the index buffer
  31748. * @param totalVertices defines the total number of vertices (could be null)
  31749. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31750. */
  31751. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  31752. }
  31753. /**
  31754. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  31755. */
  31756. export class VertexData {
  31757. /**
  31758. * Mesh side orientation : usually the external or front surface
  31759. */
  31760. static readonly FRONTSIDE: number;
  31761. /**
  31762. * Mesh side orientation : usually the internal or back surface
  31763. */
  31764. static readonly BACKSIDE: number;
  31765. /**
  31766. * Mesh side orientation : both internal and external or front and back surfaces
  31767. */
  31768. static readonly DOUBLESIDE: number;
  31769. /**
  31770. * Mesh side orientation : by default, `FRONTSIDE`
  31771. */
  31772. static readonly DEFAULTSIDE: number;
  31773. /**
  31774. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  31775. */
  31776. positions: Nullable<FloatArray>;
  31777. /**
  31778. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  31779. */
  31780. normals: Nullable<FloatArray>;
  31781. /**
  31782. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  31783. */
  31784. tangents: Nullable<FloatArray>;
  31785. /**
  31786. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31787. */
  31788. uvs: Nullable<FloatArray>;
  31789. /**
  31790. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31791. */
  31792. uvs2: Nullable<FloatArray>;
  31793. /**
  31794. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31795. */
  31796. uvs3: Nullable<FloatArray>;
  31797. /**
  31798. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31799. */
  31800. uvs4: Nullable<FloatArray>;
  31801. /**
  31802. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31803. */
  31804. uvs5: Nullable<FloatArray>;
  31805. /**
  31806. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31807. */
  31808. uvs6: Nullable<FloatArray>;
  31809. /**
  31810. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  31811. */
  31812. colors: Nullable<FloatArray>;
  31813. /**
  31814. * 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).
  31815. */
  31816. matricesIndices: Nullable<FloatArray>;
  31817. /**
  31818. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  31819. */
  31820. matricesWeights: Nullable<FloatArray>;
  31821. /**
  31822. * An array extending the number of possible indices
  31823. */
  31824. matricesIndicesExtra: Nullable<FloatArray>;
  31825. /**
  31826. * An array extending the number of possible weights when the number of indices is extended
  31827. */
  31828. matricesWeightsExtra: Nullable<FloatArray>;
  31829. /**
  31830. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  31831. */
  31832. indices: Nullable<IndicesArray>;
  31833. /**
  31834. * Uses the passed data array to set the set the values for the specified kind of data
  31835. * @param data a linear array of floating numbers
  31836. * @param kind the type of data that is being set, eg positions, colors etc
  31837. */
  31838. set(data: FloatArray, kind: string): void;
  31839. /**
  31840. * Associates the vertexData to the passed Mesh.
  31841. * Sets it as updatable or not (default `false`)
  31842. * @param mesh the mesh the vertexData is applied to
  31843. * @param updatable when used and having the value true allows new data to update the vertexData
  31844. * @returns the VertexData
  31845. */
  31846. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  31847. /**
  31848. * Associates the vertexData to the passed Geometry.
  31849. * Sets it as updatable or not (default `false`)
  31850. * @param geometry the geometry the vertexData is applied to
  31851. * @param updatable when used and having the value true allows new data to update the vertexData
  31852. * @returns VertexData
  31853. */
  31854. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  31855. /**
  31856. * Updates the associated mesh
  31857. * @param mesh the mesh to be updated
  31858. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31859. * @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
  31860. * @returns VertexData
  31861. */
  31862. updateMesh(mesh: Mesh): VertexData;
  31863. /**
  31864. * Updates the associated geometry
  31865. * @param geometry the geometry to be updated
  31866. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31867. * @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
  31868. * @returns VertexData.
  31869. */
  31870. updateGeometry(geometry: Geometry): VertexData;
  31871. private _applyTo;
  31872. private _update;
  31873. /**
  31874. * Transforms each position and each normal of the vertexData according to the passed Matrix
  31875. * @param matrix the transforming matrix
  31876. * @returns the VertexData
  31877. */
  31878. transform(matrix: Matrix): VertexData;
  31879. /**
  31880. * Merges the passed VertexData into the current one
  31881. * @param other the VertexData to be merged into the current one
  31882. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  31883. * @returns the modified VertexData
  31884. */
  31885. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  31886. private _mergeElement;
  31887. private _validate;
  31888. /**
  31889. * Serializes the VertexData
  31890. * @returns a serialized object
  31891. */
  31892. serialize(): any;
  31893. /**
  31894. * Extracts the vertexData from a mesh
  31895. * @param mesh the mesh from which to extract the VertexData
  31896. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  31897. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31898. * @returns the object VertexData associated to the passed mesh
  31899. */
  31900. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31901. /**
  31902. * Extracts the vertexData from the geometry
  31903. * @param geometry the geometry from which to extract the VertexData
  31904. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  31905. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31906. * @returns the object VertexData associated to the passed mesh
  31907. */
  31908. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31909. private static _ExtractFrom;
  31910. /**
  31911. * Creates the VertexData for a Ribbon
  31912. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  31913. * * pathArray array of paths, each of which an array of successive Vector3
  31914. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  31915. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  31916. * * 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
  31917. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31918. * * 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)
  31919. * * 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)
  31920. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  31921. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  31922. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  31923. * @returns the VertexData of the ribbon
  31924. */
  31925. static CreateRibbon(options: {
  31926. pathArray: Vector3[][];
  31927. closeArray?: boolean;
  31928. closePath?: boolean;
  31929. offset?: number;
  31930. sideOrientation?: number;
  31931. frontUVs?: Vector4;
  31932. backUVs?: Vector4;
  31933. invertUV?: boolean;
  31934. uvs?: Vector2[];
  31935. colors?: Color4[];
  31936. }): VertexData;
  31937. /**
  31938. * Creates the VertexData for a box
  31939. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31940. * * size sets the width, height and depth of the box to the value of size, optional default 1
  31941. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  31942. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  31943. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  31944. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31945. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31946. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31947. * * 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)
  31948. * * 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)
  31949. * @returns the VertexData of the box
  31950. */
  31951. static CreateBox(options: {
  31952. size?: number;
  31953. width?: number;
  31954. height?: number;
  31955. depth?: number;
  31956. faceUV?: Vector4[];
  31957. faceColors?: Color4[];
  31958. sideOrientation?: number;
  31959. frontUVs?: Vector4;
  31960. backUVs?: Vector4;
  31961. }): VertexData;
  31962. /**
  31963. * Creates the VertexData for a tiled box
  31964. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31965. * * faceTiles sets the pattern, tile size and number of tiles for a face
  31966. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31967. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31968. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31969. * @returns the VertexData of the box
  31970. */
  31971. static CreateTiledBox(options: {
  31972. pattern?: number;
  31973. width?: number;
  31974. height?: number;
  31975. depth?: number;
  31976. tileSize?: number;
  31977. tileWidth?: number;
  31978. tileHeight?: number;
  31979. alignHorizontal?: number;
  31980. alignVertical?: number;
  31981. faceUV?: Vector4[];
  31982. faceColors?: Color4[];
  31983. sideOrientation?: number;
  31984. }): VertexData;
  31985. /**
  31986. * Creates the VertexData for a tiled plane
  31987. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31988. * * pattern a limited pattern arrangement depending on the number
  31989. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  31990. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  31991. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  31992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31993. * * 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)
  31994. * * 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)
  31995. * @returns the VertexData of the tiled plane
  31996. */
  31997. static CreateTiledPlane(options: {
  31998. pattern?: number;
  31999. tileSize?: number;
  32000. tileWidth?: number;
  32001. tileHeight?: number;
  32002. size?: number;
  32003. width?: number;
  32004. height?: number;
  32005. alignHorizontal?: number;
  32006. alignVertical?: number;
  32007. sideOrientation?: number;
  32008. frontUVs?: Vector4;
  32009. backUVs?: Vector4;
  32010. }): VertexData;
  32011. /**
  32012. * Creates the VertexData for an ellipsoid, defaults to a sphere
  32013. * @param options an object used to set the following optional parameters for the box, required but can be empty
  32014. * * segments sets the number of horizontal strips optional, default 32
  32015. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  32016. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  32017. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  32018. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  32019. * * 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
  32020. * * 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
  32021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32022. * * 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)
  32023. * * 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)
  32024. * @returns the VertexData of the ellipsoid
  32025. */
  32026. static CreateSphere(options: {
  32027. segments?: number;
  32028. diameter?: number;
  32029. diameterX?: number;
  32030. diameterY?: number;
  32031. diameterZ?: number;
  32032. arc?: number;
  32033. slice?: number;
  32034. sideOrientation?: number;
  32035. frontUVs?: Vector4;
  32036. backUVs?: Vector4;
  32037. }): VertexData;
  32038. /**
  32039. * Creates the VertexData for a cylinder, cone or prism
  32040. * @param options an object used to set the following optional parameters for the box, required but can be empty
  32041. * * height sets the height (y direction) of the cylinder, optional, default 2
  32042. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  32043. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  32044. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  32045. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  32046. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  32047. * * 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
  32048. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  32049. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  32050. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  32051. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  32052. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32053. * * 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)
  32054. * * 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)
  32055. * @returns the VertexData of the cylinder, cone or prism
  32056. */
  32057. static CreateCylinder(options: {
  32058. height?: number;
  32059. diameterTop?: number;
  32060. diameterBottom?: number;
  32061. diameter?: number;
  32062. tessellation?: number;
  32063. subdivisions?: number;
  32064. arc?: number;
  32065. faceColors?: Color4[];
  32066. faceUV?: Vector4[];
  32067. hasRings?: boolean;
  32068. enclose?: boolean;
  32069. sideOrientation?: number;
  32070. frontUVs?: Vector4;
  32071. backUVs?: Vector4;
  32072. }): VertexData;
  32073. /**
  32074. * Creates the VertexData for a torus
  32075. * @param options an object used to set the following optional parameters for the box, required but can be empty
  32076. * * diameter the diameter of the torus, optional default 1
  32077. * * thickness the diameter of the tube forming the torus, optional default 0.5
  32078. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  32079. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32080. * * 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)
  32081. * * 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)
  32082. * @returns the VertexData of the torus
  32083. */
  32084. static CreateTorus(options: {
  32085. diameter?: number;
  32086. thickness?: number;
  32087. tessellation?: number;
  32088. sideOrientation?: number;
  32089. frontUVs?: Vector4;
  32090. backUVs?: Vector4;
  32091. }): VertexData;
  32092. /**
  32093. * Creates the VertexData of the LineSystem
  32094. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  32095. * - lines an array of lines, each line being an array of successive Vector3
  32096. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  32097. * @returns the VertexData of the LineSystem
  32098. */
  32099. static CreateLineSystem(options: {
  32100. lines: Vector3[][];
  32101. colors?: Nullable<Color4[][]>;
  32102. }): VertexData;
  32103. /**
  32104. * Create the VertexData for a DashedLines
  32105. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  32106. * - points an array successive Vector3
  32107. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  32108. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  32109. * - dashNb the intended total number of dashes, optional, default 200
  32110. * @returns the VertexData for the DashedLines
  32111. */
  32112. static CreateDashedLines(options: {
  32113. points: Vector3[];
  32114. dashSize?: number;
  32115. gapSize?: number;
  32116. dashNb?: number;
  32117. }): VertexData;
  32118. /**
  32119. * Creates the VertexData for a Ground
  32120. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  32121. * - width the width (x direction) of the ground, optional, default 1
  32122. * - height the height (z direction) of the ground, optional, default 1
  32123. * - subdivisions the number of subdivisions per side, optional, default 1
  32124. * @returns the VertexData of the Ground
  32125. */
  32126. static CreateGround(options: {
  32127. width?: number;
  32128. height?: number;
  32129. subdivisions?: number;
  32130. subdivisionsX?: number;
  32131. subdivisionsY?: number;
  32132. }): VertexData;
  32133. /**
  32134. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  32135. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  32136. * * xmin the ground minimum X coordinate, optional, default -1
  32137. * * zmin the ground minimum Z coordinate, optional, default -1
  32138. * * xmax the ground maximum X coordinate, optional, default 1
  32139. * * zmax the ground maximum Z coordinate, optional, default 1
  32140. * * 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}
  32141. * * 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}
  32142. * @returns the VertexData of the TiledGround
  32143. */
  32144. static CreateTiledGround(options: {
  32145. xmin: number;
  32146. zmin: number;
  32147. xmax: number;
  32148. zmax: number;
  32149. subdivisions?: {
  32150. w: number;
  32151. h: number;
  32152. };
  32153. precision?: {
  32154. w: number;
  32155. h: number;
  32156. };
  32157. }): VertexData;
  32158. /**
  32159. * Creates the VertexData of the Ground designed from a heightmap
  32160. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  32161. * * width the width (x direction) of the ground
  32162. * * height the height (z direction) of the ground
  32163. * * subdivisions the number of subdivisions per side
  32164. * * minHeight the minimum altitude on the ground, optional, default 0
  32165. * * maxHeight the maximum altitude on the ground, optional default 1
  32166. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  32167. * * buffer the array holding the image color data
  32168. * * bufferWidth the width of image
  32169. * * bufferHeight the height of image
  32170. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  32171. * @returns the VertexData of the Ground designed from a heightmap
  32172. */
  32173. static CreateGroundFromHeightMap(options: {
  32174. width: number;
  32175. height: number;
  32176. subdivisions: number;
  32177. minHeight: number;
  32178. maxHeight: number;
  32179. colorFilter: Color3;
  32180. buffer: Uint8Array;
  32181. bufferWidth: number;
  32182. bufferHeight: number;
  32183. alphaFilter: number;
  32184. }): VertexData;
  32185. /**
  32186. * Creates the VertexData for a Plane
  32187. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  32188. * * size sets the width and height of the plane to the value of size, optional default 1
  32189. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  32190. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  32191. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32192. * * 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)
  32193. * * 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)
  32194. * @returns the VertexData of the box
  32195. */
  32196. static CreatePlane(options: {
  32197. size?: number;
  32198. width?: number;
  32199. height?: number;
  32200. sideOrientation?: number;
  32201. frontUVs?: Vector4;
  32202. backUVs?: Vector4;
  32203. }): VertexData;
  32204. /**
  32205. * Creates the VertexData of the Disc or regular Polygon
  32206. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  32207. * * radius the radius of the disc, optional default 0.5
  32208. * * tessellation the number of polygon sides, optional, default 64
  32209. * * 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
  32210. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32211. * * 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)
  32212. * * 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)
  32213. * @returns the VertexData of the box
  32214. */
  32215. static CreateDisc(options: {
  32216. radius?: number;
  32217. tessellation?: number;
  32218. arc?: number;
  32219. sideOrientation?: number;
  32220. frontUVs?: Vector4;
  32221. backUVs?: Vector4;
  32222. }): VertexData;
  32223. /**
  32224. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  32225. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  32226. * @param polygon a mesh built from polygonTriangulation.build()
  32227. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32228. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  32229. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  32230. * @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)
  32231. * @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)
  32232. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  32233. * @returns the VertexData of the Polygon
  32234. */
  32235. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  32236. /**
  32237. * Creates the VertexData of the IcoSphere
  32238. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  32239. * * radius the radius of the IcoSphere, optional default 1
  32240. * * radiusX allows stretching in the x direction, optional, default radius
  32241. * * radiusY allows stretching in the y direction, optional, default radius
  32242. * * radiusZ allows stretching in the z direction, optional, default radius
  32243. * * flat when true creates a flat shaded mesh, optional, default true
  32244. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  32245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32246. * * 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)
  32247. * * 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)
  32248. * @returns the VertexData of the IcoSphere
  32249. */
  32250. static CreateIcoSphere(options: {
  32251. radius?: number;
  32252. radiusX?: number;
  32253. radiusY?: number;
  32254. radiusZ?: number;
  32255. flat?: boolean;
  32256. subdivisions?: number;
  32257. sideOrientation?: number;
  32258. frontUVs?: Vector4;
  32259. backUVs?: Vector4;
  32260. }): VertexData;
  32261. /**
  32262. * Creates the VertexData for a Polyhedron
  32263. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  32264. * * type provided types are:
  32265. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  32266. * * 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)
  32267. * * size the size of the IcoSphere, optional default 1
  32268. * * sizeX allows stretching in the x direction, optional, default size
  32269. * * sizeY allows stretching in the y direction, optional, default size
  32270. * * sizeZ allows stretching in the z direction, optional, default size
  32271. * * 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
  32272. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  32273. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  32274. * * flat when true creates a flat shaded mesh, optional, default true
  32275. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  32276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32277. * * 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)
  32278. * * 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)
  32279. * @returns the VertexData of the Polyhedron
  32280. */
  32281. static CreatePolyhedron(options: {
  32282. type?: number;
  32283. size?: number;
  32284. sizeX?: number;
  32285. sizeY?: number;
  32286. sizeZ?: number;
  32287. custom?: any;
  32288. faceUV?: Vector4[];
  32289. faceColors?: Color4[];
  32290. flat?: boolean;
  32291. sideOrientation?: number;
  32292. frontUVs?: Vector4;
  32293. backUVs?: Vector4;
  32294. }): VertexData;
  32295. /**
  32296. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  32297. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  32298. * @returns the VertexData of the Capsule
  32299. */
  32300. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  32301. /**
  32302. * Creates the VertexData for a TorusKnot
  32303. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  32304. * * radius the radius of the torus knot, optional, default 2
  32305. * * tube the thickness of the tube, optional, default 0.5
  32306. * * radialSegments the number of sides on each tube segments, optional, default 32
  32307. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  32308. * * p the number of windings around the z axis, optional, default 2
  32309. * * q the number of windings around the x axis, optional, default 3
  32310. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32311. * * 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)
  32312. * * 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)
  32313. * @returns the VertexData of the Torus Knot
  32314. */
  32315. static CreateTorusKnot(options: {
  32316. radius?: number;
  32317. tube?: number;
  32318. radialSegments?: number;
  32319. tubularSegments?: number;
  32320. p?: number;
  32321. q?: number;
  32322. sideOrientation?: number;
  32323. frontUVs?: Vector4;
  32324. backUVs?: Vector4;
  32325. }): VertexData;
  32326. /**
  32327. * Compute normals for given positions and indices
  32328. * @param positions an array of vertex positions, [...., x, y, z, ......]
  32329. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  32330. * @param normals an array of vertex normals, [...., x, y, z, ......]
  32331. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  32332. * * facetNormals : optional array of facet normals (vector3)
  32333. * * facetPositions : optional array of facet positions (vector3)
  32334. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  32335. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  32336. * * bInfo : optional bounding info, required for facetPartitioning computation
  32337. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  32338. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  32339. * * useRightHandedSystem: optional boolean to for right handed system computation
  32340. * * depthSort : optional boolean to enable the facet depth sort computation
  32341. * * distanceTo : optional Vector3 to compute the facet depth from this location
  32342. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  32343. */
  32344. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  32345. facetNormals?: any;
  32346. facetPositions?: any;
  32347. facetPartitioning?: any;
  32348. ratio?: number;
  32349. bInfo?: any;
  32350. bbSize?: Vector3;
  32351. subDiv?: any;
  32352. useRightHandedSystem?: boolean;
  32353. depthSort?: boolean;
  32354. distanceTo?: Vector3;
  32355. depthSortedFacets?: any;
  32356. }): void;
  32357. /** @hidden */
  32358. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  32359. /**
  32360. * Applies VertexData created from the imported parameters to the geometry
  32361. * @param parsedVertexData the parsed data from an imported file
  32362. * @param geometry the geometry to apply the VertexData to
  32363. */
  32364. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  32365. }
  32366. }
  32367. declare module "babylonjs/Morph/morphTarget" {
  32368. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32369. import { Observable } from "babylonjs/Misc/observable";
  32370. import { Nullable, FloatArray } from "babylonjs/types";
  32371. import { Scene } from "babylonjs/scene";
  32372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32373. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32374. /**
  32375. * Defines a target to use with MorphTargetManager
  32376. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32377. */
  32378. export class MorphTarget implements IAnimatable {
  32379. /** defines the name of the target */
  32380. name: string;
  32381. /**
  32382. * Gets or sets the list of animations
  32383. */
  32384. animations: import("babylonjs/Animations/animation").Animation[];
  32385. private _scene;
  32386. private _positions;
  32387. private _normals;
  32388. private _tangents;
  32389. private _uvs;
  32390. private _influence;
  32391. private _uniqueId;
  32392. /**
  32393. * Observable raised when the influence changes
  32394. */
  32395. onInfluenceChanged: Observable<boolean>;
  32396. /** @hidden */
  32397. _onDataLayoutChanged: Observable<void>;
  32398. /**
  32399. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32400. */
  32401. get influence(): number;
  32402. set influence(influence: number);
  32403. /**
  32404. * Gets or sets the id of the morph Target
  32405. */
  32406. id: string;
  32407. private _animationPropertiesOverride;
  32408. /**
  32409. * Gets or sets the animation properties override
  32410. */
  32411. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32412. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32413. /**
  32414. * Creates a new MorphTarget
  32415. * @param name defines the name of the target
  32416. * @param influence defines the influence to use
  32417. * @param scene defines the scene the morphtarget belongs to
  32418. */
  32419. constructor(
  32420. /** defines the name of the target */
  32421. name: string, influence?: number, scene?: Nullable<Scene>);
  32422. /**
  32423. * Gets the unique ID of this manager
  32424. */
  32425. get uniqueId(): number;
  32426. /**
  32427. * Gets a boolean defining if the target contains position data
  32428. */
  32429. get hasPositions(): boolean;
  32430. /**
  32431. * Gets a boolean defining if the target contains normal data
  32432. */
  32433. get hasNormals(): boolean;
  32434. /**
  32435. * Gets a boolean defining if the target contains tangent data
  32436. */
  32437. get hasTangents(): boolean;
  32438. /**
  32439. * Gets a boolean defining if the target contains texture coordinates data
  32440. */
  32441. get hasUVs(): boolean;
  32442. /**
  32443. * Affects position data to this target
  32444. * @param data defines the position data to use
  32445. */
  32446. setPositions(data: Nullable<FloatArray>): void;
  32447. /**
  32448. * Gets the position data stored in this target
  32449. * @returns a FloatArray containing the position data (or null if not present)
  32450. */
  32451. getPositions(): Nullable<FloatArray>;
  32452. /**
  32453. * Affects normal data to this target
  32454. * @param data defines the normal data to use
  32455. */
  32456. setNormals(data: Nullable<FloatArray>): void;
  32457. /**
  32458. * Gets the normal data stored in this target
  32459. * @returns a FloatArray containing the normal data (or null if not present)
  32460. */
  32461. getNormals(): Nullable<FloatArray>;
  32462. /**
  32463. * Affects tangent data to this target
  32464. * @param data defines the tangent data to use
  32465. */
  32466. setTangents(data: Nullable<FloatArray>): void;
  32467. /**
  32468. * Gets the tangent data stored in this target
  32469. * @returns a FloatArray containing the tangent data (or null if not present)
  32470. */
  32471. getTangents(): Nullable<FloatArray>;
  32472. /**
  32473. * Affects texture coordinates data to this target
  32474. * @param data defines the texture coordinates data to use
  32475. */
  32476. setUVs(data: Nullable<FloatArray>): void;
  32477. /**
  32478. * Gets the texture coordinates data stored in this target
  32479. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32480. */
  32481. getUVs(): Nullable<FloatArray>;
  32482. /**
  32483. * Clone the current target
  32484. * @returns a new MorphTarget
  32485. */
  32486. clone(): MorphTarget;
  32487. /**
  32488. * Serializes the current target into a Serialization object
  32489. * @returns the serialized object
  32490. */
  32491. serialize(): any;
  32492. /**
  32493. * Returns the string "MorphTarget"
  32494. * @returns "MorphTarget"
  32495. */
  32496. getClassName(): string;
  32497. /**
  32498. * Creates a new target from serialized data
  32499. * @param serializationObject defines the serialized data to use
  32500. * @returns a new MorphTarget
  32501. */
  32502. static Parse(serializationObject: any): MorphTarget;
  32503. /**
  32504. * Creates a MorphTarget from mesh data
  32505. * @param mesh defines the source mesh
  32506. * @param name defines the name to use for the new target
  32507. * @param influence defines the influence to attach to the target
  32508. * @returns a new MorphTarget
  32509. */
  32510. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32511. }
  32512. }
  32513. declare module "babylonjs/Morph/morphTargetManager" {
  32514. import { Nullable } from "babylonjs/types";
  32515. import { Scene } from "babylonjs/scene";
  32516. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32517. /**
  32518. * This class is used to deform meshes using morphing between different targets
  32519. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32520. */
  32521. export class MorphTargetManager {
  32522. private _targets;
  32523. private _targetInfluenceChangedObservers;
  32524. private _targetDataLayoutChangedObservers;
  32525. private _activeTargets;
  32526. private _scene;
  32527. private _influences;
  32528. private _supportsNormals;
  32529. private _supportsTangents;
  32530. private _supportsUVs;
  32531. private _vertexCount;
  32532. private _uniqueId;
  32533. private _tempInfluences;
  32534. /**
  32535. * Gets or sets a boolean indicating if normals must be morphed
  32536. */
  32537. enableNormalMorphing: boolean;
  32538. /**
  32539. * Gets or sets a boolean indicating if tangents must be morphed
  32540. */
  32541. enableTangentMorphing: boolean;
  32542. /**
  32543. * Gets or sets a boolean indicating if UV must be morphed
  32544. */
  32545. enableUVMorphing: boolean;
  32546. /**
  32547. * Creates a new MorphTargetManager
  32548. * @param scene defines the current scene
  32549. */
  32550. constructor(scene?: Nullable<Scene>);
  32551. /**
  32552. * Gets the unique ID of this manager
  32553. */
  32554. get uniqueId(): number;
  32555. /**
  32556. * Gets the number of vertices handled by this manager
  32557. */
  32558. get vertexCount(): number;
  32559. /**
  32560. * Gets a boolean indicating if this manager supports morphing of normals
  32561. */
  32562. get supportsNormals(): boolean;
  32563. /**
  32564. * Gets a boolean indicating if this manager supports morphing of tangents
  32565. */
  32566. get supportsTangents(): boolean;
  32567. /**
  32568. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32569. */
  32570. get supportsUVs(): boolean;
  32571. /**
  32572. * Gets the number of targets stored in this manager
  32573. */
  32574. get numTargets(): number;
  32575. /**
  32576. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32577. */
  32578. get numInfluencers(): number;
  32579. /**
  32580. * Gets the list of influences (one per target)
  32581. */
  32582. get influences(): Float32Array;
  32583. /**
  32584. * Gets the active target at specified index. An active target is a target with an influence > 0
  32585. * @param index defines the index to check
  32586. * @returns the requested target
  32587. */
  32588. getActiveTarget(index: number): MorphTarget;
  32589. /**
  32590. * Gets the target at specified index
  32591. * @param index defines the index to check
  32592. * @returns the requested target
  32593. */
  32594. getTarget(index: number): MorphTarget;
  32595. /**
  32596. * Add a new target to this manager
  32597. * @param target defines the target to add
  32598. */
  32599. addTarget(target: MorphTarget): void;
  32600. /**
  32601. * Removes a target from the manager
  32602. * @param target defines the target to remove
  32603. */
  32604. removeTarget(target: MorphTarget): void;
  32605. /**
  32606. * Clone the current manager
  32607. * @returns a new MorphTargetManager
  32608. */
  32609. clone(): MorphTargetManager;
  32610. /**
  32611. * Serializes the current manager into a Serialization object
  32612. * @returns the serialized object
  32613. */
  32614. serialize(): any;
  32615. private _syncActiveTargets;
  32616. /**
  32617. * Syncrhonize the targets with all the meshes using this morph target manager
  32618. */
  32619. synchronize(): void;
  32620. /**
  32621. * Creates a new MorphTargetManager from serialized data
  32622. * @param serializationObject defines the serialized data
  32623. * @param scene defines the hosting scene
  32624. * @returns the new MorphTargetManager
  32625. */
  32626. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32627. }
  32628. }
  32629. declare module "babylonjs/Meshes/meshLODLevel" {
  32630. import { Mesh } from "babylonjs/Meshes/mesh";
  32631. import { Nullable } from "babylonjs/types";
  32632. /**
  32633. * Class used to represent a specific level of detail of a mesh
  32634. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32635. */
  32636. export class MeshLODLevel {
  32637. /** Defines the distance where this level should start being displayed */
  32638. distance: number;
  32639. /** Defines the mesh to use to render this level */
  32640. mesh: Nullable<Mesh>;
  32641. /**
  32642. * Creates a new LOD level
  32643. * @param distance defines the distance where this level should star being displayed
  32644. * @param mesh defines the mesh to use to render this level
  32645. */
  32646. constructor(
  32647. /** Defines the distance where this level should start being displayed */
  32648. distance: number,
  32649. /** Defines the mesh to use to render this level */
  32650. mesh: Nullable<Mesh>);
  32651. }
  32652. }
  32653. declare module "babylonjs/Misc/canvasGenerator" {
  32654. /**
  32655. * Helper class used to generate a canvas to manipulate images
  32656. */
  32657. export class CanvasGenerator {
  32658. /**
  32659. * Create a new canvas (or offscreen canvas depending on the context)
  32660. * @param width defines the expected width
  32661. * @param height defines the expected height
  32662. * @return a new canvas or offscreen canvas
  32663. */
  32664. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32665. }
  32666. }
  32667. declare module "babylonjs/Meshes/groundMesh" {
  32668. import { Scene } from "babylonjs/scene";
  32669. import { Vector3 } from "babylonjs/Maths/math.vector";
  32670. import { Mesh } from "babylonjs/Meshes/mesh";
  32671. /**
  32672. * Mesh representing the gorund
  32673. */
  32674. export class GroundMesh extends Mesh {
  32675. /** If octree should be generated */
  32676. generateOctree: boolean;
  32677. private _heightQuads;
  32678. /** @hidden */
  32679. _subdivisionsX: number;
  32680. /** @hidden */
  32681. _subdivisionsY: number;
  32682. /** @hidden */
  32683. _width: number;
  32684. /** @hidden */
  32685. _height: number;
  32686. /** @hidden */
  32687. _minX: number;
  32688. /** @hidden */
  32689. _maxX: number;
  32690. /** @hidden */
  32691. _minZ: number;
  32692. /** @hidden */
  32693. _maxZ: number;
  32694. constructor(name: string, scene: Scene);
  32695. /**
  32696. * "GroundMesh"
  32697. * @returns "GroundMesh"
  32698. */
  32699. getClassName(): string;
  32700. /**
  32701. * The minimum of x and y subdivisions
  32702. */
  32703. get subdivisions(): number;
  32704. /**
  32705. * X subdivisions
  32706. */
  32707. get subdivisionsX(): number;
  32708. /**
  32709. * Y subdivisions
  32710. */
  32711. get subdivisionsY(): number;
  32712. /**
  32713. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32714. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32715. * @param chunksCount the number of subdivisions for x and y
  32716. * @param octreeBlocksSize (Default: 32)
  32717. */
  32718. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32719. /**
  32720. * Returns a height (y) value in the Worl system :
  32721. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32722. * @param x x coordinate
  32723. * @param z z coordinate
  32724. * @returns the ground y position if (x, z) are outside the ground surface.
  32725. */
  32726. getHeightAtCoordinates(x: number, z: number): number;
  32727. /**
  32728. * Returns a normalized vector (Vector3) orthogonal to the ground
  32729. * at the ground coordinates (x, z) expressed in the World system.
  32730. * @param x x coordinate
  32731. * @param z z coordinate
  32732. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32733. */
  32734. getNormalAtCoordinates(x: number, z: number): Vector3;
  32735. /**
  32736. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32737. * at the ground coordinates (x, z) expressed in the World system.
  32738. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32739. * @param x x coordinate
  32740. * @param z z coordinate
  32741. * @param ref vector to store the result
  32742. * @returns the GroundMesh.
  32743. */
  32744. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32745. /**
  32746. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32747. * if the ground has been updated.
  32748. * This can be used in the render loop.
  32749. * @returns the GroundMesh.
  32750. */
  32751. updateCoordinateHeights(): GroundMesh;
  32752. private _getFacetAt;
  32753. private _initHeightQuads;
  32754. private _computeHeightQuads;
  32755. /**
  32756. * Serializes this ground mesh
  32757. * @param serializationObject object to write serialization to
  32758. */
  32759. serialize(serializationObject: any): void;
  32760. /**
  32761. * Parses a serialized ground mesh
  32762. * @param parsedMesh the serialized mesh
  32763. * @param scene the scene to create the ground mesh in
  32764. * @returns the created ground mesh
  32765. */
  32766. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32767. }
  32768. }
  32769. declare module "babylonjs/Physics/physicsJoint" {
  32770. import { Vector3 } from "babylonjs/Maths/math.vector";
  32771. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32772. /**
  32773. * Interface for Physics-Joint data
  32774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32775. */
  32776. export interface PhysicsJointData {
  32777. /**
  32778. * The main pivot of the joint
  32779. */
  32780. mainPivot?: Vector3;
  32781. /**
  32782. * The connected pivot of the joint
  32783. */
  32784. connectedPivot?: Vector3;
  32785. /**
  32786. * The main axis of the joint
  32787. */
  32788. mainAxis?: Vector3;
  32789. /**
  32790. * The connected axis of the joint
  32791. */
  32792. connectedAxis?: Vector3;
  32793. /**
  32794. * The collision of the joint
  32795. */
  32796. collision?: boolean;
  32797. /**
  32798. * Native Oimo/Cannon/Energy data
  32799. */
  32800. nativeParams?: any;
  32801. }
  32802. /**
  32803. * This is a holder class for the physics joint created by the physics plugin
  32804. * It holds a set of functions to control the underlying joint
  32805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32806. */
  32807. export class PhysicsJoint {
  32808. /**
  32809. * The type of the physics joint
  32810. */
  32811. type: number;
  32812. /**
  32813. * The data for the physics joint
  32814. */
  32815. jointData: PhysicsJointData;
  32816. private _physicsJoint;
  32817. protected _physicsPlugin: IPhysicsEnginePlugin;
  32818. /**
  32819. * Initializes the physics joint
  32820. * @param type The type of the physics joint
  32821. * @param jointData The data for the physics joint
  32822. */
  32823. constructor(
  32824. /**
  32825. * The type of the physics joint
  32826. */
  32827. type: number,
  32828. /**
  32829. * The data for the physics joint
  32830. */
  32831. jointData: PhysicsJointData);
  32832. /**
  32833. * Gets the physics joint
  32834. */
  32835. get physicsJoint(): any;
  32836. /**
  32837. * Sets the physics joint
  32838. */
  32839. set physicsJoint(newJoint: any);
  32840. /**
  32841. * Sets the physics plugin
  32842. */
  32843. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32844. /**
  32845. * Execute a function that is physics-plugin specific.
  32846. * @param {Function} func the function that will be executed.
  32847. * It accepts two parameters: the physics world and the physics joint
  32848. */
  32849. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32850. /**
  32851. * Distance-Joint type
  32852. */
  32853. static DistanceJoint: number;
  32854. /**
  32855. * Hinge-Joint type
  32856. */
  32857. static HingeJoint: number;
  32858. /**
  32859. * Ball-and-Socket joint type
  32860. */
  32861. static BallAndSocketJoint: number;
  32862. /**
  32863. * Wheel-Joint type
  32864. */
  32865. static WheelJoint: number;
  32866. /**
  32867. * Slider-Joint type
  32868. */
  32869. static SliderJoint: number;
  32870. /**
  32871. * Prismatic-Joint type
  32872. */
  32873. static PrismaticJoint: number;
  32874. /**
  32875. * Universal-Joint type
  32876. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32877. */
  32878. static UniversalJoint: number;
  32879. /**
  32880. * Hinge-Joint 2 type
  32881. */
  32882. static Hinge2Joint: number;
  32883. /**
  32884. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32885. */
  32886. static PointToPointJoint: number;
  32887. /**
  32888. * Spring-Joint type
  32889. */
  32890. static SpringJoint: number;
  32891. /**
  32892. * Lock-Joint type
  32893. */
  32894. static LockJoint: number;
  32895. }
  32896. /**
  32897. * A class representing a physics distance joint
  32898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32899. */
  32900. export class DistanceJoint extends PhysicsJoint {
  32901. /**
  32902. *
  32903. * @param jointData The data for the Distance-Joint
  32904. */
  32905. constructor(jointData: DistanceJointData);
  32906. /**
  32907. * Update the predefined distance.
  32908. * @param maxDistance The maximum preferred distance
  32909. * @param minDistance The minimum preferred distance
  32910. */
  32911. updateDistance(maxDistance: number, minDistance?: number): void;
  32912. }
  32913. /**
  32914. * Represents a Motor-Enabled Joint
  32915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32916. */
  32917. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32918. /**
  32919. * Initializes the Motor-Enabled Joint
  32920. * @param type The type of the joint
  32921. * @param jointData The physica joint data for the joint
  32922. */
  32923. constructor(type: number, jointData: PhysicsJointData);
  32924. /**
  32925. * Set the motor values.
  32926. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32927. * @param force the force to apply
  32928. * @param maxForce max force for this motor.
  32929. */
  32930. setMotor(force?: number, maxForce?: number): void;
  32931. /**
  32932. * Set the motor's limits.
  32933. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32934. * @param upperLimit The upper limit of the motor
  32935. * @param lowerLimit The lower limit of the motor
  32936. */
  32937. setLimit(upperLimit: number, lowerLimit?: number): void;
  32938. }
  32939. /**
  32940. * This class represents a single physics Hinge-Joint
  32941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32942. */
  32943. export class HingeJoint extends MotorEnabledJoint {
  32944. /**
  32945. * Initializes the Hinge-Joint
  32946. * @param jointData The joint data for the Hinge-Joint
  32947. */
  32948. constructor(jointData: PhysicsJointData);
  32949. /**
  32950. * Set the motor values.
  32951. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32952. * @param {number} force the force to apply
  32953. * @param {number} maxForce max force for this motor.
  32954. */
  32955. setMotor(force?: number, maxForce?: number): void;
  32956. /**
  32957. * Set the motor's limits.
  32958. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32959. * @param upperLimit The upper limit of the motor
  32960. * @param lowerLimit The lower limit of the motor
  32961. */
  32962. setLimit(upperLimit: number, lowerLimit?: number): void;
  32963. }
  32964. /**
  32965. * This class represents a dual hinge physics joint (same as wheel joint)
  32966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32967. */
  32968. export class Hinge2Joint extends MotorEnabledJoint {
  32969. /**
  32970. * Initializes the Hinge2-Joint
  32971. * @param jointData The joint data for the Hinge2-Joint
  32972. */
  32973. constructor(jointData: PhysicsJointData);
  32974. /**
  32975. * Set the motor values.
  32976. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32977. * @param {number} targetSpeed the speed the motor is to reach
  32978. * @param {number} maxForce max force for this motor.
  32979. * @param {motorIndex} the motor's index, 0 or 1.
  32980. */
  32981. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32982. /**
  32983. * Set the motor limits.
  32984. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32985. * @param {number} upperLimit the upper limit
  32986. * @param {number} lowerLimit lower limit
  32987. * @param {motorIndex} the motor's index, 0 or 1.
  32988. */
  32989. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32990. }
  32991. /**
  32992. * Interface for a motor enabled joint
  32993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32994. */
  32995. export interface IMotorEnabledJoint {
  32996. /**
  32997. * Physics joint
  32998. */
  32999. physicsJoint: any;
  33000. /**
  33001. * Sets the motor of the motor-enabled joint
  33002. * @param force The force of the motor
  33003. * @param maxForce The maximum force of the motor
  33004. * @param motorIndex The index of the motor
  33005. */
  33006. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33007. /**
  33008. * Sets the limit of the motor
  33009. * @param upperLimit The upper limit of the motor
  33010. * @param lowerLimit The lower limit of the motor
  33011. * @param motorIndex The index of the motor
  33012. */
  33013. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33014. }
  33015. /**
  33016. * Joint data for a Distance-Joint
  33017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33018. */
  33019. export interface DistanceJointData extends PhysicsJointData {
  33020. /**
  33021. * Max distance the 2 joint objects can be apart
  33022. */
  33023. maxDistance: number;
  33024. }
  33025. /**
  33026. * Joint data from a spring joint
  33027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33028. */
  33029. export interface SpringJointData extends PhysicsJointData {
  33030. /**
  33031. * Length of the spring
  33032. */
  33033. length: number;
  33034. /**
  33035. * Stiffness of the spring
  33036. */
  33037. stiffness: number;
  33038. /**
  33039. * Damping of the spring
  33040. */
  33041. damping: number;
  33042. /** this callback will be called when applying the force to the impostors. */
  33043. forceApplicationCallback: () => void;
  33044. }
  33045. }
  33046. declare module "babylonjs/Physics/physicsRaycastResult" {
  33047. import { Vector3 } from "babylonjs/Maths/math.vector";
  33048. /**
  33049. * Holds the data for the raycast result
  33050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33051. */
  33052. export class PhysicsRaycastResult {
  33053. private _hasHit;
  33054. private _hitDistance;
  33055. private _hitNormalWorld;
  33056. private _hitPointWorld;
  33057. private _rayFromWorld;
  33058. private _rayToWorld;
  33059. /**
  33060. * Gets if there was a hit
  33061. */
  33062. get hasHit(): boolean;
  33063. /**
  33064. * Gets the distance from the hit
  33065. */
  33066. get hitDistance(): number;
  33067. /**
  33068. * Gets the hit normal/direction in the world
  33069. */
  33070. get hitNormalWorld(): Vector3;
  33071. /**
  33072. * Gets the hit point in the world
  33073. */
  33074. get hitPointWorld(): Vector3;
  33075. /**
  33076. * Gets the ray "start point" of the ray in the world
  33077. */
  33078. get rayFromWorld(): Vector3;
  33079. /**
  33080. * Gets the ray "end point" of the ray in the world
  33081. */
  33082. get rayToWorld(): Vector3;
  33083. /**
  33084. * Sets the hit data (normal & point in world space)
  33085. * @param hitNormalWorld defines the normal in world space
  33086. * @param hitPointWorld defines the point in world space
  33087. */
  33088. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  33089. /**
  33090. * Sets the distance from the start point to the hit point
  33091. * @param distance
  33092. */
  33093. setHitDistance(distance: number): void;
  33094. /**
  33095. * Calculates the distance manually
  33096. */
  33097. calculateHitDistance(): void;
  33098. /**
  33099. * Resets all the values to default
  33100. * @param from The from point on world space
  33101. * @param to The to point on world space
  33102. */
  33103. reset(from?: Vector3, to?: Vector3): void;
  33104. }
  33105. /**
  33106. * Interface for the size containing width and height
  33107. */
  33108. interface IXYZ {
  33109. /**
  33110. * X
  33111. */
  33112. x: number;
  33113. /**
  33114. * Y
  33115. */
  33116. y: number;
  33117. /**
  33118. * Z
  33119. */
  33120. z: number;
  33121. }
  33122. }
  33123. declare module "babylonjs/Physics/IPhysicsEngine" {
  33124. import { Nullable } from "babylonjs/types";
  33125. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  33126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33127. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33128. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  33129. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  33130. /**
  33131. * Interface used to describe a physics joint
  33132. */
  33133. export interface PhysicsImpostorJoint {
  33134. /** Defines the main impostor to which the joint is linked */
  33135. mainImpostor: PhysicsImpostor;
  33136. /** Defines the impostor that is connected to the main impostor using this joint */
  33137. connectedImpostor: PhysicsImpostor;
  33138. /** Defines the joint itself */
  33139. joint: PhysicsJoint;
  33140. }
  33141. /** @hidden */
  33142. export interface IPhysicsEnginePlugin {
  33143. world: any;
  33144. name: string;
  33145. setGravity(gravity: Vector3): void;
  33146. setTimeStep(timeStep: number): void;
  33147. getTimeStep(): number;
  33148. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33149. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33150. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33151. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33152. removePhysicsBody(impostor: PhysicsImpostor): void;
  33153. generateJoint(joint: PhysicsImpostorJoint): void;
  33154. removeJoint(joint: PhysicsImpostorJoint): void;
  33155. isSupported(): boolean;
  33156. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33157. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33158. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33159. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33160. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33161. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33162. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33163. getBodyMass(impostor: PhysicsImpostor): number;
  33164. getBodyFriction(impostor: PhysicsImpostor): number;
  33165. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33166. getBodyRestitution(impostor: PhysicsImpostor): number;
  33167. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33168. getBodyPressure?(impostor: PhysicsImpostor): number;
  33169. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  33170. getBodyStiffness?(impostor: PhysicsImpostor): number;
  33171. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  33172. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  33173. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  33174. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  33175. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  33176. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33177. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33178. sleepBody(impostor: PhysicsImpostor): void;
  33179. wakeUpBody(impostor: PhysicsImpostor): void;
  33180. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33181. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33182. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33183. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33184. getRadius(impostor: PhysicsImpostor): number;
  33185. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33186. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33187. dispose(): void;
  33188. }
  33189. /**
  33190. * Interface used to define a physics engine
  33191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33192. */
  33193. export interface IPhysicsEngine {
  33194. /**
  33195. * Gets the gravity vector used by the simulation
  33196. */
  33197. gravity: Vector3;
  33198. /**
  33199. * Sets the gravity vector used by the simulation
  33200. * @param gravity defines the gravity vector to use
  33201. */
  33202. setGravity(gravity: Vector3): void;
  33203. /**
  33204. * Set the time step of the physics engine.
  33205. * Default is 1/60.
  33206. * To slow it down, enter 1/600 for example.
  33207. * To speed it up, 1/30
  33208. * @param newTimeStep the new timestep to apply to this world.
  33209. */
  33210. setTimeStep(newTimeStep: number): void;
  33211. /**
  33212. * Get the time step of the physics engine.
  33213. * @returns the current time step
  33214. */
  33215. getTimeStep(): number;
  33216. /**
  33217. * Set the sub time step of the physics engine.
  33218. * Default is 0 meaning there is no sub steps
  33219. * To increase physics resolution precision, set a small value (like 1 ms)
  33220. * @param subTimeStep defines the new sub timestep used for physics resolution.
  33221. */
  33222. setSubTimeStep(subTimeStep: number): void;
  33223. /**
  33224. * Get the sub time step of the physics engine.
  33225. * @returns the current sub time step
  33226. */
  33227. getSubTimeStep(): number;
  33228. /**
  33229. * Release all resources
  33230. */
  33231. dispose(): void;
  33232. /**
  33233. * Gets the name of the current physics plugin
  33234. * @returns the name of the plugin
  33235. */
  33236. getPhysicsPluginName(): string;
  33237. /**
  33238. * Adding a new impostor for the impostor tracking.
  33239. * This will be done by the impostor itself.
  33240. * @param impostor the impostor to add
  33241. */
  33242. addImpostor(impostor: PhysicsImpostor): void;
  33243. /**
  33244. * Remove an impostor from the engine.
  33245. * This impostor and its mesh will not longer be updated by the physics engine.
  33246. * @param impostor the impostor to remove
  33247. */
  33248. removeImpostor(impostor: PhysicsImpostor): void;
  33249. /**
  33250. * Add a joint to the physics engine
  33251. * @param mainImpostor defines the main impostor to which the joint is added.
  33252. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33253. * @param joint defines the joint that will connect both impostors.
  33254. */
  33255. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33256. /**
  33257. * Removes a joint from the simulation
  33258. * @param mainImpostor defines the impostor used with the joint
  33259. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33260. * @param joint defines the joint to remove
  33261. */
  33262. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33263. /**
  33264. * Gets the current plugin used to run the simulation
  33265. * @returns current plugin
  33266. */
  33267. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33268. /**
  33269. * Gets the list of physic impostors
  33270. * @returns an array of PhysicsImpostor
  33271. */
  33272. getImpostors(): Array<PhysicsImpostor>;
  33273. /**
  33274. * Gets the impostor for a physics enabled object
  33275. * @param object defines the object impersonated by the impostor
  33276. * @returns the PhysicsImpostor or null if not found
  33277. */
  33278. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33279. /**
  33280. * Gets the impostor for a physics body object
  33281. * @param body defines physics body used by the impostor
  33282. * @returns the PhysicsImpostor or null if not found
  33283. */
  33284. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33285. /**
  33286. * Does a raycast in the physics world
  33287. * @param from when should the ray start?
  33288. * @param to when should the ray end?
  33289. * @returns PhysicsRaycastResult
  33290. */
  33291. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33292. /**
  33293. * Called by the scene. No need to call it.
  33294. * @param delta defines the timespam between frames
  33295. */
  33296. _step(delta: number): void;
  33297. }
  33298. }
  33299. declare module "babylonjs/Physics/physicsImpostor" {
  33300. import { Nullable, IndicesArray } from "babylonjs/types";
  33301. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  33302. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33304. import { Scene } from "babylonjs/scene";
  33305. import { Bone } from "babylonjs/Bones/bone";
  33306. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33307. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  33308. import { Space } from "babylonjs/Maths/math.axis";
  33309. /**
  33310. * The interface for the physics imposter parameters
  33311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33312. */
  33313. export interface PhysicsImpostorParameters {
  33314. /**
  33315. * The mass of the physics imposter
  33316. */
  33317. mass: number;
  33318. /**
  33319. * The friction of the physics imposter
  33320. */
  33321. friction?: number;
  33322. /**
  33323. * The coefficient of restitution of the physics imposter
  33324. */
  33325. restitution?: number;
  33326. /**
  33327. * The native options of the physics imposter
  33328. */
  33329. nativeOptions?: any;
  33330. /**
  33331. * Specifies if the parent should be ignored
  33332. */
  33333. ignoreParent?: boolean;
  33334. /**
  33335. * Specifies if bi-directional transformations should be disabled
  33336. */
  33337. disableBidirectionalTransformation?: boolean;
  33338. /**
  33339. * The pressure inside the physics imposter, soft object only
  33340. */
  33341. pressure?: number;
  33342. /**
  33343. * The stiffness the physics imposter, soft object only
  33344. */
  33345. stiffness?: number;
  33346. /**
  33347. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33348. */
  33349. velocityIterations?: number;
  33350. /**
  33351. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33352. */
  33353. positionIterations?: number;
  33354. /**
  33355. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33356. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33357. * Add to fix multiple points
  33358. */
  33359. fixedPoints?: number;
  33360. /**
  33361. * The collision margin around a soft object
  33362. */
  33363. margin?: number;
  33364. /**
  33365. * The collision margin around a soft object
  33366. */
  33367. damping?: number;
  33368. /**
  33369. * The path for a rope based on an extrusion
  33370. */
  33371. path?: any;
  33372. /**
  33373. * The shape of an extrusion used for a rope based on an extrusion
  33374. */
  33375. shape?: any;
  33376. }
  33377. /**
  33378. * Interface for a physics-enabled object
  33379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33380. */
  33381. export interface IPhysicsEnabledObject {
  33382. /**
  33383. * The position of the physics-enabled object
  33384. */
  33385. position: Vector3;
  33386. /**
  33387. * The rotation of the physics-enabled object
  33388. */
  33389. rotationQuaternion: Nullable<Quaternion>;
  33390. /**
  33391. * The scale of the physics-enabled object
  33392. */
  33393. scaling: Vector3;
  33394. /**
  33395. * The rotation of the physics-enabled object
  33396. */
  33397. rotation?: Vector3;
  33398. /**
  33399. * The parent of the physics-enabled object
  33400. */
  33401. parent?: any;
  33402. /**
  33403. * The bounding info of the physics-enabled object
  33404. * @returns The bounding info of the physics-enabled object
  33405. */
  33406. getBoundingInfo(): BoundingInfo;
  33407. /**
  33408. * Computes the world matrix
  33409. * @param force Specifies if the world matrix should be computed by force
  33410. * @returns A world matrix
  33411. */
  33412. computeWorldMatrix(force: boolean): Matrix;
  33413. /**
  33414. * Gets the world matrix
  33415. * @returns A world matrix
  33416. */
  33417. getWorldMatrix?(): Matrix;
  33418. /**
  33419. * Gets the child meshes
  33420. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33421. * @returns An array of abstract meshes
  33422. */
  33423. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33424. /**
  33425. * Gets the vertex data
  33426. * @param kind The type of vertex data
  33427. * @returns A nullable array of numbers, or a float32 array
  33428. */
  33429. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33430. /**
  33431. * Gets the indices from the mesh
  33432. * @returns A nullable array of index arrays
  33433. */
  33434. getIndices?(): Nullable<IndicesArray>;
  33435. /**
  33436. * Gets the scene from the mesh
  33437. * @returns the indices array or null
  33438. */
  33439. getScene?(): Scene;
  33440. /**
  33441. * Gets the absolute position from the mesh
  33442. * @returns the absolute position
  33443. */
  33444. getAbsolutePosition(): Vector3;
  33445. /**
  33446. * Gets the absolute pivot point from the mesh
  33447. * @returns the absolute pivot point
  33448. */
  33449. getAbsolutePivotPoint(): Vector3;
  33450. /**
  33451. * Rotates the mesh
  33452. * @param axis The axis of rotation
  33453. * @param amount The amount of rotation
  33454. * @param space The space of the rotation
  33455. * @returns The rotation transform node
  33456. */
  33457. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33458. /**
  33459. * Translates the mesh
  33460. * @param axis The axis of translation
  33461. * @param distance The distance of translation
  33462. * @param space The space of the translation
  33463. * @returns The transform node
  33464. */
  33465. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33466. /**
  33467. * Sets the absolute position of the mesh
  33468. * @param absolutePosition The absolute position of the mesh
  33469. * @returns The transform node
  33470. */
  33471. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33472. /**
  33473. * Gets the class name of the mesh
  33474. * @returns The class name
  33475. */
  33476. getClassName(): string;
  33477. }
  33478. /**
  33479. * Represents a physics imposter
  33480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33481. */
  33482. export class PhysicsImpostor {
  33483. /**
  33484. * The physics-enabled object used as the physics imposter
  33485. */
  33486. object: IPhysicsEnabledObject;
  33487. /**
  33488. * The type of the physics imposter
  33489. */
  33490. type: number;
  33491. private _options;
  33492. private _scene?;
  33493. /**
  33494. * The default object size of the imposter
  33495. */
  33496. static DEFAULT_OBJECT_SIZE: Vector3;
  33497. /**
  33498. * The identity quaternion of the imposter
  33499. */
  33500. static IDENTITY_QUATERNION: Quaternion;
  33501. /** @hidden */
  33502. _pluginData: any;
  33503. private _physicsEngine;
  33504. private _physicsBody;
  33505. private _bodyUpdateRequired;
  33506. private _onBeforePhysicsStepCallbacks;
  33507. private _onAfterPhysicsStepCallbacks;
  33508. /** @hidden */
  33509. _onPhysicsCollideCallbacks: Array<{
  33510. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33511. otherImpostors: Array<PhysicsImpostor>;
  33512. }>;
  33513. private _deltaPosition;
  33514. private _deltaRotation;
  33515. private _deltaRotationConjugated;
  33516. /** @hidden */
  33517. _isFromLine: boolean;
  33518. private _parent;
  33519. private _isDisposed;
  33520. private static _tmpVecs;
  33521. private static _tmpQuat;
  33522. /**
  33523. * Specifies if the physics imposter is disposed
  33524. */
  33525. get isDisposed(): boolean;
  33526. /**
  33527. * Gets the mass of the physics imposter
  33528. */
  33529. get mass(): number;
  33530. set mass(value: number);
  33531. /**
  33532. * Gets the coefficient of friction
  33533. */
  33534. get friction(): number;
  33535. /**
  33536. * Sets the coefficient of friction
  33537. */
  33538. set friction(value: number);
  33539. /**
  33540. * Gets the coefficient of restitution
  33541. */
  33542. get restitution(): number;
  33543. /**
  33544. * Sets the coefficient of restitution
  33545. */
  33546. set restitution(value: number);
  33547. /**
  33548. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33549. */
  33550. get pressure(): number;
  33551. /**
  33552. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33553. */
  33554. set pressure(value: number);
  33555. /**
  33556. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33557. */
  33558. get stiffness(): number;
  33559. /**
  33560. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33561. */
  33562. set stiffness(value: number);
  33563. /**
  33564. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33565. */
  33566. get velocityIterations(): number;
  33567. /**
  33568. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33569. */
  33570. set velocityIterations(value: number);
  33571. /**
  33572. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33573. */
  33574. get positionIterations(): number;
  33575. /**
  33576. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33577. */
  33578. set positionIterations(value: number);
  33579. /**
  33580. * The unique id of the physics imposter
  33581. * set by the physics engine when adding this impostor to the array
  33582. */
  33583. uniqueId: number;
  33584. /**
  33585. * @hidden
  33586. */
  33587. soft: boolean;
  33588. /**
  33589. * @hidden
  33590. */
  33591. segments: number;
  33592. private _joints;
  33593. /**
  33594. * Initializes the physics imposter
  33595. * @param object The physics-enabled object used as the physics imposter
  33596. * @param type The type of the physics imposter
  33597. * @param _options The options for the physics imposter
  33598. * @param _scene The Babylon scene
  33599. */
  33600. constructor(
  33601. /**
  33602. * The physics-enabled object used as the physics imposter
  33603. */
  33604. object: IPhysicsEnabledObject,
  33605. /**
  33606. * The type of the physics imposter
  33607. */
  33608. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33609. /**
  33610. * This function will completly initialize this impostor.
  33611. * It will create a new body - but only if this mesh has no parent.
  33612. * If it has, this impostor will not be used other than to define the impostor
  33613. * of the child mesh.
  33614. * @hidden
  33615. */
  33616. _init(): void;
  33617. private _getPhysicsParent;
  33618. /**
  33619. * Should a new body be generated.
  33620. * @returns boolean specifying if body initialization is required
  33621. */
  33622. isBodyInitRequired(): boolean;
  33623. /**
  33624. * Sets the updated scaling
  33625. * @param updated Specifies if the scaling is updated
  33626. */
  33627. setScalingUpdated(): void;
  33628. /**
  33629. * Force a regeneration of this or the parent's impostor's body.
  33630. * Use under cautious - This will remove all joints already implemented.
  33631. */
  33632. forceUpdate(): void;
  33633. /**
  33634. * Gets the body that holds this impostor. Either its own, or its parent.
  33635. */
  33636. get physicsBody(): any;
  33637. /**
  33638. * Get the parent of the physics imposter
  33639. * @returns Physics imposter or null
  33640. */
  33641. get parent(): Nullable<PhysicsImpostor>;
  33642. /**
  33643. * Sets the parent of the physics imposter
  33644. */
  33645. set parent(value: Nullable<PhysicsImpostor>);
  33646. /**
  33647. * Set the physics body. Used mainly by the physics engine/plugin
  33648. */
  33649. set physicsBody(physicsBody: any);
  33650. /**
  33651. * Resets the update flags
  33652. */
  33653. resetUpdateFlags(): void;
  33654. /**
  33655. * Gets the object extend size
  33656. * @returns the object extend size
  33657. */
  33658. getObjectExtendSize(): Vector3;
  33659. /**
  33660. * Gets the object center
  33661. * @returns The object center
  33662. */
  33663. getObjectCenter(): Vector3;
  33664. /**
  33665. * Get a specific parameter from the options parameters
  33666. * @param paramName The object parameter name
  33667. * @returns The object parameter
  33668. */
  33669. getParam(paramName: string): any;
  33670. /**
  33671. * Sets a specific parameter in the options given to the physics plugin
  33672. * @param paramName The parameter name
  33673. * @param value The value of the parameter
  33674. */
  33675. setParam(paramName: string, value: number): void;
  33676. /**
  33677. * Specifically change the body's mass option. Won't recreate the physics body object
  33678. * @param mass The mass of the physics imposter
  33679. */
  33680. setMass(mass: number): void;
  33681. /**
  33682. * Gets the linear velocity
  33683. * @returns linear velocity or null
  33684. */
  33685. getLinearVelocity(): Nullable<Vector3>;
  33686. /**
  33687. * Sets the linear velocity
  33688. * @param velocity linear velocity or null
  33689. */
  33690. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33691. /**
  33692. * Gets the angular velocity
  33693. * @returns angular velocity or null
  33694. */
  33695. getAngularVelocity(): Nullable<Vector3>;
  33696. /**
  33697. * Sets the angular velocity
  33698. * @param velocity The velocity or null
  33699. */
  33700. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33701. /**
  33702. * Execute a function with the physics plugin native code
  33703. * Provide a function the will have two variables - the world object and the physics body object
  33704. * @param func The function to execute with the physics plugin native code
  33705. */
  33706. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33707. /**
  33708. * Register a function that will be executed before the physics world is stepping forward
  33709. * @param func The function to execute before the physics world is stepped forward
  33710. */
  33711. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33712. /**
  33713. * Unregister a function that will be executed before the physics world is stepping forward
  33714. * @param func The function to execute before the physics world is stepped forward
  33715. */
  33716. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33717. /**
  33718. * Register a function that will be executed after the physics step
  33719. * @param func The function to execute after physics step
  33720. */
  33721. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33722. /**
  33723. * Unregisters a function that will be executed after the physics step
  33724. * @param func The function to execute after physics step
  33725. */
  33726. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33727. /**
  33728. * register a function that will be executed when this impostor collides against a different body
  33729. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33730. * @param func Callback that is executed on collision
  33731. */
  33732. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33733. /**
  33734. * Unregisters the physics imposter on contact
  33735. * @param collideAgainst The physics object to collide against
  33736. * @param func Callback to execute on collision
  33737. */
  33738. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33739. private _tmpQuat;
  33740. private _tmpQuat2;
  33741. /**
  33742. * Get the parent rotation
  33743. * @returns The parent rotation
  33744. */
  33745. getParentsRotation(): Quaternion;
  33746. /**
  33747. * this function is executed by the physics engine.
  33748. */
  33749. beforeStep: () => void;
  33750. /**
  33751. * this function is executed by the physics engine
  33752. */
  33753. afterStep: () => void;
  33754. /**
  33755. * Legacy collision detection event support
  33756. */
  33757. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33758. /**
  33759. * event and body object due to cannon's event-based architecture.
  33760. */
  33761. onCollide: (e: {
  33762. body: any;
  33763. point: Nullable<Vector3>;
  33764. }) => void;
  33765. /**
  33766. * Apply a force
  33767. * @param force The force to apply
  33768. * @param contactPoint The contact point for the force
  33769. * @returns The physics imposter
  33770. */
  33771. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33772. /**
  33773. * Apply an impulse
  33774. * @param force The impulse force
  33775. * @param contactPoint The contact point for the impulse force
  33776. * @returns The physics imposter
  33777. */
  33778. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33779. /**
  33780. * A help function to create a joint
  33781. * @param otherImpostor A physics imposter used to create a joint
  33782. * @param jointType The type of joint
  33783. * @param jointData The data for the joint
  33784. * @returns The physics imposter
  33785. */
  33786. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33787. /**
  33788. * Add a joint to this impostor with a different impostor
  33789. * @param otherImpostor A physics imposter used to add a joint
  33790. * @param joint The joint to add
  33791. * @returns The physics imposter
  33792. */
  33793. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33794. /**
  33795. * Add an anchor to a cloth impostor
  33796. * @param otherImpostor rigid impostor to anchor to
  33797. * @param width ratio across width from 0 to 1
  33798. * @param height ratio up height from 0 to 1
  33799. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33800. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33801. * @returns impostor the soft imposter
  33802. */
  33803. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33804. /**
  33805. * Add a hook to a rope impostor
  33806. * @param otherImpostor rigid impostor to anchor to
  33807. * @param length ratio across rope from 0 to 1
  33808. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33809. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33810. * @returns impostor the rope imposter
  33811. */
  33812. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33813. /**
  33814. * Will keep this body still, in a sleep mode.
  33815. * @returns the physics imposter
  33816. */
  33817. sleep(): PhysicsImpostor;
  33818. /**
  33819. * Wake the body up.
  33820. * @returns The physics imposter
  33821. */
  33822. wakeUp(): PhysicsImpostor;
  33823. /**
  33824. * Clones the physics imposter
  33825. * @param newObject The physics imposter clones to this physics-enabled object
  33826. * @returns A nullable physics imposter
  33827. */
  33828. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33829. /**
  33830. * Disposes the physics imposter
  33831. */
  33832. dispose(): void;
  33833. /**
  33834. * Sets the delta position
  33835. * @param position The delta position amount
  33836. */
  33837. setDeltaPosition(position: Vector3): void;
  33838. /**
  33839. * Sets the delta rotation
  33840. * @param rotation The delta rotation amount
  33841. */
  33842. setDeltaRotation(rotation: Quaternion): void;
  33843. /**
  33844. * Gets the box size of the physics imposter and stores the result in the input parameter
  33845. * @param result Stores the box size
  33846. * @returns The physics imposter
  33847. */
  33848. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33849. /**
  33850. * Gets the radius of the physics imposter
  33851. * @returns Radius of the physics imposter
  33852. */
  33853. getRadius(): number;
  33854. /**
  33855. * Sync a bone with this impostor
  33856. * @param bone The bone to sync to the impostor.
  33857. * @param boneMesh The mesh that the bone is influencing.
  33858. * @param jointPivot The pivot of the joint / bone in local space.
  33859. * @param distToJoint Optional distance from the impostor to the joint.
  33860. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33861. */
  33862. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33863. /**
  33864. * Sync impostor to a bone
  33865. * @param bone The bone that the impostor will be synced to.
  33866. * @param boneMesh The mesh that the bone is influencing.
  33867. * @param jointPivot The pivot of the joint / bone in local space.
  33868. * @param distToJoint Optional distance from the impostor to the joint.
  33869. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33870. * @param boneAxis Optional vector3 axis the bone is aligned with
  33871. */
  33872. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33873. /**
  33874. * No-Imposter type
  33875. */
  33876. static NoImpostor: number;
  33877. /**
  33878. * Sphere-Imposter type
  33879. */
  33880. static SphereImpostor: number;
  33881. /**
  33882. * Box-Imposter type
  33883. */
  33884. static BoxImpostor: number;
  33885. /**
  33886. * Plane-Imposter type
  33887. */
  33888. static PlaneImpostor: number;
  33889. /**
  33890. * Mesh-imposter type
  33891. */
  33892. static MeshImpostor: number;
  33893. /**
  33894. * Capsule-Impostor type (Ammo.js plugin only)
  33895. */
  33896. static CapsuleImpostor: number;
  33897. /**
  33898. * Cylinder-Imposter type
  33899. */
  33900. static CylinderImpostor: number;
  33901. /**
  33902. * Particle-Imposter type
  33903. */
  33904. static ParticleImpostor: number;
  33905. /**
  33906. * Heightmap-Imposter type
  33907. */
  33908. static HeightmapImpostor: number;
  33909. /**
  33910. * ConvexHull-Impostor type (Ammo.js plugin only)
  33911. */
  33912. static ConvexHullImpostor: number;
  33913. /**
  33914. * Custom-Imposter type (Ammo.js plugin only)
  33915. */
  33916. static CustomImpostor: number;
  33917. /**
  33918. * Rope-Imposter type
  33919. */
  33920. static RopeImpostor: number;
  33921. /**
  33922. * Cloth-Imposter type
  33923. */
  33924. static ClothImpostor: number;
  33925. /**
  33926. * Softbody-Imposter type
  33927. */
  33928. static SoftbodyImpostor: number;
  33929. }
  33930. }
  33931. declare module "babylonjs/Meshes/mesh" {
  33932. import { Observable } from "babylonjs/Misc/observable";
  33933. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33934. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33935. import { Camera } from "babylonjs/Cameras/camera";
  33936. import { Scene } from "babylonjs/scene";
  33937. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33938. import { Color4 } from "babylonjs/Maths/math.color";
  33939. import { Engine } from "babylonjs/Engines/engine";
  33940. import { Node } from "babylonjs/node";
  33941. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33942. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33943. import { Buffer } from "babylonjs/Meshes/buffer";
  33944. import { Geometry } from "babylonjs/Meshes/geometry";
  33945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33946. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33947. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33948. import { Effect } from "babylonjs/Materials/effect";
  33949. import { Material } from "babylonjs/Materials/material";
  33950. import { Skeleton } from "babylonjs/Bones/skeleton";
  33951. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33952. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33953. import { Path3D } from "babylonjs/Maths/math.path";
  33954. import { Plane } from "babylonjs/Maths/math.plane";
  33955. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33956. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33957. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33958. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33959. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33960. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33961. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33962. /**
  33963. * @hidden
  33964. **/
  33965. export class _CreationDataStorage {
  33966. closePath?: boolean;
  33967. closeArray?: boolean;
  33968. idx: number[];
  33969. dashSize: number;
  33970. gapSize: number;
  33971. path3D: Path3D;
  33972. pathArray: Vector3[][];
  33973. arc: number;
  33974. radius: number;
  33975. cap: number;
  33976. tessellation: number;
  33977. }
  33978. /**
  33979. * @hidden
  33980. **/
  33981. class _InstanceDataStorage {
  33982. visibleInstances: any;
  33983. batchCache: _InstancesBatch;
  33984. instancesBufferSize: number;
  33985. instancesBuffer: Nullable<Buffer>;
  33986. instancesData: Float32Array;
  33987. overridenInstanceCount: number;
  33988. isFrozen: boolean;
  33989. previousBatch: Nullable<_InstancesBatch>;
  33990. hardwareInstancedRendering: boolean;
  33991. sideOrientation: number;
  33992. manualUpdate: boolean;
  33993. previousRenderId: number;
  33994. }
  33995. /**
  33996. * @hidden
  33997. **/
  33998. export class _InstancesBatch {
  33999. mustReturn: boolean;
  34000. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  34001. renderSelf: boolean[];
  34002. hardwareInstancedRendering: boolean[];
  34003. }
  34004. /**
  34005. * @hidden
  34006. **/
  34007. class _ThinInstanceDataStorage {
  34008. instancesCount: number;
  34009. matrixBuffer: Nullable<Buffer>;
  34010. matrixBufferSize: number;
  34011. matrixData: Nullable<Float32Array>;
  34012. boundingVectors: Array<Vector3>;
  34013. worldMatrices: Nullable<Matrix[]>;
  34014. }
  34015. /**
  34016. * Class used to represent renderable models
  34017. */
  34018. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  34019. /**
  34020. * Mesh side orientation : usually the external or front surface
  34021. */
  34022. static readonly FRONTSIDE: number;
  34023. /**
  34024. * Mesh side orientation : usually the internal or back surface
  34025. */
  34026. static readonly BACKSIDE: number;
  34027. /**
  34028. * Mesh side orientation : both internal and external or front and back surfaces
  34029. */
  34030. static readonly DOUBLESIDE: number;
  34031. /**
  34032. * Mesh side orientation : by default, `FRONTSIDE`
  34033. */
  34034. static readonly DEFAULTSIDE: number;
  34035. /**
  34036. * Mesh cap setting : no cap
  34037. */
  34038. static readonly NO_CAP: number;
  34039. /**
  34040. * Mesh cap setting : one cap at the beginning of the mesh
  34041. */
  34042. static readonly CAP_START: number;
  34043. /**
  34044. * Mesh cap setting : one cap at the end of the mesh
  34045. */
  34046. static readonly CAP_END: number;
  34047. /**
  34048. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  34049. */
  34050. static readonly CAP_ALL: number;
  34051. /**
  34052. * Mesh pattern setting : no flip or rotate
  34053. */
  34054. static readonly NO_FLIP: number;
  34055. /**
  34056. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  34057. */
  34058. static readonly FLIP_TILE: number;
  34059. /**
  34060. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  34061. */
  34062. static readonly ROTATE_TILE: number;
  34063. /**
  34064. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  34065. */
  34066. static readonly FLIP_ROW: number;
  34067. /**
  34068. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  34069. */
  34070. static readonly ROTATE_ROW: number;
  34071. /**
  34072. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  34073. */
  34074. static readonly FLIP_N_ROTATE_TILE: number;
  34075. /**
  34076. * Mesh pattern setting : rotate pattern and rotate
  34077. */
  34078. static readonly FLIP_N_ROTATE_ROW: number;
  34079. /**
  34080. * Mesh tile positioning : part tiles same on left/right or top/bottom
  34081. */
  34082. static readonly CENTER: number;
  34083. /**
  34084. * Mesh tile positioning : part tiles on left
  34085. */
  34086. static readonly LEFT: number;
  34087. /**
  34088. * Mesh tile positioning : part tiles on right
  34089. */
  34090. static readonly RIGHT: number;
  34091. /**
  34092. * Mesh tile positioning : part tiles on top
  34093. */
  34094. static readonly TOP: number;
  34095. /**
  34096. * Mesh tile positioning : part tiles on bottom
  34097. */
  34098. static readonly BOTTOM: number;
  34099. /**
  34100. * Gets the default side orientation.
  34101. * @param orientation the orientation to value to attempt to get
  34102. * @returns the default orientation
  34103. * @hidden
  34104. */
  34105. static _GetDefaultSideOrientation(orientation?: number): number;
  34106. private _internalMeshDataInfo;
  34107. get computeBonesUsingShaders(): boolean;
  34108. set computeBonesUsingShaders(value: boolean);
  34109. /**
  34110. * An event triggered before rendering the mesh
  34111. */
  34112. get onBeforeRenderObservable(): Observable<Mesh>;
  34113. /**
  34114. * An event triggered before binding the mesh
  34115. */
  34116. get onBeforeBindObservable(): Observable<Mesh>;
  34117. /**
  34118. * An event triggered after rendering the mesh
  34119. */
  34120. get onAfterRenderObservable(): Observable<Mesh>;
  34121. /**
  34122. * An event triggered before drawing the mesh
  34123. */
  34124. get onBeforeDrawObservable(): Observable<Mesh>;
  34125. private _onBeforeDrawObserver;
  34126. /**
  34127. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  34128. */
  34129. set onBeforeDraw(callback: () => void);
  34130. get hasInstances(): boolean;
  34131. get hasThinInstances(): boolean;
  34132. /**
  34133. * Gets the delay loading state of the mesh (when delay loading is turned on)
  34134. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  34135. */
  34136. delayLoadState: number;
  34137. /**
  34138. * Gets the list of instances created from this mesh
  34139. * it is not supposed to be modified manually.
  34140. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  34141. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34142. */
  34143. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  34144. /**
  34145. * Gets the file containing delay loading data for this mesh
  34146. */
  34147. delayLoadingFile: string;
  34148. /** @hidden */
  34149. _binaryInfo: any;
  34150. /**
  34151. * User defined function used to change how LOD level selection is done
  34152. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34153. */
  34154. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  34155. /**
  34156. * Gets or sets the morph target manager
  34157. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  34158. */
  34159. get morphTargetManager(): Nullable<MorphTargetManager>;
  34160. set morphTargetManager(value: Nullable<MorphTargetManager>);
  34161. /** @hidden */
  34162. _creationDataStorage: Nullable<_CreationDataStorage>;
  34163. /** @hidden */
  34164. _geometry: Nullable<Geometry>;
  34165. /** @hidden */
  34166. _delayInfo: Array<string>;
  34167. /** @hidden */
  34168. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  34169. /** @hidden */
  34170. _instanceDataStorage: _InstanceDataStorage;
  34171. /** @hidden */
  34172. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  34173. private _effectiveMaterial;
  34174. /** @hidden */
  34175. _shouldGenerateFlatShading: boolean;
  34176. /** @hidden */
  34177. _originalBuilderSideOrientation: number;
  34178. /**
  34179. * Use this property to change the original side orientation defined at construction time
  34180. */
  34181. overrideMaterialSideOrientation: Nullable<number>;
  34182. /**
  34183. * Gets the source mesh (the one used to clone this one from)
  34184. */
  34185. get source(): Nullable<Mesh>;
  34186. /**
  34187. * Gets the list of clones of this mesh
  34188. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  34189. * Note that useClonedMeshMap=true is the default setting
  34190. */
  34191. get cloneMeshMap(): Nullable<{
  34192. [id: string]: Mesh | undefined;
  34193. }>;
  34194. /**
  34195. * Gets or sets a boolean indicating that this mesh does not use index buffer
  34196. */
  34197. get isUnIndexed(): boolean;
  34198. set isUnIndexed(value: boolean);
  34199. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  34200. get worldMatrixInstancedBuffer(): Float32Array;
  34201. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  34202. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  34203. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  34204. /**
  34205. * @constructor
  34206. * @param name The value used by scene.getMeshByName() to do a lookup.
  34207. * @param scene The scene to add this mesh to.
  34208. * @param parent The parent of this mesh, if it has one
  34209. * @param source An optional Mesh from which geometry is shared, cloned.
  34210. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  34211. * When false, achieved by calling a clone(), also passing False.
  34212. * This will make creation of children, recursive.
  34213. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  34214. */
  34215. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  34216. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  34217. doNotInstantiate: boolean;
  34218. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  34219. /**
  34220. * Gets the class name
  34221. * @returns the string "Mesh".
  34222. */
  34223. getClassName(): string;
  34224. /** @hidden */
  34225. get _isMesh(): boolean;
  34226. /**
  34227. * Returns a description of this mesh
  34228. * @param fullDetails define if full details about this mesh must be used
  34229. * @returns a descriptive string representing this mesh
  34230. */
  34231. toString(fullDetails?: boolean): string;
  34232. /** @hidden */
  34233. _unBindEffect(): void;
  34234. /**
  34235. * Gets a boolean indicating if this mesh has LOD
  34236. */
  34237. get hasLODLevels(): boolean;
  34238. /**
  34239. * Gets the list of MeshLODLevel associated with the current mesh
  34240. * @returns an array of MeshLODLevel
  34241. */
  34242. getLODLevels(): MeshLODLevel[];
  34243. private _sortLODLevels;
  34244. /**
  34245. * Add a mesh as LOD level triggered at the given distance.
  34246. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34247. * @param distance The distance from the center of the object to show this level
  34248. * @param mesh The mesh to be added as LOD level (can be null)
  34249. * @return This mesh (for chaining)
  34250. */
  34251. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  34252. /**
  34253. * Returns the LOD level mesh at the passed distance or null if not found.
  34254. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34255. * @param distance The distance from the center of the object to show this level
  34256. * @returns a Mesh or `null`
  34257. */
  34258. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  34259. /**
  34260. * Remove a mesh from the LOD array
  34261. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34262. * @param mesh defines the mesh to be removed
  34263. * @return This mesh (for chaining)
  34264. */
  34265. removeLODLevel(mesh: Mesh): Mesh;
  34266. /**
  34267. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  34268. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34269. * @param camera defines the camera to use to compute distance
  34270. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  34271. * @return This mesh (for chaining)
  34272. */
  34273. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  34274. /**
  34275. * Gets the mesh internal Geometry object
  34276. */
  34277. get geometry(): Nullable<Geometry>;
  34278. /**
  34279. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  34280. * @returns the total number of vertices
  34281. */
  34282. getTotalVertices(): number;
  34283. /**
  34284. * Returns the content of an associated vertex buffer
  34285. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34286. * - VertexBuffer.PositionKind
  34287. * - VertexBuffer.UVKind
  34288. * - VertexBuffer.UV2Kind
  34289. * - VertexBuffer.UV3Kind
  34290. * - VertexBuffer.UV4Kind
  34291. * - VertexBuffer.UV5Kind
  34292. * - VertexBuffer.UV6Kind
  34293. * - VertexBuffer.ColorKind
  34294. * - VertexBuffer.MatricesIndicesKind
  34295. * - VertexBuffer.MatricesIndicesExtraKind
  34296. * - VertexBuffer.MatricesWeightsKind
  34297. * - VertexBuffer.MatricesWeightsExtraKind
  34298. * @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
  34299. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  34300. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  34301. */
  34302. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34303. /**
  34304. * Returns the mesh VertexBuffer object from the requested `kind`
  34305. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34306. * - VertexBuffer.PositionKind
  34307. * - VertexBuffer.NormalKind
  34308. * - VertexBuffer.UVKind
  34309. * - VertexBuffer.UV2Kind
  34310. * - VertexBuffer.UV3Kind
  34311. * - VertexBuffer.UV4Kind
  34312. * - VertexBuffer.UV5Kind
  34313. * - VertexBuffer.UV6Kind
  34314. * - VertexBuffer.ColorKind
  34315. * - VertexBuffer.MatricesIndicesKind
  34316. * - VertexBuffer.MatricesIndicesExtraKind
  34317. * - VertexBuffer.MatricesWeightsKind
  34318. * - VertexBuffer.MatricesWeightsExtraKind
  34319. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34320. */
  34321. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34322. /**
  34323. * Tests if a specific vertex buffer is associated with this mesh
  34324. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34325. * - VertexBuffer.PositionKind
  34326. * - VertexBuffer.NormalKind
  34327. * - VertexBuffer.UVKind
  34328. * - VertexBuffer.UV2Kind
  34329. * - VertexBuffer.UV3Kind
  34330. * - VertexBuffer.UV4Kind
  34331. * - VertexBuffer.UV5Kind
  34332. * - VertexBuffer.UV6Kind
  34333. * - VertexBuffer.ColorKind
  34334. * - VertexBuffer.MatricesIndicesKind
  34335. * - VertexBuffer.MatricesIndicesExtraKind
  34336. * - VertexBuffer.MatricesWeightsKind
  34337. * - VertexBuffer.MatricesWeightsExtraKind
  34338. * @returns a boolean
  34339. */
  34340. isVerticesDataPresent(kind: string): boolean;
  34341. /**
  34342. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34343. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34344. * - VertexBuffer.PositionKind
  34345. * - VertexBuffer.UVKind
  34346. * - VertexBuffer.UV2Kind
  34347. * - VertexBuffer.UV3Kind
  34348. * - VertexBuffer.UV4Kind
  34349. * - VertexBuffer.UV5Kind
  34350. * - VertexBuffer.UV6Kind
  34351. * - VertexBuffer.ColorKind
  34352. * - VertexBuffer.MatricesIndicesKind
  34353. * - VertexBuffer.MatricesIndicesExtraKind
  34354. * - VertexBuffer.MatricesWeightsKind
  34355. * - VertexBuffer.MatricesWeightsExtraKind
  34356. * @returns a boolean
  34357. */
  34358. isVertexBufferUpdatable(kind: string): boolean;
  34359. /**
  34360. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34361. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34362. * - VertexBuffer.PositionKind
  34363. * - VertexBuffer.NormalKind
  34364. * - VertexBuffer.UVKind
  34365. * - VertexBuffer.UV2Kind
  34366. * - VertexBuffer.UV3Kind
  34367. * - VertexBuffer.UV4Kind
  34368. * - VertexBuffer.UV5Kind
  34369. * - VertexBuffer.UV6Kind
  34370. * - VertexBuffer.ColorKind
  34371. * - VertexBuffer.MatricesIndicesKind
  34372. * - VertexBuffer.MatricesIndicesExtraKind
  34373. * - VertexBuffer.MatricesWeightsKind
  34374. * - VertexBuffer.MatricesWeightsExtraKind
  34375. * @returns an array of strings
  34376. */
  34377. getVerticesDataKinds(): string[];
  34378. /**
  34379. * Returns a positive integer : the total number of indices in this mesh geometry.
  34380. * @returns the numner of indices or zero if the mesh has no geometry.
  34381. */
  34382. getTotalIndices(): number;
  34383. /**
  34384. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34385. * @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.
  34386. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34387. * @returns the indices array or an empty array if the mesh has no geometry
  34388. */
  34389. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34390. get isBlocked(): boolean;
  34391. /**
  34392. * Determine if the current mesh is ready to be rendered
  34393. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34394. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34395. * @returns true if all associated assets are ready (material, textures, shaders)
  34396. */
  34397. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34398. /**
  34399. * 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.
  34400. */
  34401. get areNormalsFrozen(): boolean;
  34402. /**
  34403. * 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.
  34404. * @returns the current mesh
  34405. */
  34406. freezeNormals(): Mesh;
  34407. /**
  34408. * 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
  34409. * @returns the current mesh
  34410. */
  34411. unfreezeNormals(): Mesh;
  34412. /**
  34413. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34414. */
  34415. set overridenInstanceCount(count: number);
  34416. /** @hidden */
  34417. _preActivate(): Mesh;
  34418. /** @hidden */
  34419. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34420. /** @hidden */
  34421. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34422. protected _afterComputeWorldMatrix(): void;
  34423. /** @hidden */
  34424. _postActivate(): void;
  34425. /**
  34426. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34427. * This means the mesh underlying bounding box and sphere are recomputed.
  34428. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34429. * @returns the current mesh
  34430. */
  34431. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34432. /** @hidden */
  34433. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34434. /**
  34435. * This function will subdivide the mesh into multiple submeshes
  34436. * @param count defines the expected number of submeshes
  34437. */
  34438. subdivide(count: number): void;
  34439. /**
  34440. * Copy a FloatArray into a specific associated vertex buffer
  34441. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34442. * - VertexBuffer.PositionKind
  34443. * - VertexBuffer.UVKind
  34444. * - VertexBuffer.UV2Kind
  34445. * - VertexBuffer.UV3Kind
  34446. * - VertexBuffer.UV4Kind
  34447. * - VertexBuffer.UV5Kind
  34448. * - VertexBuffer.UV6Kind
  34449. * - VertexBuffer.ColorKind
  34450. * - VertexBuffer.MatricesIndicesKind
  34451. * - VertexBuffer.MatricesIndicesExtraKind
  34452. * - VertexBuffer.MatricesWeightsKind
  34453. * - VertexBuffer.MatricesWeightsExtraKind
  34454. * @param data defines the data source
  34455. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34456. * @param stride defines the data stride size (can be null)
  34457. * @returns the current mesh
  34458. */
  34459. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34460. /**
  34461. * Delete a vertex buffer associated with this mesh
  34462. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34463. * - VertexBuffer.PositionKind
  34464. * - VertexBuffer.UVKind
  34465. * - VertexBuffer.UV2Kind
  34466. * - VertexBuffer.UV3Kind
  34467. * - VertexBuffer.UV4Kind
  34468. * - VertexBuffer.UV5Kind
  34469. * - VertexBuffer.UV6Kind
  34470. * - VertexBuffer.ColorKind
  34471. * - VertexBuffer.MatricesIndicesKind
  34472. * - VertexBuffer.MatricesIndicesExtraKind
  34473. * - VertexBuffer.MatricesWeightsKind
  34474. * - VertexBuffer.MatricesWeightsExtraKind
  34475. */
  34476. removeVerticesData(kind: string): void;
  34477. /**
  34478. * Flags an associated vertex buffer as updatable
  34479. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34480. * - VertexBuffer.PositionKind
  34481. * - VertexBuffer.UVKind
  34482. * - VertexBuffer.UV2Kind
  34483. * - VertexBuffer.UV3Kind
  34484. * - VertexBuffer.UV4Kind
  34485. * - VertexBuffer.UV5Kind
  34486. * - VertexBuffer.UV6Kind
  34487. * - VertexBuffer.ColorKind
  34488. * - VertexBuffer.MatricesIndicesKind
  34489. * - VertexBuffer.MatricesIndicesExtraKind
  34490. * - VertexBuffer.MatricesWeightsKind
  34491. * - VertexBuffer.MatricesWeightsExtraKind
  34492. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34493. */
  34494. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34495. /**
  34496. * Sets the mesh global Vertex Buffer
  34497. * @param buffer defines the buffer to use
  34498. * @returns the current mesh
  34499. */
  34500. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34501. /**
  34502. * Update a specific associated vertex buffer
  34503. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34504. * - VertexBuffer.PositionKind
  34505. * - VertexBuffer.UVKind
  34506. * - VertexBuffer.UV2Kind
  34507. * - VertexBuffer.UV3Kind
  34508. * - VertexBuffer.UV4Kind
  34509. * - VertexBuffer.UV5Kind
  34510. * - VertexBuffer.UV6Kind
  34511. * - VertexBuffer.ColorKind
  34512. * - VertexBuffer.MatricesIndicesKind
  34513. * - VertexBuffer.MatricesIndicesExtraKind
  34514. * - VertexBuffer.MatricesWeightsKind
  34515. * - VertexBuffer.MatricesWeightsExtraKind
  34516. * @param data defines the data source
  34517. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34518. * @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)
  34519. * @returns the current mesh
  34520. */
  34521. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34522. /**
  34523. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34524. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34525. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34526. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34527. * @returns the current mesh
  34528. */
  34529. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34530. /**
  34531. * Creates a un-shared specific occurence of the geometry for the mesh.
  34532. * @returns the current mesh
  34533. */
  34534. makeGeometryUnique(): Mesh;
  34535. /**
  34536. * Set the index buffer of this mesh
  34537. * @param indices defines the source data
  34538. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34539. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34540. * @returns the current mesh
  34541. */
  34542. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34543. /**
  34544. * Update the current index buffer
  34545. * @param indices defines the source data
  34546. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34547. * @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)
  34548. * @returns the current mesh
  34549. */
  34550. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34551. /**
  34552. * Invert the geometry to move from a right handed system to a left handed one.
  34553. * @returns the current mesh
  34554. */
  34555. toLeftHanded(): Mesh;
  34556. /** @hidden */
  34557. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34558. /** @hidden */
  34559. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34560. /**
  34561. * Registers for this mesh a javascript function called just before the rendering process
  34562. * @param func defines the function to call before rendering this mesh
  34563. * @returns the current mesh
  34564. */
  34565. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34566. /**
  34567. * Disposes a previously registered javascript function called before the rendering
  34568. * @param func defines the function to remove
  34569. * @returns the current mesh
  34570. */
  34571. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34572. /**
  34573. * Registers for this mesh a javascript function called just after the rendering is complete
  34574. * @param func defines the function to call after rendering this mesh
  34575. * @returns the current mesh
  34576. */
  34577. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34578. /**
  34579. * Disposes a previously registered javascript function called after the rendering.
  34580. * @param func defines the function to remove
  34581. * @returns the current mesh
  34582. */
  34583. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34584. /** @hidden */
  34585. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34586. /** @hidden */
  34587. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34588. /** @hidden */
  34589. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34590. /** @hidden */
  34591. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34592. /** @hidden */
  34593. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34594. /** @hidden */
  34595. _rebuild(): void;
  34596. /** @hidden */
  34597. _freeze(): void;
  34598. /** @hidden */
  34599. _unFreeze(): void;
  34600. /**
  34601. * 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
  34602. * @param subMesh defines the subMesh to render
  34603. * @param enableAlphaMode defines if alpha mode can be changed
  34604. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34605. * @returns the current mesh
  34606. */
  34607. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34608. private _onBeforeDraw;
  34609. /**
  34610. * Renormalize the mesh and patch it up if there are no weights
  34611. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34612. * However in the case of zero weights then we set just a single influence to 1.
  34613. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34614. */
  34615. cleanMatrixWeights(): void;
  34616. private normalizeSkinFourWeights;
  34617. private normalizeSkinWeightsAndExtra;
  34618. /**
  34619. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34620. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34621. * the user know there was an issue with importing the mesh
  34622. * @returns a validation object with skinned, valid and report string
  34623. */
  34624. validateSkinning(): {
  34625. skinned: boolean;
  34626. valid: boolean;
  34627. report: string;
  34628. };
  34629. /** @hidden */
  34630. _checkDelayState(): Mesh;
  34631. private _queueLoad;
  34632. /**
  34633. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34634. * A mesh is in the frustum if its bounding box intersects the frustum
  34635. * @param frustumPlanes defines the frustum to test
  34636. * @returns true if the mesh is in the frustum planes
  34637. */
  34638. isInFrustum(frustumPlanes: Plane[]): boolean;
  34639. /**
  34640. * Sets the mesh material by the material or multiMaterial `id` property
  34641. * @param id is a string identifying the material or the multiMaterial
  34642. * @returns the current mesh
  34643. */
  34644. setMaterialByID(id: string): Mesh;
  34645. /**
  34646. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34647. * @returns an array of IAnimatable
  34648. */
  34649. getAnimatables(): IAnimatable[];
  34650. /**
  34651. * Modifies the mesh geometry according to the passed transformation matrix.
  34652. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34653. * The mesh normals are modified using the same transformation.
  34654. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34655. * @param transform defines the transform matrix to use
  34656. * @see https://doc.babylonjs.com/resources/baking_transformations
  34657. * @returns the current mesh
  34658. */
  34659. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34660. /**
  34661. * Modifies the mesh geometry according to its own current World Matrix.
  34662. * The mesh World Matrix is then reset.
  34663. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34664. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34665. * @see https://doc.babylonjs.com/resources/baking_transformations
  34666. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34667. * @returns the current mesh
  34668. */
  34669. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34670. /** @hidden */
  34671. get _positions(): Nullable<Vector3[]>;
  34672. /** @hidden */
  34673. _resetPointsArrayCache(): Mesh;
  34674. /** @hidden */
  34675. _generatePointsArray(): boolean;
  34676. /**
  34677. * Returns a new Mesh object generated from the current mesh properties.
  34678. * This method must not get confused with createInstance()
  34679. * @param name is a string, the name given to the new mesh
  34680. * @param newParent can be any Node object (default `null`)
  34681. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34682. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34683. * @returns a new mesh
  34684. */
  34685. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34686. /**
  34687. * Releases resources associated with this mesh.
  34688. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34689. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34690. */
  34691. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34692. /** @hidden */
  34693. _disposeInstanceSpecificData(): void;
  34694. /** @hidden */
  34695. _disposeThinInstanceSpecificData(): void;
  34696. /**
  34697. * Modifies the mesh geometry according to a displacement map.
  34698. * 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.
  34699. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34700. * @param url is a string, the URL from the image file is to be downloaded.
  34701. * @param minHeight is the lower limit of the displacement.
  34702. * @param maxHeight is the upper limit of the displacement.
  34703. * @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.
  34704. * @param uvOffset is an optional vector2 used to offset UV.
  34705. * @param uvScale is an optional vector2 used to scale UV.
  34706. * @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.
  34707. * @returns the Mesh.
  34708. */
  34709. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34710. /**
  34711. * Modifies the mesh geometry according to a displacementMap buffer.
  34712. * 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.
  34713. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34714. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34715. * @param heightMapWidth is the width of the buffer image.
  34716. * @param heightMapHeight is the height of the buffer image.
  34717. * @param minHeight is the lower limit of the displacement.
  34718. * @param maxHeight is the upper limit of the displacement.
  34719. * @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.
  34720. * @param uvOffset is an optional vector2 used to offset UV.
  34721. * @param uvScale is an optional vector2 used to scale UV.
  34722. * @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.
  34723. * @returns the Mesh.
  34724. */
  34725. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34726. /**
  34727. * Modify the mesh to get a flat shading rendering.
  34728. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34729. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34730. * @returns current mesh
  34731. */
  34732. convertToFlatShadedMesh(): Mesh;
  34733. /**
  34734. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34735. * In other words, more vertices, no more indices and a single bigger VBO.
  34736. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34737. * @returns current mesh
  34738. */
  34739. convertToUnIndexedMesh(): Mesh;
  34740. /**
  34741. * Inverses facet orientations.
  34742. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34743. * @param flipNormals will also inverts the normals
  34744. * @returns current mesh
  34745. */
  34746. flipFaces(flipNormals?: boolean): Mesh;
  34747. /**
  34748. * Increase the number of facets and hence vertices in a mesh
  34749. * Vertex normals are interpolated from existing vertex normals
  34750. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34751. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34752. */
  34753. increaseVertices(numberPerEdge: number): void;
  34754. /**
  34755. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34756. * This will undo any application of covertToFlatShadedMesh
  34757. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34758. */
  34759. forceSharedVertices(): void;
  34760. /** @hidden */
  34761. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34762. /** @hidden */
  34763. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34764. /**
  34765. * Creates a new InstancedMesh object from the mesh model.
  34766. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34767. * @param name defines the name of the new instance
  34768. * @returns a new InstancedMesh
  34769. */
  34770. createInstance(name: string): InstancedMesh;
  34771. /**
  34772. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34773. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34774. * @returns the current mesh
  34775. */
  34776. synchronizeInstances(): Mesh;
  34777. /**
  34778. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34779. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34780. * This should be used together with the simplification to avoid disappearing triangles.
  34781. * @param successCallback an optional success callback to be called after the optimization finished.
  34782. * @returns the current mesh
  34783. */
  34784. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34785. /**
  34786. * Serialize current mesh
  34787. * @param serializationObject defines the object which will receive the serialization data
  34788. */
  34789. serialize(serializationObject: any): void;
  34790. /** @hidden */
  34791. _syncGeometryWithMorphTargetManager(): void;
  34792. /** @hidden */
  34793. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34794. /**
  34795. * Returns a new Mesh object parsed from the source provided.
  34796. * @param parsedMesh is the source
  34797. * @param scene defines the hosting scene
  34798. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34799. * @returns a new Mesh
  34800. */
  34801. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34802. /**
  34803. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34804. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34805. * @param name defines the name of the mesh to create
  34806. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34807. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34808. * @param closePath creates a seam between the first and the last points of each path of the path array
  34809. * @param offset is taken in account only if the `pathArray` is containing a single path
  34810. * @param scene defines the hosting scene
  34811. * @param updatable defines if the mesh must be flagged as updatable
  34812. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34813. * @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)
  34814. * @returns a new Mesh
  34815. */
  34816. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34817. /**
  34818. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34819. * @param name defines the name of the mesh to create
  34820. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34821. * @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
  34822. * @param scene defines the hosting scene
  34823. * @param updatable defines if the mesh must be flagged as updatable
  34824. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34825. * @returns a new Mesh
  34826. */
  34827. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34828. /**
  34829. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34830. * @param name defines the name of the mesh to create
  34831. * @param size sets the size (float) of each box side (default 1)
  34832. * @param scene defines the hosting scene
  34833. * @param updatable defines if the mesh must be flagged as updatable
  34834. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34835. * @returns a new Mesh
  34836. */
  34837. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34838. /**
  34839. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34840. * @param name defines the name of the mesh to create
  34841. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34842. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34843. * @param scene defines the hosting scene
  34844. * @param updatable defines if the mesh must be flagged as updatable
  34845. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34846. * @returns a new Mesh
  34847. */
  34848. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34849. /**
  34850. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34851. * @param name defines the name of the mesh to create
  34852. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34853. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34854. * @param scene defines the hosting scene
  34855. * @returns a new Mesh
  34856. */
  34857. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34858. /**
  34859. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34860. * @param name defines the name of the mesh to create
  34861. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34862. * @param diameterTop set the top cap diameter (floats, default 1)
  34863. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34864. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34865. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34866. * @param scene defines the hosting scene
  34867. * @param updatable defines if the mesh must be flagged as updatable
  34868. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34869. * @returns a new Mesh
  34870. */
  34871. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34872. /**
  34873. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34874. * @param name defines the name of the mesh to create
  34875. * @param diameter sets the diameter size (float) of the torus (default 1)
  34876. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34877. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34878. * @param scene defines the hosting scene
  34879. * @param updatable defines if the mesh must be flagged as updatable
  34880. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34881. * @returns a new Mesh
  34882. */
  34883. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34884. /**
  34885. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34886. * @param name defines the name of the mesh to create
  34887. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34888. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34889. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34890. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34891. * @param p the number of windings on X axis (positive integers, default 2)
  34892. * @param q the number of windings on Y axis (positive integers, default 3)
  34893. * @param scene defines the hosting scene
  34894. * @param updatable defines if the mesh must be flagged as updatable
  34895. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34896. * @returns a new Mesh
  34897. */
  34898. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34899. /**
  34900. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34901. * @param name defines the name of the mesh to create
  34902. * @param points is an array successive Vector3
  34903. * @param scene defines the hosting scene
  34904. * @param updatable defines if the mesh must be flagged as updatable
  34905. * @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).
  34906. * @returns a new Mesh
  34907. */
  34908. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34909. /**
  34910. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34911. * @param name defines the name of the mesh to create
  34912. * @param points is an array successive Vector3
  34913. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34914. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34915. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34916. * @param scene defines the hosting scene
  34917. * @param updatable defines if the mesh must be flagged as updatable
  34918. * @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)
  34919. * @returns a new Mesh
  34920. */
  34921. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34922. /**
  34923. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34924. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34925. * 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.
  34926. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34927. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34928. * Remember you can only change the shape positions, not their number when updating a polygon.
  34929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34930. * @param name defines the name of the mesh to create
  34931. * @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
  34932. * @param scene defines the hosting scene
  34933. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34934. * @param updatable defines if the mesh must be flagged as updatable
  34935. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34936. * @param earcutInjection can be used to inject your own earcut reference
  34937. * @returns a new Mesh
  34938. */
  34939. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34940. /**
  34941. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34943. * @param name defines the name of the mesh to create
  34944. * @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
  34945. * @param depth defines the height of extrusion
  34946. * @param scene defines the hosting scene
  34947. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34948. * @param updatable defines if the mesh must be flagged as updatable
  34949. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34950. * @param earcutInjection can be used to inject your own earcut reference
  34951. * @returns a new Mesh
  34952. */
  34953. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34954. /**
  34955. * Creates an extruded shape mesh.
  34956. * 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
  34957. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34958. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34959. * @param name defines the name of the mesh to create
  34960. * @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
  34961. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34962. * @param scale is the value to scale the shape
  34963. * @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
  34964. * @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
  34965. * @param scene defines the hosting scene
  34966. * @param updatable defines if the mesh must be flagged as updatable
  34967. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34968. * @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)
  34969. * @returns a new Mesh
  34970. */
  34971. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34972. /**
  34973. * Creates an custom extruded shape mesh.
  34974. * The custom extrusion is a parametric shape.
  34975. * It has no predefined shape. Its final shape will depend on the input parameters.
  34976. * Please consider using the same method from the MeshBuilder class instead
  34977. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34978. * @param name defines the name of the mesh to create
  34979. * @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
  34980. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34981. * @param scaleFunction is a custom Javascript function called on each path point
  34982. * @param rotationFunction is a custom Javascript function called on each path point
  34983. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34984. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34985. * @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
  34986. * @param scene defines the hosting scene
  34987. * @param updatable defines if the mesh must be flagged as updatable
  34988. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34989. * @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)
  34990. * @returns a new Mesh
  34991. */
  34992. 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;
  34993. /**
  34994. * Creates lathe mesh.
  34995. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34996. * Please consider using the same method from the MeshBuilder class instead
  34997. * @param name defines the name of the mesh to create
  34998. * @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
  34999. * @param radius is the radius value of the lathe
  35000. * @param tessellation is the side number of the lathe.
  35001. * @param scene defines the hosting scene
  35002. * @param updatable defines if the mesh must be flagged as updatable
  35003. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35004. * @returns a new Mesh
  35005. */
  35006. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35007. /**
  35008. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  35009. * @param name defines the name of the mesh to create
  35010. * @param size sets the size (float) of both sides of the plane at once (default 1)
  35011. * @param scene defines the hosting scene
  35012. * @param updatable defines if the mesh must be flagged as updatable
  35013. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35014. * @returns a new Mesh
  35015. */
  35016. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35017. /**
  35018. * Creates a ground mesh.
  35019. * Please consider using the same method from the MeshBuilder class instead
  35020. * @param name defines the name of the mesh to create
  35021. * @param width set the width of the ground
  35022. * @param height set the height of the ground
  35023. * @param subdivisions sets the number of subdivisions per side
  35024. * @param scene defines the hosting scene
  35025. * @param updatable defines if the mesh must be flagged as updatable
  35026. * @returns a new Mesh
  35027. */
  35028. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  35029. /**
  35030. * Creates a tiled ground mesh.
  35031. * Please consider using the same method from the MeshBuilder class instead
  35032. * @param name defines the name of the mesh to create
  35033. * @param xmin set the ground minimum X coordinate
  35034. * @param zmin set the ground minimum Y coordinate
  35035. * @param xmax set the ground maximum X coordinate
  35036. * @param zmax set the ground maximum Z coordinate
  35037. * @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
  35038. * @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
  35039. * @param scene defines the hosting scene
  35040. * @param updatable defines if the mesh must be flagged as updatable
  35041. * @returns a new Mesh
  35042. */
  35043. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  35044. w: number;
  35045. h: number;
  35046. }, precision: {
  35047. w: number;
  35048. h: number;
  35049. }, scene: Scene, updatable?: boolean): Mesh;
  35050. /**
  35051. * Creates a ground mesh from a height map.
  35052. * Please consider using the same method from the MeshBuilder class instead
  35053. * @see https://doc.babylonjs.com/babylon101/height_map
  35054. * @param name defines the name of the mesh to create
  35055. * @param url sets the URL of the height map image resource
  35056. * @param width set the ground width size
  35057. * @param height set the ground height size
  35058. * @param subdivisions sets the number of subdivision per side
  35059. * @param minHeight is the minimum altitude on the ground
  35060. * @param maxHeight is the maximum altitude on the ground
  35061. * @param scene defines the hosting scene
  35062. * @param updatable defines if the mesh must be flagged as updatable
  35063. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  35064. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  35065. * @returns a new Mesh
  35066. */
  35067. 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;
  35068. /**
  35069. * Creates a tube mesh.
  35070. * The tube is a parametric shape.
  35071. * It has no predefined shape. Its final shape will depend on the input parameters.
  35072. * Please consider using the same method from the MeshBuilder class instead
  35073. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35074. * @param name defines the name of the mesh to create
  35075. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  35076. * @param radius sets the tube radius size
  35077. * @param tessellation is the number of sides on the tubular surface
  35078. * @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
  35079. * @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
  35080. * @param scene defines the hosting scene
  35081. * @param updatable defines if the mesh must be flagged as updatable
  35082. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35083. * @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)
  35084. * @returns a new Mesh
  35085. */
  35086. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  35087. (i: number, distance: number): number;
  35088. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35089. /**
  35090. * Creates a polyhedron mesh.
  35091. * Please consider using the same method from the MeshBuilder class instead.
  35092. * * 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
  35093. * * The parameter `size` (positive float, default 1) sets the polygon size
  35094. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  35095. * * 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`
  35096. * * 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
  35097. * * 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)`)
  35098. * * 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
  35099. * * 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
  35100. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35103. * @param name defines the name of the mesh to create
  35104. * @param options defines the options used to create the mesh
  35105. * @param scene defines the hosting scene
  35106. * @returns a new Mesh
  35107. */
  35108. static CreatePolyhedron(name: string, options: {
  35109. type?: number;
  35110. size?: number;
  35111. sizeX?: number;
  35112. sizeY?: number;
  35113. sizeZ?: number;
  35114. custom?: any;
  35115. faceUV?: Vector4[];
  35116. faceColors?: Color4[];
  35117. updatable?: boolean;
  35118. sideOrientation?: number;
  35119. }, scene: Scene): Mesh;
  35120. /**
  35121. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  35122. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  35123. * * 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`)
  35124. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  35125. * * 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
  35126. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35129. * @param name defines the name of the mesh
  35130. * @param options defines the options used to create the mesh
  35131. * @param scene defines the hosting scene
  35132. * @returns a new Mesh
  35133. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  35134. */
  35135. static CreateIcoSphere(name: string, options: {
  35136. radius?: number;
  35137. flat?: boolean;
  35138. subdivisions?: number;
  35139. sideOrientation?: number;
  35140. updatable?: boolean;
  35141. }, scene: Scene): Mesh;
  35142. /**
  35143. * Creates a decal mesh.
  35144. * Please consider using the same method from the MeshBuilder class instead.
  35145. * A decal is a mesh usually applied as a model onto the surface of another mesh
  35146. * @param name defines the name of the mesh
  35147. * @param sourceMesh defines the mesh receiving the decal
  35148. * @param position sets the position of the decal in world coordinates
  35149. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  35150. * @param size sets the decal scaling
  35151. * @param angle sets the angle to rotate the decal
  35152. * @returns a new Mesh
  35153. */
  35154. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  35155. /** Creates a Capsule Mesh
  35156. * @param name defines the name of the mesh.
  35157. * @param options the constructors options used to shape the mesh.
  35158. * @param scene defines the scene the mesh is scoped to.
  35159. * @returns the capsule mesh
  35160. * @see https://doc.babylonjs.com/how_to/capsule_shape
  35161. */
  35162. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  35163. /**
  35164. * Prepare internal position array for software CPU skinning
  35165. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  35166. */
  35167. setPositionsForCPUSkinning(): Float32Array;
  35168. /**
  35169. * Prepare internal normal array for software CPU skinning
  35170. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  35171. */
  35172. setNormalsForCPUSkinning(): Float32Array;
  35173. /**
  35174. * Updates the vertex buffer by applying transformation from the bones
  35175. * @param skeleton defines the skeleton to apply to current mesh
  35176. * @returns the current mesh
  35177. */
  35178. applySkeleton(skeleton: Skeleton): Mesh;
  35179. /**
  35180. * 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
  35181. * @param meshes defines the list of meshes to scan
  35182. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  35183. */
  35184. static MinMax(meshes: AbstractMesh[]): {
  35185. min: Vector3;
  35186. max: Vector3;
  35187. };
  35188. /**
  35189. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  35190. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  35191. * @returns a vector3
  35192. */
  35193. static Center(meshesOrMinMaxVector: {
  35194. min: Vector3;
  35195. max: Vector3;
  35196. } | AbstractMesh[]): Vector3;
  35197. /**
  35198. * Merge the array of meshes into a single mesh for performance reasons.
  35199. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  35200. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  35201. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  35202. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  35203. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  35204. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  35205. * @returns a new mesh
  35206. */
  35207. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  35208. /** @hidden */
  35209. addInstance(instance: InstancedMesh): void;
  35210. /** @hidden */
  35211. removeInstance(instance: InstancedMesh): void;
  35212. }
  35213. }
  35214. declare module "babylonjs/Cameras/camera" {
  35215. import { SmartArray } from "babylonjs/Misc/smartArray";
  35216. import { Observable } from "babylonjs/Misc/observable";
  35217. import { Nullable } from "babylonjs/types";
  35218. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35219. import { Scene } from "babylonjs/scene";
  35220. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  35221. import { Node } from "babylonjs/node";
  35222. import { Mesh } from "babylonjs/Meshes/mesh";
  35223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35224. import { ICullable } from "babylonjs/Culling/boundingInfo";
  35225. import { Viewport } from "babylonjs/Maths/math.viewport";
  35226. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35227. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35228. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  35229. import { Ray } from "babylonjs/Culling/ray";
  35230. /**
  35231. * This is the base class of all the camera used in the application.
  35232. * @see https://doc.babylonjs.com/features/cameras
  35233. */
  35234. export class Camera extends Node {
  35235. /** @hidden */
  35236. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  35237. /**
  35238. * This is the default projection mode used by the cameras.
  35239. * It helps recreating a feeling of perspective and better appreciate depth.
  35240. * This is the best way to simulate real life cameras.
  35241. */
  35242. static readonly PERSPECTIVE_CAMERA: number;
  35243. /**
  35244. * This helps creating camera with an orthographic mode.
  35245. * 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.
  35246. */
  35247. static readonly ORTHOGRAPHIC_CAMERA: number;
  35248. /**
  35249. * This is the default FOV mode for perspective cameras.
  35250. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  35251. */
  35252. static readonly FOVMODE_VERTICAL_FIXED: number;
  35253. /**
  35254. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  35255. */
  35256. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  35257. /**
  35258. * This specifies ther is no need for a camera rig.
  35259. * Basically only one eye is rendered corresponding to the camera.
  35260. */
  35261. static readonly RIG_MODE_NONE: number;
  35262. /**
  35263. * Simulates a camera Rig with one blue eye and one red eye.
  35264. * This can be use with 3d blue and red glasses.
  35265. */
  35266. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  35267. /**
  35268. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  35269. */
  35270. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  35271. /**
  35272. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  35273. */
  35274. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  35275. /**
  35276. * Defines that both eyes of the camera will be rendered over under each other.
  35277. */
  35278. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  35279. /**
  35280. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  35281. */
  35282. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  35283. /**
  35284. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  35285. */
  35286. static readonly RIG_MODE_VR: number;
  35287. /**
  35288. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  35289. */
  35290. static readonly RIG_MODE_WEBVR: number;
  35291. /**
  35292. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  35293. */
  35294. static readonly RIG_MODE_CUSTOM: number;
  35295. /**
  35296. * Defines if by default attaching controls should prevent the default javascript event to continue.
  35297. */
  35298. static ForceAttachControlToAlwaysPreventDefault: boolean;
  35299. /**
  35300. * Define the input manager associated with the camera.
  35301. */
  35302. inputs: CameraInputsManager<Camera>;
  35303. /** @hidden */
  35304. _position: Vector3;
  35305. /**
  35306. * Define the current local position of the camera in the scene
  35307. */
  35308. get position(): Vector3;
  35309. set position(newPosition: Vector3);
  35310. protected _upVector: Vector3;
  35311. /**
  35312. * The vector the camera should consider as up.
  35313. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  35314. */
  35315. set upVector(vec: Vector3);
  35316. get upVector(): Vector3;
  35317. /**
  35318. * Define the current limit on the left side for an orthographic camera
  35319. * In scene unit
  35320. */
  35321. orthoLeft: Nullable<number>;
  35322. /**
  35323. * Define the current limit on the right side for an orthographic camera
  35324. * In scene unit
  35325. */
  35326. orthoRight: Nullable<number>;
  35327. /**
  35328. * Define the current limit on the bottom side for an orthographic camera
  35329. * In scene unit
  35330. */
  35331. orthoBottom: Nullable<number>;
  35332. /**
  35333. * Define the current limit on the top side for an orthographic camera
  35334. * In scene unit
  35335. */
  35336. orthoTop: Nullable<number>;
  35337. /**
  35338. * Field Of View is set in Radians. (default is 0.8)
  35339. */
  35340. fov: number;
  35341. /**
  35342. * Define the minimum distance the camera can see from.
  35343. * This is important to note that the depth buffer are not infinite and the closer it starts
  35344. * the more your scene might encounter depth fighting issue.
  35345. */
  35346. minZ: number;
  35347. /**
  35348. * Define the maximum distance the camera can see to.
  35349. * This is important to note that the depth buffer are not infinite and the further it end
  35350. * the more your scene might encounter depth fighting issue.
  35351. */
  35352. maxZ: number;
  35353. /**
  35354. * Define the default inertia of the camera.
  35355. * This helps giving a smooth feeling to the camera movement.
  35356. */
  35357. inertia: number;
  35358. /**
  35359. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  35360. */
  35361. mode: number;
  35362. /**
  35363. * Define whether the camera is intermediate.
  35364. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  35365. */
  35366. isIntermediate: boolean;
  35367. /**
  35368. * Define the viewport of the camera.
  35369. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  35370. */
  35371. viewport: Viewport;
  35372. /**
  35373. * Restricts the camera to viewing objects with the same layerMask.
  35374. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  35375. */
  35376. layerMask: number;
  35377. /**
  35378. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  35379. */
  35380. fovMode: number;
  35381. /**
  35382. * Rig mode of the camera.
  35383. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  35384. * This is normally controlled byt the camera themselves as internal use.
  35385. */
  35386. cameraRigMode: number;
  35387. /**
  35388. * Defines the distance between both "eyes" in case of a RIG
  35389. */
  35390. interaxialDistance: number;
  35391. /**
  35392. * Defines if stereoscopic rendering is done side by side or over under.
  35393. */
  35394. isStereoscopicSideBySide: boolean;
  35395. /**
  35396. * 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
  35397. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  35398. * else in the scene. (Eg. security camera)
  35399. *
  35400. * 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)
  35401. */
  35402. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  35403. /**
  35404. * When set, the camera will render to this render target instead of the default canvas
  35405. *
  35406. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  35407. */
  35408. outputRenderTarget: Nullable<RenderTargetTexture>;
  35409. /**
  35410. * Observable triggered when the camera view matrix has changed.
  35411. */
  35412. onViewMatrixChangedObservable: Observable<Camera>;
  35413. /**
  35414. * Observable triggered when the camera Projection matrix has changed.
  35415. */
  35416. onProjectionMatrixChangedObservable: Observable<Camera>;
  35417. /**
  35418. * Observable triggered when the inputs have been processed.
  35419. */
  35420. onAfterCheckInputsObservable: Observable<Camera>;
  35421. /**
  35422. * Observable triggered when reset has been called and applied to the camera.
  35423. */
  35424. onRestoreStateObservable: Observable<Camera>;
  35425. /**
  35426. * Is this camera a part of a rig system?
  35427. */
  35428. isRigCamera: boolean;
  35429. /**
  35430. * If isRigCamera set to true this will be set with the parent camera.
  35431. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  35432. */
  35433. rigParent?: Camera;
  35434. /** @hidden */
  35435. _cameraRigParams: any;
  35436. /** @hidden */
  35437. _rigCameras: Camera[];
  35438. /** @hidden */
  35439. _rigPostProcess: Nullable<PostProcess>;
  35440. protected _webvrViewMatrix: Matrix;
  35441. /** @hidden */
  35442. _skipRendering: boolean;
  35443. /** @hidden */
  35444. _projectionMatrix: Matrix;
  35445. /** @hidden */
  35446. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  35447. /** @hidden */
  35448. _activeMeshes: SmartArray<AbstractMesh>;
  35449. protected _globalPosition: Vector3;
  35450. /** @hidden */
  35451. _computedViewMatrix: Matrix;
  35452. private _doNotComputeProjectionMatrix;
  35453. private _transformMatrix;
  35454. private _frustumPlanes;
  35455. private _refreshFrustumPlanes;
  35456. private _storedFov;
  35457. private _stateStored;
  35458. /**
  35459. * Instantiates a new camera object.
  35460. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  35461. * @see https://doc.babylonjs.com/features/cameras
  35462. * @param name Defines the name of the camera in the scene
  35463. * @param position Defines the position of the camera
  35464. * @param scene Defines the scene the camera belongs too
  35465. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  35466. */
  35467. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35468. /**
  35469. * Store current camera state (fov, position, etc..)
  35470. * @returns the camera
  35471. */
  35472. storeState(): Camera;
  35473. /**
  35474. * Restores the camera state values if it has been stored. You must call storeState() first
  35475. */
  35476. protected _restoreStateValues(): boolean;
  35477. /**
  35478. * Restored camera state. You must call storeState() first.
  35479. * @returns true if restored and false otherwise
  35480. */
  35481. restoreState(): boolean;
  35482. /**
  35483. * Gets the class name of the camera.
  35484. * @returns the class name
  35485. */
  35486. getClassName(): string;
  35487. /** @hidden */
  35488. readonly _isCamera: boolean;
  35489. /**
  35490. * Gets a string representation of the camera useful for debug purpose.
  35491. * @param fullDetails Defines that a more verboe level of logging is required
  35492. * @returns the string representation
  35493. */
  35494. toString(fullDetails?: boolean): string;
  35495. /**
  35496. * Gets the current world space position of the camera.
  35497. */
  35498. get globalPosition(): Vector3;
  35499. /**
  35500. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  35501. * @returns the active meshe list
  35502. */
  35503. getActiveMeshes(): SmartArray<AbstractMesh>;
  35504. /**
  35505. * Check whether a mesh is part of the current active mesh list of the camera
  35506. * @param mesh Defines the mesh to check
  35507. * @returns true if active, false otherwise
  35508. */
  35509. isActiveMesh(mesh: Mesh): boolean;
  35510. /**
  35511. * Is this camera ready to be used/rendered
  35512. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  35513. * @return true if the camera is ready
  35514. */
  35515. isReady(completeCheck?: boolean): boolean;
  35516. /** @hidden */
  35517. _initCache(): void;
  35518. /** @hidden */
  35519. _updateCache(ignoreParentClass?: boolean): void;
  35520. /** @hidden */
  35521. _isSynchronized(): boolean;
  35522. /** @hidden */
  35523. _isSynchronizedViewMatrix(): boolean;
  35524. /** @hidden */
  35525. _isSynchronizedProjectionMatrix(): boolean;
  35526. /**
  35527. * Attach the input controls to a specific dom element to get the input from.
  35528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35529. */
  35530. attachControl(noPreventDefault?: boolean): void;
  35531. /**
  35532. * Detach the current controls from the specified dom element.
  35533. */
  35534. detachControl(): void;
  35535. /**
  35536. * Update the camera state according to the different inputs gathered during the frame.
  35537. */
  35538. update(): void;
  35539. /** @hidden */
  35540. _checkInputs(): void;
  35541. /** @hidden */
  35542. get rigCameras(): Camera[];
  35543. /**
  35544. * Gets the post process used by the rig cameras
  35545. */
  35546. get rigPostProcess(): Nullable<PostProcess>;
  35547. /**
  35548. * Internal, gets the first post proces.
  35549. * @returns the first post process to be run on this camera.
  35550. */
  35551. _getFirstPostProcess(): Nullable<PostProcess>;
  35552. private _cascadePostProcessesToRigCams;
  35553. /**
  35554. * Attach a post process to the camera.
  35555. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35556. * @param postProcess The post process to attach to the camera
  35557. * @param insertAt The position of the post process in case several of them are in use in the scene
  35558. * @returns the position the post process has been inserted at
  35559. */
  35560. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  35561. /**
  35562. * Detach a post process to the camera.
  35563. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35564. * @param postProcess The post process to detach from the camera
  35565. */
  35566. detachPostProcess(postProcess: PostProcess): void;
  35567. /**
  35568. * Gets the current world matrix of the camera
  35569. */
  35570. getWorldMatrix(): Matrix;
  35571. /** @hidden */
  35572. _getViewMatrix(): Matrix;
  35573. /**
  35574. * Gets the current view matrix of the camera.
  35575. * @param force forces the camera to recompute the matrix without looking at the cached state
  35576. * @returns the view matrix
  35577. */
  35578. getViewMatrix(force?: boolean): Matrix;
  35579. /**
  35580. * Freeze the projection matrix.
  35581. * It will prevent the cache check of the camera projection compute and can speed up perf
  35582. * if no parameter of the camera are meant to change
  35583. * @param projection Defines manually a projection if necessary
  35584. */
  35585. freezeProjectionMatrix(projection?: Matrix): void;
  35586. /**
  35587. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  35588. */
  35589. unfreezeProjectionMatrix(): void;
  35590. /**
  35591. * Gets the current projection matrix of the camera.
  35592. * @param force forces the camera to recompute the matrix without looking at the cached state
  35593. * @returns the projection matrix
  35594. */
  35595. getProjectionMatrix(force?: boolean): Matrix;
  35596. /**
  35597. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  35598. * @returns a Matrix
  35599. */
  35600. getTransformationMatrix(): Matrix;
  35601. private _updateFrustumPlanes;
  35602. /**
  35603. * Checks if a cullable object (mesh...) is in the camera frustum
  35604. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  35605. * @param target The object to check
  35606. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  35607. * @returns true if the object is in frustum otherwise false
  35608. */
  35609. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  35610. /**
  35611. * Checks if a cullable object (mesh...) is in the camera frustum
  35612. * Unlike isInFrustum this cheks the full bounding box
  35613. * @param target The object to check
  35614. * @returns true if the object is in frustum otherwise false
  35615. */
  35616. isCompletelyInFrustum(target: ICullable): boolean;
  35617. /**
  35618. * Gets a ray in the forward direction from the camera.
  35619. * @param length Defines the length of the ray to create
  35620. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35621. * @param origin Defines the start point of the ray which defaults to the camera position
  35622. * @returns the forward ray
  35623. */
  35624. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35625. /**
  35626. * Gets a ray in the forward direction from the camera.
  35627. * @param refRay the ray to (re)use when setting the values
  35628. * @param length Defines the length of the ray to create
  35629. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35630. * @param origin Defines the start point of the ray which defaults to the camera position
  35631. * @returns the forward ray
  35632. */
  35633. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35634. /**
  35635. * Releases resources associated with this node.
  35636. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35637. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35638. */
  35639. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35640. /** @hidden */
  35641. _isLeftCamera: boolean;
  35642. /**
  35643. * Gets the left camera of a rig setup in case of Rigged Camera
  35644. */
  35645. get isLeftCamera(): boolean;
  35646. /** @hidden */
  35647. _isRightCamera: boolean;
  35648. /**
  35649. * Gets the right camera of a rig setup in case of Rigged Camera
  35650. */
  35651. get isRightCamera(): boolean;
  35652. /**
  35653. * Gets the left camera of a rig setup in case of Rigged Camera
  35654. */
  35655. get leftCamera(): Nullable<FreeCamera>;
  35656. /**
  35657. * Gets the right camera of a rig setup in case of Rigged Camera
  35658. */
  35659. get rightCamera(): Nullable<FreeCamera>;
  35660. /**
  35661. * Gets the left camera target of a rig setup in case of Rigged Camera
  35662. * @returns the target position
  35663. */
  35664. getLeftTarget(): Nullable<Vector3>;
  35665. /**
  35666. * Gets the right camera target of a rig setup in case of Rigged Camera
  35667. * @returns the target position
  35668. */
  35669. getRightTarget(): Nullable<Vector3>;
  35670. /**
  35671. * @hidden
  35672. */
  35673. setCameraRigMode(mode: number, rigParams: any): void;
  35674. /** @hidden */
  35675. static _setStereoscopicRigMode(camera: Camera): void;
  35676. /** @hidden */
  35677. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  35678. /** @hidden */
  35679. static _setVRRigMode(camera: Camera, rigParams: any): void;
  35680. /** @hidden */
  35681. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  35682. /** @hidden */
  35683. _getVRProjectionMatrix(): Matrix;
  35684. protected _updateCameraRotationMatrix(): void;
  35685. protected _updateWebVRCameraRotationMatrix(): void;
  35686. /**
  35687. * This function MUST be overwritten by the different WebVR cameras available.
  35688. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35689. * @hidden
  35690. */
  35691. _getWebVRProjectionMatrix(): Matrix;
  35692. /**
  35693. * This function MUST be overwritten by the different WebVR cameras available.
  35694. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35695. * @hidden
  35696. */
  35697. _getWebVRViewMatrix(): Matrix;
  35698. /** @hidden */
  35699. setCameraRigParameter(name: string, value: any): void;
  35700. /**
  35701. * needs to be overridden by children so sub has required properties to be copied
  35702. * @hidden
  35703. */
  35704. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  35705. /**
  35706. * May need to be overridden by children
  35707. * @hidden
  35708. */
  35709. _updateRigCameras(): void;
  35710. /** @hidden */
  35711. _setupInputs(): void;
  35712. /**
  35713. * Serialiaze the camera setup to a json represention
  35714. * @returns the JSON representation
  35715. */
  35716. serialize(): any;
  35717. /**
  35718. * Clones the current camera.
  35719. * @param name The cloned camera name
  35720. * @returns the cloned camera
  35721. */
  35722. clone(name: string): Camera;
  35723. /**
  35724. * Gets the direction of the camera relative to a given local axis.
  35725. * @param localAxis Defines the reference axis to provide a relative direction.
  35726. * @return the direction
  35727. */
  35728. getDirection(localAxis: Vector3): Vector3;
  35729. /**
  35730. * Returns the current camera absolute rotation
  35731. */
  35732. get absoluteRotation(): Quaternion;
  35733. /**
  35734. * Gets the direction of the camera relative to a given local axis into a passed vector.
  35735. * @param localAxis Defines the reference axis to provide a relative direction.
  35736. * @param result Defines the vector to store the result in
  35737. */
  35738. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  35739. /**
  35740. * Gets a camera constructor for a given camera type
  35741. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  35742. * @param name The name of the camera the result will be able to instantiate
  35743. * @param scene The scene the result will construct the camera in
  35744. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  35745. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  35746. * @returns a factory method to construc the camera
  35747. */
  35748. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  35749. /**
  35750. * Compute the world matrix of the camera.
  35751. * @returns the camera world matrix
  35752. */
  35753. computeWorldMatrix(): Matrix;
  35754. /**
  35755. * Parse a JSON and creates the camera from the parsed information
  35756. * @param parsedCamera The JSON to parse
  35757. * @param scene The scene to instantiate the camera in
  35758. * @returns the newly constructed camera
  35759. */
  35760. static Parse(parsedCamera: any, scene: Scene): Camera;
  35761. }
  35762. }
  35763. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35764. import { Nullable } from "babylonjs/types";
  35765. import { Scene } from "babylonjs/scene";
  35766. import { Vector4 } from "babylonjs/Maths/math.vector";
  35767. import { Mesh } from "babylonjs/Meshes/mesh";
  35768. /**
  35769. * Class containing static functions to help procedurally build meshes
  35770. */
  35771. export class DiscBuilder {
  35772. /**
  35773. * Creates a plane polygonal mesh. By default, this is a disc
  35774. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35775. * * 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
  35776. * * 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
  35777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35780. * @param name defines the name of the mesh
  35781. * @param options defines the options used to create the mesh
  35782. * @param scene defines the hosting scene
  35783. * @returns the plane polygonal mesh
  35784. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35785. */
  35786. static CreateDisc(name: string, options: {
  35787. radius?: number;
  35788. tessellation?: number;
  35789. arc?: number;
  35790. updatable?: boolean;
  35791. sideOrientation?: number;
  35792. frontUVs?: Vector4;
  35793. backUVs?: Vector4;
  35794. }, scene?: Nullable<Scene>): Mesh;
  35795. }
  35796. }
  35797. declare module "babylonjs/Particles/solidParticleSystem" {
  35798. import { Nullable } from "babylonjs/types";
  35799. import { Mesh } from "babylonjs/Meshes/mesh";
  35800. import { Scene, IDisposable } from "babylonjs/scene";
  35801. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35802. import { Material } from "babylonjs/Materials/material";
  35803. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35804. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35805. /**
  35806. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35807. *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.
  35808. * The SPS is also a particle system. It provides some methods to manage the particles.
  35809. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35810. *
  35811. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35812. */
  35813. export class SolidParticleSystem implements IDisposable {
  35814. /**
  35815. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35816. * Example : var p = SPS.particles[i];
  35817. */
  35818. particles: SolidParticle[];
  35819. /**
  35820. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35821. */
  35822. nbParticles: number;
  35823. /**
  35824. * If the particles must ever face the camera (default false). Useful for planar particles.
  35825. */
  35826. billboard: boolean;
  35827. /**
  35828. * Recompute normals when adding a shape
  35829. */
  35830. recomputeNormals: boolean;
  35831. /**
  35832. * This a counter ofr your own usage. It's not set by any SPS functions.
  35833. */
  35834. counter: number;
  35835. /**
  35836. * The SPS name. This name is also given to the underlying mesh.
  35837. */
  35838. name: string;
  35839. /**
  35840. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35841. */
  35842. mesh: Mesh;
  35843. /**
  35844. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35845. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35846. */
  35847. vars: any;
  35848. /**
  35849. * This array is populated when the SPS is set as 'pickable'.
  35850. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35851. * Each element of this array is an object `{idx: int, faceId: int}`.
  35852. * `idx` is the picked particle index in the `SPS.particles` array
  35853. * `faceId` is the picked face index counted within this particle.
  35854. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35855. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35856. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35857. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35858. */
  35859. pickedParticles: {
  35860. idx: number;
  35861. faceId: number;
  35862. }[];
  35863. /**
  35864. * This array is populated when the SPS is set as 'pickable'
  35865. * Each key of this array is a submesh index.
  35866. * Each element of this array is a second array defined like this :
  35867. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35868. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35869. * `idx` is the picked particle index in the `SPS.particles` array
  35870. * `faceId` is the picked face index counted within this particle.
  35871. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35872. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35873. */
  35874. pickedBySubMesh: {
  35875. idx: number;
  35876. faceId: number;
  35877. }[][];
  35878. /**
  35879. * This array is populated when `enableDepthSort` is set to true.
  35880. * Each element of this array is an instance of the class DepthSortedParticle.
  35881. */
  35882. depthSortedParticles: DepthSortedParticle[];
  35883. /**
  35884. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35885. * @hidden
  35886. */
  35887. _bSphereOnly: boolean;
  35888. /**
  35889. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35890. * @hidden
  35891. */
  35892. _bSphereRadiusFactor: number;
  35893. private _scene;
  35894. private _positions;
  35895. private _indices;
  35896. private _normals;
  35897. private _colors;
  35898. private _uvs;
  35899. private _indices32;
  35900. private _positions32;
  35901. private _normals32;
  35902. private _fixedNormal32;
  35903. private _colors32;
  35904. private _uvs32;
  35905. private _index;
  35906. private _updatable;
  35907. private _pickable;
  35908. private _isVisibilityBoxLocked;
  35909. private _alwaysVisible;
  35910. private _depthSort;
  35911. private _expandable;
  35912. private _shapeCounter;
  35913. private _copy;
  35914. private _color;
  35915. private _computeParticleColor;
  35916. private _computeParticleTexture;
  35917. private _computeParticleRotation;
  35918. private _computeParticleVertex;
  35919. private _computeBoundingBox;
  35920. private _depthSortParticles;
  35921. private _camera;
  35922. private _mustUnrotateFixedNormals;
  35923. private _particlesIntersect;
  35924. private _needs32Bits;
  35925. private _isNotBuilt;
  35926. private _lastParticleId;
  35927. private _idxOfId;
  35928. private _multimaterialEnabled;
  35929. private _useModelMaterial;
  35930. private _indicesByMaterial;
  35931. private _materialIndexes;
  35932. private _depthSortFunction;
  35933. private _materialSortFunction;
  35934. private _materials;
  35935. private _multimaterial;
  35936. private _materialIndexesById;
  35937. private _defaultMaterial;
  35938. private _autoUpdateSubMeshes;
  35939. private _tmpVertex;
  35940. /**
  35941. * Creates a SPS (Solid Particle System) object.
  35942. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35943. * @param scene (Scene) is the scene in which the SPS is added.
  35944. * @param options defines the options of the sps e.g.
  35945. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35946. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35947. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35948. * * 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.
  35949. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35950. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35951. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35952. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35953. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35954. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35955. */
  35956. constructor(name: string, scene: Scene, options?: {
  35957. updatable?: boolean;
  35958. isPickable?: boolean;
  35959. enableDepthSort?: boolean;
  35960. particleIntersection?: boolean;
  35961. boundingSphereOnly?: boolean;
  35962. bSphereRadiusFactor?: number;
  35963. expandable?: boolean;
  35964. useModelMaterial?: boolean;
  35965. enableMultiMaterial?: boolean;
  35966. });
  35967. /**
  35968. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35969. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35970. * @returns the created mesh
  35971. */
  35972. buildMesh(): Mesh;
  35973. /**
  35974. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35975. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35976. * Thus the particles generated from `digest()` have their property `position` set yet.
  35977. * @param mesh ( Mesh ) is the mesh to be digested
  35978. * @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
  35979. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35980. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35981. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35982. * @returns the current SPS
  35983. */
  35984. digest(mesh: Mesh, options?: {
  35985. facetNb?: number;
  35986. number?: number;
  35987. delta?: number;
  35988. storage?: [];
  35989. }): SolidParticleSystem;
  35990. /**
  35991. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35992. * @hidden
  35993. */
  35994. private _unrotateFixedNormals;
  35995. /**
  35996. * Resets the temporary working copy particle
  35997. * @hidden
  35998. */
  35999. private _resetCopy;
  36000. /**
  36001. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  36002. * @param p the current index in the positions array to be updated
  36003. * @param ind the current index in the indices array
  36004. * @param shape a Vector3 array, the shape geometry
  36005. * @param positions the positions array to be updated
  36006. * @param meshInd the shape indices array
  36007. * @param indices the indices array to be updated
  36008. * @param meshUV the shape uv array
  36009. * @param uvs the uv array to be updated
  36010. * @param meshCol the shape color array
  36011. * @param colors the color array to be updated
  36012. * @param meshNor the shape normals array
  36013. * @param normals the normals array to be updated
  36014. * @param idx the particle index
  36015. * @param idxInShape the particle index in its shape
  36016. * @param options the addShape() method passed options
  36017. * @model the particle model
  36018. * @hidden
  36019. */
  36020. private _meshBuilder;
  36021. /**
  36022. * Returns a shape Vector3 array from positions float array
  36023. * @param positions float array
  36024. * @returns a vector3 array
  36025. * @hidden
  36026. */
  36027. private _posToShape;
  36028. /**
  36029. * Returns a shapeUV array from a float uvs (array deep copy)
  36030. * @param uvs as a float array
  36031. * @returns a shapeUV array
  36032. * @hidden
  36033. */
  36034. private _uvsToShapeUV;
  36035. /**
  36036. * Adds a new particle object in the particles array
  36037. * @param idx particle index in particles array
  36038. * @param id particle id
  36039. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  36040. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  36041. * @param model particle ModelShape object
  36042. * @param shapeId model shape identifier
  36043. * @param idxInShape index of the particle in the current model
  36044. * @param bInfo model bounding info object
  36045. * @param storage target storage array, if any
  36046. * @hidden
  36047. */
  36048. private _addParticle;
  36049. /**
  36050. * Adds some particles to the SPS from the model shape. Returns the shape id.
  36051. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  36052. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  36053. * @param nb (positive integer) the number of particles to be created from this model
  36054. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  36055. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  36056. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36057. * @returns the number of shapes in the system
  36058. */
  36059. addShape(mesh: Mesh, nb: number, options?: {
  36060. positionFunction?: any;
  36061. vertexFunction?: any;
  36062. storage?: [];
  36063. }): number;
  36064. /**
  36065. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  36066. * @hidden
  36067. */
  36068. private _rebuildParticle;
  36069. /**
  36070. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  36071. * @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.
  36072. * @returns the SPS.
  36073. */
  36074. rebuildMesh(reset?: boolean): SolidParticleSystem;
  36075. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  36076. * Returns an array with the removed particles.
  36077. * 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.
  36078. * The SPS can't be empty so at least one particle needs to remain in place.
  36079. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  36080. * @param start index of the first particle to remove
  36081. * @param end index of the last particle to remove (included)
  36082. * @returns an array populated with the removed particles
  36083. */
  36084. removeParticles(start: number, end: number): SolidParticle[];
  36085. /**
  36086. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  36087. * @param solidParticleArray an array populated with Solid Particles objects
  36088. * @returns the SPS
  36089. */
  36090. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  36091. /**
  36092. * Creates a new particle and modifies the SPS mesh geometry :
  36093. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  36094. * - calls _addParticle() to populate the particle array
  36095. * factorized code from addShape() and insertParticlesFromArray()
  36096. * @param idx particle index in the particles array
  36097. * @param i particle index in its shape
  36098. * @param modelShape particle ModelShape object
  36099. * @param shape shape vertex array
  36100. * @param meshInd shape indices array
  36101. * @param meshUV shape uv array
  36102. * @param meshCol shape color array
  36103. * @param meshNor shape normals array
  36104. * @param bbInfo shape bounding info
  36105. * @param storage target particle storage
  36106. * @options addShape() passed options
  36107. * @hidden
  36108. */
  36109. private _insertNewParticle;
  36110. /**
  36111. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  36112. * This method calls `updateParticle()` for each particle of the SPS.
  36113. * For an animated SPS, it is usually called within the render loop.
  36114. * 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.
  36115. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  36116. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  36117. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  36118. * @returns the SPS.
  36119. */
  36120. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  36121. /**
  36122. * Disposes the SPS.
  36123. */
  36124. dispose(): void;
  36125. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  36126. * idx is the particle index in the SPS
  36127. * faceId is the picked face index counted within this particle.
  36128. * Returns null if the pickInfo can't identify a picked particle.
  36129. * @param pickingInfo (PickingInfo object)
  36130. * @returns {idx: number, faceId: number} or null
  36131. */
  36132. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  36133. idx: number;
  36134. faceId: number;
  36135. }>;
  36136. /**
  36137. * Returns a SolidParticle object from its identifier : particle.id
  36138. * @param id (integer) the particle Id
  36139. * @returns the searched particle or null if not found in the SPS.
  36140. */
  36141. getParticleById(id: number): Nullable<SolidParticle>;
  36142. /**
  36143. * Returns a new array populated with the particles having the passed shapeId.
  36144. * @param shapeId (integer) the shape identifier
  36145. * @returns a new solid particle array
  36146. */
  36147. getParticlesByShapeId(shapeId: number): SolidParticle[];
  36148. /**
  36149. * Populates the passed array "ref" with the particles having the passed shapeId.
  36150. * @param shapeId the shape identifier
  36151. * @returns the SPS
  36152. * @param ref
  36153. */
  36154. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  36155. /**
  36156. * Computes the required SubMeshes according the materials assigned to the particles.
  36157. * @returns the solid particle system.
  36158. * Does nothing if called before the SPS mesh is built.
  36159. */
  36160. computeSubMeshes(): SolidParticleSystem;
  36161. /**
  36162. * Sorts the solid particles by material when MultiMaterial is enabled.
  36163. * Updates the indices32 array.
  36164. * Updates the indicesByMaterial array.
  36165. * Updates the mesh indices array.
  36166. * @returns the SPS
  36167. * @hidden
  36168. */
  36169. private _sortParticlesByMaterial;
  36170. /**
  36171. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  36172. * @hidden
  36173. */
  36174. private _setMaterialIndexesById;
  36175. /**
  36176. * Returns an array with unique values of Materials from the passed array
  36177. * @param array the material array to be checked and filtered
  36178. * @hidden
  36179. */
  36180. private _filterUniqueMaterialId;
  36181. /**
  36182. * Sets a new Standard Material as _defaultMaterial if not already set.
  36183. * @hidden
  36184. */
  36185. private _setDefaultMaterial;
  36186. /**
  36187. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  36188. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36189. * @returns the SPS.
  36190. */
  36191. refreshVisibleSize(): SolidParticleSystem;
  36192. /**
  36193. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  36194. * @param size the size (float) of the visibility box
  36195. * note : this doesn't lock the SPS mesh bounding box.
  36196. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36197. */
  36198. setVisibilityBox(size: number): void;
  36199. /**
  36200. * Gets whether the SPS as always visible or not
  36201. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36202. */
  36203. get isAlwaysVisible(): boolean;
  36204. /**
  36205. * Sets the SPS as always visible or not
  36206. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36207. */
  36208. set isAlwaysVisible(val: boolean);
  36209. /**
  36210. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36211. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36212. */
  36213. set isVisibilityBoxLocked(val: boolean);
  36214. /**
  36215. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36216. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36217. */
  36218. get isVisibilityBoxLocked(): boolean;
  36219. /**
  36220. * Tells to `setParticles()` to compute the particle rotations or not.
  36221. * Default value : true. The SPS is faster when it's set to false.
  36222. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36223. */
  36224. set computeParticleRotation(val: boolean);
  36225. /**
  36226. * Tells to `setParticles()` to compute the particle colors or not.
  36227. * Default value : true. The SPS is faster when it's set to false.
  36228. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36229. */
  36230. set computeParticleColor(val: boolean);
  36231. set computeParticleTexture(val: boolean);
  36232. /**
  36233. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  36234. * Default value : false. The SPS is faster when it's set to false.
  36235. * Note : the particle custom vertex positions aren't stored values.
  36236. */
  36237. set computeParticleVertex(val: boolean);
  36238. /**
  36239. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  36240. */
  36241. set computeBoundingBox(val: boolean);
  36242. /**
  36243. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  36244. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36245. * Default : `true`
  36246. */
  36247. set depthSortParticles(val: boolean);
  36248. /**
  36249. * Gets if `setParticles()` computes the particle rotations or not.
  36250. * Default value : true. The SPS is faster when it's set to false.
  36251. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36252. */
  36253. get computeParticleRotation(): boolean;
  36254. /**
  36255. * Gets if `setParticles()` computes the particle colors or not.
  36256. * Default value : true. The SPS is faster when it's set to false.
  36257. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36258. */
  36259. get computeParticleColor(): boolean;
  36260. /**
  36261. * Gets if `setParticles()` computes the particle textures or not.
  36262. * Default value : true. The SPS is faster when it's set to false.
  36263. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  36264. */
  36265. get computeParticleTexture(): boolean;
  36266. /**
  36267. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  36268. * Default value : false. The SPS is faster when it's set to false.
  36269. * Note : the particle custom vertex positions aren't stored values.
  36270. */
  36271. get computeParticleVertex(): boolean;
  36272. /**
  36273. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  36274. */
  36275. get computeBoundingBox(): boolean;
  36276. /**
  36277. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  36278. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36279. * Default : `true`
  36280. */
  36281. get depthSortParticles(): boolean;
  36282. /**
  36283. * Gets if the SPS is created as expandable at construction time.
  36284. * Default : `false`
  36285. */
  36286. get expandable(): boolean;
  36287. /**
  36288. * Gets if the SPS supports the Multi Materials
  36289. */
  36290. get multimaterialEnabled(): boolean;
  36291. /**
  36292. * Gets if the SPS uses the model materials for its own multimaterial.
  36293. */
  36294. get useModelMaterial(): boolean;
  36295. /**
  36296. * The SPS used material array.
  36297. */
  36298. get materials(): Material[];
  36299. /**
  36300. * Sets the SPS MultiMaterial from the passed materials.
  36301. * Note : the passed array is internally copied and not used then by reference.
  36302. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36303. */
  36304. setMultiMaterial(materials: Material[]): void;
  36305. /**
  36306. * The SPS computed multimaterial object
  36307. */
  36308. get multimaterial(): MultiMaterial;
  36309. set multimaterial(mm: MultiMaterial);
  36310. /**
  36311. * If the subMeshes must be updated on the next call to setParticles()
  36312. */
  36313. get autoUpdateSubMeshes(): boolean;
  36314. set autoUpdateSubMeshes(val: boolean);
  36315. /**
  36316. * This function does nothing. It may be overwritten to set all the particle first values.
  36317. * The SPS doesn't call this function, you may have to call it by your own.
  36318. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36319. */
  36320. initParticles(): void;
  36321. /**
  36322. * This function does nothing. It may be overwritten to recycle a particle.
  36323. * The SPS doesn't call this function, you may have to call it by your own.
  36324. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36325. * @param particle The particle to recycle
  36326. * @returns the recycled particle
  36327. */
  36328. recycleParticle(particle: SolidParticle): SolidParticle;
  36329. /**
  36330. * Updates a particle : this function should be overwritten by the user.
  36331. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36332. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36333. * @example : just set a particle position or velocity and recycle conditions
  36334. * @param particle The particle to update
  36335. * @returns the updated particle
  36336. */
  36337. updateParticle(particle: SolidParticle): SolidParticle;
  36338. /**
  36339. * Updates a vertex of a particle : it can be overwritten by the user.
  36340. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36341. * @param particle the current particle
  36342. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36343. * @param pt the index of the current vertex in the particle shape
  36344. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36345. * @example : just set a vertex particle position or color
  36346. * @returns the sps
  36347. */
  36348. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36349. /**
  36350. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36351. * This does nothing and may be overwritten by the user.
  36352. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36353. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36354. * @param update the boolean update value actually passed to setParticles()
  36355. */
  36356. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36357. /**
  36358. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36359. * This will be passed three parameters.
  36360. * This does nothing and may be overwritten by the user.
  36361. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36362. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36363. * @param update the boolean update value actually passed to setParticles()
  36364. */
  36365. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36366. }
  36367. }
  36368. declare module "babylonjs/Particles/solidParticle" {
  36369. import { Nullable } from "babylonjs/types";
  36370. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36371. import { Color4 } from "babylonjs/Maths/math.color";
  36372. import { Mesh } from "babylonjs/Meshes/mesh";
  36373. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36374. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36375. import { Plane } from "babylonjs/Maths/math.plane";
  36376. import { Material } from "babylonjs/Materials/material";
  36377. /**
  36378. * Represents one particle of a solid particle system.
  36379. */
  36380. export class SolidParticle {
  36381. /**
  36382. * particle global index
  36383. */
  36384. idx: number;
  36385. /**
  36386. * particle identifier
  36387. */
  36388. id: number;
  36389. /**
  36390. * The color of the particle
  36391. */
  36392. color: Nullable<Color4>;
  36393. /**
  36394. * The world space position of the particle.
  36395. */
  36396. position: Vector3;
  36397. /**
  36398. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36399. */
  36400. rotation: Vector3;
  36401. /**
  36402. * The world space rotation quaternion of the particle.
  36403. */
  36404. rotationQuaternion: Nullable<Quaternion>;
  36405. /**
  36406. * The scaling of the particle.
  36407. */
  36408. scaling: Vector3;
  36409. /**
  36410. * The uvs of the particle.
  36411. */
  36412. uvs: Vector4;
  36413. /**
  36414. * The current speed of the particle.
  36415. */
  36416. velocity: Vector3;
  36417. /**
  36418. * The pivot point in the particle local space.
  36419. */
  36420. pivot: Vector3;
  36421. /**
  36422. * Must the particle be translated from its pivot point in its local space ?
  36423. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36424. * Default : false
  36425. */
  36426. translateFromPivot: boolean;
  36427. /**
  36428. * Is the particle active or not ?
  36429. */
  36430. alive: boolean;
  36431. /**
  36432. * Is the particle visible or not ?
  36433. */
  36434. isVisible: boolean;
  36435. /**
  36436. * Index of this particle in the global "positions" array (Internal use)
  36437. * @hidden
  36438. */
  36439. _pos: number;
  36440. /**
  36441. * @hidden Index of this particle in the global "indices" array (Internal use)
  36442. */
  36443. _ind: number;
  36444. /**
  36445. * @hidden ModelShape of this particle (Internal use)
  36446. */
  36447. _model: ModelShape;
  36448. /**
  36449. * ModelShape id of this particle
  36450. */
  36451. shapeId: number;
  36452. /**
  36453. * Index of the particle in its shape id
  36454. */
  36455. idxInShape: number;
  36456. /**
  36457. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36458. */
  36459. _modelBoundingInfo: BoundingInfo;
  36460. /**
  36461. * @hidden Particle BoundingInfo object (Internal use)
  36462. */
  36463. _boundingInfo: BoundingInfo;
  36464. /**
  36465. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36466. */
  36467. _sps: SolidParticleSystem;
  36468. /**
  36469. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36470. */
  36471. _stillInvisible: boolean;
  36472. /**
  36473. * @hidden Last computed particle rotation matrix
  36474. */
  36475. _rotationMatrix: number[];
  36476. /**
  36477. * Parent particle Id, if any.
  36478. * Default null.
  36479. */
  36480. parentId: Nullable<number>;
  36481. /**
  36482. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36483. */
  36484. materialIndex: Nullable<number>;
  36485. /**
  36486. * Custom object or properties.
  36487. */
  36488. props: Nullable<any>;
  36489. /**
  36490. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36491. * The possible values are :
  36492. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36493. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36494. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36495. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36496. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36497. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36498. * */
  36499. cullingStrategy: number;
  36500. /**
  36501. * @hidden Internal global position in the SPS.
  36502. */
  36503. _globalPosition: Vector3;
  36504. /**
  36505. * Creates a Solid Particle object.
  36506. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36507. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36508. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36509. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36510. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36511. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36512. * @param shapeId (integer) is the model shape identifier in the SPS.
  36513. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36514. * @param sps defines the sps it is associated to
  36515. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36516. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36517. */
  36518. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36519. /**
  36520. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36521. * @param target the particle target
  36522. * @returns the current particle
  36523. */
  36524. copyToRef(target: SolidParticle): SolidParticle;
  36525. /**
  36526. * Legacy support, changed scale to scaling
  36527. */
  36528. get scale(): Vector3;
  36529. /**
  36530. * Legacy support, changed scale to scaling
  36531. */
  36532. set scale(scale: Vector3);
  36533. /**
  36534. * Legacy support, changed quaternion to rotationQuaternion
  36535. */
  36536. get quaternion(): Nullable<Quaternion>;
  36537. /**
  36538. * Legacy support, changed quaternion to rotationQuaternion
  36539. */
  36540. set quaternion(q: Nullable<Quaternion>);
  36541. /**
  36542. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36543. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36544. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36545. * @returns true if it intersects
  36546. */
  36547. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36548. /**
  36549. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36550. * A particle is in the frustum if its bounding box intersects the frustum
  36551. * @param frustumPlanes defines the frustum to test
  36552. * @returns true if the particle is in the frustum planes
  36553. */
  36554. isInFrustum(frustumPlanes: Plane[]): boolean;
  36555. /**
  36556. * get the rotation matrix of the particle
  36557. * @hidden
  36558. */
  36559. getRotationMatrix(m: Matrix): void;
  36560. }
  36561. /**
  36562. * Represents the shape of the model used by one particle of a solid particle system.
  36563. * SPS internal tool, don't use it manually.
  36564. */
  36565. export class ModelShape {
  36566. /**
  36567. * The shape id
  36568. * @hidden
  36569. */
  36570. shapeID: number;
  36571. /**
  36572. * flat array of model positions (internal use)
  36573. * @hidden
  36574. */
  36575. _shape: Vector3[];
  36576. /**
  36577. * flat array of model UVs (internal use)
  36578. * @hidden
  36579. */
  36580. _shapeUV: number[];
  36581. /**
  36582. * color array of the model
  36583. * @hidden
  36584. */
  36585. _shapeColors: number[];
  36586. /**
  36587. * indices array of the model
  36588. * @hidden
  36589. */
  36590. _indices: number[];
  36591. /**
  36592. * normals array of the model
  36593. * @hidden
  36594. */
  36595. _normals: number[];
  36596. /**
  36597. * length of the shape in the model indices array (internal use)
  36598. * @hidden
  36599. */
  36600. _indicesLength: number;
  36601. /**
  36602. * Custom position function (internal use)
  36603. * @hidden
  36604. */
  36605. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36606. /**
  36607. * Custom vertex function (internal use)
  36608. * @hidden
  36609. */
  36610. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36611. /**
  36612. * Model material (internal use)
  36613. * @hidden
  36614. */
  36615. _material: Nullable<Material>;
  36616. /**
  36617. * 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.
  36618. * SPS internal tool, don't use it manually.
  36619. * @hidden
  36620. */
  36621. 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>);
  36622. }
  36623. /**
  36624. * Represents a Depth Sorted Particle in the solid particle system.
  36625. * @hidden
  36626. */
  36627. export class DepthSortedParticle {
  36628. /**
  36629. * Particle index
  36630. */
  36631. idx: number;
  36632. /**
  36633. * Index of the particle in the "indices" array
  36634. */
  36635. ind: number;
  36636. /**
  36637. * Length of the particle shape in the "indices" array
  36638. */
  36639. indicesLength: number;
  36640. /**
  36641. * Squared distance from the particle to the camera
  36642. */
  36643. sqDistance: number;
  36644. /**
  36645. * Material index when used with MultiMaterials
  36646. */
  36647. materialIndex: number;
  36648. /**
  36649. * Creates a new sorted particle
  36650. * @param materialIndex
  36651. */
  36652. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36653. }
  36654. /**
  36655. * Represents a solid particle vertex
  36656. */
  36657. export class SolidParticleVertex {
  36658. /**
  36659. * Vertex position
  36660. */
  36661. position: Vector3;
  36662. /**
  36663. * Vertex color
  36664. */
  36665. color: Color4;
  36666. /**
  36667. * Vertex UV
  36668. */
  36669. uv: Vector2;
  36670. /**
  36671. * Creates a new solid particle vertex
  36672. */
  36673. constructor();
  36674. /** Vertex x coordinate */
  36675. get x(): number;
  36676. set x(val: number);
  36677. /** Vertex y coordinate */
  36678. get y(): number;
  36679. set y(val: number);
  36680. /** Vertex z coordinate */
  36681. get z(): number;
  36682. set z(val: number);
  36683. }
  36684. }
  36685. declare module "babylonjs/Collisions/meshCollisionData" {
  36686. import { Collider } from "babylonjs/Collisions/collider";
  36687. import { Vector3 } from "babylonjs/Maths/math.vector";
  36688. import { Nullable } from "babylonjs/types";
  36689. import { Observer } from "babylonjs/Misc/observable";
  36690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36691. /**
  36692. * @hidden
  36693. */
  36694. export class _MeshCollisionData {
  36695. _checkCollisions: boolean;
  36696. _collisionMask: number;
  36697. _collisionGroup: number;
  36698. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36699. _collider: Nullable<Collider>;
  36700. _oldPositionForCollisions: Vector3;
  36701. _diffPositionForCollisions: Vector3;
  36702. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36703. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36704. _collisionResponse: boolean;
  36705. }
  36706. }
  36707. declare module "babylonjs/Meshes/abstractMesh" {
  36708. import { Observable } from "babylonjs/Misc/observable";
  36709. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36710. import { Camera } from "babylonjs/Cameras/camera";
  36711. import { Scene, IDisposable } from "babylonjs/scene";
  36712. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36713. import { Node } from "babylonjs/node";
  36714. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36715. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36716. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36717. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36718. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36719. import { Material } from "babylonjs/Materials/material";
  36720. import { Light } from "babylonjs/Lights/light";
  36721. import { Skeleton } from "babylonjs/Bones/skeleton";
  36722. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36723. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36724. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36725. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36726. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36727. import { Plane } from "babylonjs/Maths/math.plane";
  36728. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36729. import { Ray } from "babylonjs/Culling/ray";
  36730. import { Collider } from "babylonjs/Collisions/collider";
  36731. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36732. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36733. /** @hidden */
  36734. class _FacetDataStorage {
  36735. facetPositions: Vector3[];
  36736. facetNormals: Vector3[];
  36737. facetPartitioning: number[][];
  36738. facetNb: number;
  36739. partitioningSubdivisions: number;
  36740. partitioningBBoxRatio: number;
  36741. facetDataEnabled: boolean;
  36742. facetParameters: any;
  36743. bbSize: Vector3;
  36744. subDiv: {
  36745. max: number;
  36746. X: number;
  36747. Y: number;
  36748. Z: number;
  36749. };
  36750. facetDepthSort: boolean;
  36751. facetDepthSortEnabled: boolean;
  36752. depthSortedIndices: IndicesArray;
  36753. depthSortedFacets: {
  36754. ind: number;
  36755. sqDistance: number;
  36756. }[];
  36757. facetDepthSortFunction: (f1: {
  36758. ind: number;
  36759. sqDistance: number;
  36760. }, f2: {
  36761. ind: number;
  36762. sqDistance: number;
  36763. }) => number;
  36764. facetDepthSortFrom: Vector3;
  36765. facetDepthSortOrigin: Vector3;
  36766. invertedMatrix: Matrix;
  36767. }
  36768. /**
  36769. * @hidden
  36770. **/
  36771. class _InternalAbstractMeshDataInfo {
  36772. _hasVertexAlpha: boolean;
  36773. _useVertexColors: boolean;
  36774. _numBoneInfluencers: number;
  36775. _applyFog: boolean;
  36776. _receiveShadows: boolean;
  36777. _facetData: _FacetDataStorage;
  36778. _visibility: number;
  36779. _skeleton: Nullable<Skeleton>;
  36780. _layerMask: number;
  36781. _computeBonesUsingShaders: boolean;
  36782. _isActive: boolean;
  36783. _onlyForInstances: boolean;
  36784. _isActiveIntermediate: boolean;
  36785. _onlyForInstancesIntermediate: boolean;
  36786. _actAsRegularMesh: boolean;
  36787. _currentLOD: Nullable<AbstractMesh>;
  36788. }
  36789. /**
  36790. * Class used to store all common mesh properties
  36791. */
  36792. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36793. /** No occlusion */
  36794. static OCCLUSION_TYPE_NONE: number;
  36795. /** Occlusion set to optimisitic */
  36796. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36797. /** Occlusion set to strict */
  36798. static OCCLUSION_TYPE_STRICT: number;
  36799. /** Use an accurante occlusion algorithm */
  36800. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36801. /** Use a conservative occlusion algorithm */
  36802. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36803. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36804. * Test order :
  36805. * Is the bounding sphere outside the frustum ?
  36806. * If not, are the bounding box vertices outside the frustum ?
  36807. * It not, then the cullable object is in the frustum.
  36808. */
  36809. static readonly CULLINGSTRATEGY_STANDARD: number;
  36810. /** Culling strategy : Bounding Sphere Only.
  36811. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36812. * It's also less accurate than the standard because some not visible objects can still be selected.
  36813. * Test : is the bounding sphere outside the frustum ?
  36814. * If not, then the cullable object is in the frustum.
  36815. */
  36816. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36817. /** Culling strategy : Optimistic Inclusion.
  36818. * This in an inclusion test first, then the standard exclusion test.
  36819. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36820. * 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.
  36821. * Anyway, it's as accurate as the standard strategy.
  36822. * Test :
  36823. * Is the cullable object bounding sphere center in the frustum ?
  36824. * If not, apply the default culling strategy.
  36825. */
  36826. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36827. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36828. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36829. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36830. * 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.
  36831. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36832. * Test :
  36833. * Is the cullable object bounding sphere center in the frustum ?
  36834. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36835. */
  36836. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36837. /**
  36838. * No billboard
  36839. */
  36840. static get BILLBOARDMODE_NONE(): number;
  36841. /** Billboard on X axis */
  36842. static get BILLBOARDMODE_X(): number;
  36843. /** Billboard on Y axis */
  36844. static get BILLBOARDMODE_Y(): number;
  36845. /** Billboard on Z axis */
  36846. static get BILLBOARDMODE_Z(): number;
  36847. /** Billboard on all axes */
  36848. static get BILLBOARDMODE_ALL(): number;
  36849. /** Billboard on using position instead of orientation */
  36850. static get BILLBOARDMODE_USE_POSITION(): number;
  36851. /** @hidden */
  36852. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36853. /**
  36854. * The culling strategy to use to check whether the mesh must be rendered or not.
  36855. * This value can be changed at any time and will be used on the next render mesh selection.
  36856. * The possible values are :
  36857. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36858. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36859. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36860. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36861. * Please read each static variable documentation to get details about the culling process.
  36862. * */
  36863. cullingStrategy: number;
  36864. /**
  36865. * Gets the number of facets in the mesh
  36866. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36867. */
  36868. get facetNb(): number;
  36869. /**
  36870. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36871. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36872. */
  36873. get partitioningSubdivisions(): number;
  36874. set partitioningSubdivisions(nb: number);
  36875. /**
  36876. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36877. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36878. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36879. */
  36880. get partitioningBBoxRatio(): number;
  36881. set partitioningBBoxRatio(ratio: number);
  36882. /**
  36883. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36884. * Works only for updatable meshes.
  36885. * Doesn't work with multi-materials
  36886. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36887. */
  36888. get mustDepthSortFacets(): boolean;
  36889. set mustDepthSortFacets(sort: boolean);
  36890. /**
  36891. * The location (Vector3) where the facet depth sort must be computed from.
  36892. * By default, the active camera position.
  36893. * Used only when facet depth sort is enabled
  36894. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36895. */
  36896. get facetDepthSortFrom(): Vector3;
  36897. set facetDepthSortFrom(location: Vector3);
  36898. /**
  36899. * gets a boolean indicating if facetData is enabled
  36900. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36901. */
  36902. get isFacetDataEnabled(): boolean;
  36903. /** @hidden */
  36904. _updateNonUniformScalingState(value: boolean): boolean;
  36905. /**
  36906. * An event triggered when this mesh collides with another one
  36907. */
  36908. onCollideObservable: Observable<AbstractMesh>;
  36909. /** Set a function to call when this mesh collides with another one */
  36910. set onCollide(callback: () => void);
  36911. /**
  36912. * An event triggered when the collision's position changes
  36913. */
  36914. onCollisionPositionChangeObservable: Observable<Vector3>;
  36915. /** Set a function to call when the collision's position changes */
  36916. set onCollisionPositionChange(callback: () => void);
  36917. /**
  36918. * An event triggered when material is changed
  36919. */
  36920. onMaterialChangedObservable: Observable<AbstractMesh>;
  36921. /**
  36922. * Gets or sets the orientation for POV movement & rotation
  36923. */
  36924. definedFacingForward: boolean;
  36925. /** @hidden */
  36926. _occlusionQuery: Nullable<WebGLQuery>;
  36927. /** @hidden */
  36928. _renderingGroup: Nullable<RenderingGroup>;
  36929. /**
  36930. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36931. */
  36932. get visibility(): number;
  36933. /**
  36934. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36935. */
  36936. set visibility(value: number);
  36937. /** Gets or sets the alpha index used to sort transparent meshes
  36938. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36939. */
  36940. alphaIndex: number;
  36941. /**
  36942. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36943. */
  36944. isVisible: boolean;
  36945. /**
  36946. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36947. */
  36948. isPickable: boolean;
  36949. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36950. showSubMeshesBoundingBox: boolean;
  36951. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36952. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36953. */
  36954. isBlocker: boolean;
  36955. /**
  36956. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36957. */
  36958. enablePointerMoveEvents: boolean;
  36959. private _renderingGroupId;
  36960. /**
  36961. * Specifies the rendering group id for this mesh (0 by default)
  36962. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36963. */
  36964. get renderingGroupId(): number;
  36965. set renderingGroupId(value: number);
  36966. private _material;
  36967. /** Gets or sets current material */
  36968. get material(): Nullable<Material>;
  36969. set material(value: Nullable<Material>);
  36970. /**
  36971. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36972. * @see https://doc.babylonjs.com/babylon101/shadows
  36973. */
  36974. get receiveShadows(): boolean;
  36975. set receiveShadows(value: boolean);
  36976. /** Defines color to use when rendering outline */
  36977. outlineColor: Color3;
  36978. /** Define width to use when rendering outline */
  36979. outlineWidth: number;
  36980. /** Defines color to use when rendering overlay */
  36981. overlayColor: Color3;
  36982. /** Defines alpha to use when rendering overlay */
  36983. overlayAlpha: number;
  36984. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36985. get hasVertexAlpha(): boolean;
  36986. set hasVertexAlpha(value: boolean);
  36987. /** 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) */
  36988. get useVertexColors(): boolean;
  36989. set useVertexColors(value: boolean);
  36990. /**
  36991. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36992. */
  36993. get computeBonesUsingShaders(): boolean;
  36994. set computeBonesUsingShaders(value: boolean);
  36995. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36996. get numBoneInfluencers(): number;
  36997. set numBoneInfluencers(value: number);
  36998. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36999. get applyFog(): boolean;
  37000. set applyFog(value: boolean);
  37001. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  37002. useOctreeForRenderingSelection: boolean;
  37003. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  37004. useOctreeForPicking: boolean;
  37005. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  37006. useOctreeForCollisions: boolean;
  37007. /**
  37008. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  37009. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  37010. */
  37011. get layerMask(): number;
  37012. set layerMask(value: number);
  37013. /**
  37014. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  37015. */
  37016. alwaysSelectAsActiveMesh: boolean;
  37017. /**
  37018. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  37019. */
  37020. doNotSyncBoundingInfo: boolean;
  37021. /**
  37022. * Gets or sets the current action manager
  37023. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37024. */
  37025. actionManager: Nullable<AbstractActionManager>;
  37026. private _meshCollisionData;
  37027. /**
  37028. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  37029. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37030. */
  37031. ellipsoid: Vector3;
  37032. /**
  37033. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  37034. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37035. */
  37036. ellipsoidOffset: Vector3;
  37037. /**
  37038. * Gets or sets a collision mask used to mask collisions (default is -1).
  37039. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37040. */
  37041. get collisionMask(): number;
  37042. set collisionMask(mask: number);
  37043. /**
  37044. * Gets or sets a collision response flag (default is true).
  37045. * when collisionResponse is false, events are still triggered but colliding entity has no response
  37046. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  37047. * to respond to the collision.
  37048. */
  37049. get collisionResponse(): boolean;
  37050. set collisionResponse(response: boolean);
  37051. /**
  37052. * Gets or sets the current collision group mask (-1 by default).
  37053. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37054. */
  37055. get collisionGroup(): number;
  37056. set collisionGroup(mask: number);
  37057. /**
  37058. * Gets or sets current surrounding meshes (null by default).
  37059. *
  37060. * By default collision detection is tested against every mesh in the scene.
  37061. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  37062. * meshes will be tested for the collision.
  37063. *
  37064. * Note: if set to an empty array no collision will happen when this mesh is moved.
  37065. */
  37066. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  37067. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  37068. /**
  37069. * Defines edge width used when edgesRenderer is enabled
  37070. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37071. */
  37072. edgesWidth: number;
  37073. /**
  37074. * Defines edge color used when edgesRenderer is enabled
  37075. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37076. */
  37077. edgesColor: Color4;
  37078. /** @hidden */
  37079. _edgesRenderer: Nullable<IEdgesRenderer>;
  37080. /** @hidden */
  37081. _masterMesh: Nullable<AbstractMesh>;
  37082. /** @hidden */
  37083. _boundingInfo: Nullable<BoundingInfo>;
  37084. /** @hidden */
  37085. _renderId: number;
  37086. /**
  37087. * Gets or sets the list of subMeshes
  37088. * @see https://doc.babylonjs.com/how_to/multi_materials
  37089. */
  37090. subMeshes: SubMesh[];
  37091. /** @hidden */
  37092. _intersectionsInProgress: AbstractMesh[];
  37093. /** @hidden */
  37094. _unIndexed: boolean;
  37095. /** @hidden */
  37096. _lightSources: Light[];
  37097. /** Gets the list of lights affecting that mesh */
  37098. get lightSources(): Light[];
  37099. /** @hidden */
  37100. get _positions(): Nullable<Vector3[]>;
  37101. /** @hidden */
  37102. _waitingData: {
  37103. lods: Nullable<any>;
  37104. actions: Nullable<any>;
  37105. freezeWorldMatrix: Nullable<boolean>;
  37106. };
  37107. /** @hidden */
  37108. _bonesTransformMatrices: Nullable<Float32Array>;
  37109. /** @hidden */
  37110. _transformMatrixTexture: Nullable<RawTexture>;
  37111. /**
  37112. * Gets or sets a skeleton to apply skining transformations
  37113. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37114. */
  37115. set skeleton(value: Nullable<Skeleton>);
  37116. get skeleton(): Nullable<Skeleton>;
  37117. /**
  37118. * An event triggered when the mesh is rebuilt.
  37119. */
  37120. onRebuildObservable: Observable<AbstractMesh>;
  37121. /**
  37122. * Creates a new AbstractMesh
  37123. * @param name defines the name of the mesh
  37124. * @param scene defines the hosting scene
  37125. */
  37126. constructor(name: string, scene?: Nullable<Scene>);
  37127. /**
  37128. * Returns the string "AbstractMesh"
  37129. * @returns "AbstractMesh"
  37130. */
  37131. getClassName(): string;
  37132. /**
  37133. * Gets a string representation of the current mesh
  37134. * @param fullDetails defines a boolean indicating if full details must be included
  37135. * @returns a string representation of the current mesh
  37136. */
  37137. toString(fullDetails?: boolean): string;
  37138. /**
  37139. * @hidden
  37140. */
  37141. protected _getEffectiveParent(): Nullable<Node>;
  37142. /** @hidden */
  37143. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37144. /** @hidden */
  37145. _rebuild(): void;
  37146. /** @hidden */
  37147. _resyncLightSources(): void;
  37148. /** @hidden */
  37149. _resyncLightSource(light: Light): void;
  37150. /** @hidden */
  37151. _unBindEffect(): void;
  37152. /** @hidden */
  37153. _removeLightSource(light: Light, dispose: boolean): void;
  37154. private _markSubMeshesAsDirty;
  37155. /** @hidden */
  37156. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  37157. /** @hidden */
  37158. _markSubMeshesAsAttributesDirty(): void;
  37159. /** @hidden */
  37160. _markSubMeshesAsMiscDirty(): void;
  37161. /**
  37162. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  37163. */
  37164. get scaling(): Vector3;
  37165. set scaling(newScaling: Vector3);
  37166. /**
  37167. * Returns true if the mesh is blocked. Implemented by child classes
  37168. */
  37169. get isBlocked(): boolean;
  37170. /**
  37171. * Returns the mesh itself by default. Implemented by child classes
  37172. * @param camera defines the camera to use to pick the right LOD level
  37173. * @returns the currentAbstractMesh
  37174. */
  37175. getLOD(camera: Camera): Nullable<AbstractMesh>;
  37176. /**
  37177. * Returns 0 by default. Implemented by child classes
  37178. * @returns an integer
  37179. */
  37180. getTotalVertices(): number;
  37181. /**
  37182. * Returns a positive integer : the total number of indices in this mesh geometry.
  37183. * @returns the numner of indices or zero if the mesh has no geometry.
  37184. */
  37185. getTotalIndices(): number;
  37186. /**
  37187. * Returns null by default. Implemented by child classes
  37188. * @returns null
  37189. */
  37190. getIndices(): Nullable<IndicesArray>;
  37191. /**
  37192. * Returns the array of the requested vertex data kind. Implemented by child classes
  37193. * @param kind defines the vertex data kind to use
  37194. * @returns null
  37195. */
  37196. getVerticesData(kind: string): Nullable<FloatArray>;
  37197. /**
  37198. * Sets the vertex data of the mesh geometry for the requested `kind`.
  37199. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  37200. * Note that a new underlying VertexBuffer object is created each call.
  37201. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  37202. * @param kind defines vertex data kind:
  37203. * * VertexBuffer.PositionKind
  37204. * * VertexBuffer.UVKind
  37205. * * VertexBuffer.UV2Kind
  37206. * * VertexBuffer.UV3Kind
  37207. * * VertexBuffer.UV4Kind
  37208. * * VertexBuffer.UV5Kind
  37209. * * VertexBuffer.UV6Kind
  37210. * * VertexBuffer.ColorKind
  37211. * * VertexBuffer.MatricesIndicesKind
  37212. * * VertexBuffer.MatricesIndicesExtraKind
  37213. * * VertexBuffer.MatricesWeightsKind
  37214. * * VertexBuffer.MatricesWeightsExtraKind
  37215. * @param data defines the data source
  37216. * @param updatable defines if the data must be flagged as updatable (or static)
  37217. * @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
  37218. * @returns the current mesh
  37219. */
  37220. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  37221. /**
  37222. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  37223. * If the mesh has no geometry, it is simply returned as it is.
  37224. * @param kind defines vertex data kind:
  37225. * * VertexBuffer.PositionKind
  37226. * * VertexBuffer.UVKind
  37227. * * VertexBuffer.UV2Kind
  37228. * * VertexBuffer.UV3Kind
  37229. * * VertexBuffer.UV4Kind
  37230. * * VertexBuffer.UV5Kind
  37231. * * VertexBuffer.UV6Kind
  37232. * * VertexBuffer.ColorKind
  37233. * * VertexBuffer.MatricesIndicesKind
  37234. * * VertexBuffer.MatricesIndicesExtraKind
  37235. * * VertexBuffer.MatricesWeightsKind
  37236. * * VertexBuffer.MatricesWeightsExtraKind
  37237. * @param data defines the data source
  37238. * @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
  37239. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  37240. * @returns the current mesh
  37241. */
  37242. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  37243. /**
  37244. * Sets the mesh indices,
  37245. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  37246. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  37247. * @param totalVertices Defines the total number of vertices
  37248. * @returns the current mesh
  37249. */
  37250. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  37251. /**
  37252. * Gets a boolean indicating if specific vertex data is present
  37253. * @param kind defines the vertex data kind to use
  37254. * @returns true is data kind is present
  37255. */
  37256. isVerticesDataPresent(kind: string): boolean;
  37257. /**
  37258. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  37259. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  37260. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  37261. * @returns a BoundingInfo
  37262. */
  37263. getBoundingInfo(): BoundingInfo;
  37264. /**
  37265. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  37266. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  37267. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  37268. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  37269. * @returns the current mesh
  37270. */
  37271. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  37272. /**
  37273. * Overwrite the current bounding info
  37274. * @param boundingInfo defines the new bounding info
  37275. * @returns the current mesh
  37276. */
  37277. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  37278. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  37279. get useBones(): boolean;
  37280. /** @hidden */
  37281. _preActivate(): void;
  37282. /** @hidden */
  37283. _preActivateForIntermediateRendering(renderId: number): void;
  37284. /** @hidden */
  37285. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37286. /** @hidden */
  37287. _postActivate(): void;
  37288. /** @hidden */
  37289. _freeze(): void;
  37290. /** @hidden */
  37291. _unFreeze(): void;
  37292. /**
  37293. * Gets the current world matrix
  37294. * @returns a Matrix
  37295. */
  37296. getWorldMatrix(): Matrix;
  37297. /** @hidden */
  37298. _getWorldMatrixDeterminant(): number;
  37299. /**
  37300. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37301. */
  37302. get isAnInstance(): boolean;
  37303. /**
  37304. * Gets a boolean indicating if this mesh has instances
  37305. */
  37306. get hasInstances(): boolean;
  37307. /**
  37308. * Gets a boolean indicating if this mesh has thin instances
  37309. */
  37310. get hasThinInstances(): boolean;
  37311. /**
  37312. * Perform relative position change from the point of view of behind the front of the mesh.
  37313. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37314. * Supports definition of mesh facing forward or backward
  37315. * @param amountRight defines the distance on the right axis
  37316. * @param amountUp defines the distance on the up axis
  37317. * @param amountForward defines the distance on the forward axis
  37318. * @returns the current mesh
  37319. */
  37320. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37321. /**
  37322. * Calculate relative position change from the point of view of behind the front of the mesh.
  37323. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37324. * Supports definition of mesh facing forward or backward
  37325. * @param amountRight defines the distance on the right axis
  37326. * @param amountUp defines the distance on the up axis
  37327. * @param amountForward defines the distance on the forward axis
  37328. * @returns the new displacement vector
  37329. */
  37330. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37331. /**
  37332. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37333. * Supports definition of mesh facing forward or backward
  37334. * @param flipBack defines the flip
  37335. * @param twirlClockwise defines the twirl
  37336. * @param tiltRight defines the tilt
  37337. * @returns the current mesh
  37338. */
  37339. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37340. /**
  37341. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37342. * Supports definition of mesh facing forward or backward.
  37343. * @param flipBack defines the flip
  37344. * @param twirlClockwise defines the twirl
  37345. * @param tiltRight defines the tilt
  37346. * @returns the new rotation vector
  37347. */
  37348. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37349. /**
  37350. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37351. * This means the mesh underlying bounding box and sphere are recomputed.
  37352. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37353. * @returns the current mesh
  37354. */
  37355. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37356. /** @hidden */
  37357. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37358. /** @hidden */
  37359. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37360. /** @hidden */
  37361. _updateBoundingInfo(): AbstractMesh;
  37362. /** @hidden */
  37363. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37364. /** @hidden */
  37365. protected _afterComputeWorldMatrix(): void;
  37366. /** @hidden */
  37367. get _effectiveMesh(): AbstractMesh;
  37368. /**
  37369. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37370. * A mesh is in the frustum if its bounding box intersects the frustum
  37371. * @param frustumPlanes defines the frustum to test
  37372. * @returns true if the mesh is in the frustum planes
  37373. */
  37374. isInFrustum(frustumPlanes: Plane[]): boolean;
  37375. /**
  37376. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37377. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37378. * @param frustumPlanes defines the frustum to test
  37379. * @returns true if the mesh is completely in the frustum planes
  37380. */
  37381. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37382. /**
  37383. * True if the mesh intersects another mesh or a SolidParticle object
  37384. * @param mesh defines a target mesh or SolidParticle to test
  37385. * @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)
  37386. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37387. * @returns true if there is an intersection
  37388. */
  37389. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37390. /**
  37391. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37392. * @param point defines the point to test
  37393. * @returns true if there is an intersection
  37394. */
  37395. intersectsPoint(point: Vector3): boolean;
  37396. /**
  37397. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37398. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37399. */
  37400. get checkCollisions(): boolean;
  37401. set checkCollisions(collisionEnabled: boolean);
  37402. /**
  37403. * Gets Collider object used to compute collisions (not physics)
  37404. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37405. */
  37406. get collider(): Nullable<Collider>;
  37407. /**
  37408. * Move the mesh using collision engine
  37409. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37410. * @param displacement defines the requested displacement vector
  37411. * @returns the current mesh
  37412. */
  37413. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37414. private _onCollisionPositionChange;
  37415. /** @hidden */
  37416. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37417. /** @hidden */
  37418. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37419. /** @hidden */
  37420. _checkCollision(collider: Collider): AbstractMesh;
  37421. /** @hidden */
  37422. _generatePointsArray(): boolean;
  37423. /**
  37424. * Checks if the passed Ray intersects with the mesh
  37425. * @param ray defines the ray to use
  37426. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37427. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37428. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37429. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37430. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37431. * @returns the picking info
  37432. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37433. */
  37434. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37435. /**
  37436. * Clones the current mesh
  37437. * @param name defines the mesh name
  37438. * @param newParent defines the new mesh parent
  37439. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37440. * @returns the new mesh
  37441. */
  37442. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37443. /**
  37444. * Disposes all the submeshes of the current meshnp
  37445. * @returns the current mesh
  37446. */
  37447. releaseSubMeshes(): AbstractMesh;
  37448. /**
  37449. * Releases resources associated with this abstract mesh.
  37450. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37451. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37452. */
  37453. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37454. /**
  37455. * Adds the passed mesh as a child to the current mesh
  37456. * @param mesh defines the child mesh
  37457. * @returns the current mesh
  37458. */
  37459. addChild(mesh: AbstractMesh): AbstractMesh;
  37460. /**
  37461. * Removes the passed mesh from the current mesh children list
  37462. * @param mesh defines the child mesh
  37463. * @returns the current mesh
  37464. */
  37465. removeChild(mesh: AbstractMesh): AbstractMesh;
  37466. /** @hidden */
  37467. private _initFacetData;
  37468. /**
  37469. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37470. * This method can be called within the render loop.
  37471. * 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
  37472. * @returns the current mesh
  37473. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37474. */
  37475. updateFacetData(): AbstractMesh;
  37476. /**
  37477. * Returns the facetLocalNormals array.
  37478. * The normals are expressed in the mesh local spac
  37479. * @returns an array of Vector3
  37480. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37481. */
  37482. getFacetLocalNormals(): Vector3[];
  37483. /**
  37484. * Returns the facetLocalPositions array.
  37485. * The facet positions are expressed in the mesh local space
  37486. * @returns an array of Vector3
  37487. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37488. */
  37489. getFacetLocalPositions(): Vector3[];
  37490. /**
  37491. * Returns the facetLocalPartioning array
  37492. * @returns an array of array of numbers
  37493. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37494. */
  37495. getFacetLocalPartitioning(): number[][];
  37496. /**
  37497. * Returns the i-th facet position in the world system.
  37498. * This method allocates a new Vector3 per call
  37499. * @param i defines the facet index
  37500. * @returns a new Vector3
  37501. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37502. */
  37503. getFacetPosition(i: number): Vector3;
  37504. /**
  37505. * Sets the reference Vector3 with the i-th facet position in the world system
  37506. * @param i defines the facet index
  37507. * @param ref defines the target vector
  37508. * @returns the current mesh
  37509. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37510. */
  37511. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37512. /**
  37513. * Returns the i-th facet normal in the world system.
  37514. * This method allocates a new Vector3 per call
  37515. * @param i defines the facet index
  37516. * @returns a new Vector3
  37517. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37518. */
  37519. getFacetNormal(i: number): Vector3;
  37520. /**
  37521. * Sets the reference Vector3 with the i-th facet normal in the world system
  37522. * @param i defines the facet index
  37523. * @param ref defines the target vector
  37524. * @returns the current mesh
  37525. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37526. */
  37527. getFacetNormalToRef(i: number, ref: Vector3): this;
  37528. /**
  37529. * 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)
  37530. * @param x defines x coordinate
  37531. * @param y defines y coordinate
  37532. * @param z defines z coordinate
  37533. * @returns the array of facet indexes
  37534. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37535. */
  37536. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37537. /**
  37538. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37539. * @param projected sets as the (x,y,z) world projection on the facet
  37540. * @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
  37541. * @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
  37542. * @param x defines x coordinate
  37543. * @param y defines y coordinate
  37544. * @param z defines z coordinate
  37545. * @returns the face index if found (or null instead)
  37546. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37547. */
  37548. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37549. /**
  37550. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37551. * @param projected sets as the (x,y,z) local projection on the facet
  37552. * @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
  37553. * @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
  37554. * @param x defines x coordinate
  37555. * @param y defines y coordinate
  37556. * @param z defines z coordinate
  37557. * @returns the face index if found (or null instead)
  37558. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37559. */
  37560. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37561. /**
  37562. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37563. * @returns the parameters
  37564. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37565. */
  37566. getFacetDataParameters(): any;
  37567. /**
  37568. * Disables the feature FacetData and frees the related memory
  37569. * @returns the current mesh
  37570. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37571. */
  37572. disableFacetData(): AbstractMesh;
  37573. /**
  37574. * Updates the AbstractMesh indices array
  37575. * @param indices defines the data source
  37576. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37577. * @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)
  37578. * @returns the current mesh
  37579. */
  37580. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37581. /**
  37582. * Creates new normals data for the mesh
  37583. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37584. * @returns the current mesh
  37585. */
  37586. createNormals(updatable: boolean): AbstractMesh;
  37587. /**
  37588. * Align the mesh with a normal
  37589. * @param normal defines the normal to use
  37590. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37591. * @returns the current mesh
  37592. */
  37593. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37594. /** @hidden */
  37595. _checkOcclusionQuery(): boolean;
  37596. /**
  37597. * Disables the mesh edge rendering mode
  37598. * @returns the currentAbstractMesh
  37599. */
  37600. disableEdgesRendering(): AbstractMesh;
  37601. /**
  37602. * Enables the edge rendering mode on the mesh.
  37603. * This mode makes the mesh edges visible
  37604. * @param epsilon defines the maximal distance between two angles to detect a face
  37605. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37606. * @returns the currentAbstractMesh
  37607. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37608. */
  37609. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  37610. /**
  37611. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37612. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37613. */
  37614. getConnectedParticleSystems(): IParticleSystem[];
  37615. }
  37616. }
  37617. declare module "babylonjs/Actions/actionEvent" {
  37618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37619. import { Nullable } from "babylonjs/types";
  37620. import { Sprite } from "babylonjs/Sprites/sprite";
  37621. import { Scene } from "babylonjs/scene";
  37622. import { Vector2 } from "babylonjs/Maths/math.vector";
  37623. /**
  37624. * Interface used to define ActionEvent
  37625. */
  37626. export interface IActionEvent {
  37627. /** The mesh or sprite that triggered the action */
  37628. source: any;
  37629. /** The X mouse cursor position at the time of the event */
  37630. pointerX: number;
  37631. /** The Y mouse cursor position at the time of the event */
  37632. pointerY: number;
  37633. /** The mesh that is currently pointed at (can be null) */
  37634. meshUnderPointer: Nullable<AbstractMesh>;
  37635. /** the original (browser) event that triggered the ActionEvent */
  37636. sourceEvent?: any;
  37637. /** additional data for the event */
  37638. additionalData?: any;
  37639. }
  37640. /**
  37641. * ActionEvent is the event being sent when an action is triggered.
  37642. */
  37643. export class ActionEvent implements IActionEvent {
  37644. /** The mesh or sprite that triggered the action */
  37645. source: any;
  37646. /** The X mouse cursor position at the time of the event */
  37647. pointerX: number;
  37648. /** The Y mouse cursor position at the time of the event */
  37649. pointerY: number;
  37650. /** The mesh that is currently pointed at (can be null) */
  37651. meshUnderPointer: Nullable<AbstractMesh>;
  37652. /** the original (browser) event that triggered the ActionEvent */
  37653. sourceEvent?: any;
  37654. /** additional data for the event */
  37655. additionalData?: any;
  37656. /**
  37657. * Creates a new ActionEvent
  37658. * @param source The mesh or sprite that triggered the action
  37659. * @param pointerX The X mouse cursor position at the time of the event
  37660. * @param pointerY The Y mouse cursor position at the time of the event
  37661. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37662. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37663. * @param additionalData additional data for the event
  37664. */
  37665. constructor(
  37666. /** The mesh or sprite that triggered the action */
  37667. source: any,
  37668. /** The X mouse cursor position at the time of the event */
  37669. pointerX: number,
  37670. /** The Y mouse cursor position at the time of the event */
  37671. pointerY: number,
  37672. /** The mesh that is currently pointed at (can be null) */
  37673. meshUnderPointer: Nullable<AbstractMesh>,
  37674. /** the original (browser) event that triggered the ActionEvent */
  37675. sourceEvent?: any,
  37676. /** additional data for the event */
  37677. additionalData?: any);
  37678. /**
  37679. * Helper function to auto-create an ActionEvent from a source mesh.
  37680. * @param source The source mesh that triggered the event
  37681. * @param evt The original (browser) event
  37682. * @param additionalData additional data for the event
  37683. * @returns the new ActionEvent
  37684. */
  37685. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37686. /**
  37687. * Helper function to auto-create an ActionEvent from a source sprite
  37688. * @param source The source sprite that triggered the event
  37689. * @param scene Scene associated with the sprite
  37690. * @param evt The original (browser) event
  37691. * @param additionalData additional data for the event
  37692. * @returns the new ActionEvent
  37693. */
  37694. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37695. /**
  37696. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37697. * @param scene the scene where the event occurred
  37698. * @param evt The original (browser) event
  37699. * @returns the new ActionEvent
  37700. */
  37701. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37702. /**
  37703. * Helper function to auto-create an ActionEvent from a primitive
  37704. * @param prim defines the target primitive
  37705. * @param pointerPos defines the pointer position
  37706. * @param evt The original (browser) event
  37707. * @param additionalData additional data for the event
  37708. * @returns the new ActionEvent
  37709. */
  37710. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37711. }
  37712. }
  37713. declare module "babylonjs/Actions/abstractActionManager" {
  37714. import { IDisposable } from "babylonjs/scene";
  37715. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37716. import { IAction } from "babylonjs/Actions/action";
  37717. import { Nullable } from "babylonjs/types";
  37718. /**
  37719. * Abstract class used to decouple action Manager from scene and meshes.
  37720. * Do not instantiate.
  37721. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37722. */
  37723. export abstract class AbstractActionManager implements IDisposable {
  37724. /** Gets the list of active triggers */
  37725. static Triggers: {
  37726. [key: string]: number;
  37727. };
  37728. /** Gets the cursor to use when hovering items */
  37729. hoverCursor: string;
  37730. /** Gets the list of actions */
  37731. actions: IAction[];
  37732. /**
  37733. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37734. */
  37735. isRecursive: boolean;
  37736. /**
  37737. * Releases all associated resources
  37738. */
  37739. abstract dispose(): void;
  37740. /**
  37741. * Does this action manager has pointer triggers
  37742. */
  37743. abstract get hasPointerTriggers(): boolean;
  37744. /**
  37745. * Does this action manager has pick triggers
  37746. */
  37747. abstract get hasPickTriggers(): boolean;
  37748. /**
  37749. * Process a specific trigger
  37750. * @param trigger defines the trigger to process
  37751. * @param evt defines the event details to be processed
  37752. */
  37753. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37754. /**
  37755. * Does this action manager handles actions of any of the given triggers
  37756. * @param triggers defines the triggers to be tested
  37757. * @return a boolean indicating whether one (or more) of the triggers is handled
  37758. */
  37759. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37760. /**
  37761. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37762. * speed.
  37763. * @param triggerA defines the trigger to be tested
  37764. * @param triggerB defines the trigger to be tested
  37765. * @return a boolean indicating whether one (or more) of the triggers is handled
  37766. */
  37767. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37768. /**
  37769. * Does this action manager handles actions of a given trigger
  37770. * @param trigger defines the trigger to be tested
  37771. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37772. * @return whether the trigger is handled
  37773. */
  37774. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37775. /**
  37776. * Serialize this manager to a JSON object
  37777. * @param name defines the property name to store this manager
  37778. * @returns a JSON representation of this manager
  37779. */
  37780. abstract serialize(name: string): any;
  37781. /**
  37782. * Registers an action to this action manager
  37783. * @param action defines the action to be registered
  37784. * @return the action amended (prepared) after registration
  37785. */
  37786. abstract registerAction(action: IAction): Nullable<IAction>;
  37787. /**
  37788. * Unregisters an action to this action manager
  37789. * @param action defines the action to be unregistered
  37790. * @return a boolean indicating whether the action has been unregistered
  37791. */
  37792. abstract unregisterAction(action: IAction): Boolean;
  37793. /**
  37794. * Does exist one action manager with at least one trigger
  37795. **/
  37796. static get HasTriggers(): boolean;
  37797. /**
  37798. * Does exist one action manager with at least one pick trigger
  37799. **/
  37800. static get HasPickTriggers(): boolean;
  37801. /**
  37802. * Does exist one action manager that handles actions of a given trigger
  37803. * @param trigger defines the trigger to be tested
  37804. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37805. **/
  37806. static HasSpecificTrigger(trigger: number): boolean;
  37807. }
  37808. }
  37809. declare module "babylonjs/node" {
  37810. import { Scene } from "babylonjs/scene";
  37811. import { Nullable } from "babylonjs/types";
  37812. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37813. import { Engine } from "babylonjs/Engines/engine";
  37814. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37815. import { Observable } from "babylonjs/Misc/observable";
  37816. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37817. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37818. import { Animatable } from "babylonjs/Animations/animatable";
  37819. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37820. import { Animation } from "babylonjs/Animations/animation";
  37821. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37823. /**
  37824. * Defines how a node can be built from a string name.
  37825. */
  37826. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37827. /**
  37828. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37829. */
  37830. export class Node implements IBehaviorAware<Node> {
  37831. /** @hidden */
  37832. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37833. private static _NodeConstructors;
  37834. /**
  37835. * Add a new node constructor
  37836. * @param type defines the type name of the node to construct
  37837. * @param constructorFunc defines the constructor function
  37838. */
  37839. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37840. /**
  37841. * Returns a node constructor based on type name
  37842. * @param type defines the type name
  37843. * @param name defines the new node name
  37844. * @param scene defines the hosting scene
  37845. * @param options defines optional options to transmit to constructors
  37846. * @returns the new constructor or null
  37847. */
  37848. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37849. /**
  37850. * Gets or sets the name of the node
  37851. */
  37852. name: string;
  37853. /**
  37854. * Gets or sets the id of the node
  37855. */
  37856. id: string;
  37857. /**
  37858. * Gets or sets the unique id of the node
  37859. */
  37860. uniqueId: number;
  37861. /**
  37862. * Gets or sets a string used to store user defined state for the node
  37863. */
  37864. state: string;
  37865. /**
  37866. * Gets or sets an object used to store user defined information for the node
  37867. */
  37868. metadata: any;
  37869. /**
  37870. * For internal use only. Please do not use.
  37871. */
  37872. reservedDataStore: any;
  37873. /**
  37874. * List of inspectable custom properties (used by the Inspector)
  37875. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37876. */
  37877. inspectableCustomProperties: IInspectable[];
  37878. private _doNotSerialize;
  37879. /**
  37880. * Gets or sets a boolean used to define if the node must be serialized
  37881. */
  37882. get doNotSerialize(): boolean;
  37883. set doNotSerialize(value: boolean);
  37884. /** @hidden */
  37885. _isDisposed: boolean;
  37886. /**
  37887. * Gets a list of Animations associated with the node
  37888. */
  37889. animations: import("babylonjs/Animations/animation").Animation[];
  37890. protected _ranges: {
  37891. [name: string]: Nullable<AnimationRange>;
  37892. };
  37893. /**
  37894. * Callback raised when the node is ready to be used
  37895. */
  37896. onReady: Nullable<(node: Node) => void>;
  37897. private _isEnabled;
  37898. private _isParentEnabled;
  37899. private _isReady;
  37900. /** @hidden */
  37901. _currentRenderId: number;
  37902. private _parentUpdateId;
  37903. /** @hidden */
  37904. _childUpdateId: number;
  37905. /** @hidden */
  37906. _waitingParentId: Nullable<string>;
  37907. /** @hidden */
  37908. _scene: Scene;
  37909. /** @hidden */
  37910. _cache: any;
  37911. private _parentNode;
  37912. private _children;
  37913. /** @hidden */
  37914. _worldMatrix: Matrix;
  37915. /** @hidden */
  37916. _worldMatrixDeterminant: number;
  37917. /** @hidden */
  37918. _worldMatrixDeterminantIsDirty: boolean;
  37919. /** @hidden */
  37920. private _sceneRootNodesIndex;
  37921. /**
  37922. * Gets a boolean indicating if the node has been disposed
  37923. * @returns true if the node was disposed
  37924. */
  37925. isDisposed(): boolean;
  37926. /**
  37927. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37928. * @see https://doc.babylonjs.com/how_to/parenting
  37929. */
  37930. set parent(parent: Nullable<Node>);
  37931. get parent(): Nullable<Node>;
  37932. /** @hidden */
  37933. _addToSceneRootNodes(): void;
  37934. /** @hidden */
  37935. _removeFromSceneRootNodes(): void;
  37936. private _animationPropertiesOverride;
  37937. /**
  37938. * Gets or sets the animation properties override
  37939. */
  37940. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37941. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37942. /**
  37943. * Gets a string identifying the name of the class
  37944. * @returns "Node" string
  37945. */
  37946. getClassName(): string;
  37947. /** @hidden */
  37948. readonly _isNode: boolean;
  37949. /**
  37950. * An event triggered when the mesh is disposed
  37951. */
  37952. onDisposeObservable: Observable<Node>;
  37953. private _onDisposeObserver;
  37954. /**
  37955. * Sets a callback that will be raised when the node will be disposed
  37956. */
  37957. set onDispose(callback: () => void);
  37958. /**
  37959. * Creates a new Node
  37960. * @param name the name and id to be given to this node
  37961. * @param scene the scene this node will be added to
  37962. */
  37963. constructor(name: string, scene?: Nullable<Scene>);
  37964. /**
  37965. * Gets the scene of the node
  37966. * @returns a scene
  37967. */
  37968. getScene(): Scene;
  37969. /**
  37970. * Gets the engine of the node
  37971. * @returns a Engine
  37972. */
  37973. getEngine(): Engine;
  37974. private _behaviors;
  37975. /**
  37976. * Attach a behavior to the node
  37977. * @see https://doc.babylonjs.com/features/behaviour
  37978. * @param behavior defines the behavior to attach
  37979. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37980. * @returns the current Node
  37981. */
  37982. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37983. /**
  37984. * Remove an attached behavior
  37985. * @see https://doc.babylonjs.com/features/behaviour
  37986. * @param behavior defines the behavior to attach
  37987. * @returns the current Node
  37988. */
  37989. removeBehavior(behavior: Behavior<Node>): Node;
  37990. /**
  37991. * Gets the list of attached behaviors
  37992. * @see https://doc.babylonjs.com/features/behaviour
  37993. */
  37994. get behaviors(): Behavior<Node>[];
  37995. /**
  37996. * Gets an attached behavior by name
  37997. * @param name defines the name of the behavior to look for
  37998. * @see https://doc.babylonjs.com/features/behaviour
  37999. * @returns null if behavior was not found else the requested behavior
  38000. */
  38001. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  38002. /**
  38003. * Returns the latest update of the World matrix
  38004. * @returns a Matrix
  38005. */
  38006. getWorldMatrix(): Matrix;
  38007. /** @hidden */
  38008. _getWorldMatrixDeterminant(): number;
  38009. /**
  38010. * Returns directly the latest state of the mesh World matrix.
  38011. * A Matrix is returned.
  38012. */
  38013. get worldMatrixFromCache(): Matrix;
  38014. /** @hidden */
  38015. _initCache(): void;
  38016. /** @hidden */
  38017. updateCache(force?: boolean): void;
  38018. /** @hidden */
  38019. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  38020. /** @hidden */
  38021. _updateCache(ignoreParentClass?: boolean): void;
  38022. /** @hidden */
  38023. _isSynchronized(): boolean;
  38024. /** @hidden */
  38025. _markSyncedWithParent(): void;
  38026. /** @hidden */
  38027. isSynchronizedWithParent(): boolean;
  38028. /** @hidden */
  38029. isSynchronized(): boolean;
  38030. /**
  38031. * Is this node ready to be used/rendered
  38032. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  38033. * @return true if the node is ready
  38034. */
  38035. isReady(completeCheck?: boolean): boolean;
  38036. /**
  38037. * Is this node enabled?
  38038. * 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
  38039. * @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
  38040. * @return whether this node (and its parent) is enabled
  38041. */
  38042. isEnabled(checkAncestors?: boolean): boolean;
  38043. /** @hidden */
  38044. protected _syncParentEnabledState(): void;
  38045. /**
  38046. * Set the enabled state of this node
  38047. * @param value defines the new enabled state
  38048. */
  38049. setEnabled(value: boolean): void;
  38050. /**
  38051. * Is this node a descendant of the given node?
  38052. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  38053. * @param ancestor defines the parent node to inspect
  38054. * @returns a boolean indicating if this node is a descendant of the given node
  38055. */
  38056. isDescendantOf(ancestor: Node): boolean;
  38057. /** @hidden */
  38058. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  38059. /**
  38060. * Will return all nodes that have this node as ascendant
  38061. * @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
  38062. * @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
  38063. * @return all children nodes of all types
  38064. */
  38065. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  38066. /**
  38067. * Get all child-meshes of this node
  38068. * @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)
  38069. * @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
  38070. * @returns an array of AbstractMesh
  38071. */
  38072. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  38073. /**
  38074. * Get all direct children of this node
  38075. * @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
  38076. * @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)
  38077. * @returns an array of Node
  38078. */
  38079. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  38080. /** @hidden */
  38081. _setReady(state: boolean): void;
  38082. /**
  38083. * Get an animation by name
  38084. * @param name defines the name of the animation to look for
  38085. * @returns null if not found else the requested animation
  38086. */
  38087. getAnimationByName(name: string): Nullable<Animation>;
  38088. /**
  38089. * Creates an animation range for this node
  38090. * @param name defines the name of the range
  38091. * @param from defines the starting key
  38092. * @param to defines the end key
  38093. */
  38094. createAnimationRange(name: string, from: number, to: number): void;
  38095. /**
  38096. * Delete a specific animation range
  38097. * @param name defines the name of the range to delete
  38098. * @param deleteFrames defines if animation frames from the range must be deleted as well
  38099. */
  38100. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  38101. /**
  38102. * Get an animation range by name
  38103. * @param name defines the name of the animation range to look for
  38104. * @returns null if not found else the requested animation range
  38105. */
  38106. getAnimationRange(name: string): Nullable<AnimationRange>;
  38107. /**
  38108. * Gets the list of all animation ranges defined on this node
  38109. * @returns an array
  38110. */
  38111. getAnimationRanges(): Nullable<AnimationRange>[];
  38112. /**
  38113. * Will start the animation sequence
  38114. * @param name defines the range frames for animation sequence
  38115. * @param loop defines if the animation should loop (false by default)
  38116. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  38117. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  38118. * @returns the object created for this animation. If range does not exist, it will return null
  38119. */
  38120. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  38121. /**
  38122. * Serialize animation ranges into a JSON compatible object
  38123. * @returns serialization object
  38124. */
  38125. serializeAnimationRanges(): any;
  38126. /**
  38127. * Computes the world matrix of the node
  38128. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  38129. * @returns the world matrix
  38130. */
  38131. computeWorldMatrix(force?: boolean): Matrix;
  38132. /**
  38133. * Releases resources associated with this node.
  38134. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38135. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38136. */
  38137. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38138. /**
  38139. * Parse animation range data from a serialization object and store them into a given node
  38140. * @param node defines where to store the animation ranges
  38141. * @param parsedNode defines the serialization object to read data from
  38142. * @param scene defines the hosting scene
  38143. */
  38144. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  38145. /**
  38146. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  38147. * @param includeDescendants Include bounding info from descendants as well (true by default)
  38148. * @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
  38149. * @returns the new bounding vectors
  38150. */
  38151. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  38152. min: Vector3;
  38153. max: Vector3;
  38154. };
  38155. }
  38156. }
  38157. declare module "babylonjs/Animations/animation" {
  38158. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  38159. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  38160. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  38161. import { Nullable } from "babylonjs/types";
  38162. import { Scene } from "babylonjs/scene";
  38163. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  38164. import { AnimationRange } from "babylonjs/Animations/animationRange";
  38165. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  38166. import { Node } from "babylonjs/node";
  38167. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38168. import { Size } from "babylonjs/Maths/math.size";
  38169. import { Animatable } from "babylonjs/Animations/animatable";
  38170. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  38171. /**
  38172. * @hidden
  38173. */
  38174. export class _IAnimationState {
  38175. key: number;
  38176. repeatCount: number;
  38177. workValue?: any;
  38178. loopMode?: number;
  38179. offsetValue?: any;
  38180. highLimitValue?: any;
  38181. }
  38182. /**
  38183. * Class used to store any kind of animation
  38184. */
  38185. export class Animation {
  38186. /**Name of the animation */
  38187. name: string;
  38188. /**Property to animate */
  38189. targetProperty: string;
  38190. /**The frames per second of the animation */
  38191. framePerSecond: number;
  38192. /**The data type of the animation */
  38193. dataType: number;
  38194. /**The loop mode of the animation */
  38195. loopMode?: number | undefined;
  38196. /**Specifies if blending should be enabled */
  38197. enableBlending?: boolean | undefined;
  38198. /**
  38199. * Use matrix interpolation instead of using direct key value when animating matrices
  38200. */
  38201. static AllowMatricesInterpolation: boolean;
  38202. /**
  38203. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  38204. */
  38205. static AllowMatrixDecomposeForInterpolation: boolean;
  38206. /** Define the Url to load snippets */
  38207. static SnippetUrl: string;
  38208. /** Snippet ID if the animation was created from the snippet server */
  38209. snippetId: string;
  38210. /**
  38211. * Stores the key frames of the animation
  38212. */
  38213. private _keys;
  38214. /**
  38215. * Stores the easing function of the animation
  38216. */
  38217. private _easingFunction;
  38218. /**
  38219. * @hidden Internal use only
  38220. */
  38221. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  38222. /**
  38223. * The set of event that will be linked to this animation
  38224. */
  38225. private _events;
  38226. /**
  38227. * Stores an array of target property paths
  38228. */
  38229. targetPropertyPath: string[];
  38230. /**
  38231. * Stores the blending speed of the animation
  38232. */
  38233. blendingSpeed: number;
  38234. /**
  38235. * Stores the animation ranges for the animation
  38236. */
  38237. private _ranges;
  38238. /**
  38239. * @hidden Internal use
  38240. */
  38241. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  38242. /**
  38243. * Sets up an animation
  38244. * @param property The property to animate
  38245. * @param animationType The animation type to apply
  38246. * @param framePerSecond The frames per second of the animation
  38247. * @param easingFunction The easing function used in the animation
  38248. * @returns The created animation
  38249. */
  38250. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  38251. /**
  38252. * Create and start an animation on a node
  38253. * @param name defines the name of the global animation that will be run on all nodes
  38254. * @param node defines the root node where the animation will take place
  38255. * @param targetProperty defines property to animate
  38256. * @param framePerSecond defines the number of frame per second yo use
  38257. * @param totalFrame defines the number of frames in total
  38258. * @param from defines the initial value
  38259. * @param to defines the final value
  38260. * @param loopMode defines which loop mode you want to use (off by default)
  38261. * @param easingFunction defines the easing function to use (linear by default)
  38262. * @param onAnimationEnd defines the callback to call when animation end
  38263. * @returns the animatable created for this animation
  38264. */
  38265. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38266. /**
  38267. * Create and start an animation on a node and its descendants
  38268. * @param name defines the name of the global animation that will be run on all nodes
  38269. * @param node defines the root node where the animation will take place
  38270. * @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
  38271. * @param targetProperty defines property to animate
  38272. * @param framePerSecond defines the number of frame per second to use
  38273. * @param totalFrame defines the number of frames in total
  38274. * @param from defines the initial value
  38275. * @param to defines the final value
  38276. * @param loopMode defines which loop mode you want to use (off by default)
  38277. * @param easingFunction defines the easing function to use (linear by default)
  38278. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  38279. * @returns the list of animatables created for all nodes
  38280. * @example https://www.babylonjs-playground.com/#MH0VLI
  38281. */
  38282. 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[]>;
  38283. /**
  38284. * Creates a new animation, merges it with the existing animations and starts it
  38285. * @param name Name of the animation
  38286. * @param node Node which contains the scene that begins the animations
  38287. * @param targetProperty Specifies which property to animate
  38288. * @param framePerSecond The frames per second of the animation
  38289. * @param totalFrame The total number of frames
  38290. * @param from The frame at the beginning of the animation
  38291. * @param to The frame at the end of the animation
  38292. * @param loopMode Specifies the loop mode of the animation
  38293. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38294. * @param onAnimationEnd Callback to run once the animation is complete
  38295. * @returns Nullable animation
  38296. */
  38297. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38298. /**
  38299. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38300. * @param sourceAnimation defines the Animation containing keyframes to convert
  38301. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38302. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38303. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38304. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38305. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38306. */
  38307. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38308. /**
  38309. * Transition property of an host to the target Value
  38310. * @param property The property to transition
  38311. * @param targetValue The target Value of the property
  38312. * @param host The object where the property to animate belongs
  38313. * @param scene Scene used to run the animation
  38314. * @param frameRate Framerate (in frame/s) to use
  38315. * @param transition The transition type we want to use
  38316. * @param duration The duration of the animation, in milliseconds
  38317. * @param onAnimationEnd Callback trigger at the end of the animation
  38318. * @returns Nullable animation
  38319. */
  38320. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38321. /**
  38322. * Return the array of runtime animations currently using this animation
  38323. */
  38324. get runtimeAnimations(): RuntimeAnimation[];
  38325. /**
  38326. * Specifies if any of the runtime animations are currently running
  38327. */
  38328. get hasRunningRuntimeAnimations(): boolean;
  38329. /**
  38330. * Initializes the animation
  38331. * @param name Name of the animation
  38332. * @param targetProperty Property to animate
  38333. * @param framePerSecond The frames per second of the animation
  38334. * @param dataType The data type of the animation
  38335. * @param loopMode The loop mode of the animation
  38336. * @param enableBlending Specifies if blending should be enabled
  38337. */
  38338. constructor(
  38339. /**Name of the animation */
  38340. name: string,
  38341. /**Property to animate */
  38342. targetProperty: string,
  38343. /**The frames per second of the animation */
  38344. framePerSecond: number,
  38345. /**The data type of the animation */
  38346. dataType: number,
  38347. /**The loop mode of the animation */
  38348. loopMode?: number | undefined,
  38349. /**Specifies if blending should be enabled */
  38350. enableBlending?: boolean | undefined);
  38351. /**
  38352. * Converts the animation to a string
  38353. * @param fullDetails support for multiple levels of logging within scene loading
  38354. * @returns String form of the animation
  38355. */
  38356. toString(fullDetails?: boolean): string;
  38357. /**
  38358. * Add an event to this animation
  38359. * @param event Event to add
  38360. */
  38361. addEvent(event: AnimationEvent): void;
  38362. /**
  38363. * Remove all events found at the given frame
  38364. * @param frame The frame to remove events from
  38365. */
  38366. removeEvents(frame: number): void;
  38367. /**
  38368. * Retrieves all the events from the animation
  38369. * @returns Events from the animation
  38370. */
  38371. getEvents(): AnimationEvent[];
  38372. /**
  38373. * Creates an animation range
  38374. * @param name Name of the animation range
  38375. * @param from Starting frame of the animation range
  38376. * @param to Ending frame of the animation
  38377. */
  38378. createRange(name: string, from: number, to: number): void;
  38379. /**
  38380. * Deletes an animation range by name
  38381. * @param name Name of the animation range to delete
  38382. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38383. */
  38384. deleteRange(name: string, deleteFrames?: boolean): void;
  38385. /**
  38386. * Gets the animation range by name, or null if not defined
  38387. * @param name Name of the animation range
  38388. * @returns Nullable animation range
  38389. */
  38390. getRange(name: string): Nullable<AnimationRange>;
  38391. /**
  38392. * Gets the key frames from the animation
  38393. * @returns The key frames of the animation
  38394. */
  38395. getKeys(): Array<IAnimationKey>;
  38396. /**
  38397. * Gets the highest frame rate of the animation
  38398. * @returns Highest frame rate of the animation
  38399. */
  38400. getHighestFrame(): number;
  38401. /**
  38402. * Gets the easing function of the animation
  38403. * @returns Easing function of the animation
  38404. */
  38405. getEasingFunction(): IEasingFunction;
  38406. /**
  38407. * Sets the easing function of the animation
  38408. * @param easingFunction A custom mathematical formula for animation
  38409. */
  38410. setEasingFunction(easingFunction: EasingFunction): void;
  38411. /**
  38412. * Interpolates a scalar linearly
  38413. * @param startValue Start value of the animation curve
  38414. * @param endValue End value of the animation curve
  38415. * @param gradient Scalar amount to interpolate
  38416. * @returns Interpolated scalar value
  38417. */
  38418. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38419. /**
  38420. * Interpolates a scalar cubically
  38421. * @param startValue Start value of the animation curve
  38422. * @param outTangent End tangent of the animation
  38423. * @param endValue End value of the animation curve
  38424. * @param inTangent Start tangent of the animation curve
  38425. * @param gradient Scalar amount to interpolate
  38426. * @returns Interpolated scalar value
  38427. */
  38428. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38429. /**
  38430. * Interpolates a quaternion using a spherical linear interpolation
  38431. * @param startValue Start value of the animation curve
  38432. * @param endValue End value of the animation curve
  38433. * @param gradient Scalar amount to interpolate
  38434. * @returns Interpolated quaternion value
  38435. */
  38436. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38437. /**
  38438. * Interpolates a quaternion cubically
  38439. * @param startValue Start value of the animation curve
  38440. * @param outTangent End tangent of the animation curve
  38441. * @param endValue End value of the animation curve
  38442. * @param inTangent Start tangent of the animation curve
  38443. * @param gradient Scalar amount to interpolate
  38444. * @returns Interpolated quaternion value
  38445. */
  38446. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38447. /**
  38448. * Interpolates a Vector3 linearl
  38449. * @param startValue Start value of the animation curve
  38450. * @param endValue End value of the animation curve
  38451. * @param gradient Scalar amount to interpolate
  38452. * @returns Interpolated scalar value
  38453. */
  38454. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38455. /**
  38456. * Interpolates a Vector3 cubically
  38457. * @param startValue Start value of the animation curve
  38458. * @param outTangent End tangent of the animation
  38459. * @param endValue End value of the animation curve
  38460. * @param inTangent Start tangent of the animation curve
  38461. * @param gradient Scalar amount to interpolate
  38462. * @returns InterpolatedVector3 value
  38463. */
  38464. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38465. /**
  38466. * Interpolates a Vector2 linearly
  38467. * @param startValue Start value of the animation curve
  38468. * @param endValue End value of the animation curve
  38469. * @param gradient Scalar amount to interpolate
  38470. * @returns Interpolated Vector2 value
  38471. */
  38472. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38473. /**
  38474. * Interpolates a Vector2 cubically
  38475. * @param startValue Start value of the animation curve
  38476. * @param outTangent End tangent of the animation
  38477. * @param endValue End value of the animation curve
  38478. * @param inTangent Start tangent of the animation curve
  38479. * @param gradient Scalar amount to interpolate
  38480. * @returns Interpolated Vector2 value
  38481. */
  38482. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38483. /**
  38484. * Interpolates a size linearly
  38485. * @param startValue Start value of the animation curve
  38486. * @param endValue End value of the animation curve
  38487. * @param gradient Scalar amount to interpolate
  38488. * @returns Interpolated Size value
  38489. */
  38490. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38491. /**
  38492. * Interpolates a Color3 linearly
  38493. * @param startValue Start value of the animation curve
  38494. * @param endValue End value of the animation curve
  38495. * @param gradient Scalar amount to interpolate
  38496. * @returns Interpolated Color3 value
  38497. */
  38498. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38499. /**
  38500. * Interpolates a Color4 linearly
  38501. * @param startValue Start value of the animation curve
  38502. * @param endValue End value of the animation curve
  38503. * @param gradient Scalar amount to interpolate
  38504. * @returns Interpolated Color3 value
  38505. */
  38506. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38507. /**
  38508. * @hidden Internal use only
  38509. */
  38510. _getKeyValue(value: any): any;
  38511. /**
  38512. * @hidden Internal use only
  38513. */
  38514. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38515. /**
  38516. * Defines the function to use to interpolate matrices
  38517. * @param startValue defines the start matrix
  38518. * @param endValue defines the end matrix
  38519. * @param gradient defines the gradient between both matrices
  38520. * @param result defines an optional target matrix where to store the interpolation
  38521. * @returns the interpolated matrix
  38522. */
  38523. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38524. /**
  38525. * Makes a copy of the animation
  38526. * @returns Cloned animation
  38527. */
  38528. clone(): Animation;
  38529. /**
  38530. * Sets the key frames of the animation
  38531. * @param values The animation key frames to set
  38532. */
  38533. setKeys(values: Array<IAnimationKey>): void;
  38534. /**
  38535. * Serializes the animation to an object
  38536. * @returns Serialized object
  38537. */
  38538. serialize(): any;
  38539. /**
  38540. * Float animation type
  38541. */
  38542. static readonly ANIMATIONTYPE_FLOAT: number;
  38543. /**
  38544. * Vector3 animation type
  38545. */
  38546. static readonly ANIMATIONTYPE_VECTOR3: number;
  38547. /**
  38548. * Quaternion animation type
  38549. */
  38550. static readonly ANIMATIONTYPE_QUATERNION: number;
  38551. /**
  38552. * Matrix animation type
  38553. */
  38554. static readonly ANIMATIONTYPE_MATRIX: number;
  38555. /**
  38556. * Color3 animation type
  38557. */
  38558. static readonly ANIMATIONTYPE_COLOR3: number;
  38559. /**
  38560. * Color3 animation type
  38561. */
  38562. static readonly ANIMATIONTYPE_COLOR4: number;
  38563. /**
  38564. * Vector2 animation type
  38565. */
  38566. static readonly ANIMATIONTYPE_VECTOR2: number;
  38567. /**
  38568. * Size animation type
  38569. */
  38570. static readonly ANIMATIONTYPE_SIZE: number;
  38571. /**
  38572. * Relative Loop Mode
  38573. */
  38574. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38575. /**
  38576. * Cycle Loop Mode
  38577. */
  38578. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38579. /**
  38580. * Constant Loop Mode
  38581. */
  38582. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38583. /** @hidden */
  38584. static _UniversalLerp(left: any, right: any, amount: number): any;
  38585. /**
  38586. * Parses an animation object and creates an animation
  38587. * @param parsedAnimation Parsed animation object
  38588. * @returns Animation object
  38589. */
  38590. static Parse(parsedAnimation: any): Animation;
  38591. /**
  38592. * Appends the serialized animations from the source animations
  38593. * @param source Source containing the animations
  38594. * @param destination Target to store the animations
  38595. */
  38596. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38597. /**
  38598. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38599. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38600. * @param url defines the url to load from
  38601. * @returns a promise that will resolve to the new animation or an array of animations
  38602. */
  38603. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38604. /**
  38605. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38606. * @param snippetId defines the snippet to load
  38607. * @returns a promise that will resolve to the new animation or a new array of animations
  38608. */
  38609. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38610. }
  38611. }
  38612. declare module "babylonjs/Animations/animatable.interface" {
  38613. import { Nullable } from "babylonjs/types";
  38614. import { Animation } from "babylonjs/Animations/animation";
  38615. /**
  38616. * Interface containing an array of animations
  38617. */
  38618. export interface IAnimatable {
  38619. /**
  38620. * Array of animations
  38621. */
  38622. animations: Nullable<Array<Animation>>;
  38623. }
  38624. }
  38625. declare module "babylonjs/Misc/decorators" {
  38626. import { Nullable } from "babylonjs/types";
  38627. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38628. import { Scene } from "babylonjs/scene";
  38629. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38630. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38631. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38633. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38634. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38635. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38636. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38637. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38638. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38639. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38640. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38641. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38642. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38643. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38644. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38645. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38646. /**
  38647. * Decorator used to define property that can be serialized as reference to a camera
  38648. * @param sourceName defines the name of the property to decorate
  38649. */
  38650. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38651. /**
  38652. * Class used to help serialization objects
  38653. */
  38654. export class SerializationHelper {
  38655. /** @hidden */
  38656. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38657. /** @hidden */
  38658. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38659. /** @hidden */
  38660. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38661. /** @hidden */
  38662. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38663. /**
  38664. * Appends the serialized animations from the source animations
  38665. * @param source Source containing the animations
  38666. * @param destination Target to store the animations
  38667. */
  38668. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38669. /**
  38670. * Static function used to serialized a specific entity
  38671. * @param entity defines the entity to serialize
  38672. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38673. * @returns a JSON compatible object representing the serialization of the entity
  38674. */
  38675. static Serialize<T>(entity: T, serializationObject?: any): any;
  38676. /**
  38677. * Creates a new entity from a serialization data object
  38678. * @param creationFunction defines a function used to instanciated the new entity
  38679. * @param source defines the source serialization data
  38680. * @param scene defines the hosting scene
  38681. * @param rootUrl defines the root url for resources
  38682. * @returns a new entity
  38683. */
  38684. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38685. /**
  38686. * Clones an object
  38687. * @param creationFunction defines the function used to instanciate the new object
  38688. * @param source defines the source object
  38689. * @returns the cloned object
  38690. */
  38691. static Clone<T>(creationFunction: () => T, source: T): T;
  38692. /**
  38693. * Instanciates a new object based on a source one (some data will be shared between both object)
  38694. * @param creationFunction defines the function used to instanciate the new object
  38695. * @param source defines the source object
  38696. * @returns the new object
  38697. */
  38698. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38699. }
  38700. }
  38701. declare module "babylonjs/Materials/Textures/baseTexture" {
  38702. import { Observable } from "babylonjs/Misc/observable";
  38703. import { Nullable } from "babylonjs/types";
  38704. import { Scene } from "babylonjs/scene";
  38705. import { Matrix } from "babylonjs/Maths/math.vector";
  38706. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38707. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38708. import { ISize } from "babylonjs/Maths/math.size";
  38709. import "babylonjs/Misc/fileTools";
  38710. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38711. /**
  38712. * Base class of all the textures in babylon.
  38713. * It groups all the common properties the materials, post process, lights... might need
  38714. * in order to make a correct use of the texture.
  38715. */
  38716. export class BaseTexture implements IAnimatable {
  38717. /**
  38718. * Default anisotropic filtering level for the application.
  38719. * It is set to 4 as a good tradeoff between perf and quality.
  38720. */
  38721. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  38722. /**
  38723. * Gets or sets the unique id of the texture
  38724. */
  38725. uniqueId: number;
  38726. /**
  38727. * Define the name of the texture.
  38728. */
  38729. name: string;
  38730. /**
  38731. * Gets or sets an object used to store user defined information.
  38732. */
  38733. metadata: any;
  38734. /**
  38735. * For internal use only. Please do not use.
  38736. */
  38737. reservedDataStore: any;
  38738. private _hasAlpha;
  38739. /**
  38740. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  38741. */
  38742. set hasAlpha(value: boolean);
  38743. get hasAlpha(): boolean;
  38744. /**
  38745. * Defines if the alpha value should be determined via the rgb values.
  38746. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  38747. */
  38748. getAlphaFromRGB: boolean;
  38749. /**
  38750. * Intensity or strength of the texture.
  38751. * It is commonly used by materials to fine tune the intensity of the texture
  38752. */
  38753. level: number;
  38754. /**
  38755. * Define the UV chanel to use starting from 0 and defaulting to 0.
  38756. * This is part of the texture as textures usually maps to one uv set.
  38757. */
  38758. coordinatesIndex: number;
  38759. protected _coordinatesMode: number;
  38760. /**
  38761. * How a texture is mapped.
  38762. *
  38763. * | Value | Type | Description |
  38764. * | ----- | ----------------------------------- | ----------- |
  38765. * | 0 | EXPLICIT_MODE | |
  38766. * | 1 | SPHERICAL_MODE | |
  38767. * | 2 | PLANAR_MODE | |
  38768. * | 3 | CUBIC_MODE | |
  38769. * | 4 | PROJECTION_MODE | |
  38770. * | 5 | SKYBOX_MODE | |
  38771. * | 6 | INVCUBIC_MODE | |
  38772. * | 7 | EQUIRECTANGULAR_MODE | |
  38773. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  38774. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  38775. */
  38776. set coordinatesMode(value: number);
  38777. get coordinatesMode(): number;
  38778. private _wrapU;
  38779. /**
  38780. * | Value | Type | Description |
  38781. * | ----- | ------------------ | ----------- |
  38782. * | 0 | CLAMP_ADDRESSMODE | |
  38783. * | 1 | WRAP_ADDRESSMODE | |
  38784. * | 2 | MIRROR_ADDRESSMODE | |
  38785. */
  38786. get wrapU(): number;
  38787. set wrapU(value: number);
  38788. private _wrapV;
  38789. /**
  38790. * | Value | Type | Description |
  38791. * | ----- | ------------------ | ----------- |
  38792. * | 0 | CLAMP_ADDRESSMODE | |
  38793. * | 1 | WRAP_ADDRESSMODE | |
  38794. * | 2 | MIRROR_ADDRESSMODE | |
  38795. */
  38796. get wrapV(): number;
  38797. set wrapV(value: number);
  38798. /**
  38799. * | Value | Type | Description |
  38800. * | ----- | ------------------ | ----------- |
  38801. * | 0 | CLAMP_ADDRESSMODE | |
  38802. * | 1 | WRAP_ADDRESSMODE | |
  38803. * | 2 | MIRROR_ADDRESSMODE | |
  38804. */
  38805. wrapR: number;
  38806. /**
  38807. * With compliant hardware and browser (supporting anisotropic filtering)
  38808. * this defines the level of anisotropic filtering in the texture.
  38809. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  38810. */
  38811. anisotropicFilteringLevel: number;
  38812. /**
  38813. * Define if the texture is a cube texture or if false a 2d texture.
  38814. */
  38815. get isCube(): boolean;
  38816. set isCube(value: boolean);
  38817. /**
  38818. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  38819. */
  38820. get is3D(): boolean;
  38821. set is3D(value: boolean);
  38822. /**
  38823. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  38824. */
  38825. get is2DArray(): boolean;
  38826. set is2DArray(value: boolean);
  38827. private _gammaSpace;
  38828. /**
  38829. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  38830. * HDR texture are usually stored in linear space.
  38831. * This only impacts the PBR and Background materials
  38832. */
  38833. get gammaSpace(): boolean;
  38834. set gammaSpace(gamma: boolean);
  38835. /**
  38836. * Gets or sets whether or not the texture contains RGBD data.
  38837. */
  38838. get isRGBD(): boolean;
  38839. set isRGBD(value: boolean);
  38840. /**
  38841. * Is Z inverted in the texture (useful in a cube texture).
  38842. */
  38843. invertZ: boolean;
  38844. /**
  38845. * Are mip maps generated for this texture or not.
  38846. */
  38847. get noMipmap(): boolean;
  38848. /**
  38849. * @hidden
  38850. */
  38851. lodLevelInAlpha: boolean;
  38852. /**
  38853. * With prefiltered texture, defined the offset used during the prefiltering steps.
  38854. */
  38855. get lodGenerationOffset(): number;
  38856. set lodGenerationOffset(value: number);
  38857. /**
  38858. * With prefiltered texture, defined the scale used during the prefiltering steps.
  38859. */
  38860. get lodGenerationScale(): number;
  38861. set lodGenerationScale(value: number);
  38862. /**
  38863. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  38864. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  38865. * average roughness values.
  38866. */
  38867. get linearSpecularLOD(): boolean;
  38868. set linearSpecularLOD(value: boolean);
  38869. /**
  38870. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  38871. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  38872. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  38873. */
  38874. get irradianceTexture(): Nullable<BaseTexture>;
  38875. set irradianceTexture(value: Nullable<BaseTexture>);
  38876. /**
  38877. * Define if the texture is a render target.
  38878. */
  38879. isRenderTarget: boolean;
  38880. /**
  38881. * Define the unique id of the texture in the scene.
  38882. */
  38883. get uid(): string;
  38884. /** @hidden */
  38885. _prefiltered: boolean;
  38886. /**
  38887. * Return a string representation of the texture.
  38888. * @returns the texture as a string
  38889. */
  38890. toString(): string;
  38891. /**
  38892. * Get the class name of the texture.
  38893. * @returns "BaseTexture"
  38894. */
  38895. getClassName(): string;
  38896. /**
  38897. * Define the list of animation attached to the texture.
  38898. */
  38899. animations: import("babylonjs/Animations/animation").Animation[];
  38900. /**
  38901. * An event triggered when the texture is disposed.
  38902. */
  38903. onDisposeObservable: Observable<BaseTexture>;
  38904. private _onDisposeObserver;
  38905. /**
  38906. * Callback triggered when the texture has been disposed.
  38907. * Kept for back compatibility, you can use the onDisposeObservable instead.
  38908. */
  38909. set onDispose(callback: () => void);
  38910. /**
  38911. * Define the current state of the loading sequence when in delayed load mode.
  38912. */
  38913. delayLoadState: number;
  38914. protected _scene: Nullable<Scene>;
  38915. protected _engine: Nullable<ThinEngine>;
  38916. /** @hidden */
  38917. _texture: Nullable<InternalTexture>;
  38918. private _uid;
  38919. /**
  38920. * Define if the texture is preventinga material to render or not.
  38921. * If not and the texture is not ready, the engine will use a default black texture instead.
  38922. */
  38923. get isBlocking(): boolean;
  38924. /**
  38925. * Instantiates a new BaseTexture.
  38926. * Base class of all the textures in babylon.
  38927. * It groups all the common properties the materials, post process, lights... might need
  38928. * in order to make a correct use of the texture.
  38929. * @param sceneOrEngine Define the scene or engine the texture blongs to
  38930. */
  38931. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  38932. /**
  38933. * Get the scene the texture belongs to.
  38934. * @returns the scene or null if undefined
  38935. */
  38936. getScene(): Nullable<Scene>;
  38937. /** @hidden */
  38938. protected _getEngine(): Nullable<ThinEngine>;
  38939. /**
  38940. * Checks if the texture has the same transform matrix than another texture
  38941. * @param texture texture to check against
  38942. * @returns true if the transforms are the same, else false
  38943. */
  38944. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  38945. /**
  38946. * Get the texture transform matrix used to offset tile the texture for istance.
  38947. * @returns the transformation matrix
  38948. */
  38949. getTextureMatrix(): Matrix;
  38950. /**
  38951. * Get the texture reflection matrix used to rotate/transform the reflection.
  38952. * @returns the reflection matrix
  38953. */
  38954. getReflectionTextureMatrix(): Matrix;
  38955. /**
  38956. * Get the underlying lower level texture from Babylon.
  38957. * @returns the insternal texture
  38958. */
  38959. getInternalTexture(): Nullable<InternalTexture>;
  38960. /**
  38961. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  38962. * @returns true if ready or not blocking
  38963. */
  38964. isReadyOrNotBlocking(): boolean;
  38965. /**
  38966. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  38967. * @returns true if fully ready
  38968. */
  38969. isReady(): boolean;
  38970. private _cachedSize;
  38971. /**
  38972. * Get the size of the texture.
  38973. * @returns the texture size.
  38974. */
  38975. getSize(): ISize;
  38976. /**
  38977. * Get the base size of the texture.
  38978. * It can be different from the size if the texture has been resized for POT for instance
  38979. * @returns the base size
  38980. */
  38981. getBaseSize(): ISize;
  38982. /**
  38983. * Update the sampling mode of the texture.
  38984. * Default is Trilinear mode.
  38985. *
  38986. * | Value | Type | Description |
  38987. * | ----- | ------------------ | ----------- |
  38988. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38989. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38990. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38991. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38992. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38993. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38994. * | 7 | NEAREST_LINEAR | |
  38995. * | 8 | NEAREST_NEAREST | |
  38996. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38997. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38998. * | 11 | LINEAR_LINEAR | |
  38999. * | 12 | LINEAR_NEAREST | |
  39000. *
  39001. * > _mag_: magnification filter (close to the viewer)
  39002. * > _min_: minification filter (far from the viewer)
  39003. * > _mip_: filter used between mip map levels
  39004. *@param samplingMode Define the new sampling mode of the texture
  39005. */
  39006. updateSamplingMode(samplingMode: number): void;
  39007. /**
  39008. * Scales the texture if is `canRescale()`
  39009. * @param ratio the resize factor we want to use to rescale
  39010. */
  39011. scale(ratio: number): void;
  39012. /**
  39013. * Get if the texture can rescale.
  39014. */
  39015. get canRescale(): boolean;
  39016. /** @hidden */
  39017. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  39018. /** @hidden */
  39019. _rebuild(): void;
  39020. /**
  39021. * Triggers the load sequence in delayed load mode.
  39022. */
  39023. delayLoad(): void;
  39024. /**
  39025. * Clones the texture.
  39026. * @returns the cloned texture
  39027. */
  39028. clone(): Nullable<BaseTexture>;
  39029. /**
  39030. * Get the texture underlying type (INT, FLOAT...)
  39031. */
  39032. get textureType(): number;
  39033. /**
  39034. * Get the texture underlying format (RGB, RGBA...)
  39035. */
  39036. get textureFormat(): number;
  39037. /**
  39038. * Indicates that textures need to be re-calculated for all materials
  39039. */
  39040. protected _markAllSubMeshesAsTexturesDirty(): void;
  39041. /**
  39042. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  39043. * This will returns an RGBA array buffer containing either in values (0-255) or
  39044. * float values (0-1) depending of the underlying buffer type.
  39045. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  39046. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  39047. * @param buffer defines a user defined buffer to fill with data (can be null)
  39048. * @returns The Array buffer containing the pixels data.
  39049. */
  39050. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  39051. /**
  39052. * Release and destroy the underlying lower level texture aka internalTexture.
  39053. */
  39054. releaseInternalTexture(): void;
  39055. /** @hidden */
  39056. get _lodTextureHigh(): Nullable<BaseTexture>;
  39057. /** @hidden */
  39058. get _lodTextureMid(): Nullable<BaseTexture>;
  39059. /** @hidden */
  39060. get _lodTextureLow(): Nullable<BaseTexture>;
  39061. /**
  39062. * Dispose the texture and release its associated resources.
  39063. */
  39064. dispose(): void;
  39065. /**
  39066. * Serialize the texture into a JSON representation that can be parsed later on.
  39067. * @returns the JSON representation of the texture
  39068. */
  39069. serialize(): any;
  39070. /**
  39071. * Helper function to be called back once a list of texture contains only ready textures.
  39072. * @param textures Define the list of textures to wait for
  39073. * @param callback Define the callback triggered once the entire list will be ready
  39074. */
  39075. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  39076. private static _isScene;
  39077. }
  39078. }
  39079. declare module "babylonjs/Materials/effect" {
  39080. import { Observable } from "babylonjs/Misc/observable";
  39081. import { Nullable } from "babylonjs/types";
  39082. import { IDisposable } from "babylonjs/scene";
  39083. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39084. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39085. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  39086. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39087. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39088. import { Engine } from "babylonjs/Engines/engine";
  39089. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39090. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39091. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39092. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39093. /**
  39094. * Options to be used when creating an effect.
  39095. */
  39096. export interface IEffectCreationOptions {
  39097. /**
  39098. * Atrributes that will be used in the shader.
  39099. */
  39100. attributes: string[];
  39101. /**
  39102. * Uniform varible names that will be set in the shader.
  39103. */
  39104. uniformsNames: string[];
  39105. /**
  39106. * Uniform buffer variable names that will be set in the shader.
  39107. */
  39108. uniformBuffersNames: string[];
  39109. /**
  39110. * Sampler texture variable names that will be set in the shader.
  39111. */
  39112. samplers: string[];
  39113. /**
  39114. * Define statements that will be set in the shader.
  39115. */
  39116. defines: any;
  39117. /**
  39118. * Possible fallbacks for this effect to improve performance when needed.
  39119. */
  39120. fallbacks: Nullable<IEffectFallbacks>;
  39121. /**
  39122. * Callback that will be called when the shader is compiled.
  39123. */
  39124. onCompiled: Nullable<(effect: Effect) => void>;
  39125. /**
  39126. * Callback that will be called if an error occurs during shader compilation.
  39127. */
  39128. onError: Nullable<(effect: Effect, errors: string) => void>;
  39129. /**
  39130. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39131. */
  39132. indexParameters?: any;
  39133. /**
  39134. * Max number of lights that can be used in the shader.
  39135. */
  39136. maxSimultaneousLights?: number;
  39137. /**
  39138. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39139. */
  39140. transformFeedbackVaryings?: Nullable<string[]>;
  39141. /**
  39142. * 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
  39143. */
  39144. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39145. /**
  39146. * Is this effect rendering to several color attachments ?
  39147. */
  39148. multiTarget?: boolean;
  39149. }
  39150. /**
  39151. * Effect containing vertex and fragment shader that can be executed on an object.
  39152. */
  39153. export class Effect implements IDisposable {
  39154. /**
  39155. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39156. */
  39157. static ShadersRepository: string;
  39158. /**
  39159. * Enable logging of the shader code when a compilation error occurs
  39160. */
  39161. static LogShaderCodeOnCompilationError: boolean;
  39162. /**
  39163. * Name of the effect.
  39164. */
  39165. name: any;
  39166. /**
  39167. * String container all the define statements that should be set on the shader.
  39168. */
  39169. defines: string;
  39170. /**
  39171. * Callback that will be called when the shader is compiled.
  39172. */
  39173. onCompiled: Nullable<(effect: Effect) => void>;
  39174. /**
  39175. * Callback that will be called if an error occurs during shader compilation.
  39176. */
  39177. onError: Nullable<(effect: Effect, errors: string) => void>;
  39178. /**
  39179. * Callback that will be called when effect is bound.
  39180. */
  39181. onBind: Nullable<(effect: Effect) => void>;
  39182. /**
  39183. * Unique ID of the effect.
  39184. */
  39185. uniqueId: number;
  39186. /**
  39187. * Observable that will be called when the shader is compiled.
  39188. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39189. */
  39190. onCompileObservable: Observable<Effect>;
  39191. /**
  39192. * Observable that will be called if an error occurs during shader compilation.
  39193. */
  39194. onErrorObservable: Observable<Effect>;
  39195. /** @hidden */
  39196. _onBindObservable: Nullable<Observable<Effect>>;
  39197. /**
  39198. * @hidden
  39199. * Specifies if the effect was previously ready
  39200. */
  39201. _wasPreviouslyReady: boolean;
  39202. /**
  39203. * Observable that will be called when effect is bound.
  39204. */
  39205. get onBindObservable(): Observable<Effect>;
  39206. /** @hidden */
  39207. _bonesComputationForcedToCPU: boolean;
  39208. /** @hidden */
  39209. _multiTarget: boolean;
  39210. private static _uniqueIdSeed;
  39211. private _engine;
  39212. private _uniformBuffersNames;
  39213. private _uniformBuffersNamesList;
  39214. private _uniformsNames;
  39215. private _samplerList;
  39216. private _samplers;
  39217. private _isReady;
  39218. private _compilationError;
  39219. private _allFallbacksProcessed;
  39220. private _attributesNames;
  39221. private _attributes;
  39222. private _attributeLocationByName;
  39223. private _uniforms;
  39224. /**
  39225. * Key for the effect.
  39226. * @hidden
  39227. */
  39228. _key: string;
  39229. private _indexParameters;
  39230. private _fallbacks;
  39231. private _vertexSourceCode;
  39232. private _fragmentSourceCode;
  39233. private _vertexSourceCodeOverride;
  39234. private _fragmentSourceCodeOverride;
  39235. private _transformFeedbackVaryings;
  39236. private _rawVertexSourceCode;
  39237. private _rawFragmentSourceCode;
  39238. /**
  39239. * Compiled shader to webGL program.
  39240. * @hidden
  39241. */
  39242. _pipelineContext: Nullable<IPipelineContext>;
  39243. private _valueCache;
  39244. private static _baseCache;
  39245. /**
  39246. * Instantiates an effect.
  39247. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39248. * @param baseName Name of the effect.
  39249. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39250. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39251. * @param samplers List of sampler variables that will be passed to the shader.
  39252. * @param engine Engine to be used to render the effect
  39253. * @param defines Define statements to be added to the shader.
  39254. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39255. * @param onCompiled Callback that will be called when the shader is compiled.
  39256. * @param onError Callback that will be called if an error occurs during shader compilation.
  39257. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39258. */
  39259. 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);
  39260. private _useFinalCode;
  39261. /**
  39262. * Unique key for this effect
  39263. */
  39264. get key(): string;
  39265. /**
  39266. * If the effect has been compiled and prepared.
  39267. * @returns if the effect is compiled and prepared.
  39268. */
  39269. isReady(): boolean;
  39270. private _isReadyInternal;
  39271. /**
  39272. * The engine the effect was initialized with.
  39273. * @returns the engine.
  39274. */
  39275. getEngine(): Engine;
  39276. /**
  39277. * The pipeline context for this effect
  39278. * @returns the associated pipeline context
  39279. */
  39280. getPipelineContext(): Nullable<IPipelineContext>;
  39281. /**
  39282. * The set of names of attribute variables for the shader.
  39283. * @returns An array of attribute names.
  39284. */
  39285. getAttributesNames(): string[];
  39286. /**
  39287. * Returns the attribute at the given index.
  39288. * @param index The index of the attribute.
  39289. * @returns The location of the attribute.
  39290. */
  39291. getAttributeLocation(index: number): number;
  39292. /**
  39293. * Returns the attribute based on the name of the variable.
  39294. * @param name of the attribute to look up.
  39295. * @returns the attribute location.
  39296. */
  39297. getAttributeLocationByName(name: string): number;
  39298. /**
  39299. * The number of attributes.
  39300. * @returns the numnber of attributes.
  39301. */
  39302. getAttributesCount(): number;
  39303. /**
  39304. * Gets the index of a uniform variable.
  39305. * @param uniformName of the uniform to look up.
  39306. * @returns the index.
  39307. */
  39308. getUniformIndex(uniformName: string): number;
  39309. /**
  39310. * Returns the attribute based on the name of the variable.
  39311. * @param uniformName of the uniform to look up.
  39312. * @returns the location of the uniform.
  39313. */
  39314. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39315. /**
  39316. * Returns an array of sampler variable names
  39317. * @returns The array of sampler variable names.
  39318. */
  39319. getSamplers(): string[];
  39320. /**
  39321. * Returns an array of uniform variable names
  39322. * @returns The array of uniform variable names.
  39323. */
  39324. getUniformNames(): string[];
  39325. /**
  39326. * Returns an array of uniform buffer variable names
  39327. * @returns The array of uniform buffer variable names.
  39328. */
  39329. getUniformBuffersNames(): string[];
  39330. /**
  39331. * Returns the index parameters used to create the effect
  39332. * @returns The index parameters object
  39333. */
  39334. getIndexParameters(): any;
  39335. /**
  39336. * The error from the last compilation.
  39337. * @returns the error string.
  39338. */
  39339. getCompilationError(): string;
  39340. /**
  39341. * Gets a boolean indicating that all fallbacks were used during compilation
  39342. * @returns true if all fallbacks were used
  39343. */
  39344. allFallbacksProcessed(): boolean;
  39345. /**
  39346. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39347. * @param func The callback to be used.
  39348. */
  39349. executeWhenCompiled(func: (effect: Effect) => void): void;
  39350. private _checkIsReady;
  39351. private _loadShader;
  39352. /**
  39353. * Gets the vertex shader source code of this effect
  39354. */
  39355. get vertexSourceCode(): string;
  39356. /**
  39357. * Gets the fragment shader source code of this effect
  39358. */
  39359. get fragmentSourceCode(): string;
  39360. /**
  39361. * Gets the vertex shader source code before it has been processed by the preprocessor
  39362. */
  39363. get rawVertexSourceCode(): string;
  39364. /**
  39365. * Gets the fragment shader source code before it has been processed by the preprocessor
  39366. */
  39367. get rawFragmentSourceCode(): string;
  39368. /**
  39369. * Recompiles the webGL program
  39370. * @param vertexSourceCode The source code for the vertex shader.
  39371. * @param fragmentSourceCode The source code for the fragment shader.
  39372. * @param onCompiled Callback called when completed.
  39373. * @param onError Callback called on error.
  39374. * @hidden
  39375. */
  39376. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39377. /**
  39378. * Prepares the effect
  39379. * @hidden
  39380. */
  39381. _prepareEffect(): void;
  39382. private _getShaderCodeAndErrorLine;
  39383. private _processCompilationErrors;
  39384. /**
  39385. * Checks if the effect is supported. (Must be called after compilation)
  39386. */
  39387. get isSupported(): boolean;
  39388. /**
  39389. * Binds a texture to the engine to be used as output of the shader.
  39390. * @param channel Name of the output variable.
  39391. * @param texture Texture to bind.
  39392. * @hidden
  39393. */
  39394. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39395. /**
  39396. * Sets a texture on the engine to be used in the shader.
  39397. * @param channel Name of the sampler variable.
  39398. * @param texture Texture to set.
  39399. */
  39400. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  39401. /**
  39402. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39403. * @param channel Name of the sampler variable.
  39404. * @param texture Texture to set.
  39405. */
  39406. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39407. /**
  39408. * Sets an array of textures on the engine to be used in the shader.
  39409. * @param channel Name of the variable.
  39410. * @param textures Textures to set.
  39411. */
  39412. setTextureArray(channel: string, textures: BaseTexture[]): void;
  39413. /**
  39414. * 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)
  39415. * @param channel Name of the sampler variable.
  39416. * @param postProcess Post process to get the input texture from.
  39417. */
  39418. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39419. /**
  39420. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39421. * 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)
  39422. * @param channel Name of the sampler variable.
  39423. * @param postProcess Post process to get the output texture from.
  39424. */
  39425. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39426. /** @hidden */
  39427. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39428. /** @hidden */
  39429. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39430. /** @hidden */
  39431. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39432. /** @hidden */
  39433. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39434. /**
  39435. * Binds a buffer to a uniform.
  39436. * @param buffer Buffer to bind.
  39437. * @param name Name of the uniform variable to bind to.
  39438. */
  39439. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39440. /**
  39441. * Binds block to a uniform.
  39442. * @param blockName Name of the block to bind.
  39443. * @param index Index to bind.
  39444. */
  39445. bindUniformBlock(blockName: string, index: number): void;
  39446. /**
  39447. * Sets an interger value on a uniform variable.
  39448. * @param uniformName Name of the variable.
  39449. * @param value Value to be set.
  39450. * @returns this effect.
  39451. */
  39452. setInt(uniformName: string, value: number): Effect;
  39453. /**
  39454. * Sets an int array on a uniform variable.
  39455. * @param uniformName Name of the variable.
  39456. * @param array array to be set.
  39457. * @returns this effect.
  39458. */
  39459. setIntArray(uniformName: string, array: Int32Array): Effect;
  39460. /**
  39461. * 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)
  39462. * @param uniformName Name of the variable.
  39463. * @param array array to be set.
  39464. * @returns this effect.
  39465. */
  39466. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39467. /**
  39468. * 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)
  39469. * @param uniformName Name of the variable.
  39470. * @param array array to be set.
  39471. * @returns this effect.
  39472. */
  39473. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39474. /**
  39475. * 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)
  39476. * @param uniformName Name of the variable.
  39477. * @param array array to be set.
  39478. * @returns this effect.
  39479. */
  39480. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39481. /**
  39482. * Sets an float array on a uniform variable.
  39483. * @param uniformName Name of the variable.
  39484. * @param array array to be set.
  39485. * @returns this effect.
  39486. */
  39487. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39488. /**
  39489. * 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)
  39490. * @param uniformName Name of the variable.
  39491. * @param array array to be set.
  39492. * @returns this effect.
  39493. */
  39494. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39495. /**
  39496. * 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)
  39497. * @param uniformName Name of the variable.
  39498. * @param array array to be set.
  39499. * @returns this effect.
  39500. */
  39501. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39502. /**
  39503. * 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)
  39504. * @param uniformName Name of the variable.
  39505. * @param array array to be set.
  39506. * @returns this effect.
  39507. */
  39508. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39509. /**
  39510. * Sets an array on a uniform variable.
  39511. * @param uniformName Name of the variable.
  39512. * @param array array to be set.
  39513. * @returns this effect.
  39514. */
  39515. setArray(uniformName: string, array: number[]): Effect;
  39516. /**
  39517. * 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)
  39518. * @param uniformName Name of the variable.
  39519. * @param array array to be set.
  39520. * @returns this effect.
  39521. */
  39522. setArray2(uniformName: string, array: number[]): Effect;
  39523. /**
  39524. * 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)
  39525. * @param uniformName Name of the variable.
  39526. * @param array array to be set.
  39527. * @returns this effect.
  39528. */
  39529. setArray3(uniformName: string, array: number[]): Effect;
  39530. /**
  39531. * 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)
  39532. * @param uniformName Name of the variable.
  39533. * @param array array to be set.
  39534. * @returns this effect.
  39535. */
  39536. setArray4(uniformName: string, array: number[]): Effect;
  39537. /**
  39538. * Sets matrices on a uniform variable.
  39539. * @param uniformName Name of the variable.
  39540. * @param matrices matrices to be set.
  39541. * @returns this effect.
  39542. */
  39543. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39544. /**
  39545. * Sets matrix on a uniform variable.
  39546. * @param uniformName Name of the variable.
  39547. * @param matrix matrix to be set.
  39548. * @returns this effect.
  39549. */
  39550. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39551. /**
  39552. * 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)
  39553. * @param uniformName Name of the variable.
  39554. * @param matrix matrix to be set.
  39555. * @returns this effect.
  39556. */
  39557. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39558. /**
  39559. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39560. * @param uniformName Name of the variable.
  39561. * @param matrix matrix to be set.
  39562. * @returns this effect.
  39563. */
  39564. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39565. /**
  39566. * Sets a float on a uniform variable.
  39567. * @param uniformName Name of the variable.
  39568. * @param value value to be set.
  39569. * @returns this effect.
  39570. */
  39571. setFloat(uniformName: string, value: number): Effect;
  39572. /**
  39573. * Sets a boolean on a uniform variable.
  39574. * @param uniformName Name of the variable.
  39575. * @param bool value to be set.
  39576. * @returns this effect.
  39577. */
  39578. setBool(uniformName: string, bool: boolean): Effect;
  39579. /**
  39580. * Sets a Vector2 on a uniform variable.
  39581. * @param uniformName Name of the variable.
  39582. * @param vector2 vector2 to be set.
  39583. * @returns this effect.
  39584. */
  39585. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39586. /**
  39587. * Sets a float2 on a uniform variable.
  39588. * @param uniformName Name of the variable.
  39589. * @param x First float in float2.
  39590. * @param y Second float in float2.
  39591. * @returns this effect.
  39592. */
  39593. setFloat2(uniformName: string, x: number, y: number): Effect;
  39594. /**
  39595. * Sets a Vector3 on a uniform variable.
  39596. * @param uniformName Name of the variable.
  39597. * @param vector3 Value to be set.
  39598. * @returns this effect.
  39599. */
  39600. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39601. /**
  39602. * Sets a float3 on a uniform variable.
  39603. * @param uniformName Name of the variable.
  39604. * @param x First float in float3.
  39605. * @param y Second float in float3.
  39606. * @param z Third float in float3.
  39607. * @returns this effect.
  39608. */
  39609. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39610. /**
  39611. * Sets a Vector4 on a uniform variable.
  39612. * @param uniformName Name of the variable.
  39613. * @param vector4 Value to be set.
  39614. * @returns this effect.
  39615. */
  39616. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39617. /**
  39618. * Sets a float4 on a uniform variable.
  39619. * @param uniformName Name of the variable.
  39620. * @param x First float in float4.
  39621. * @param y Second float in float4.
  39622. * @param z Third float in float4.
  39623. * @param w Fourth float in float4.
  39624. * @returns this effect.
  39625. */
  39626. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39627. /**
  39628. * Sets a Color3 on a uniform variable.
  39629. * @param uniformName Name of the variable.
  39630. * @param color3 Value to be set.
  39631. * @returns this effect.
  39632. */
  39633. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39634. /**
  39635. * Sets a Color4 on a uniform variable.
  39636. * @param uniformName Name of the variable.
  39637. * @param color3 Value to be set.
  39638. * @param alpha Alpha value to be set.
  39639. * @returns this effect.
  39640. */
  39641. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39642. /**
  39643. * Sets a Color4 on a uniform variable
  39644. * @param uniformName defines the name of the variable
  39645. * @param color4 defines the value to be set
  39646. * @returns this effect.
  39647. */
  39648. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39649. /** Release all associated resources */
  39650. dispose(): void;
  39651. /**
  39652. * This function will add a new shader to the shader store
  39653. * @param name the name of the shader
  39654. * @param pixelShader optional pixel shader content
  39655. * @param vertexShader optional vertex shader content
  39656. */
  39657. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39658. /**
  39659. * Store of each shader (The can be looked up using effect.key)
  39660. */
  39661. static ShadersStore: {
  39662. [key: string]: string;
  39663. };
  39664. /**
  39665. * Store of each included file for a shader (The can be looked up using effect.key)
  39666. */
  39667. static IncludesShadersStore: {
  39668. [key: string]: string;
  39669. };
  39670. /**
  39671. * Resets the cache of effects.
  39672. */
  39673. static ResetCache(): void;
  39674. }
  39675. }
  39676. declare module "babylonjs/Engines/engineCapabilities" {
  39677. /**
  39678. * Interface used to describe the capabilities of the engine relatively to the current browser
  39679. */
  39680. export interface EngineCapabilities {
  39681. /** Maximum textures units per fragment shader */
  39682. maxTexturesImageUnits: number;
  39683. /** Maximum texture units per vertex shader */
  39684. maxVertexTextureImageUnits: number;
  39685. /** Maximum textures units in the entire pipeline */
  39686. maxCombinedTexturesImageUnits: number;
  39687. /** Maximum texture size */
  39688. maxTextureSize: number;
  39689. /** Maximum texture samples */
  39690. maxSamples?: number;
  39691. /** Maximum cube texture size */
  39692. maxCubemapTextureSize: number;
  39693. /** Maximum render texture size */
  39694. maxRenderTextureSize: number;
  39695. /** Maximum number of vertex attributes */
  39696. maxVertexAttribs: number;
  39697. /** Maximum number of varyings */
  39698. maxVaryingVectors: number;
  39699. /** Maximum number of uniforms per vertex shader */
  39700. maxVertexUniformVectors: number;
  39701. /** Maximum number of uniforms per fragment shader */
  39702. maxFragmentUniformVectors: number;
  39703. /** Defines if standard derivates (dx/dy) are supported */
  39704. standardDerivatives: boolean;
  39705. /** Defines if s3tc texture compression is supported */
  39706. s3tc?: WEBGL_compressed_texture_s3tc;
  39707. /** Defines if pvrtc texture compression is supported */
  39708. pvrtc: any;
  39709. /** Defines if etc1 texture compression is supported */
  39710. etc1: any;
  39711. /** Defines if etc2 texture compression is supported */
  39712. etc2: any;
  39713. /** Defines if astc texture compression is supported */
  39714. astc: any;
  39715. /** Defines if bptc texture compression is supported */
  39716. bptc: any;
  39717. /** Defines if float textures are supported */
  39718. textureFloat: boolean;
  39719. /** Defines if vertex array objects are supported */
  39720. vertexArrayObject: boolean;
  39721. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39722. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39723. /** Gets the maximum level of anisotropy supported */
  39724. maxAnisotropy: number;
  39725. /** Defines if instancing is supported */
  39726. instancedArrays: boolean;
  39727. /** Defines if 32 bits indices are supported */
  39728. uintIndices: boolean;
  39729. /** Defines if high precision shaders are supported */
  39730. highPrecisionShaderSupported: boolean;
  39731. /** Defines if depth reading in the fragment shader is supported */
  39732. fragmentDepthSupported: boolean;
  39733. /** Defines if float texture linear filtering is supported*/
  39734. textureFloatLinearFiltering: boolean;
  39735. /** Defines if rendering to float textures is supported */
  39736. textureFloatRender: boolean;
  39737. /** Defines if half float textures are supported*/
  39738. textureHalfFloat: boolean;
  39739. /** Defines if half float texture linear filtering is supported*/
  39740. textureHalfFloatLinearFiltering: boolean;
  39741. /** Defines if rendering to half float textures is supported */
  39742. textureHalfFloatRender: boolean;
  39743. /** Defines if textureLOD shader command is supported */
  39744. textureLOD: boolean;
  39745. /** Defines if draw buffers extension is supported */
  39746. drawBuffersExtension: boolean;
  39747. /** Defines if depth textures are supported */
  39748. depthTextureExtension: boolean;
  39749. /** Defines if float color buffer are supported */
  39750. colorBufferFloat: boolean;
  39751. /** Gets disjoint timer query extension (null if not supported) */
  39752. timerQuery?: EXT_disjoint_timer_query;
  39753. /** Defines if timestamp can be used with timer query */
  39754. canUseTimestampForTimerQuery: boolean;
  39755. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39756. multiview?: any;
  39757. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39758. oculusMultiview?: any;
  39759. /** Function used to let the system compiles shaders in background */
  39760. parallelShaderCompile?: {
  39761. COMPLETION_STATUS_KHR: number;
  39762. };
  39763. /** Max number of texture samples for MSAA */
  39764. maxMSAASamples: number;
  39765. /** Defines if the blend min max extension is supported */
  39766. blendMinMax: boolean;
  39767. }
  39768. }
  39769. declare module "babylonjs/States/depthCullingState" {
  39770. import { Nullable } from "babylonjs/types";
  39771. /**
  39772. * @hidden
  39773. **/
  39774. export class DepthCullingState {
  39775. private _isDepthTestDirty;
  39776. private _isDepthMaskDirty;
  39777. private _isDepthFuncDirty;
  39778. private _isCullFaceDirty;
  39779. private _isCullDirty;
  39780. private _isZOffsetDirty;
  39781. private _isFrontFaceDirty;
  39782. private _depthTest;
  39783. private _depthMask;
  39784. private _depthFunc;
  39785. private _cull;
  39786. private _cullFace;
  39787. private _zOffset;
  39788. private _frontFace;
  39789. /**
  39790. * Initializes the state.
  39791. */
  39792. constructor();
  39793. get isDirty(): boolean;
  39794. get zOffset(): number;
  39795. set zOffset(value: number);
  39796. get cullFace(): Nullable<number>;
  39797. set cullFace(value: Nullable<number>);
  39798. get cull(): Nullable<boolean>;
  39799. set cull(value: Nullable<boolean>);
  39800. get depthFunc(): Nullable<number>;
  39801. set depthFunc(value: Nullable<number>);
  39802. get depthMask(): boolean;
  39803. set depthMask(value: boolean);
  39804. get depthTest(): boolean;
  39805. set depthTest(value: boolean);
  39806. get frontFace(): Nullable<number>;
  39807. set frontFace(value: Nullable<number>);
  39808. reset(): void;
  39809. apply(gl: WebGLRenderingContext): void;
  39810. }
  39811. }
  39812. declare module "babylonjs/States/stencilState" {
  39813. /**
  39814. * @hidden
  39815. **/
  39816. export class StencilState {
  39817. /** 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 */
  39818. static readonly ALWAYS: number;
  39819. /** Passed to stencilOperation to specify that stencil value must be kept */
  39820. static readonly KEEP: number;
  39821. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39822. static readonly REPLACE: number;
  39823. private _isStencilTestDirty;
  39824. private _isStencilMaskDirty;
  39825. private _isStencilFuncDirty;
  39826. private _isStencilOpDirty;
  39827. private _stencilTest;
  39828. private _stencilMask;
  39829. private _stencilFunc;
  39830. private _stencilFuncRef;
  39831. private _stencilFuncMask;
  39832. private _stencilOpStencilFail;
  39833. private _stencilOpDepthFail;
  39834. private _stencilOpStencilDepthPass;
  39835. get isDirty(): boolean;
  39836. get stencilFunc(): number;
  39837. set stencilFunc(value: number);
  39838. get stencilFuncRef(): number;
  39839. set stencilFuncRef(value: number);
  39840. get stencilFuncMask(): number;
  39841. set stencilFuncMask(value: number);
  39842. get stencilOpStencilFail(): number;
  39843. set stencilOpStencilFail(value: number);
  39844. get stencilOpDepthFail(): number;
  39845. set stencilOpDepthFail(value: number);
  39846. get stencilOpStencilDepthPass(): number;
  39847. set stencilOpStencilDepthPass(value: number);
  39848. get stencilMask(): number;
  39849. set stencilMask(value: number);
  39850. get stencilTest(): boolean;
  39851. set stencilTest(value: boolean);
  39852. constructor();
  39853. reset(): void;
  39854. apply(gl: WebGLRenderingContext): void;
  39855. }
  39856. }
  39857. declare module "babylonjs/States/alphaCullingState" {
  39858. /**
  39859. * @hidden
  39860. **/
  39861. export class AlphaState {
  39862. private _isAlphaBlendDirty;
  39863. private _isBlendFunctionParametersDirty;
  39864. private _isBlendEquationParametersDirty;
  39865. private _isBlendConstantsDirty;
  39866. private _alphaBlend;
  39867. private _blendFunctionParameters;
  39868. private _blendEquationParameters;
  39869. private _blendConstants;
  39870. /**
  39871. * Initializes the state.
  39872. */
  39873. constructor();
  39874. get isDirty(): boolean;
  39875. get alphaBlend(): boolean;
  39876. set alphaBlend(value: boolean);
  39877. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39878. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39879. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39880. reset(): void;
  39881. apply(gl: WebGLRenderingContext): void;
  39882. }
  39883. }
  39884. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  39885. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39886. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39887. /** @hidden */
  39888. export class WebGLShaderProcessor implements IShaderProcessor {
  39889. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  39890. }
  39891. }
  39892. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  39893. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39894. /** @hidden */
  39895. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39896. attributeProcessor(attribute: string): string;
  39897. varyingProcessor(varying: string, isFragment: boolean): string;
  39898. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  39899. }
  39900. }
  39901. declare module "babylonjs/Engines/instancingAttributeInfo" {
  39902. /**
  39903. * Interface for attribute information associated with buffer instanciation
  39904. */
  39905. export interface InstancingAttributeInfo {
  39906. /**
  39907. * Name of the GLSL attribute
  39908. * if attribute index is not specified, this is used to retrieve the index from the effect
  39909. */
  39910. attributeName: string;
  39911. /**
  39912. * Index/offset of the attribute in the vertex shader
  39913. * if not specified, this will be computes from the name.
  39914. */
  39915. index?: number;
  39916. /**
  39917. * size of the attribute, 1, 2, 3 or 4
  39918. */
  39919. attributeSize: number;
  39920. /**
  39921. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39922. */
  39923. offset: number;
  39924. /**
  39925. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39926. * default to 1
  39927. */
  39928. divisor?: number;
  39929. /**
  39930. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39931. * default is FLOAT
  39932. */
  39933. attributeType?: number;
  39934. /**
  39935. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39936. */
  39937. normalized?: boolean;
  39938. }
  39939. }
  39940. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  39941. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39942. import { Nullable } from "babylonjs/types";
  39943. module "babylonjs/Engines/thinEngine" {
  39944. interface ThinEngine {
  39945. /**
  39946. * Update a video texture
  39947. * @param texture defines the texture to update
  39948. * @param video defines the video element to use
  39949. * @param invertY defines if data must be stored with Y axis inverted
  39950. */
  39951. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39952. }
  39953. }
  39954. }
  39955. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  39956. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39957. import { Nullable } from "babylonjs/types";
  39958. module "babylonjs/Engines/thinEngine" {
  39959. interface ThinEngine {
  39960. /**
  39961. * Creates a dynamic texture
  39962. * @param width defines the width of the texture
  39963. * @param height defines the height of the texture
  39964. * @param generateMipMaps defines if the engine should generate the mip levels
  39965. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39966. * @returns the dynamic texture inside an InternalTexture
  39967. */
  39968. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39969. /**
  39970. * Update the content of a dynamic texture
  39971. * @param texture defines the texture to update
  39972. * @param canvas defines the canvas containing the source
  39973. * @param invertY defines if data must be stored with Y axis inverted
  39974. * @param premulAlpha defines if alpha is stored as premultiplied
  39975. * @param format defines the format of the data
  39976. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39977. */
  39978. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39979. }
  39980. }
  39981. }
  39982. declare module "babylonjs/Materials/Textures/videoTexture" {
  39983. import { Observable } from "babylonjs/Misc/observable";
  39984. import { Nullable } from "babylonjs/types";
  39985. import { Scene } from "babylonjs/scene";
  39986. import { Texture } from "babylonjs/Materials/Textures/texture";
  39987. import "babylonjs/Engines/Extensions/engine.videoTexture";
  39988. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  39989. /**
  39990. * Settings for finer control over video usage
  39991. */
  39992. export interface VideoTextureSettings {
  39993. /**
  39994. * Applies `autoplay` to video, if specified
  39995. */
  39996. autoPlay?: boolean;
  39997. /**
  39998. * Applies `muted` to video, if specified
  39999. */
  40000. muted?: boolean;
  40001. /**
  40002. * Applies `loop` to video, if specified
  40003. */
  40004. loop?: boolean;
  40005. /**
  40006. * Automatically updates internal texture from video at every frame in the render loop
  40007. */
  40008. autoUpdateTexture: boolean;
  40009. /**
  40010. * Image src displayed during the video loading or until the user interacts with the video.
  40011. */
  40012. poster?: string;
  40013. }
  40014. /**
  40015. * If you want to display a video in your scene, this is the special texture for that.
  40016. * This special texture works similar to other textures, with the exception of a few parameters.
  40017. * @see https://doc.babylonjs.com/how_to/video_texture
  40018. */
  40019. export class VideoTexture extends Texture {
  40020. /**
  40021. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40022. */
  40023. readonly autoUpdateTexture: boolean;
  40024. /**
  40025. * The video instance used by the texture internally
  40026. */
  40027. readonly video: HTMLVideoElement;
  40028. private _onUserActionRequestedObservable;
  40029. /**
  40030. * Event triggerd when a dom action is required by the user to play the video.
  40031. * This happens due to recent changes in browser policies preventing video to auto start.
  40032. */
  40033. get onUserActionRequestedObservable(): Observable<Texture>;
  40034. private _generateMipMaps;
  40035. private _stillImageCaptured;
  40036. private _displayingPosterTexture;
  40037. private _settings;
  40038. private _createInternalTextureOnEvent;
  40039. private _frameId;
  40040. private _currentSrc;
  40041. /**
  40042. * Creates a video texture.
  40043. * If you want to display a video in your scene, this is the special texture for that.
  40044. * This special texture works similar to other textures, with the exception of a few parameters.
  40045. * @see https://doc.babylonjs.com/how_to/video_texture
  40046. * @param name optional name, will detect from video source, if not defined
  40047. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40048. * @param scene is obviously the current scene.
  40049. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40050. * @param invertY is false by default but can be used to invert video on Y axis
  40051. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40052. * @param settings allows finer control over video usage
  40053. */
  40054. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40055. private _getName;
  40056. private _getVideo;
  40057. private _createInternalTexture;
  40058. private reset;
  40059. /**
  40060. * @hidden Internal method to initiate `update`.
  40061. */
  40062. _rebuild(): void;
  40063. /**
  40064. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40065. */
  40066. update(): void;
  40067. /**
  40068. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40069. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  40070. */
  40071. updateTexture(isVisible: boolean): void;
  40072. protected _updateInternalTexture: () => void;
  40073. /**
  40074. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40075. * @param url New url.
  40076. */
  40077. updateURL(url: string): void;
  40078. /**
  40079. * Clones the texture.
  40080. * @returns the cloned texture
  40081. */
  40082. clone(): VideoTexture;
  40083. /**
  40084. * Dispose the texture and release its associated resources.
  40085. */
  40086. dispose(): void;
  40087. /**
  40088. * Creates a video texture straight from a stream.
  40089. * @param scene Define the scene the texture should be created in
  40090. * @param stream Define the stream the texture should be created from
  40091. * @returns The created video texture as a promise
  40092. */
  40093. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40094. /**
  40095. * Creates a video texture straight from your WebCam video feed.
  40096. * @param scene Define the scene the texture should be created in
  40097. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40098. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40099. * @returns The created video texture as a promise
  40100. */
  40101. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40102. minWidth: number;
  40103. maxWidth: number;
  40104. minHeight: number;
  40105. maxHeight: number;
  40106. deviceId: string;
  40107. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40108. /**
  40109. * Creates a video texture straight from your WebCam video feed.
  40110. * @param scene Define the scene the texture should be created in
  40111. * @param onReady Define a callback to triggered once the texture will be ready
  40112. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40113. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40114. */
  40115. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40116. minWidth: number;
  40117. maxWidth: number;
  40118. minHeight: number;
  40119. maxHeight: number;
  40120. deviceId: string;
  40121. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40122. }
  40123. }
  40124. declare module "babylonjs/Engines/thinEngine" {
  40125. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  40126. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  40127. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40128. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40129. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  40130. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  40131. import { Observable } from "babylonjs/Misc/observable";
  40132. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  40133. import { StencilState } from "babylonjs/States/stencilState";
  40134. import { AlphaState } from "babylonjs/States/alphaCullingState";
  40135. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40136. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  40137. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40138. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40139. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40140. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  40141. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  40142. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  40143. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40144. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40145. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40146. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  40147. import { WebRequest } from "babylonjs/Misc/webRequest";
  40148. import { LoadFileError } from "babylonjs/Misc/fileTools";
  40149. /**
  40150. * Defines the interface used by objects working like Scene
  40151. * @hidden
  40152. */
  40153. export interface ISceneLike {
  40154. _addPendingData(data: any): void;
  40155. _removePendingData(data: any): void;
  40156. offlineProvider: IOfflineProvider;
  40157. }
  40158. /**
  40159. * Information about the current host
  40160. */
  40161. export interface HostInformation {
  40162. /**
  40163. * Defines if the current host is a mobile
  40164. */
  40165. isMobile: boolean;
  40166. }
  40167. /** Interface defining initialization parameters for Engine class */
  40168. export interface EngineOptions extends WebGLContextAttributes {
  40169. /**
  40170. * Defines if the engine should no exceed a specified device ratio
  40171. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40172. */
  40173. limitDeviceRatio?: number;
  40174. /**
  40175. * Defines if webvr should be enabled automatically
  40176. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40177. */
  40178. autoEnableWebVR?: boolean;
  40179. /**
  40180. * Defines if webgl2 should be turned off even if supported
  40181. * @see https://doc.babylonjs.com/features/webgl2
  40182. */
  40183. disableWebGL2Support?: boolean;
  40184. /**
  40185. * Defines if webaudio should be initialized as well
  40186. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40187. */
  40188. audioEngine?: boolean;
  40189. /**
  40190. * Defines if animations should run using a deterministic lock step
  40191. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40192. */
  40193. deterministicLockstep?: boolean;
  40194. /** Defines the maximum steps to use with deterministic lock step mode */
  40195. lockstepMaxSteps?: number;
  40196. /** Defines the seconds between each deterministic lock step */
  40197. timeStep?: number;
  40198. /**
  40199. * Defines that engine should ignore context lost events
  40200. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40201. */
  40202. doNotHandleContextLost?: boolean;
  40203. /**
  40204. * Defines that engine should ignore modifying touch action attribute and style
  40205. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40206. */
  40207. doNotHandleTouchAction?: boolean;
  40208. /**
  40209. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40210. */
  40211. useHighPrecisionFloats?: boolean;
  40212. /**
  40213. * Make the canvas XR Compatible for XR sessions
  40214. */
  40215. xrCompatible?: boolean;
  40216. /**
  40217. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40218. */
  40219. useHighPrecisionMatrix?: boolean;
  40220. /**
  40221. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40222. */
  40223. failIfMajorPerformanceCaveat?: boolean;
  40224. }
  40225. /**
  40226. * The base engine class (root of all engines)
  40227. */
  40228. export class ThinEngine {
  40229. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40230. static ExceptionList: ({
  40231. key: string;
  40232. capture: string;
  40233. captureConstraint: number;
  40234. targets: string[];
  40235. } | {
  40236. key: string;
  40237. capture: null;
  40238. captureConstraint: null;
  40239. targets: string[];
  40240. })[];
  40241. /** @hidden */
  40242. static _TextureLoaders: IInternalTextureLoader[];
  40243. /**
  40244. * Returns the current npm package of the sdk
  40245. */
  40246. static get NpmPackage(): string;
  40247. /**
  40248. * Returns the current version of the framework
  40249. */
  40250. static get Version(): string;
  40251. /**
  40252. * Returns a string describing the current engine
  40253. */
  40254. get description(): string;
  40255. /**
  40256. * Gets or sets the epsilon value used by collision engine
  40257. */
  40258. static CollisionsEpsilon: number;
  40259. /**
  40260. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40261. */
  40262. static get ShadersRepository(): string;
  40263. static set ShadersRepository(value: string);
  40264. /** @hidden */
  40265. _shaderProcessor: IShaderProcessor;
  40266. /**
  40267. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40268. */
  40269. forcePOTTextures: boolean;
  40270. /**
  40271. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40272. */
  40273. isFullscreen: boolean;
  40274. /**
  40275. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40276. */
  40277. cullBackFaces: boolean;
  40278. /**
  40279. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40280. */
  40281. renderEvenInBackground: boolean;
  40282. /**
  40283. * Gets or sets a boolean indicating that cache can be kept between frames
  40284. */
  40285. preventCacheWipeBetweenFrames: boolean;
  40286. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40287. validateShaderPrograms: boolean;
  40288. /**
  40289. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40290. * This can provide greater z depth for distant objects.
  40291. */
  40292. useReverseDepthBuffer: boolean;
  40293. /**
  40294. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40295. */
  40296. disableUniformBuffers: boolean;
  40297. /** @hidden */
  40298. _uniformBuffers: UniformBuffer[];
  40299. /**
  40300. * Gets a boolean indicating that the engine supports uniform buffers
  40301. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40302. */
  40303. get supportsUniformBuffers(): boolean;
  40304. /** @hidden */
  40305. _gl: WebGLRenderingContext;
  40306. /** @hidden */
  40307. _webGLVersion: number;
  40308. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40309. protected _windowIsBackground: boolean;
  40310. protected _creationOptions: EngineOptions;
  40311. protected _highPrecisionShadersAllowed: boolean;
  40312. /** @hidden */
  40313. get _shouldUseHighPrecisionShader(): boolean;
  40314. /**
  40315. * Gets a boolean indicating that only power of 2 textures are supported
  40316. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40317. */
  40318. get needPOTTextures(): boolean;
  40319. /** @hidden */
  40320. _badOS: boolean;
  40321. /** @hidden */
  40322. _badDesktopOS: boolean;
  40323. private _hardwareScalingLevel;
  40324. /** @hidden */
  40325. _caps: EngineCapabilities;
  40326. private _isStencilEnable;
  40327. private _glVersion;
  40328. private _glRenderer;
  40329. private _glVendor;
  40330. /** @hidden */
  40331. _videoTextureSupported: boolean;
  40332. protected _renderingQueueLaunched: boolean;
  40333. protected _activeRenderLoops: (() => void)[];
  40334. /**
  40335. * Observable signaled when a context lost event is raised
  40336. */
  40337. onContextLostObservable: Observable<ThinEngine>;
  40338. /**
  40339. * Observable signaled when a context restored event is raised
  40340. */
  40341. onContextRestoredObservable: Observable<ThinEngine>;
  40342. private _onContextLost;
  40343. private _onContextRestored;
  40344. protected _contextWasLost: boolean;
  40345. /** @hidden */
  40346. _doNotHandleContextLost: boolean;
  40347. /**
  40348. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40349. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40350. */
  40351. get doNotHandleContextLost(): boolean;
  40352. set doNotHandleContextLost(value: boolean);
  40353. /**
  40354. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40355. */
  40356. disableVertexArrayObjects: boolean;
  40357. /** @hidden */
  40358. protected _colorWrite: boolean;
  40359. /** @hidden */
  40360. protected _colorWriteChanged: boolean;
  40361. /** @hidden */
  40362. protected _depthCullingState: DepthCullingState;
  40363. /** @hidden */
  40364. protected _stencilState: StencilState;
  40365. /** @hidden */
  40366. _alphaState: AlphaState;
  40367. /** @hidden */
  40368. _alphaMode: number;
  40369. /** @hidden */
  40370. _alphaEquation: number;
  40371. /** @hidden */
  40372. _internalTexturesCache: InternalTexture[];
  40373. /** @hidden */
  40374. protected _activeChannel: number;
  40375. private _currentTextureChannel;
  40376. /** @hidden */
  40377. protected _boundTexturesCache: {
  40378. [key: string]: Nullable<InternalTexture>;
  40379. };
  40380. /** @hidden */
  40381. protected _currentEffect: Nullable<Effect>;
  40382. /** @hidden */
  40383. protected _currentProgram: Nullable<WebGLProgram>;
  40384. private _compiledEffects;
  40385. private _vertexAttribArraysEnabled;
  40386. /** @hidden */
  40387. protected _cachedViewport: Nullable<IViewportLike>;
  40388. private _cachedVertexArrayObject;
  40389. /** @hidden */
  40390. protected _cachedVertexBuffers: any;
  40391. /** @hidden */
  40392. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40393. /** @hidden */
  40394. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40395. /** @hidden */
  40396. _currentRenderTarget: Nullable<InternalTexture>;
  40397. private _uintIndicesCurrentlySet;
  40398. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40399. /** @hidden */
  40400. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40401. /** @hidden */
  40402. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40403. private _currentBufferPointers;
  40404. private _currentInstanceLocations;
  40405. private _currentInstanceBuffers;
  40406. private _textureUnits;
  40407. /** @hidden */
  40408. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40409. /** @hidden */
  40410. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40411. /** @hidden */
  40412. _boundRenderFunction: any;
  40413. private _vaoRecordInProgress;
  40414. private _mustWipeVertexAttributes;
  40415. private _emptyTexture;
  40416. private _emptyCubeTexture;
  40417. private _emptyTexture3D;
  40418. private _emptyTexture2DArray;
  40419. /** @hidden */
  40420. _frameHandler: number;
  40421. private _nextFreeTextureSlots;
  40422. private _maxSimultaneousTextures;
  40423. private _activeRequests;
  40424. /** @hidden */
  40425. _transformTextureUrl: Nullable<(url: string) => string>;
  40426. /**
  40427. * Gets information about the current host
  40428. */
  40429. hostInformation: HostInformation;
  40430. protected get _supportsHardwareTextureRescaling(): boolean;
  40431. private _framebufferDimensionsObject;
  40432. /**
  40433. * sets the object from which width and height will be taken from when getting render width and height
  40434. * Will fallback to the gl object
  40435. * @param dimensions the framebuffer width and height that will be used.
  40436. */
  40437. set framebufferDimensionsObject(dimensions: Nullable<{
  40438. framebufferWidth: number;
  40439. framebufferHeight: number;
  40440. }>);
  40441. /**
  40442. * Gets the current viewport
  40443. */
  40444. get currentViewport(): Nullable<IViewportLike>;
  40445. /**
  40446. * Gets the default empty texture
  40447. */
  40448. get emptyTexture(): InternalTexture;
  40449. /**
  40450. * Gets the default empty 3D texture
  40451. */
  40452. get emptyTexture3D(): InternalTexture;
  40453. /**
  40454. * Gets the default empty 2D array texture
  40455. */
  40456. get emptyTexture2DArray(): InternalTexture;
  40457. /**
  40458. * Gets the default empty cube texture
  40459. */
  40460. get emptyCubeTexture(): InternalTexture;
  40461. /**
  40462. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40463. */
  40464. readonly premultipliedAlpha: boolean;
  40465. /**
  40466. * Observable event triggered before each texture is initialized
  40467. */
  40468. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40469. /**
  40470. * Creates a new engine
  40471. * @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
  40472. * @param antialias defines enable antialiasing (default: false)
  40473. * @param options defines further options to be sent to the getContext() function
  40474. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40475. */
  40476. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40477. private _rebuildInternalTextures;
  40478. private _rebuildEffects;
  40479. /**
  40480. * Gets a boolean indicating if all created effects are ready
  40481. * @returns true if all effects are ready
  40482. */
  40483. areAllEffectsReady(): boolean;
  40484. protected _rebuildBuffers(): void;
  40485. protected _initGLContext(): void;
  40486. /**
  40487. * Gets version of the current webGL context
  40488. */
  40489. get webGLVersion(): number;
  40490. /**
  40491. * Gets a string identifying the name of the class
  40492. * @returns "Engine" string
  40493. */
  40494. getClassName(): string;
  40495. /**
  40496. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40497. */
  40498. get isStencilEnable(): boolean;
  40499. /** @hidden */
  40500. _prepareWorkingCanvas(): void;
  40501. /**
  40502. * Reset the texture cache to empty state
  40503. */
  40504. resetTextureCache(): void;
  40505. /**
  40506. * Gets an object containing information about the current webGL context
  40507. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40508. */
  40509. getGlInfo(): {
  40510. vendor: string;
  40511. renderer: string;
  40512. version: string;
  40513. };
  40514. /**
  40515. * Defines the hardware scaling level.
  40516. * By default the hardware scaling level is computed from the window device ratio.
  40517. * 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.
  40518. * @param level defines the level to use
  40519. */
  40520. setHardwareScalingLevel(level: number): void;
  40521. /**
  40522. * Gets the current hardware scaling level.
  40523. * By default the hardware scaling level is computed from the window device ratio.
  40524. * 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.
  40525. * @returns a number indicating the current hardware scaling level
  40526. */
  40527. getHardwareScalingLevel(): number;
  40528. /**
  40529. * Gets the list of loaded textures
  40530. * @returns an array containing all loaded textures
  40531. */
  40532. getLoadedTexturesCache(): InternalTexture[];
  40533. /**
  40534. * Gets the object containing all engine capabilities
  40535. * @returns the EngineCapabilities object
  40536. */
  40537. getCaps(): EngineCapabilities;
  40538. /**
  40539. * stop executing a render loop function and remove it from the execution array
  40540. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40541. */
  40542. stopRenderLoop(renderFunction?: () => void): void;
  40543. /** @hidden */
  40544. _renderLoop(): void;
  40545. /**
  40546. * Gets the HTML canvas attached with the current webGL context
  40547. * @returns a HTML canvas
  40548. */
  40549. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40550. /**
  40551. * Gets host window
  40552. * @returns the host window object
  40553. */
  40554. getHostWindow(): Nullable<Window>;
  40555. /**
  40556. * Gets the current render width
  40557. * @param useScreen defines if screen size must be used (or the current render target if any)
  40558. * @returns a number defining the current render width
  40559. */
  40560. getRenderWidth(useScreen?: boolean): number;
  40561. /**
  40562. * Gets the current render height
  40563. * @param useScreen defines if screen size must be used (or the current render target if any)
  40564. * @returns a number defining the current render height
  40565. */
  40566. getRenderHeight(useScreen?: boolean): number;
  40567. /**
  40568. * Can be used to override the current requestAnimationFrame requester.
  40569. * @hidden
  40570. */
  40571. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40572. /**
  40573. * Register and execute a render loop. The engine can have more than one render function
  40574. * @param renderFunction defines the function to continuously execute
  40575. */
  40576. runRenderLoop(renderFunction: () => void): void;
  40577. /**
  40578. * Clear the current render buffer or the current render target (if any is set up)
  40579. * @param color defines the color to use
  40580. * @param backBuffer defines if the back buffer must be cleared
  40581. * @param depth defines if the depth buffer must be cleared
  40582. * @param stencil defines if the stencil buffer must be cleared
  40583. */
  40584. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40585. private _viewportCached;
  40586. /** @hidden */
  40587. _viewport(x: number, y: number, width: number, height: number): void;
  40588. /**
  40589. * Set the WebGL's viewport
  40590. * @param viewport defines the viewport element to be used
  40591. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40592. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40593. */
  40594. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40595. /**
  40596. * Begin a new frame
  40597. */
  40598. beginFrame(): void;
  40599. /**
  40600. * Enf the current frame
  40601. */
  40602. endFrame(): void;
  40603. /**
  40604. * Resize the view according to the canvas' size
  40605. */
  40606. resize(): void;
  40607. /**
  40608. * Force a specific size of the canvas
  40609. * @param width defines the new canvas' width
  40610. * @param height defines the new canvas' height
  40611. * @returns true if the size was changed
  40612. */
  40613. setSize(width: number, height: number): boolean;
  40614. /**
  40615. * Binds the frame buffer to the specified texture.
  40616. * @param texture The texture to render to or null for the default canvas
  40617. * @param faceIndex The face of the texture to render to in case of cube texture
  40618. * @param requiredWidth The width of the target to render to
  40619. * @param requiredHeight The height of the target to render to
  40620. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40621. * @param lodLevel defines the lod level to bind to the frame buffer
  40622. * @param layer defines the 2d array index to bind to frame buffer to
  40623. */
  40624. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40625. /** @hidden */
  40626. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40627. /**
  40628. * Unbind the current render target texture from the webGL context
  40629. * @param texture defines the render target texture to unbind
  40630. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40631. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40632. */
  40633. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40634. /**
  40635. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40636. */
  40637. flushFramebuffer(): void;
  40638. /**
  40639. * Unbind the current render target and bind the default framebuffer
  40640. */
  40641. restoreDefaultFramebuffer(): void;
  40642. /** @hidden */
  40643. protected _resetVertexBufferBinding(): void;
  40644. /**
  40645. * Creates a vertex buffer
  40646. * @param data the data for the vertex buffer
  40647. * @returns the new WebGL static buffer
  40648. */
  40649. createVertexBuffer(data: DataArray): DataBuffer;
  40650. private _createVertexBuffer;
  40651. /**
  40652. * Creates a dynamic vertex buffer
  40653. * @param data the data for the dynamic vertex buffer
  40654. * @returns the new WebGL dynamic buffer
  40655. */
  40656. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40657. protected _resetIndexBufferBinding(): void;
  40658. /**
  40659. * Creates a new index buffer
  40660. * @param indices defines the content of the index buffer
  40661. * @param updatable defines if the index buffer must be updatable
  40662. * @returns a new webGL buffer
  40663. */
  40664. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40665. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40666. /**
  40667. * Bind a webGL buffer to the webGL context
  40668. * @param buffer defines the buffer to bind
  40669. */
  40670. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40671. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40672. private bindBuffer;
  40673. /**
  40674. * update the bound buffer with the given data
  40675. * @param data defines the data to update
  40676. */
  40677. updateArrayBuffer(data: Float32Array): void;
  40678. private _vertexAttribPointer;
  40679. /** @hidden */
  40680. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40681. private _bindVertexBuffersAttributes;
  40682. /**
  40683. * Records a vertex array object
  40684. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40685. * @param vertexBuffers defines the list of vertex buffers to store
  40686. * @param indexBuffer defines the index buffer to store
  40687. * @param effect defines the effect to store
  40688. * @returns the new vertex array object
  40689. */
  40690. recordVertexArrayObject(vertexBuffers: {
  40691. [key: string]: VertexBuffer;
  40692. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40693. /**
  40694. * Bind a specific vertex array object
  40695. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40696. * @param vertexArrayObject defines the vertex array object to bind
  40697. * @param indexBuffer defines the index buffer to bind
  40698. */
  40699. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40700. /**
  40701. * Bind webGl buffers directly to the webGL context
  40702. * @param vertexBuffer defines the vertex buffer to bind
  40703. * @param indexBuffer defines the index buffer to bind
  40704. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40705. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40706. * @param effect defines the effect associated with the vertex buffer
  40707. */
  40708. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40709. private _unbindVertexArrayObject;
  40710. /**
  40711. * Bind a list of vertex buffers to the webGL context
  40712. * @param vertexBuffers defines the list of vertex buffers to bind
  40713. * @param indexBuffer defines the index buffer to bind
  40714. * @param effect defines the effect associated with the vertex buffers
  40715. */
  40716. bindBuffers(vertexBuffers: {
  40717. [key: string]: Nullable<VertexBuffer>;
  40718. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40719. /**
  40720. * Unbind all instance attributes
  40721. */
  40722. unbindInstanceAttributes(): void;
  40723. /**
  40724. * Release and free the memory of a vertex array object
  40725. * @param vao defines the vertex array object to delete
  40726. */
  40727. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40728. /** @hidden */
  40729. _releaseBuffer(buffer: DataBuffer): boolean;
  40730. protected _deleteBuffer(buffer: DataBuffer): void;
  40731. /**
  40732. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40733. * @param instancesBuffer defines the webGL buffer to update and bind
  40734. * @param data defines the data to store in the buffer
  40735. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40736. */
  40737. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40738. /**
  40739. * Bind the content of a webGL buffer used with instantiation
  40740. * @param instancesBuffer defines the webGL buffer to bind
  40741. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40742. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40743. */
  40744. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40745. /**
  40746. * Disable the instance attribute corresponding to the name in parameter
  40747. * @param name defines the name of the attribute to disable
  40748. */
  40749. disableInstanceAttributeByName(name: string): void;
  40750. /**
  40751. * Disable the instance attribute corresponding to the location in parameter
  40752. * @param attributeLocation defines the attribute location of the attribute to disable
  40753. */
  40754. disableInstanceAttribute(attributeLocation: number): void;
  40755. /**
  40756. * Disable the attribute corresponding to the location in parameter
  40757. * @param attributeLocation defines the attribute location of the attribute to disable
  40758. */
  40759. disableAttributeByIndex(attributeLocation: number): void;
  40760. /**
  40761. * Send a draw order
  40762. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40763. * @param indexStart defines the starting index
  40764. * @param indexCount defines the number of index to draw
  40765. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40766. */
  40767. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40768. /**
  40769. * Draw a list of points
  40770. * @param verticesStart defines the index of first vertex to draw
  40771. * @param verticesCount defines the count of vertices to draw
  40772. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40773. */
  40774. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40775. /**
  40776. * Draw a list of unindexed primitives
  40777. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40778. * @param verticesStart defines the index of first vertex to draw
  40779. * @param verticesCount defines the count of vertices to draw
  40780. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40781. */
  40782. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40783. /**
  40784. * Draw a list of indexed primitives
  40785. * @param fillMode defines the primitive to use
  40786. * @param indexStart defines the starting index
  40787. * @param indexCount defines the number of index to draw
  40788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40789. */
  40790. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40791. /**
  40792. * Draw a list of unindexed primitives
  40793. * @param fillMode defines the primitive to use
  40794. * @param verticesStart defines the index of first vertex to draw
  40795. * @param verticesCount defines the count of vertices to draw
  40796. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40797. */
  40798. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40799. private _drawMode;
  40800. /** @hidden */
  40801. protected _reportDrawCall(): void;
  40802. /** @hidden */
  40803. _releaseEffect(effect: Effect): void;
  40804. /** @hidden */
  40805. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40806. /**
  40807. * Create a new effect (used to store vertex/fragment shaders)
  40808. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40809. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40810. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40811. * @param samplers defines an array of string used to represent textures
  40812. * @param defines defines the string containing the defines to use to compile the shaders
  40813. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40814. * @param onCompiled defines a function to call when the effect creation is successful
  40815. * @param onError defines a function to call when the effect creation has failed
  40816. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40817. * @returns the new Effect
  40818. */
  40819. 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;
  40820. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40821. private _compileShader;
  40822. private _compileRawShader;
  40823. /** @hidden */
  40824. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40825. /**
  40826. * Directly creates a webGL program
  40827. * @param pipelineContext defines the pipeline context to attach to
  40828. * @param vertexCode defines the vertex shader code to use
  40829. * @param fragmentCode defines the fragment shader code to use
  40830. * @param context defines the webGL context to use (if not set, the current one will be used)
  40831. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40832. * @returns the new webGL program
  40833. */
  40834. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40835. /**
  40836. * Creates a webGL program
  40837. * @param pipelineContext defines the pipeline context to attach to
  40838. * @param vertexCode defines the vertex shader code to use
  40839. * @param fragmentCode defines the fragment shader code to use
  40840. * @param defines defines the string containing the defines to use to compile the shaders
  40841. * @param context defines the webGL context to use (if not set, the current one will be used)
  40842. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40843. * @returns the new webGL program
  40844. */
  40845. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40846. /**
  40847. * Creates a new pipeline context
  40848. * @returns the new pipeline
  40849. */
  40850. createPipelineContext(): IPipelineContext;
  40851. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40852. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40853. /** @hidden */
  40854. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  40855. /** @hidden */
  40856. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40857. /** @hidden */
  40858. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40859. /**
  40860. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40861. * @param pipelineContext defines the pipeline context to use
  40862. * @param uniformsNames defines the list of uniform names
  40863. * @returns an array of webGL uniform locations
  40864. */
  40865. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40866. /**
  40867. * Gets the lsit of active attributes for a given webGL program
  40868. * @param pipelineContext defines the pipeline context to use
  40869. * @param attributesNames defines the list of attribute names to get
  40870. * @returns an array of indices indicating the offset of each attribute
  40871. */
  40872. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40873. /**
  40874. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40875. * @param effect defines the effect to activate
  40876. */
  40877. enableEffect(effect: Nullable<Effect>): void;
  40878. /**
  40879. * Set the value of an uniform to a number (int)
  40880. * @param uniform defines the webGL uniform location where to store the value
  40881. * @param value defines the int number to store
  40882. * @returns true if the value was set
  40883. */
  40884. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40885. /**
  40886. * Set the value of an uniform to an array of int32
  40887. * @param uniform defines the webGL uniform location where to store the value
  40888. * @param array defines the array of int32 to store
  40889. * @returns true if the value was set
  40890. */
  40891. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40892. /**
  40893. * Set the value of an uniform to an array of int32 (stored as vec2)
  40894. * @param uniform defines the webGL uniform location where to store the value
  40895. * @param array defines the array of int32 to store
  40896. * @returns true if the value was set
  40897. */
  40898. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40899. /**
  40900. * Set the value of an uniform to an array of int32 (stored as vec3)
  40901. * @param uniform defines the webGL uniform location where to store the value
  40902. * @param array defines the array of int32 to store
  40903. * @returns true if the value was set
  40904. */
  40905. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40906. /**
  40907. * Set the value of an uniform to an array of int32 (stored as vec4)
  40908. * @param uniform defines the webGL uniform location where to store the value
  40909. * @param array defines the array of int32 to store
  40910. * @returns true if the value was set
  40911. */
  40912. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40913. /**
  40914. * Set the value of an uniform to an array of number
  40915. * @param uniform defines the webGL uniform location where to store the value
  40916. * @param array defines the array of number to store
  40917. * @returns true if the value was set
  40918. */
  40919. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40920. /**
  40921. * Set the value of an uniform to an array of number (stored as vec2)
  40922. * @param uniform defines the webGL uniform location where to store the value
  40923. * @param array defines the array of number to store
  40924. * @returns true if the value was set
  40925. */
  40926. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40927. /**
  40928. * Set the value of an uniform to an array of number (stored as vec3)
  40929. * @param uniform defines the webGL uniform location where to store the value
  40930. * @param array defines the array of number to store
  40931. * @returns true if the value was set
  40932. */
  40933. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40934. /**
  40935. * Set the value of an uniform to an array of number (stored as vec4)
  40936. * @param uniform defines the webGL uniform location where to store the value
  40937. * @param array defines the array of number to store
  40938. * @returns true if the value was set
  40939. */
  40940. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40941. /**
  40942. * Set the value of an uniform to an array of float32 (stored as matrices)
  40943. * @param uniform defines the webGL uniform location where to store the value
  40944. * @param matrices defines the array of float32 to store
  40945. * @returns true if the value was set
  40946. */
  40947. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40948. /**
  40949. * Set the value of an uniform to a matrix (3x3)
  40950. * @param uniform defines the webGL uniform location where to store the value
  40951. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40952. * @returns true if the value was set
  40953. */
  40954. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40955. /**
  40956. * Set the value of an uniform to a matrix (2x2)
  40957. * @param uniform defines the webGL uniform location where to store the value
  40958. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40959. * @returns true if the value was set
  40960. */
  40961. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40962. /**
  40963. * Set the value of an uniform to a number (float)
  40964. * @param uniform defines the webGL uniform location where to store the value
  40965. * @param value defines the float number to store
  40966. * @returns true if the value was transfered
  40967. */
  40968. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40969. /**
  40970. * Set the value of an uniform to a vec2
  40971. * @param uniform defines the webGL uniform location where to store the value
  40972. * @param x defines the 1st component of the value
  40973. * @param y defines the 2nd component of the value
  40974. * @returns true if the value was set
  40975. */
  40976. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40977. /**
  40978. * Set the value of an uniform to a vec3
  40979. * @param uniform defines the webGL uniform location where to store the value
  40980. * @param x defines the 1st component of the value
  40981. * @param y defines the 2nd component of the value
  40982. * @param z defines the 3rd component of the value
  40983. * @returns true if the value was set
  40984. */
  40985. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40986. /**
  40987. * Set the value of an uniform to a vec4
  40988. * @param uniform defines the webGL uniform location where to store the value
  40989. * @param x defines the 1st component of the value
  40990. * @param y defines the 2nd component of the value
  40991. * @param z defines the 3rd component of the value
  40992. * @param w defines the 4th component of the value
  40993. * @returns true if the value was set
  40994. */
  40995. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40996. /**
  40997. * Apply all cached states (depth, culling, stencil and alpha)
  40998. */
  40999. applyStates(): void;
  41000. /**
  41001. * Enable or disable color writing
  41002. * @param enable defines the state to set
  41003. */
  41004. setColorWrite(enable: boolean): void;
  41005. /**
  41006. * Gets a boolean indicating if color writing is enabled
  41007. * @returns the current color writing state
  41008. */
  41009. getColorWrite(): boolean;
  41010. /**
  41011. * Gets the depth culling state manager
  41012. */
  41013. get depthCullingState(): DepthCullingState;
  41014. /**
  41015. * Gets the alpha state manager
  41016. */
  41017. get alphaState(): AlphaState;
  41018. /**
  41019. * Gets the stencil state manager
  41020. */
  41021. get stencilState(): StencilState;
  41022. /**
  41023. * Clears the list of texture accessible through engine.
  41024. * This can help preventing texture load conflict due to name collision.
  41025. */
  41026. clearInternalTexturesCache(): void;
  41027. /**
  41028. * Force the entire cache to be cleared
  41029. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41030. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41031. */
  41032. wipeCaches(bruteForce?: boolean): void;
  41033. /** @hidden */
  41034. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41035. min: number;
  41036. mag: number;
  41037. };
  41038. /** @hidden */
  41039. _createTexture(): WebGLTexture;
  41040. /**
  41041. * Usually called from Texture.ts.
  41042. * Passed information to create a WebGLTexture
  41043. * @param url defines a value which contains one of the following:
  41044. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41045. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41046. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41047. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41048. * @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)
  41049. * @param scene needed for loading to the correct scene
  41050. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41051. * @param onLoad optional callback to be called upon successful completion
  41052. * @param onError optional callback to be called upon failure
  41053. * @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
  41054. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41055. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41056. * @param forcedExtension defines the extension to use to pick the right loader
  41057. * @param mimeType defines an optional mime type
  41058. * @param loaderOptions options to be passed to the loader
  41059. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41060. */
  41061. 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;
  41062. /**
  41063. * Loads an image as an HTMLImageElement.
  41064. * @param input url string, ArrayBuffer, or Blob to load
  41065. * @param onLoad callback called when the image successfully loads
  41066. * @param onError callback called when the image fails to load
  41067. * @param offlineProvider offline provider for caching
  41068. * @param mimeType optional mime type
  41069. * @returns the HTMLImageElement of the loaded image
  41070. * @hidden
  41071. */
  41072. 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>;
  41073. /**
  41074. * @hidden
  41075. */
  41076. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41077. private _unpackFlipYCached;
  41078. /**
  41079. * In case you are sharing the context with other applications, it might
  41080. * be interested to not cache the unpack flip y state to ensure a consistent
  41081. * value would be set.
  41082. */
  41083. enableUnpackFlipYCached: boolean;
  41084. /** @hidden */
  41085. _unpackFlipY(value: boolean): void;
  41086. /** @hidden */
  41087. _getUnpackAlignement(): number;
  41088. private _getTextureTarget;
  41089. /**
  41090. * Update the sampling mode of a given texture
  41091. * @param samplingMode defines the required sampling mode
  41092. * @param texture defines the texture to update
  41093. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41094. */
  41095. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41096. /**
  41097. * Update the sampling mode of a given texture
  41098. * @param texture defines the texture to update
  41099. * @param wrapU defines the texture wrap mode of the u coordinates
  41100. * @param wrapV defines the texture wrap mode of the v coordinates
  41101. * @param wrapR defines the texture wrap mode of the r coordinates
  41102. */
  41103. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41104. /** @hidden */
  41105. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41106. width: number;
  41107. height: number;
  41108. layers?: number;
  41109. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  41110. /** @hidden */
  41111. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41112. /** @hidden */
  41113. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41114. /**
  41115. * Update a portion of an internal texture
  41116. * @param texture defines the texture to update
  41117. * @param imageData defines the data to store into the texture
  41118. * @param xOffset defines the x coordinates of the update rectangle
  41119. * @param yOffset defines the y coordinates of the update rectangle
  41120. * @param width defines the width of the update rectangle
  41121. * @param height defines the height of the update rectangle
  41122. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41123. * @param lod defines the lod level to update (0 by default)
  41124. */
  41125. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41126. /** @hidden */
  41127. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41128. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41129. private _prepareWebGLTexture;
  41130. /** @hidden */
  41131. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41132. private _getDepthStencilBuffer;
  41133. /** @hidden */
  41134. _releaseFramebufferObjects(texture: InternalTexture): void;
  41135. /** @hidden */
  41136. _releaseTexture(texture: InternalTexture): void;
  41137. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41138. protected _setProgram(program: WebGLProgram): void;
  41139. protected _boundUniforms: {
  41140. [key: number]: WebGLUniformLocation;
  41141. };
  41142. /**
  41143. * Binds an effect to the webGL context
  41144. * @param effect defines the effect to bind
  41145. */
  41146. bindSamplers(effect: Effect): void;
  41147. private _activateCurrentTexture;
  41148. /** @hidden */
  41149. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41150. /** @hidden */
  41151. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  41152. /**
  41153. * Unbind all textures from the webGL context
  41154. */
  41155. unbindAllTextures(): void;
  41156. /**
  41157. * Sets a texture to the according uniform.
  41158. * @param channel The texture channel
  41159. * @param uniform The uniform to set
  41160. * @param texture The texture to apply
  41161. */
  41162. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  41163. private _bindSamplerUniformToChannel;
  41164. private _getTextureWrapMode;
  41165. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  41166. /**
  41167. * Sets an array of texture to the webGL context
  41168. * @param channel defines the channel where the texture array must be set
  41169. * @param uniform defines the associated uniform location
  41170. * @param textures defines the array of textures to bind
  41171. */
  41172. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  41173. /** @hidden */
  41174. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41175. private _setTextureParameterFloat;
  41176. private _setTextureParameterInteger;
  41177. /**
  41178. * Unbind all vertex attributes from the webGL context
  41179. */
  41180. unbindAllAttributes(): void;
  41181. /**
  41182. * 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
  41183. */
  41184. releaseEffects(): void;
  41185. /**
  41186. * Dispose and release all associated resources
  41187. */
  41188. dispose(): void;
  41189. /**
  41190. * Attach a new callback raised when context lost event is fired
  41191. * @param callback defines the callback to call
  41192. */
  41193. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41194. /**
  41195. * Attach a new callback raised when context restored event is fired
  41196. * @param callback defines the callback to call
  41197. */
  41198. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41199. /**
  41200. * Get the current error code of the webGL context
  41201. * @returns the error code
  41202. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41203. */
  41204. getError(): number;
  41205. private _canRenderToFloatFramebuffer;
  41206. private _canRenderToHalfFloatFramebuffer;
  41207. private _canRenderToFramebuffer;
  41208. /** @hidden */
  41209. _getWebGLTextureType(type: number): number;
  41210. /** @hidden */
  41211. _getInternalFormat(format: number): number;
  41212. /** @hidden */
  41213. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41214. /** @hidden */
  41215. _getRGBAMultiSampleBufferFormat(type: number): number;
  41216. /** @hidden */
  41217. _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;
  41218. /**
  41219. * Loads a file from a url
  41220. * @param url url to load
  41221. * @param onSuccess callback called when the file successfully loads
  41222. * @param onProgress callback called while file is loading (if the server supports this mode)
  41223. * @param offlineProvider defines the offline provider for caching
  41224. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41225. * @param onError callback called when the file fails to load
  41226. * @returns a file request object
  41227. * @hidden
  41228. */
  41229. 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;
  41230. /**
  41231. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41232. * @param x defines the x coordinate of the rectangle where pixels must be read
  41233. * @param y defines the y coordinate of the rectangle where pixels must be read
  41234. * @param width defines the width of the rectangle where pixels must be read
  41235. * @param height defines the height of the rectangle where pixels must be read
  41236. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41237. * @returns a Uint8Array containing RGBA colors
  41238. */
  41239. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  41240. private static _IsSupported;
  41241. private static _HasMajorPerformanceCaveat;
  41242. /**
  41243. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41244. */
  41245. static get IsSupported(): boolean;
  41246. /**
  41247. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41248. * @returns true if the engine can be created
  41249. * @ignorenaming
  41250. */
  41251. static isSupported(): boolean;
  41252. /**
  41253. * 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)
  41254. */
  41255. static get HasMajorPerformanceCaveat(): boolean;
  41256. /**
  41257. * Find the next highest power of two.
  41258. * @param x Number to start search from.
  41259. * @return Next highest power of two.
  41260. */
  41261. static CeilingPOT(x: number): number;
  41262. /**
  41263. * Find the next lowest power of two.
  41264. * @param x Number to start search from.
  41265. * @return Next lowest power of two.
  41266. */
  41267. static FloorPOT(x: number): number;
  41268. /**
  41269. * Find the nearest power of two.
  41270. * @param x Number to start search from.
  41271. * @return Next nearest power of two.
  41272. */
  41273. static NearestPOT(x: number): number;
  41274. /**
  41275. * Get the closest exponent of two
  41276. * @param value defines the value to approximate
  41277. * @param max defines the maximum value to return
  41278. * @param mode defines how to define the closest value
  41279. * @returns closest exponent of two of the given value
  41280. */
  41281. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41282. /**
  41283. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41284. * @param func - the function to be called
  41285. * @param requester - the object that will request the next frame. Falls back to window.
  41286. * @returns frame number
  41287. */
  41288. static QueueNewFrame(func: () => void, requester?: any): number;
  41289. /**
  41290. * Gets host document
  41291. * @returns the host document object
  41292. */
  41293. getHostDocument(): Nullable<Document>;
  41294. }
  41295. }
  41296. declare module "babylonjs/Materials/Textures/internalTexture" {
  41297. import { Observable } from "babylonjs/Misc/observable";
  41298. import { Nullable, int } from "babylonjs/types";
  41299. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41300. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41301. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  41302. /**
  41303. * Defines the source of the internal texture
  41304. */
  41305. export enum InternalTextureSource {
  41306. /**
  41307. * The source of the texture data is unknown
  41308. */
  41309. Unknown = 0,
  41310. /**
  41311. * Texture data comes from an URL
  41312. */
  41313. Url = 1,
  41314. /**
  41315. * Texture data is only used for temporary storage
  41316. */
  41317. Temp = 2,
  41318. /**
  41319. * Texture data comes from raw data (ArrayBuffer)
  41320. */
  41321. Raw = 3,
  41322. /**
  41323. * Texture content is dynamic (video or dynamic texture)
  41324. */
  41325. Dynamic = 4,
  41326. /**
  41327. * Texture content is generated by rendering to it
  41328. */
  41329. RenderTarget = 5,
  41330. /**
  41331. * Texture content is part of a multi render target process
  41332. */
  41333. MultiRenderTarget = 6,
  41334. /**
  41335. * Texture data comes from a cube data file
  41336. */
  41337. Cube = 7,
  41338. /**
  41339. * Texture data comes from a raw cube data
  41340. */
  41341. CubeRaw = 8,
  41342. /**
  41343. * Texture data come from a prefiltered cube data file
  41344. */
  41345. CubePrefiltered = 9,
  41346. /**
  41347. * Texture content is raw 3D data
  41348. */
  41349. Raw3D = 10,
  41350. /**
  41351. * Texture content is raw 2D array data
  41352. */
  41353. Raw2DArray = 11,
  41354. /**
  41355. * Texture content is a depth texture
  41356. */
  41357. Depth = 12,
  41358. /**
  41359. * Texture data comes from a raw cube data encoded with RGBD
  41360. */
  41361. CubeRawRGBD = 13
  41362. }
  41363. /**
  41364. * Class used to store data associated with WebGL texture data for the engine
  41365. * This class should not be used directly
  41366. */
  41367. export class InternalTexture {
  41368. /** @hidden */
  41369. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41370. /**
  41371. * Defines if the texture is ready
  41372. */
  41373. isReady: boolean;
  41374. /**
  41375. * Defines if the texture is a cube texture
  41376. */
  41377. isCube: boolean;
  41378. /**
  41379. * Defines if the texture contains 3D data
  41380. */
  41381. is3D: boolean;
  41382. /**
  41383. * Defines if the texture contains 2D array data
  41384. */
  41385. is2DArray: boolean;
  41386. /**
  41387. * Defines if the texture contains multiview data
  41388. */
  41389. isMultiview: boolean;
  41390. /**
  41391. * Gets the URL used to load this texture
  41392. */
  41393. url: string;
  41394. /**
  41395. * Gets the sampling mode of the texture
  41396. */
  41397. samplingMode: number;
  41398. /**
  41399. * Gets a boolean indicating if the texture needs mipmaps generation
  41400. */
  41401. generateMipMaps: boolean;
  41402. /**
  41403. * Gets the number of samples used by the texture (WebGL2+ only)
  41404. */
  41405. samples: number;
  41406. /**
  41407. * Gets the type of the texture (int, float...)
  41408. */
  41409. type: number;
  41410. /**
  41411. * Gets the format of the texture (RGB, RGBA...)
  41412. */
  41413. format: number;
  41414. /**
  41415. * Observable called when the texture is loaded
  41416. */
  41417. onLoadedObservable: Observable<InternalTexture>;
  41418. /**
  41419. * Gets the width of the texture
  41420. */
  41421. width: number;
  41422. /**
  41423. * Gets the height of the texture
  41424. */
  41425. height: number;
  41426. /**
  41427. * Gets the depth of the texture
  41428. */
  41429. depth: number;
  41430. /**
  41431. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41432. */
  41433. baseWidth: number;
  41434. /**
  41435. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41436. */
  41437. baseHeight: number;
  41438. /**
  41439. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41440. */
  41441. baseDepth: number;
  41442. /**
  41443. * Gets a boolean indicating if the texture is inverted on Y axis
  41444. */
  41445. invertY: boolean;
  41446. /** @hidden */
  41447. _invertVScale: boolean;
  41448. /** @hidden */
  41449. _associatedChannel: number;
  41450. /** @hidden */
  41451. _source: InternalTextureSource;
  41452. /** @hidden */
  41453. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41454. /** @hidden */
  41455. _bufferView: Nullable<ArrayBufferView>;
  41456. /** @hidden */
  41457. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41458. /** @hidden */
  41459. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41460. /** @hidden */
  41461. _size: number;
  41462. /** @hidden */
  41463. _extension: string;
  41464. /** @hidden */
  41465. _files: Nullable<string[]>;
  41466. /** @hidden */
  41467. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41468. /** @hidden */
  41469. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41470. /** @hidden */
  41471. _framebuffer: Nullable<WebGLFramebuffer>;
  41472. /** @hidden */
  41473. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41474. /** @hidden */
  41475. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41476. /** @hidden */
  41477. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41478. /** @hidden */
  41479. _attachments: Nullable<number[]>;
  41480. /** @hidden */
  41481. _textureArray: Nullable<InternalTexture[]>;
  41482. /** @hidden */
  41483. _cachedCoordinatesMode: Nullable<number>;
  41484. /** @hidden */
  41485. _cachedWrapU: Nullable<number>;
  41486. /** @hidden */
  41487. _cachedWrapV: Nullable<number>;
  41488. /** @hidden */
  41489. _cachedWrapR: Nullable<number>;
  41490. /** @hidden */
  41491. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41492. /** @hidden */
  41493. _isDisabled: boolean;
  41494. /** @hidden */
  41495. _compression: Nullable<string>;
  41496. /** @hidden */
  41497. _generateStencilBuffer: boolean;
  41498. /** @hidden */
  41499. _generateDepthBuffer: boolean;
  41500. /** @hidden */
  41501. _comparisonFunction: number;
  41502. /** @hidden */
  41503. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41504. /** @hidden */
  41505. _lodGenerationScale: number;
  41506. /** @hidden */
  41507. _lodGenerationOffset: number;
  41508. /** @hidden */
  41509. _depthStencilTexture: Nullable<InternalTexture>;
  41510. /** @hidden */
  41511. _colorTextureArray: Nullable<WebGLTexture>;
  41512. /** @hidden */
  41513. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41514. /** @hidden */
  41515. _lodTextureHigh: Nullable<BaseTexture>;
  41516. /** @hidden */
  41517. _lodTextureMid: Nullable<BaseTexture>;
  41518. /** @hidden */
  41519. _lodTextureLow: Nullable<BaseTexture>;
  41520. /** @hidden */
  41521. _isRGBD: boolean;
  41522. /** @hidden */
  41523. _linearSpecularLOD: boolean;
  41524. /** @hidden */
  41525. _irradianceTexture: Nullable<BaseTexture>;
  41526. /** @hidden */
  41527. _webGLTexture: Nullable<WebGLTexture>;
  41528. /** @hidden */
  41529. _references: number;
  41530. /** @hidden */
  41531. _gammaSpace: Nullable<boolean>;
  41532. private _engine;
  41533. /**
  41534. * Gets the Engine the texture belongs to.
  41535. * @returns The babylon engine
  41536. */
  41537. getEngine(): ThinEngine;
  41538. /**
  41539. * Gets the data source type of the texture
  41540. */
  41541. get source(): InternalTextureSource;
  41542. /**
  41543. * Creates a new InternalTexture
  41544. * @param engine defines the engine to use
  41545. * @param source defines the type of data that will be used
  41546. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41547. */
  41548. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41549. /**
  41550. * Increments the number of references (ie. the number of Texture that point to it)
  41551. */
  41552. incrementReferences(): void;
  41553. /**
  41554. * Change the size of the texture (not the size of the content)
  41555. * @param width defines the new width
  41556. * @param height defines the new height
  41557. * @param depth defines the new depth (1 by default)
  41558. */
  41559. updateSize(width: int, height: int, depth?: int): void;
  41560. /** @hidden */
  41561. _rebuild(): void;
  41562. /** @hidden */
  41563. _swapAndDie(target: InternalTexture): void;
  41564. /**
  41565. * Dispose the current allocated resources
  41566. */
  41567. dispose(): void;
  41568. }
  41569. }
  41570. declare module "babylonjs/Loading/loadingScreen" {
  41571. /**
  41572. * Interface used to present a loading screen while loading a scene
  41573. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41574. */
  41575. export interface ILoadingScreen {
  41576. /**
  41577. * Function called to display the loading screen
  41578. */
  41579. displayLoadingUI: () => void;
  41580. /**
  41581. * Function called to hide the loading screen
  41582. */
  41583. hideLoadingUI: () => void;
  41584. /**
  41585. * Gets or sets the color to use for the background
  41586. */
  41587. loadingUIBackgroundColor: string;
  41588. /**
  41589. * Gets or sets the text to display while loading
  41590. */
  41591. loadingUIText: string;
  41592. }
  41593. /**
  41594. * Class used for the default loading screen
  41595. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41596. */
  41597. export class DefaultLoadingScreen implements ILoadingScreen {
  41598. private _renderingCanvas;
  41599. private _loadingText;
  41600. private _loadingDivBackgroundColor;
  41601. private _loadingDiv;
  41602. private _loadingTextDiv;
  41603. /** Gets or sets the logo url to use for the default loading screen */
  41604. static DefaultLogoUrl: string;
  41605. /** Gets or sets the spinner url to use for the default loading screen */
  41606. static DefaultSpinnerUrl: string;
  41607. /**
  41608. * Creates a new default loading screen
  41609. * @param _renderingCanvas defines the canvas used to render the scene
  41610. * @param _loadingText defines the default text to display
  41611. * @param _loadingDivBackgroundColor defines the default background color
  41612. */
  41613. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41614. /**
  41615. * Function called to display the loading screen
  41616. */
  41617. displayLoadingUI(): void;
  41618. /**
  41619. * Function called to hide the loading screen
  41620. */
  41621. hideLoadingUI(): void;
  41622. /**
  41623. * Gets or sets the text to display while loading
  41624. */
  41625. set loadingUIText(text: string);
  41626. get loadingUIText(): string;
  41627. /**
  41628. * Gets or sets the color to use for the background
  41629. */
  41630. get loadingUIBackgroundColor(): string;
  41631. set loadingUIBackgroundColor(color: string);
  41632. private _resizeLoadingUI;
  41633. }
  41634. }
  41635. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41636. /**
  41637. * Interface for any object that can request an animation frame
  41638. */
  41639. export interface ICustomAnimationFrameRequester {
  41640. /**
  41641. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41642. */
  41643. renderFunction?: Function;
  41644. /**
  41645. * Called to request the next frame to render to
  41646. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41647. */
  41648. requestAnimationFrame: Function;
  41649. /**
  41650. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41651. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41652. */
  41653. requestID?: number;
  41654. }
  41655. }
  41656. declare module "babylonjs/Misc/performanceMonitor" {
  41657. /**
  41658. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41659. */
  41660. export class PerformanceMonitor {
  41661. private _enabled;
  41662. private _rollingFrameTime;
  41663. private _lastFrameTimeMs;
  41664. /**
  41665. * constructor
  41666. * @param frameSampleSize The number of samples required to saturate the sliding window
  41667. */
  41668. constructor(frameSampleSize?: number);
  41669. /**
  41670. * Samples current frame
  41671. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41672. */
  41673. sampleFrame(timeMs?: number): void;
  41674. /**
  41675. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41676. */
  41677. get averageFrameTime(): number;
  41678. /**
  41679. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41680. */
  41681. get averageFrameTimeVariance(): number;
  41682. /**
  41683. * Returns the frame time of the most recent frame
  41684. */
  41685. get instantaneousFrameTime(): number;
  41686. /**
  41687. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41688. */
  41689. get averageFPS(): number;
  41690. /**
  41691. * Returns the average framerate in frames per second using the most recent frame time
  41692. */
  41693. get instantaneousFPS(): number;
  41694. /**
  41695. * Returns true if enough samples have been taken to completely fill the sliding window
  41696. */
  41697. get isSaturated(): boolean;
  41698. /**
  41699. * Enables contributions to the sliding window sample set
  41700. */
  41701. enable(): void;
  41702. /**
  41703. * Disables contributions to the sliding window sample set
  41704. * Samples will not be interpolated over the disabled period
  41705. */
  41706. disable(): void;
  41707. /**
  41708. * Returns true if sampling is enabled
  41709. */
  41710. get isEnabled(): boolean;
  41711. /**
  41712. * Resets performance monitor
  41713. */
  41714. reset(): void;
  41715. }
  41716. /**
  41717. * RollingAverage
  41718. *
  41719. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41720. */
  41721. export class RollingAverage {
  41722. /**
  41723. * Current average
  41724. */
  41725. average: number;
  41726. /**
  41727. * Current variance
  41728. */
  41729. variance: number;
  41730. protected _samples: Array<number>;
  41731. protected _sampleCount: number;
  41732. protected _pos: number;
  41733. protected _m2: number;
  41734. /**
  41735. * constructor
  41736. * @param length The number of samples required to saturate the sliding window
  41737. */
  41738. constructor(length: number);
  41739. /**
  41740. * Adds a sample to the sample set
  41741. * @param v The sample value
  41742. */
  41743. add(v: number): void;
  41744. /**
  41745. * Returns previously added values or null if outside of history or outside the sliding window domain
  41746. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41747. * @return Value previously recorded with add() or null if outside of range
  41748. */
  41749. history(i: number): number;
  41750. /**
  41751. * Returns true if enough samples have been taken to completely fill the sliding window
  41752. * @return true if sample-set saturated
  41753. */
  41754. isSaturated(): boolean;
  41755. /**
  41756. * Resets the rolling average (equivalent to 0 samples taken so far)
  41757. */
  41758. reset(): void;
  41759. /**
  41760. * Wraps a value around the sample range boundaries
  41761. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41762. * @return Wrapped position in sample range
  41763. */
  41764. protected _wrapPosition(i: number): number;
  41765. }
  41766. }
  41767. declare module "babylonjs/Misc/perfCounter" {
  41768. /**
  41769. * This class is used to track a performance counter which is number based.
  41770. * The user has access to many properties which give statistics of different nature.
  41771. *
  41772. * The implementer can track two kinds of Performance Counter: time and count.
  41773. * 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.
  41774. * 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.
  41775. */
  41776. export class PerfCounter {
  41777. /**
  41778. * Gets or sets a global boolean to turn on and off all the counters
  41779. */
  41780. static Enabled: boolean;
  41781. /**
  41782. * Returns the smallest value ever
  41783. */
  41784. get min(): number;
  41785. /**
  41786. * Returns the biggest value ever
  41787. */
  41788. get max(): number;
  41789. /**
  41790. * Returns the average value since the performance counter is running
  41791. */
  41792. get average(): number;
  41793. /**
  41794. * Returns the average value of the last second the counter was monitored
  41795. */
  41796. get lastSecAverage(): number;
  41797. /**
  41798. * Returns the current value
  41799. */
  41800. get current(): number;
  41801. /**
  41802. * Gets the accumulated total
  41803. */
  41804. get total(): number;
  41805. /**
  41806. * Gets the total value count
  41807. */
  41808. get count(): number;
  41809. /**
  41810. * Creates a new counter
  41811. */
  41812. constructor();
  41813. /**
  41814. * Call this method to start monitoring a new frame.
  41815. * 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.
  41816. */
  41817. fetchNewFrame(): void;
  41818. /**
  41819. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41820. * @param newCount the count value to add to the monitored count
  41821. * @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.
  41822. */
  41823. addCount(newCount: number, fetchResult: boolean): void;
  41824. /**
  41825. * Start monitoring this performance counter
  41826. */
  41827. beginMonitoring(): void;
  41828. /**
  41829. * Compute the time lapsed since the previous beginMonitoring() call.
  41830. * @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
  41831. */
  41832. endMonitoring(newFrame?: boolean): void;
  41833. private _fetchResult;
  41834. private _startMonitoringTime;
  41835. private _min;
  41836. private _max;
  41837. private _average;
  41838. private _current;
  41839. private _totalValueCount;
  41840. private _totalAccumulated;
  41841. private _lastSecAverage;
  41842. private _lastSecAccumulated;
  41843. private _lastSecTime;
  41844. private _lastSecValueCount;
  41845. }
  41846. }
  41847. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  41848. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41849. import { Nullable } from "babylonjs/types";
  41850. module "babylonjs/Engines/thinEngine" {
  41851. interface ThinEngine {
  41852. /** @hidden */
  41853. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  41854. }
  41855. }
  41856. }
  41857. declare module "babylonjs/Audio/analyser" {
  41858. import { Scene } from "babylonjs/scene";
  41859. /**
  41860. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41861. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41862. */
  41863. export class Analyser {
  41864. /**
  41865. * Gets or sets the smoothing
  41866. * @ignorenaming
  41867. */
  41868. SMOOTHING: number;
  41869. /**
  41870. * Gets or sets the FFT table size
  41871. * @ignorenaming
  41872. */
  41873. FFT_SIZE: number;
  41874. /**
  41875. * Gets or sets the bar graph amplitude
  41876. * @ignorenaming
  41877. */
  41878. BARGRAPHAMPLITUDE: number;
  41879. /**
  41880. * Gets or sets the position of the debug canvas
  41881. * @ignorenaming
  41882. */
  41883. DEBUGCANVASPOS: {
  41884. x: number;
  41885. y: number;
  41886. };
  41887. /**
  41888. * Gets or sets the debug canvas size
  41889. * @ignorenaming
  41890. */
  41891. DEBUGCANVASSIZE: {
  41892. width: number;
  41893. height: number;
  41894. };
  41895. private _byteFreqs;
  41896. private _byteTime;
  41897. private _floatFreqs;
  41898. private _webAudioAnalyser;
  41899. private _debugCanvas;
  41900. private _debugCanvasContext;
  41901. private _scene;
  41902. private _registerFunc;
  41903. private _audioEngine;
  41904. /**
  41905. * Creates a new analyser
  41906. * @param scene defines hosting scene
  41907. */
  41908. constructor(scene: Scene);
  41909. /**
  41910. * Get the number of data values you will have to play with for the visualization
  41911. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41912. * @returns a number
  41913. */
  41914. getFrequencyBinCount(): number;
  41915. /**
  41916. * Gets the current frequency data as a byte array
  41917. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41918. * @returns a Uint8Array
  41919. */
  41920. getByteFrequencyData(): Uint8Array;
  41921. /**
  41922. * Gets the current waveform as a byte array
  41923. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41924. * @returns a Uint8Array
  41925. */
  41926. getByteTimeDomainData(): Uint8Array;
  41927. /**
  41928. * Gets the current frequency data as a float array
  41929. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41930. * @returns a Float32Array
  41931. */
  41932. getFloatFrequencyData(): Float32Array;
  41933. /**
  41934. * Renders the debug canvas
  41935. */
  41936. drawDebugCanvas(): void;
  41937. /**
  41938. * Stops rendering the debug canvas and removes it
  41939. */
  41940. stopDebugCanvas(): void;
  41941. /**
  41942. * Connects two audio nodes
  41943. * @param inputAudioNode defines first node to connect
  41944. * @param outputAudioNode defines second node to connect
  41945. */
  41946. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41947. /**
  41948. * Releases all associated resources
  41949. */
  41950. dispose(): void;
  41951. }
  41952. }
  41953. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  41954. import { Observable } from "babylonjs/Misc/observable";
  41955. import { IDisposable } from "babylonjs/scene";
  41956. import { Nullable } from "babylonjs/types";
  41957. import { Analyser } from "babylonjs/Audio/analyser";
  41958. /**
  41959. * This represents an audio engine and it is responsible
  41960. * to play, synchronize and analyse sounds throughout the application.
  41961. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41962. */
  41963. export interface IAudioEngine extends IDisposable {
  41964. /**
  41965. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41966. */
  41967. readonly canUseWebAudio: boolean;
  41968. /**
  41969. * Gets the current AudioContext if available.
  41970. */
  41971. readonly audioContext: Nullable<AudioContext>;
  41972. /**
  41973. * The master gain node defines the global audio volume of your audio engine.
  41974. */
  41975. readonly masterGain: GainNode;
  41976. /**
  41977. * Gets whether or not mp3 are supported by your browser.
  41978. */
  41979. readonly isMP3supported: boolean;
  41980. /**
  41981. * Gets whether or not ogg are supported by your browser.
  41982. */
  41983. readonly isOGGsupported: boolean;
  41984. /**
  41985. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41986. * @ignoreNaming
  41987. */
  41988. WarnedWebAudioUnsupported: boolean;
  41989. /**
  41990. * Defines if the audio engine relies on a custom unlocked button.
  41991. * In this case, the embedded button will not be displayed.
  41992. */
  41993. useCustomUnlockedButton: boolean;
  41994. /**
  41995. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41996. */
  41997. readonly unlocked: boolean;
  41998. /**
  41999. * Event raised when audio has been unlocked on the browser.
  42000. */
  42001. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42002. /**
  42003. * Event raised when audio has been locked on the browser.
  42004. */
  42005. onAudioLockedObservable: Observable<IAudioEngine>;
  42006. /**
  42007. * Flags the audio engine in Locked state.
  42008. * This happens due to new browser policies preventing audio to autoplay.
  42009. */
  42010. lock(): void;
  42011. /**
  42012. * Unlocks the audio engine once a user action has been done on the dom.
  42013. * This is helpful to resume play once browser policies have been satisfied.
  42014. */
  42015. unlock(): void;
  42016. /**
  42017. * Gets the global volume sets on the master gain.
  42018. * @returns the global volume if set or -1 otherwise
  42019. */
  42020. getGlobalVolume(): number;
  42021. /**
  42022. * Sets the global volume of your experience (sets on the master gain).
  42023. * @param newVolume Defines the new global volume of the application
  42024. */
  42025. setGlobalVolume(newVolume: number): void;
  42026. /**
  42027. * Connect the audio engine to an audio analyser allowing some amazing
  42028. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42029. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42030. * @param analyser The analyser to connect to the engine
  42031. */
  42032. connectToAnalyser(analyser: Analyser): void;
  42033. }
  42034. }
  42035. declare module "babylonjs/Engines/engine" {
  42036. import { Observable } from "babylonjs/Misc/observable";
  42037. import { Nullable } from "babylonjs/types";
  42038. import { Scene } from "babylonjs/scene";
  42039. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42040. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42041. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  42042. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  42043. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42044. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  42045. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  42046. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  42047. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42048. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  42049. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42050. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  42051. import "babylonjs/Engines/Extensions/engine.alpha";
  42052. import "babylonjs/Engines/Extensions/engine.readTexture";
  42053. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  42054. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  42055. import { Material } from "babylonjs/Materials/material";
  42056. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42057. /**
  42058. * Defines the interface used by display changed events
  42059. */
  42060. export interface IDisplayChangedEventArgs {
  42061. /** Gets the vrDisplay object (if any) */
  42062. vrDisplay: Nullable<any>;
  42063. /** Gets a boolean indicating if webVR is supported */
  42064. vrSupported: boolean;
  42065. }
  42066. /**
  42067. * Defines the interface used by objects containing a viewport (like a camera)
  42068. */
  42069. interface IViewportOwnerLike {
  42070. /**
  42071. * Gets or sets the viewport
  42072. */
  42073. viewport: IViewportLike;
  42074. }
  42075. /**
  42076. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42077. */
  42078. export class Engine extends ThinEngine {
  42079. /** Defines that alpha blending is disabled */
  42080. static readonly ALPHA_DISABLE: number;
  42081. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42082. static readonly ALPHA_ADD: number;
  42083. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42084. static readonly ALPHA_COMBINE: number;
  42085. /** Defines that alpha blending to DEST - SRC * DEST */
  42086. static readonly ALPHA_SUBTRACT: number;
  42087. /** Defines that alpha blending to SRC * DEST */
  42088. static readonly ALPHA_MULTIPLY: number;
  42089. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42090. static readonly ALPHA_MAXIMIZED: number;
  42091. /** Defines that alpha blending to SRC + DEST */
  42092. static readonly ALPHA_ONEONE: number;
  42093. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42094. static readonly ALPHA_PREMULTIPLIED: number;
  42095. /**
  42096. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42097. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42098. */
  42099. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42100. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42101. static readonly ALPHA_INTERPOLATE: number;
  42102. /**
  42103. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42104. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42105. */
  42106. static readonly ALPHA_SCREENMODE: number;
  42107. /** Defines that the ressource is not delayed*/
  42108. static readonly DELAYLOADSTATE_NONE: number;
  42109. /** Defines that the ressource was successfully delay loaded */
  42110. static readonly DELAYLOADSTATE_LOADED: number;
  42111. /** Defines that the ressource is currently delay loading */
  42112. static readonly DELAYLOADSTATE_LOADING: number;
  42113. /** Defines that the ressource is delayed and has not started loading */
  42114. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42115. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42116. static readonly NEVER: number;
  42117. /** 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 */
  42118. static readonly ALWAYS: number;
  42119. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42120. static readonly LESS: number;
  42121. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42122. static readonly EQUAL: number;
  42123. /** 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 */
  42124. static readonly LEQUAL: number;
  42125. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42126. static readonly GREATER: number;
  42127. /** 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 */
  42128. static readonly GEQUAL: number;
  42129. /** 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 */
  42130. static readonly NOTEQUAL: number;
  42131. /** Passed to stencilOperation to specify that stencil value must be kept */
  42132. static readonly KEEP: number;
  42133. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42134. static readonly REPLACE: number;
  42135. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42136. static readonly INCR: number;
  42137. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42138. static readonly DECR: number;
  42139. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42140. static readonly INVERT: number;
  42141. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42142. static readonly INCR_WRAP: number;
  42143. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42144. static readonly DECR_WRAP: number;
  42145. /** Texture is not repeating outside of 0..1 UVs */
  42146. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42147. /** Texture is repeating outside of 0..1 UVs */
  42148. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42149. /** Texture is repeating and mirrored */
  42150. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42151. /** ALPHA */
  42152. static readonly TEXTUREFORMAT_ALPHA: number;
  42153. /** LUMINANCE */
  42154. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42155. /** LUMINANCE_ALPHA */
  42156. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42157. /** RGB */
  42158. static readonly TEXTUREFORMAT_RGB: number;
  42159. /** RGBA */
  42160. static readonly TEXTUREFORMAT_RGBA: number;
  42161. /** RED */
  42162. static readonly TEXTUREFORMAT_RED: number;
  42163. /** RED (2nd reference) */
  42164. static readonly TEXTUREFORMAT_R: number;
  42165. /** RG */
  42166. static readonly TEXTUREFORMAT_RG: number;
  42167. /** RED_INTEGER */
  42168. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42169. /** RED_INTEGER (2nd reference) */
  42170. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42171. /** RG_INTEGER */
  42172. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42173. /** RGB_INTEGER */
  42174. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42175. /** RGBA_INTEGER */
  42176. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42177. /** UNSIGNED_BYTE */
  42178. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42179. /** UNSIGNED_BYTE (2nd reference) */
  42180. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42181. /** FLOAT */
  42182. static readonly TEXTURETYPE_FLOAT: number;
  42183. /** HALF_FLOAT */
  42184. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42185. /** BYTE */
  42186. static readonly TEXTURETYPE_BYTE: number;
  42187. /** SHORT */
  42188. static readonly TEXTURETYPE_SHORT: number;
  42189. /** UNSIGNED_SHORT */
  42190. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42191. /** INT */
  42192. static readonly TEXTURETYPE_INT: number;
  42193. /** UNSIGNED_INT */
  42194. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42195. /** UNSIGNED_SHORT_4_4_4_4 */
  42196. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42197. /** UNSIGNED_SHORT_5_5_5_1 */
  42198. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42199. /** UNSIGNED_SHORT_5_6_5 */
  42200. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42201. /** UNSIGNED_INT_2_10_10_10_REV */
  42202. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42203. /** UNSIGNED_INT_24_8 */
  42204. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42205. /** UNSIGNED_INT_10F_11F_11F_REV */
  42206. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42207. /** UNSIGNED_INT_5_9_9_9_REV */
  42208. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42209. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42210. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42211. /** nearest is mag = nearest and min = nearest and mip = linear */
  42212. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42213. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42214. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42215. /** Trilinear is mag = linear and min = linear and mip = linear */
  42216. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42217. /** nearest is mag = nearest and min = nearest and mip = linear */
  42218. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42219. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42220. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42221. /** Trilinear is mag = linear and min = linear and mip = linear */
  42222. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42223. /** mag = nearest and min = nearest and mip = nearest */
  42224. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42225. /** mag = nearest and min = linear and mip = nearest */
  42226. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42227. /** mag = nearest and min = linear and mip = linear */
  42228. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42229. /** mag = nearest and min = linear and mip = none */
  42230. static readonly TEXTURE_NEAREST_LINEAR: number;
  42231. /** mag = nearest and min = nearest and mip = none */
  42232. static readonly TEXTURE_NEAREST_NEAREST: number;
  42233. /** mag = linear and min = nearest and mip = nearest */
  42234. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42235. /** mag = linear and min = nearest and mip = linear */
  42236. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42237. /** mag = linear and min = linear and mip = none */
  42238. static readonly TEXTURE_LINEAR_LINEAR: number;
  42239. /** mag = linear and min = nearest and mip = none */
  42240. static readonly TEXTURE_LINEAR_NEAREST: number;
  42241. /** Explicit coordinates mode */
  42242. static readonly TEXTURE_EXPLICIT_MODE: number;
  42243. /** Spherical coordinates mode */
  42244. static readonly TEXTURE_SPHERICAL_MODE: number;
  42245. /** Planar coordinates mode */
  42246. static readonly TEXTURE_PLANAR_MODE: number;
  42247. /** Cubic coordinates mode */
  42248. static readonly TEXTURE_CUBIC_MODE: number;
  42249. /** Projection coordinates mode */
  42250. static readonly TEXTURE_PROJECTION_MODE: number;
  42251. /** Skybox coordinates mode */
  42252. static readonly TEXTURE_SKYBOX_MODE: number;
  42253. /** Inverse Cubic coordinates mode */
  42254. static readonly TEXTURE_INVCUBIC_MODE: number;
  42255. /** Equirectangular coordinates mode */
  42256. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42257. /** Equirectangular Fixed coordinates mode */
  42258. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42259. /** Equirectangular Fixed Mirrored coordinates mode */
  42260. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42261. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42262. static readonly SCALEMODE_FLOOR: number;
  42263. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42264. static readonly SCALEMODE_NEAREST: number;
  42265. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42266. static readonly SCALEMODE_CEILING: number;
  42267. /**
  42268. * Returns the current npm package of the sdk
  42269. */
  42270. static get NpmPackage(): string;
  42271. /**
  42272. * Returns the current version of the framework
  42273. */
  42274. static get Version(): string;
  42275. /** Gets the list of created engines */
  42276. static get Instances(): Engine[];
  42277. /**
  42278. * Gets the latest created engine
  42279. */
  42280. static get LastCreatedEngine(): Nullable<Engine>;
  42281. /**
  42282. * Gets the latest created scene
  42283. */
  42284. static get LastCreatedScene(): Nullable<Scene>;
  42285. /**
  42286. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42287. * @param flag defines which part of the materials must be marked as dirty
  42288. * @param predicate defines a predicate used to filter which materials should be affected
  42289. */
  42290. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42291. /**
  42292. * Method called to create the default loading screen.
  42293. * This can be overriden in your own app.
  42294. * @param canvas The rendering canvas element
  42295. * @returns The loading screen
  42296. */
  42297. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42298. /**
  42299. * Method called to create the default rescale post process on each engine.
  42300. */
  42301. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42302. /**
  42303. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42304. **/
  42305. enableOfflineSupport: boolean;
  42306. /**
  42307. * 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)
  42308. **/
  42309. disableManifestCheck: boolean;
  42310. /**
  42311. * Gets the list of created scenes
  42312. */
  42313. scenes: Scene[];
  42314. /**
  42315. * Event raised when a new scene is created
  42316. */
  42317. onNewSceneAddedObservable: Observable<Scene>;
  42318. /**
  42319. * Gets the list of created postprocesses
  42320. */
  42321. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42322. /**
  42323. * Gets a boolean indicating if the pointer is currently locked
  42324. */
  42325. isPointerLock: boolean;
  42326. /**
  42327. * Observable event triggered each time the rendering canvas is resized
  42328. */
  42329. onResizeObservable: Observable<Engine>;
  42330. /**
  42331. * Observable event triggered each time the canvas loses focus
  42332. */
  42333. onCanvasBlurObservable: Observable<Engine>;
  42334. /**
  42335. * Observable event triggered each time the canvas gains focus
  42336. */
  42337. onCanvasFocusObservable: Observable<Engine>;
  42338. /**
  42339. * Observable event triggered each time the canvas receives pointerout event
  42340. */
  42341. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42342. /**
  42343. * Observable raised when the engine begins a new frame
  42344. */
  42345. onBeginFrameObservable: Observable<Engine>;
  42346. /**
  42347. * If set, will be used to request the next animation frame for the render loop
  42348. */
  42349. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42350. /**
  42351. * Observable raised when the engine ends the current frame
  42352. */
  42353. onEndFrameObservable: Observable<Engine>;
  42354. /**
  42355. * Observable raised when the engine is about to compile a shader
  42356. */
  42357. onBeforeShaderCompilationObservable: Observable<Engine>;
  42358. /**
  42359. * Observable raised when the engine has jsut compiled a shader
  42360. */
  42361. onAfterShaderCompilationObservable: Observable<Engine>;
  42362. /**
  42363. * Gets the audio engine
  42364. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42365. * @ignorenaming
  42366. */
  42367. static audioEngine: IAudioEngine;
  42368. /**
  42369. * Default AudioEngine factory responsible of creating the Audio Engine.
  42370. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42371. */
  42372. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42373. /**
  42374. * Default offline support factory responsible of creating a tool used to store data locally.
  42375. * By default, this will create a Database object if the workload has been embedded.
  42376. */
  42377. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42378. private _loadingScreen;
  42379. private _pointerLockRequested;
  42380. private _rescalePostProcess;
  42381. private _deterministicLockstep;
  42382. private _lockstepMaxSteps;
  42383. private _timeStep;
  42384. protected get _supportsHardwareTextureRescaling(): boolean;
  42385. private _fps;
  42386. private _deltaTime;
  42387. /** @hidden */
  42388. _drawCalls: PerfCounter;
  42389. /** 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 */
  42390. canvasTabIndex: number;
  42391. /**
  42392. * Turn this value on if you want to pause FPS computation when in background
  42393. */
  42394. disablePerformanceMonitorInBackground: boolean;
  42395. private _performanceMonitor;
  42396. /**
  42397. * Gets the performance monitor attached to this engine
  42398. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42399. */
  42400. get performanceMonitor(): PerformanceMonitor;
  42401. private _onFocus;
  42402. private _onBlur;
  42403. private _onCanvasPointerOut;
  42404. private _onCanvasBlur;
  42405. private _onCanvasFocus;
  42406. private _onFullscreenChange;
  42407. private _onPointerLockChange;
  42408. /**
  42409. * Gets the HTML element used to attach event listeners
  42410. * @returns a HTML element
  42411. */
  42412. getInputElement(): Nullable<HTMLElement>;
  42413. /**
  42414. * Creates a new engine
  42415. * @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
  42416. * @param antialias defines enable antialiasing (default: false)
  42417. * @param options defines further options to be sent to the getContext() function
  42418. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42419. */
  42420. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42421. /**
  42422. * Gets current aspect ratio
  42423. * @param viewportOwner defines the camera to use to get the aspect ratio
  42424. * @param useScreen defines if screen size must be used (or the current render target if any)
  42425. * @returns a number defining the aspect ratio
  42426. */
  42427. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42428. /**
  42429. * Gets current screen aspect ratio
  42430. * @returns a number defining the aspect ratio
  42431. */
  42432. getScreenAspectRatio(): number;
  42433. /**
  42434. * Gets the client rect of the HTML canvas attached with the current webGL context
  42435. * @returns a client rectanglee
  42436. */
  42437. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42438. /**
  42439. * Gets the client rect of the HTML element used for events
  42440. * @returns a client rectanglee
  42441. */
  42442. getInputElementClientRect(): Nullable<ClientRect>;
  42443. /**
  42444. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42445. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42446. * @returns true if engine is in deterministic lock step mode
  42447. */
  42448. isDeterministicLockStep(): boolean;
  42449. /**
  42450. * Gets the max steps when engine is running in deterministic lock step
  42451. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42452. * @returns the max steps
  42453. */
  42454. getLockstepMaxSteps(): number;
  42455. /**
  42456. * Returns the time in ms between steps when using deterministic lock step.
  42457. * @returns time step in (ms)
  42458. */
  42459. getTimeStep(): number;
  42460. /**
  42461. * Force the mipmap generation for the given render target texture
  42462. * @param texture defines the render target texture to use
  42463. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42464. */
  42465. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42466. /** States */
  42467. /**
  42468. * Set various states to the webGL context
  42469. * @param culling defines backface culling state
  42470. * @param zOffset defines the value to apply to zOffset (0 by default)
  42471. * @param force defines if states must be applied even if cache is up to date
  42472. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42473. */
  42474. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42475. /**
  42476. * Set the z offset to apply to current rendering
  42477. * @param value defines the offset to apply
  42478. */
  42479. setZOffset(value: number): void;
  42480. /**
  42481. * Gets the current value of the zOffset
  42482. * @returns the current zOffset state
  42483. */
  42484. getZOffset(): number;
  42485. /**
  42486. * Enable or disable depth buffering
  42487. * @param enable defines the state to set
  42488. */
  42489. setDepthBuffer(enable: boolean): void;
  42490. /**
  42491. * Gets a boolean indicating if depth writing is enabled
  42492. * @returns the current depth writing state
  42493. */
  42494. getDepthWrite(): boolean;
  42495. /**
  42496. * Enable or disable depth writing
  42497. * @param enable defines the state to set
  42498. */
  42499. setDepthWrite(enable: boolean): void;
  42500. /**
  42501. * Gets a boolean indicating if stencil buffer is enabled
  42502. * @returns the current stencil buffer state
  42503. */
  42504. getStencilBuffer(): boolean;
  42505. /**
  42506. * Enable or disable the stencil buffer
  42507. * @param enable defines if the stencil buffer must be enabled or disabled
  42508. */
  42509. setStencilBuffer(enable: boolean): void;
  42510. /**
  42511. * Gets the current stencil mask
  42512. * @returns a number defining the new stencil mask to use
  42513. */
  42514. getStencilMask(): number;
  42515. /**
  42516. * Sets the current stencil mask
  42517. * @param mask defines the new stencil mask to use
  42518. */
  42519. setStencilMask(mask: number): void;
  42520. /**
  42521. * Gets the current stencil function
  42522. * @returns a number defining the stencil function to use
  42523. */
  42524. getStencilFunction(): number;
  42525. /**
  42526. * Gets the current stencil reference value
  42527. * @returns a number defining the stencil reference value to use
  42528. */
  42529. getStencilFunctionReference(): number;
  42530. /**
  42531. * Gets the current stencil mask
  42532. * @returns a number defining the stencil mask to use
  42533. */
  42534. getStencilFunctionMask(): number;
  42535. /**
  42536. * Sets the current stencil function
  42537. * @param stencilFunc defines the new stencil function to use
  42538. */
  42539. setStencilFunction(stencilFunc: number): void;
  42540. /**
  42541. * Sets the current stencil reference
  42542. * @param reference defines the new stencil reference to use
  42543. */
  42544. setStencilFunctionReference(reference: number): void;
  42545. /**
  42546. * Sets the current stencil mask
  42547. * @param mask defines the new stencil mask to use
  42548. */
  42549. setStencilFunctionMask(mask: number): void;
  42550. /**
  42551. * Gets the current stencil operation when stencil fails
  42552. * @returns a number defining stencil operation to use when stencil fails
  42553. */
  42554. getStencilOperationFail(): number;
  42555. /**
  42556. * Gets the current stencil operation when depth fails
  42557. * @returns a number defining stencil operation to use when depth fails
  42558. */
  42559. getStencilOperationDepthFail(): number;
  42560. /**
  42561. * Gets the current stencil operation when stencil passes
  42562. * @returns a number defining stencil operation to use when stencil passes
  42563. */
  42564. getStencilOperationPass(): number;
  42565. /**
  42566. * Sets the stencil operation to use when stencil fails
  42567. * @param operation defines the stencil operation to use when stencil fails
  42568. */
  42569. setStencilOperationFail(operation: number): void;
  42570. /**
  42571. * Sets the stencil operation to use when depth fails
  42572. * @param operation defines the stencil operation to use when depth fails
  42573. */
  42574. setStencilOperationDepthFail(operation: number): void;
  42575. /**
  42576. * Sets the stencil operation to use when stencil passes
  42577. * @param operation defines the stencil operation to use when stencil passes
  42578. */
  42579. setStencilOperationPass(operation: number): void;
  42580. /**
  42581. * Sets a boolean indicating if the dithering state is enabled or disabled
  42582. * @param value defines the dithering state
  42583. */
  42584. setDitheringState(value: boolean): void;
  42585. /**
  42586. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42587. * @param value defines the rasterizer state
  42588. */
  42589. setRasterizerState(value: boolean): void;
  42590. /**
  42591. * Gets the current depth function
  42592. * @returns a number defining the depth function
  42593. */
  42594. getDepthFunction(): Nullable<number>;
  42595. /**
  42596. * Sets the current depth function
  42597. * @param depthFunc defines the function to use
  42598. */
  42599. setDepthFunction(depthFunc: number): void;
  42600. /**
  42601. * Sets the current depth function to GREATER
  42602. */
  42603. setDepthFunctionToGreater(): void;
  42604. /**
  42605. * Sets the current depth function to GEQUAL
  42606. */
  42607. setDepthFunctionToGreaterOrEqual(): void;
  42608. /**
  42609. * Sets the current depth function to LESS
  42610. */
  42611. setDepthFunctionToLess(): void;
  42612. /**
  42613. * Sets the current depth function to LEQUAL
  42614. */
  42615. setDepthFunctionToLessOrEqual(): void;
  42616. private _cachedStencilBuffer;
  42617. private _cachedStencilFunction;
  42618. private _cachedStencilMask;
  42619. private _cachedStencilOperationPass;
  42620. private _cachedStencilOperationFail;
  42621. private _cachedStencilOperationDepthFail;
  42622. private _cachedStencilReference;
  42623. /**
  42624. * Caches the the state of the stencil buffer
  42625. */
  42626. cacheStencilState(): void;
  42627. /**
  42628. * Restores the state of the stencil buffer
  42629. */
  42630. restoreStencilState(): void;
  42631. /**
  42632. * Directly set the WebGL Viewport
  42633. * @param x defines the x coordinate of the viewport (in screen space)
  42634. * @param y defines the y coordinate of the viewport (in screen space)
  42635. * @param width defines the width of the viewport (in screen space)
  42636. * @param height defines the height of the viewport (in screen space)
  42637. * @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
  42638. */
  42639. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42640. /**
  42641. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42642. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42643. * @param y defines the y-coordinate of the corner of the clear rectangle
  42644. * @param width defines the width of the clear rectangle
  42645. * @param height defines the height of the clear rectangle
  42646. * @param clearColor defines the clear color
  42647. */
  42648. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42649. /**
  42650. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42651. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42652. * @param y defines the y-coordinate of the corner of the clear rectangle
  42653. * @param width defines the width of the clear rectangle
  42654. * @param height defines the height of the clear rectangle
  42655. */
  42656. enableScissor(x: number, y: number, width: number, height: number): void;
  42657. /**
  42658. * Disable previously set scissor test rectangle
  42659. */
  42660. disableScissor(): void;
  42661. protected _reportDrawCall(): void;
  42662. /**
  42663. * Initializes a webVR display and starts listening to display change events
  42664. * The onVRDisplayChangedObservable will be notified upon these changes
  42665. * @returns The onVRDisplayChangedObservable
  42666. */
  42667. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42668. /** @hidden */
  42669. _prepareVRComponent(): void;
  42670. /** @hidden */
  42671. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42672. /** @hidden */
  42673. _submitVRFrame(): void;
  42674. /**
  42675. * Call this function to leave webVR mode
  42676. * Will do nothing if webVR is not supported or if there is no webVR device
  42677. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42678. */
  42679. disableVR(): void;
  42680. /**
  42681. * Gets a boolean indicating that the system is in VR mode and is presenting
  42682. * @returns true if VR mode is engaged
  42683. */
  42684. isVRPresenting(): boolean;
  42685. /** @hidden */
  42686. _requestVRFrame(): void;
  42687. /** @hidden */
  42688. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42689. /**
  42690. * Gets the source code of the vertex shader associated with a specific webGL program
  42691. * @param program defines the program to use
  42692. * @returns a string containing the source code of the vertex shader associated with the program
  42693. */
  42694. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42695. /**
  42696. * Gets the source code of the fragment shader associated with a specific webGL program
  42697. * @param program defines the program to use
  42698. * @returns a string containing the source code of the fragment shader associated with the program
  42699. */
  42700. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42701. /**
  42702. * Sets a depth stencil texture from a render target to the according uniform.
  42703. * @param channel The texture channel
  42704. * @param uniform The uniform to set
  42705. * @param texture The render target texture containing the depth stencil texture to apply
  42706. */
  42707. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42708. /**
  42709. * Sets a texture to the webGL context from a postprocess
  42710. * @param channel defines the channel to use
  42711. * @param postProcess defines the source postprocess
  42712. */
  42713. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42714. /**
  42715. * Binds the output of the passed in post process to the texture channel specified
  42716. * @param channel The channel the texture should be bound to
  42717. * @param postProcess The post process which's output should be bound
  42718. */
  42719. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42720. protected _rebuildBuffers(): void;
  42721. /** @hidden */
  42722. _renderFrame(): void;
  42723. _renderLoop(): void;
  42724. /** @hidden */
  42725. _renderViews(): boolean;
  42726. /**
  42727. * Toggle full screen mode
  42728. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42729. */
  42730. switchFullscreen(requestPointerLock: boolean): void;
  42731. /**
  42732. * Enters full screen mode
  42733. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42734. */
  42735. enterFullscreen(requestPointerLock: boolean): void;
  42736. /**
  42737. * Exits full screen mode
  42738. */
  42739. exitFullscreen(): void;
  42740. /**
  42741. * Enters Pointerlock mode
  42742. */
  42743. enterPointerlock(): void;
  42744. /**
  42745. * Exits Pointerlock mode
  42746. */
  42747. exitPointerlock(): void;
  42748. /**
  42749. * Begin a new frame
  42750. */
  42751. beginFrame(): void;
  42752. /**
  42753. * Enf the current frame
  42754. */
  42755. endFrame(): void;
  42756. resize(): void;
  42757. /**
  42758. * Force a specific size of the canvas
  42759. * @param width defines the new canvas' width
  42760. * @param height defines the new canvas' height
  42761. * @returns true if the size was changed
  42762. */
  42763. setSize(width: number, height: number): boolean;
  42764. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42765. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42766. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42767. _releaseTexture(texture: InternalTexture): void;
  42768. /**
  42769. * @hidden
  42770. * Rescales a texture
  42771. * @param source input texutre
  42772. * @param destination destination texture
  42773. * @param scene scene to use to render the resize
  42774. * @param internalFormat format to use when resizing
  42775. * @param onComplete callback to be called when resize has completed
  42776. */
  42777. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42778. /**
  42779. * Gets the current framerate
  42780. * @returns a number representing the framerate
  42781. */
  42782. getFps(): number;
  42783. /**
  42784. * Gets the time spent between current and previous frame
  42785. * @returns a number representing the delta time in ms
  42786. */
  42787. getDeltaTime(): number;
  42788. private _measureFps;
  42789. /** @hidden */
  42790. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42791. /**
  42792. * Updates the sample count of a render target texture
  42793. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42794. * @param texture defines the texture to update
  42795. * @param samples defines the sample count to set
  42796. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42797. */
  42798. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42799. /**
  42800. * Updates a depth texture Comparison Mode and Function.
  42801. * If the comparison Function is equal to 0, the mode will be set to none.
  42802. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42803. * @param texture The texture to set the comparison function for
  42804. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42805. */
  42806. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42807. /**
  42808. * Creates a webGL buffer to use with instanciation
  42809. * @param capacity defines the size of the buffer
  42810. * @returns the webGL buffer
  42811. */
  42812. createInstancesBuffer(capacity: number): DataBuffer;
  42813. /**
  42814. * Delete a webGL buffer used with instanciation
  42815. * @param buffer defines the webGL buffer to delete
  42816. */
  42817. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42818. private _clientWaitAsync;
  42819. /** @hidden */
  42820. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  42821. dispose(): void;
  42822. private _disableTouchAction;
  42823. /**
  42824. * Display the loading screen
  42825. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42826. */
  42827. displayLoadingUI(): void;
  42828. /**
  42829. * Hide the loading screen
  42830. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42831. */
  42832. hideLoadingUI(): void;
  42833. /**
  42834. * Gets the current loading screen object
  42835. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42836. */
  42837. get loadingScreen(): ILoadingScreen;
  42838. /**
  42839. * Sets the current loading screen object
  42840. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42841. */
  42842. set loadingScreen(loadingScreen: ILoadingScreen);
  42843. /**
  42844. * Sets the current loading screen text
  42845. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42846. */
  42847. set loadingUIText(text: string);
  42848. /**
  42849. * Sets the current loading screen background color
  42850. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42851. */
  42852. set loadingUIBackgroundColor(color: string);
  42853. /** Pointerlock and fullscreen */
  42854. /**
  42855. * Ask the browser to promote the current element to pointerlock mode
  42856. * @param element defines the DOM element to promote
  42857. */
  42858. static _RequestPointerlock(element: HTMLElement): void;
  42859. /**
  42860. * Asks the browser to exit pointerlock mode
  42861. */
  42862. static _ExitPointerlock(): void;
  42863. /**
  42864. * Ask the browser to promote the current element to fullscreen rendering mode
  42865. * @param element defines the DOM element to promote
  42866. */
  42867. static _RequestFullscreen(element: HTMLElement): void;
  42868. /**
  42869. * Asks the browser to exit fullscreen mode
  42870. */
  42871. static _ExitFullscreen(): void;
  42872. }
  42873. }
  42874. declare module "babylonjs/Engines/engineStore" {
  42875. import { Nullable } from "babylonjs/types";
  42876. import { Engine } from "babylonjs/Engines/engine";
  42877. import { Scene } from "babylonjs/scene";
  42878. /**
  42879. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42880. * during the life time of the application.
  42881. */
  42882. export class EngineStore {
  42883. /** Gets the list of created engines */
  42884. static Instances: import("babylonjs/Engines/engine").Engine[];
  42885. /** @hidden */
  42886. static _LastCreatedScene: Nullable<Scene>;
  42887. /**
  42888. * Gets the latest created engine
  42889. */
  42890. static get LastCreatedEngine(): Nullable<Engine>;
  42891. /**
  42892. * Gets the latest created scene
  42893. */
  42894. static get LastCreatedScene(): Nullable<Scene>;
  42895. /**
  42896. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42897. * @ignorenaming
  42898. */
  42899. static UseFallbackTexture: boolean;
  42900. /**
  42901. * Texture content used if a texture cannot loaded
  42902. * @ignorenaming
  42903. */
  42904. static FallbackTexture: string;
  42905. }
  42906. }
  42907. declare module "babylonjs/Misc/promise" {
  42908. /**
  42909. * Helper class that provides a small promise polyfill
  42910. */
  42911. export class PromisePolyfill {
  42912. /**
  42913. * Static function used to check if the polyfill is required
  42914. * If this is the case then the function will inject the polyfill to window.Promise
  42915. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42916. */
  42917. static Apply(force?: boolean): void;
  42918. }
  42919. }
  42920. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  42921. /**
  42922. * Interface for screenshot methods with describe argument called `size` as object with options
  42923. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42924. */
  42925. export interface IScreenshotSize {
  42926. /**
  42927. * number in pixels for canvas height
  42928. */
  42929. height?: number;
  42930. /**
  42931. * multiplier allowing render at a higher or lower resolution
  42932. * If value is defined then height and width will be ignored and taken from camera
  42933. */
  42934. precision?: number;
  42935. /**
  42936. * number in pixels for canvas width
  42937. */
  42938. width?: number;
  42939. }
  42940. }
  42941. declare module "babylonjs/Misc/tools" {
  42942. import { Nullable, float } from "babylonjs/types";
  42943. import { DomManagement } from "babylonjs/Misc/domManagement";
  42944. import { WebRequest } from "babylonjs/Misc/webRequest";
  42945. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  42946. import { ReadFileError } from "babylonjs/Misc/fileTools";
  42947. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42948. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  42949. import { Camera } from "babylonjs/Cameras/camera";
  42950. import { Engine } from "babylonjs/Engines/engine";
  42951. interface IColor4Like {
  42952. r: float;
  42953. g: float;
  42954. b: float;
  42955. a: float;
  42956. }
  42957. /**
  42958. * Class containing a set of static utilities functions
  42959. */
  42960. export class Tools {
  42961. /**
  42962. * Gets or sets the base URL to use to load assets
  42963. */
  42964. static get BaseUrl(): string;
  42965. static set BaseUrl(value: string);
  42966. /**
  42967. * Enable/Disable Custom HTTP Request Headers globally.
  42968. * default = false
  42969. * @see CustomRequestHeaders
  42970. */
  42971. static UseCustomRequestHeaders: boolean;
  42972. /**
  42973. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42974. * i.e. when loading files, where the server/service expects an Authorization header
  42975. */
  42976. static CustomRequestHeaders: {
  42977. [key: string]: string;
  42978. };
  42979. /**
  42980. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42981. */
  42982. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42983. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42984. /**
  42985. * Default behaviour for cors in the application.
  42986. * It can be a string if the expected behavior is identical in the entire app.
  42987. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42988. */
  42989. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42990. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42991. /**
  42992. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42993. * @ignorenaming
  42994. */
  42995. static get UseFallbackTexture(): boolean;
  42996. static set UseFallbackTexture(value: boolean);
  42997. /**
  42998. * Use this object to register external classes like custom textures or material
  42999. * to allow the laoders to instantiate them
  43000. */
  43001. static get RegisteredExternalClasses(): {
  43002. [key: string]: Object;
  43003. };
  43004. static set RegisteredExternalClasses(classes: {
  43005. [key: string]: Object;
  43006. });
  43007. /**
  43008. * Texture content used if a texture cannot loaded
  43009. * @ignorenaming
  43010. */
  43011. static get fallbackTexture(): string;
  43012. static set fallbackTexture(value: string);
  43013. /**
  43014. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43015. * @param u defines the coordinate on X axis
  43016. * @param v defines the coordinate on Y axis
  43017. * @param width defines the width of the source data
  43018. * @param height defines the height of the source data
  43019. * @param pixels defines the source byte array
  43020. * @param color defines the output color
  43021. */
  43022. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43023. /**
  43024. * Interpolates between a and b via alpha
  43025. * @param a The lower value (returned when alpha = 0)
  43026. * @param b The upper value (returned when alpha = 1)
  43027. * @param alpha The interpolation-factor
  43028. * @return The mixed value
  43029. */
  43030. static Mix(a: number, b: number, alpha: number): number;
  43031. /**
  43032. * Tries to instantiate a new object from a given class name
  43033. * @param className defines the class name to instantiate
  43034. * @returns the new object or null if the system was not able to do the instantiation
  43035. */
  43036. static Instantiate(className: string): any;
  43037. /**
  43038. * Provides a slice function that will work even on IE
  43039. * @param data defines the array to slice
  43040. * @param start defines the start of the data (optional)
  43041. * @param end defines the end of the data (optional)
  43042. * @returns the new sliced array
  43043. */
  43044. static Slice<T>(data: T, start?: number, end?: number): T;
  43045. /**
  43046. * Provides a slice function that will work even on IE
  43047. * The difference between this and Slice is that this will force-convert to array
  43048. * @param data defines the array to slice
  43049. * @param start defines the start of the data (optional)
  43050. * @param end defines the end of the data (optional)
  43051. * @returns the new sliced array
  43052. */
  43053. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43054. /**
  43055. * Polyfill for setImmediate
  43056. * @param action defines the action to execute after the current execution block
  43057. */
  43058. static SetImmediate(action: () => void): void;
  43059. /**
  43060. * Function indicating if a number is an exponent of 2
  43061. * @param value defines the value to test
  43062. * @returns true if the value is an exponent of 2
  43063. */
  43064. static IsExponentOfTwo(value: number): boolean;
  43065. private static _tmpFloatArray;
  43066. /**
  43067. * Returns the nearest 32-bit single precision float representation of a Number
  43068. * @param value A Number. If the parameter is of a different type, it will get converted
  43069. * to a number or to NaN if it cannot be converted
  43070. * @returns number
  43071. */
  43072. static FloatRound(value: number): number;
  43073. /**
  43074. * Extracts the filename from a path
  43075. * @param path defines the path to use
  43076. * @returns the filename
  43077. */
  43078. static GetFilename(path: string): string;
  43079. /**
  43080. * Extracts the "folder" part of a path (everything before the filename).
  43081. * @param uri The URI to extract the info from
  43082. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43083. * @returns The "folder" part of the path
  43084. */
  43085. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43086. /**
  43087. * Extracts text content from a DOM element hierarchy
  43088. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43089. */
  43090. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43091. /**
  43092. * Convert an angle in radians to degrees
  43093. * @param angle defines the angle to convert
  43094. * @returns the angle in degrees
  43095. */
  43096. static ToDegrees(angle: number): number;
  43097. /**
  43098. * Convert an angle in degrees to radians
  43099. * @param angle defines the angle to convert
  43100. * @returns the angle in radians
  43101. */
  43102. static ToRadians(angle: number): number;
  43103. /**
  43104. * Returns an array if obj is not an array
  43105. * @param obj defines the object to evaluate as an array
  43106. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43107. * @returns either obj directly if obj is an array or a new array containing obj
  43108. */
  43109. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43110. /**
  43111. * Gets the pointer prefix to use
  43112. * @param engine defines the engine we are finding the prefix for
  43113. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43114. */
  43115. static GetPointerPrefix(engine: Engine): string;
  43116. /**
  43117. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43118. * @param url define the url we are trying
  43119. * @param element define the dom element where to configure the cors policy
  43120. */
  43121. static SetCorsBehavior(url: string | string[], element: {
  43122. crossOrigin: string | null;
  43123. }): void;
  43124. /**
  43125. * Removes unwanted characters from an url
  43126. * @param url defines the url to clean
  43127. * @returns the cleaned url
  43128. */
  43129. static CleanUrl(url: string): string;
  43130. /**
  43131. * Gets or sets a function used to pre-process url before using them to load assets
  43132. */
  43133. static get PreprocessUrl(): (url: string) => string;
  43134. static set PreprocessUrl(processor: (url: string) => string);
  43135. /**
  43136. * Loads an image as an HTMLImageElement.
  43137. * @param input url string, ArrayBuffer, or Blob to load
  43138. * @param onLoad callback called when the image successfully loads
  43139. * @param onError callback called when the image fails to load
  43140. * @param offlineProvider offline provider for caching
  43141. * @param mimeType optional mime type
  43142. * @returns the HTMLImageElement of the loaded image
  43143. */
  43144. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43145. /**
  43146. * Loads a file from a url
  43147. * @param url url string, ArrayBuffer, or Blob to load
  43148. * @param onSuccess callback called when the file successfully loads
  43149. * @param onProgress callback called while file is loading (if the server supports this mode)
  43150. * @param offlineProvider defines the offline provider for caching
  43151. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43152. * @param onError callback called when the file fails to load
  43153. * @returns a file request object
  43154. */
  43155. 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;
  43156. /**
  43157. * Loads a file from a url
  43158. * @param url the file url to load
  43159. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43160. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43161. */
  43162. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43163. /**
  43164. * Load a script (identified by an url). When the url returns, the
  43165. * content of this file is added into a new script element, attached to the DOM (body element)
  43166. * @param scriptUrl defines the url of the script to laod
  43167. * @param onSuccess defines the callback called when the script is loaded
  43168. * @param onError defines the callback to call if an error occurs
  43169. * @param scriptId defines the id of the script element
  43170. */
  43171. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43172. /**
  43173. * Load an asynchronous script (identified by an url). When the url returns, the
  43174. * content of this file is added into a new script element, attached to the DOM (body element)
  43175. * @param scriptUrl defines the url of the script to laod
  43176. * @param scriptId defines the id of the script element
  43177. * @returns a promise request object
  43178. */
  43179. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43180. /**
  43181. * Loads a file from a blob
  43182. * @param fileToLoad defines the blob to use
  43183. * @param callback defines the callback to call when data is loaded
  43184. * @param progressCallback defines the callback to call during loading process
  43185. * @returns a file request object
  43186. */
  43187. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43188. /**
  43189. * Reads a file from a File object
  43190. * @param file defines the file to load
  43191. * @param onSuccess defines the callback to call when data is loaded
  43192. * @param onProgress defines the callback to call during loading process
  43193. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43194. * @param onError defines the callback to call when an error occurs
  43195. * @returns a file request object
  43196. */
  43197. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43198. /**
  43199. * Creates a data url from a given string content
  43200. * @param content defines the content to convert
  43201. * @returns the new data url link
  43202. */
  43203. static FileAsURL(content: string): string;
  43204. /**
  43205. * Format the given number to a specific decimal format
  43206. * @param value defines the number to format
  43207. * @param decimals defines the number of decimals to use
  43208. * @returns the formatted string
  43209. */
  43210. static Format(value: number, decimals?: number): string;
  43211. /**
  43212. * Tries to copy an object by duplicating every property
  43213. * @param source defines the source object
  43214. * @param destination defines the target object
  43215. * @param doNotCopyList defines a list of properties to avoid
  43216. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43217. */
  43218. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43219. /**
  43220. * Gets a boolean indicating if the given object has no own property
  43221. * @param obj defines the object to test
  43222. * @returns true if object has no own property
  43223. */
  43224. static IsEmpty(obj: any): boolean;
  43225. /**
  43226. * Function used to register events at window level
  43227. * @param windowElement defines the Window object to use
  43228. * @param events defines the events to register
  43229. */
  43230. static RegisterTopRootEvents(windowElement: Window, events: {
  43231. name: string;
  43232. handler: Nullable<(e: FocusEvent) => any>;
  43233. }[]): void;
  43234. /**
  43235. * Function used to unregister events from window level
  43236. * @param windowElement defines the Window object to use
  43237. * @param events defines the events to unregister
  43238. */
  43239. static UnregisterTopRootEvents(windowElement: Window, events: {
  43240. name: string;
  43241. handler: Nullable<(e: FocusEvent) => any>;
  43242. }[]): void;
  43243. /**
  43244. * @ignore
  43245. */
  43246. static _ScreenshotCanvas: HTMLCanvasElement;
  43247. /**
  43248. * Dumps the current bound framebuffer
  43249. * @param width defines the rendering width
  43250. * @param height defines the rendering height
  43251. * @param engine defines the hosting engine
  43252. * @param successCallback defines the callback triggered once the data are available
  43253. * @param mimeType defines the mime type of the result
  43254. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43255. */
  43256. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43257. /**
  43258. * Converts the canvas data to blob.
  43259. * This acts as a polyfill for browsers not supporting the to blob function.
  43260. * @param canvas Defines the canvas to extract the data from
  43261. * @param successCallback Defines the callback triggered once the data are available
  43262. * @param mimeType Defines the mime type of the result
  43263. */
  43264. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43265. /**
  43266. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43267. * @param successCallback defines the callback triggered once the data are available
  43268. * @param mimeType defines the mime type of the result
  43269. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43270. */
  43271. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43272. /**
  43273. * Downloads a blob in the browser
  43274. * @param blob defines the blob to download
  43275. * @param fileName defines the name of the downloaded file
  43276. */
  43277. static Download(blob: Blob, fileName: string): void;
  43278. /**
  43279. * Will return the right value of the noPreventDefault variable
  43280. * Needed to keep backwards compatibility to the old API.
  43281. *
  43282. * @param args arguments passed to the attachControl function
  43283. * @returns the correct value for noPreventDefault
  43284. */
  43285. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43286. /**
  43287. * Captures a screenshot of the current rendering
  43288. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43289. * @param engine defines the rendering engine
  43290. * @param camera defines the source camera
  43291. * @param size This parameter can be set to a single number or to an object with the
  43292. * following (optional) properties: precision, width, height. If a single number is passed,
  43293. * it will be used for both width and height. If an object is passed, the screenshot size
  43294. * will be derived from the parameters. The precision property is a multiplier allowing
  43295. * rendering at a higher or lower resolution
  43296. * @param successCallback defines the callback receives a single parameter which contains the
  43297. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43298. * src parameter of an <img> to display it
  43299. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43300. * Check your browser for supported MIME types
  43301. */
  43302. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43303. /**
  43304. * Captures a screenshot of the current rendering
  43305. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43306. * @param engine defines the rendering engine
  43307. * @param camera defines the source camera
  43308. * @param size This parameter can be set to a single number or to an object with the
  43309. * following (optional) properties: precision, width, height. If a single number is passed,
  43310. * it will be used for both width and height. If an object is passed, the screenshot size
  43311. * will be derived from the parameters. The precision property is a multiplier allowing
  43312. * rendering at a higher or lower resolution
  43313. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43314. * Check your browser for supported MIME types
  43315. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43316. * to the src parameter of an <img> to display it
  43317. */
  43318. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43319. /**
  43320. * Generates an image screenshot from the specified camera.
  43321. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43322. * @param engine The engine to use for rendering
  43323. * @param camera The camera to use for rendering
  43324. * @param size This parameter can be set to a single number or to an object with the
  43325. * following (optional) properties: precision, width, height. If a single number is passed,
  43326. * it will be used for both width and height. If an object is passed, the screenshot size
  43327. * will be derived from the parameters. The precision property is a multiplier allowing
  43328. * rendering at a higher or lower resolution
  43329. * @param successCallback The callback receives a single parameter which contains the
  43330. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43331. * src parameter of an <img> to display it
  43332. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43333. * Check your browser for supported MIME types
  43334. * @param samples Texture samples (default: 1)
  43335. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43336. * @param fileName A name for for the downloaded file.
  43337. */
  43338. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43339. /**
  43340. * Generates an image screenshot from the specified camera.
  43341. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43342. * @param engine The engine to use for rendering
  43343. * @param camera The camera to use for rendering
  43344. * @param size This parameter can be set to a single number or to an object with the
  43345. * following (optional) properties: precision, width, height. If a single number is passed,
  43346. * it will be used for both width and height. If an object is passed, the screenshot size
  43347. * will be derived from the parameters. The precision property is a multiplier allowing
  43348. * rendering at a higher or lower resolution
  43349. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43350. * Check your browser for supported MIME types
  43351. * @param samples Texture samples (default: 1)
  43352. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43353. * @param fileName A name for for the downloaded file.
  43354. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43355. * to the src parameter of an <img> to display it
  43356. */
  43357. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43358. /**
  43359. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43360. * Be aware Math.random() could cause collisions, but:
  43361. * "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"
  43362. * @returns a pseudo random id
  43363. */
  43364. static RandomId(): string;
  43365. /**
  43366. * Test if the given uri is a base64 string
  43367. * @param uri The uri to test
  43368. * @return True if the uri is a base64 string or false otherwise
  43369. */
  43370. static IsBase64(uri: string): boolean;
  43371. /**
  43372. * Decode the given base64 uri.
  43373. * @param uri The uri to decode
  43374. * @return The decoded base64 data.
  43375. */
  43376. static DecodeBase64(uri: string): ArrayBuffer;
  43377. /**
  43378. * Gets the absolute url.
  43379. * @param url the input url
  43380. * @return the absolute url
  43381. */
  43382. static GetAbsoluteUrl(url: string): string;
  43383. /**
  43384. * No log
  43385. */
  43386. static readonly NoneLogLevel: number;
  43387. /**
  43388. * Only message logs
  43389. */
  43390. static readonly MessageLogLevel: number;
  43391. /**
  43392. * Only warning logs
  43393. */
  43394. static readonly WarningLogLevel: number;
  43395. /**
  43396. * Only error logs
  43397. */
  43398. static readonly ErrorLogLevel: number;
  43399. /**
  43400. * All logs
  43401. */
  43402. static readonly AllLogLevel: number;
  43403. /**
  43404. * Gets a value indicating the number of loading errors
  43405. * @ignorenaming
  43406. */
  43407. static get errorsCount(): number;
  43408. /**
  43409. * Callback called when a new log is added
  43410. */
  43411. static OnNewCacheEntry: (entry: string) => void;
  43412. /**
  43413. * Log a message to the console
  43414. * @param message defines the message to log
  43415. */
  43416. static Log(message: string): void;
  43417. /**
  43418. * Write a warning message to the console
  43419. * @param message defines the message to log
  43420. */
  43421. static Warn(message: string): void;
  43422. /**
  43423. * Write an error message to the console
  43424. * @param message defines the message to log
  43425. */
  43426. static Error(message: string): void;
  43427. /**
  43428. * Gets current log cache (list of logs)
  43429. */
  43430. static get LogCache(): string;
  43431. /**
  43432. * Clears the log cache
  43433. */
  43434. static ClearLogCache(): void;
  43435. /**
  43436. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43437. */
  43438. static set LogLevels(level: number);
  43439. /**
  43440. * Checks if the window object exists
  43441. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43442. */
  43443. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43444. /**
  43445. * No performance log
  43446. */
  43447. static readonly PerformanceNoneLogLevel: number;
  43448. /**
  43449. * Use user marks to log performance
  43450. */
  43451. static readonly PerformanceUserMarkLogLevel: number;
  43452. /**
  43453. * Log performance to the console
  43454. */
  43455. static readonly PerformanceConsoleLogLevel: number;
  43456. private static _performance;
  43457. /**
  43458. * Sets the current performance log level
  43459. */
  43460. static set PerformanceLogLevel(level: number);
  43461. private static _StartPerformanceCounterDisabled;
  43462. private static _EndPerformanceCounterDisabled;
  43463. private static _StartUserMark;
  43464. private static _EndUserMark;
  43465. private static _StartPerformanceConsole;
  43466. private static _EndPerformanceConsole;
  43467. /**
  43468. * Starts a performance counter
  43469. */
  43470. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43471. /**
  43472. * Ends a specific performance coutner
  43473. */
  43474. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43475. /**
  43476. * Gets either window.performance.now() if supported or Date.now() else
  43477. */
  43478. static get Now(): number;
  43479. /**
  43480. * This method will return the name of the class used to create the instance of the given object.
  43481. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43482. * @param object the object to get the class name from
  43483. * @param isType defines if the object is actually a type
  43484. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43485. */
  43486. static GetClassName(object: any, isType?: boolean): string;
  43487. /**
  43488. * Gets the first element of an array satisfying a given predicate
  43489. * @param array defines the array to browse
  43490. * @param predicate defines the predicate to use
  43491. * @returns null if not found or the element
  43492. */
  43493. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43494. /**
  43495. * This method will return the name of the full name of the class, including its owning module (if any).
  43496. * 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).
  43497. * @param object the object to get the class name from
  43498. * @param isType defines if the object is actually a type
  43499. * @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.
  43500. * @ignorenaming
  43501. */
  43502. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43503. /**
  43504. * Returns a promise that resolves after the given amount of time.
  43505. * @param delay Number of milliseconds to delay
  43506. * @returns Promise that resolves after the given amount of time
  43507. */
  43508. static DelayAsync(delay: number): Promise<void>;
  43509. /**
  43510. * Utility function to detect if the current user agent is Safari
  43511. * @returns whether or not the current user agent is safari
  43512. */
  43513. static IsSafari(): boolean;
  43514. }
  43515. /**
  43516. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43517. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43518. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43519. * @param name The name of the class, case should be preserved
  43520. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43521. */
  43522. export function className(name: string, module?: string): (target: Object) => void;
  43523. /**
  43524. * An implementation of a loop for asynchronous functions.
  43525. */
  43526. export class AsyncLoop {
  43527. /**
  43528. * Defines the number of iterations for the loop
  43529. */
  43530. iterations: number;
  43531. /**
  43532. * Defines the current index of the loop.
  43533. */
  43534. index: number;
  43535. private _done;
  43536. private _fn;
  43537. private _successCallback;
  43538. /**
  43539. * Constructor.
  43540. * @param iterations the number of iterations.
  43541. * @param func the function to run each iteration
  43542. * @param successCallback the callback that will be called upon succesful execution
  43543. * @param offset starting offset.
  43544. */
  43545. constructor(
  43546. /**
  43547. * Defines the number of iterations for the loop
  43548. */
  43549. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43550. /**
  43551. * Execute the next iteration. Must be called after the last iteration was finished.
  43552. */
  43553. executeNext(): void;
  43554. /**
  43555. * Break the loop and run the success callback.
  43556. */
  43557. breakLoop(): void;
  43558. /**
  43559. * Create and run an async loop.
  43560. * @param iterations the number of iterations.
  43561. * @param fn the function to run each iteration
  43562. * @param successCallback the callback that will be called upon succesful execution
  43563. * @param offset starting offset.
  43564. * @returns the created async loop object
  43565. */
  43566. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43567. /**
  43568. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43569. * @param iterations total number of iterations
  43570. * @param syncedIterations number of synchronous iterations in each async iteration.
  43571. * @param fn the function to call each iteration.
  43572. * @param callback a success call back that will be called when iterating stops.
  43573. * @param breakFunction a break condition (optional)
  43574. * @param timeout timeout settings for the setTimeout function. default - 0.
  43575. * @returns the created async loop object
  43576. */
  43577. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43578. }
  43579. }
  43580. declare module "babylonjs/Misc/stringDictionary" {
  43581. import { Nullable } from "babylonjs/types";
  43582. /**
  43583. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43584. * The underlying implementation relies on an associative array to ensure the best performances.
  43585. * The value can be anything including 'null' but except 'undefined'
  43586. */
  43587. export class StringDictionary<T> {
  43588. /**
  43589. * This will clear this dictionary and copy the content from the 'source' one.
  43590. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43591. * @param source the dictionary to take the content from and copy to this dictionary
  43592. */
  43593. copyFrom(source: StringDictionary<T>): void;
  43594. /**
  43595. * Get a value based from its key
  43596. * @param key the given key to get the matching value from
  43597. * @return the value if found, otherwise undefined is returned
  43598. */
  43599. get(key: string): T | undefined;
  43600. /**
  43601. * Get a value from its key or add it if it doesn't exist.
  43602. * This method will ensure you that a given key/data will be present in the dictionary.
  43603. * @param key the given key to get the matching value from
  43604. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43605. * The factory will only be invoked if there's no data for the given key.
  43606. * @return the value corresponding to the key.
  43607. */
  43608. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43609. /**
  43610. * Get a value from its key if present in the dictionary otherwise add it
  43611. * @param key the key to get the value from
  43612. * @param val if there's no such key/value pair in the dictionary add it with this value
  43613. * @return the value corresponding to the key
  43614. */
  43615. getOrAdd(key: string, val: T): T;
  43616. /**
  43617. * Check if there's a given key in the dictionary
  43618. * @param key the key to check for
  43619. * @return true if the key is present, false otherwise
  43620. */
  43621. contains(key: string): boolean;
  43622. /**
  43623. * Add a new key and its corresponding value
  43624. * @param key the key to add
  43625. * @param value the value corresponding to the key
  43626. * @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
  43627. */
  43628. add(key: string, value: T): boolean;
  43629. /**
  43630. * Update a specific value associated to a key
  43631. * @param key defines the key to use
  43632. * @param value defines the value to store
  43633. * @returns true if the value was updated (or false if the key was not found)
  43634. */
  43635. set(key: string, value: T): boolean;
  43636. /**
  43637. * Get the element of the given key and remove it from the dictionary
  43638. * @param key defines the key to search
  43639. * @returns the value associated with the key or null if not found
  43640. */
  43641. getAndRemove(key: string): Nullable<T>;
  43642. /**
  43643. * Remove a key/value from the dictionary.
  43644. * @param key the key to remove
  43645. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43646. */
  43647. remove(key: string): boolean;
  43648. /**
  43649. * Clear the whole content of the dictionary
  43650. */
  43651. clear(): void;
  43652. /**
  43653. * Gets the current count
  43654. */
  43655. get count(): number;
  43656. /**
  43657. * Execute a callback on each key/val of the dictionary.
  43658. * Note that you can remove any element in this dictionary in the callback implementation
  43659. * @param callback the callback to execute on a given key/value pair
  43660. */
  43661. forEach(callback: (key: string, val: T) => void): void;
  43662. /**
  43663. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43664. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43665. * Note that you can remove any element in this dictionary in the callback implementation
  43666. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43667. * @returns the first item
  43668. */
  43669. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43670. private _count;
  43671. private _data;
  43672. }
  43673. }
  43674. declare module "babylonjs/Collisions/collisionCoordinator" {
  43675. import { Nullable } from "babylonjs/types";
  43676. import { Scene } from "babylonjs/scene";
  43677. import { Vector3 } from "babylonjs/Maths/math.vector";
  43678. import { Collider } from "babylonjs/Collisions/collider";
  43679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43680. /** @hidden */
  43681. export interface ICollisionCoordinator {
  43682. createCollider(): Collider;
  43683. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43684. init(scene: Scene): void;
  43685. }
  43686. /** @hidden */
  43687. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43688. private _scene;
  43689. private _scaledPosition;
  43690. private _scaledVelocity;
  43691. private _finalPosition;
  43692. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43693. createCollider(): Collider;
  43694. init(scene: Scene): void;
  43695. private _collideWithWorld;
  43696. }
  43697. }
  43698. declare module "babylonjs/Inputs/scene.inputManager" {
  43699. import { Nullable } from "babylonjs/types";
  43700. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43701. import { Vector2 } from "babylonjs/Maths/math.vector";
  43702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43703. import { Scene } from "babylonjs/scene";
  43704. /**
  43705. * Class used to manage all inputs for the scene.
  43706. */
  43707. export class InputManager {
  43708. /** The distance in pixel that you have to move to prevent some events */
  43709. static DragMovementThreshold: number;
  43710. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43711. static LongPressDelay: number;
  43712. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43713. static DoubleClickDelay: number;
  43714. /** If you need to check double click without raising a single click at first click, enable this flag */
  43715. static ExclusiveDoubleClickMode: boolean;
  43716. /** 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. */
  43717. private _alreadyAttached;
  43718. private _alreadyAttachedTo;
  43719. private _wheelEventName;
  43720. private _onPointerMove;
  43721. private _onPointerDown;
  43722. private _onPointerUp;
  43723. private _initClickEvent;
  43724. private _initActionManager;
  43725. private _delayedSimpleClick;
  43726. private _delayedSimpleClickTimeout;
  43727. private _previousDelayedSimpleClickTimeout;
  43728. private _meshPickProceed;
  43729. private _previousButtonPressed;
  43730. private _currentPickResult;
  43731. private _previousPickResult;
  43732. private _totalPointersPressed;
  43733. private _doubleClickOccured;
  43734. private _pointerOverMesh;
  43735. private _pickedDownMesh;
  43736. private _pickedUpMesh;
  43737. private _pointerX;
  43738. private _pointerY;
  43739. private _unTranslatedPointerX;
  43740. private _unTranslatedPointerY;
  43741. private _startingPointerPosition;
  43742. private _previousStartingPointerPosition;
  43743. private _startingPointerTime;
  43744. private _previousStartingPointerTime;
  43745. private _pointerCaptures;
  43746. private _meshUnderPointerId;
  43747. private _onKeyDown;
  43748. private _onKeyUp;
  43749. private _keyboardIsAttached;
  43750. private _onCanvasFocusObserver;
  43751. private _onCanvasBlurObserver;
  43752. private _scene;
  43753. /**
  43754. * Creates a new InputManager
  43755. * @param scene defines the hosting scene
  43756. */
  43757. constructor(scene: Scene);
  43758. /**
  43759. * Gets the mesh that is currently under the pointer
  43760. */
  43761. get meshUnderPointer(): Nullable<AbstractMesh>;
  43762. /**
  43763. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43764. * @param pointerId the pointer id to use
  43765. * @returns The mesh under this pointer id or null if not found
  43766. */
  43767. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43768. /**
  43769. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43770. */
  43771. get unTranslatedPointer(): Vector2;
  43772. /**
  43773. * Gets or sets the current on-screen X position of the pointer
  43774. */
  43775. get pointerX(): number;
  43776. set pointerX(value: number);
  43777. /**
  43778. * Gets or sets the current on-screen Y position of the pointer
  43779. */
  43780. get pointerY(): number;
  43781. set pointerY(value: number);
  43782. private _updatePointerPosition;
  43783. private _processPointerMove;
  43784. private _setRayOnPointerInfo;
  43785. private _checkPrePointerObservable;
  43786. /**
  43787. * Use this method to simulate a pointer move on a mesh
  43788. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43789. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43790. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43791. */
  43792. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43793. /**
  43794. * Use this method to simulate a pointer down on a mesh
  43795. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43796. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43797. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43798. */
  43799. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43800. private _processPointerDown;
  43801. /** @hidden */
  43802. _isPointerSwiping(): boolean;
  43803. /**
  43804. * Use this method to simulate a pointer up on a mesh
  43805. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43806. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43807. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43808. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43809. */
  43810. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43811. private _processPointerUp;
  43812. /**
  43813. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43814. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43815. * @returns true if the pointer was captured
  43816. */
  43817. isPointerCaptured(pointerId?: number): boolean;
  43818. /**
  43819. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43820. * @param attachUp defines if you want to attach events to pointerup
  43821. * @param attachDown defines if you want to attach events to pointerdown
  43822. * @param attachMove defines if you want to attach events to pointermove
  43823. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43824. */
  43825. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43826. /**
  43827. * Detaches all event handlers
  43828. */
  43829. detachControl(): void;
  43830. /**
  43831. * Force the value of meshUnderPointer
  43832. * @param mesh defines the mesh to use
  43833. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43834. */
  43835. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43836. /**
  43837. * Gets the mesh under the pointer
  43838. * @returns a Mesh or null if no mesh is under the pointer
  43839. */
  43840. getPointerOverMesh(): Nullable<AbstractMesh>;
  43841. }
  43842. }
  43843. declare module "babylonjs/Animations/animationGroup" {
  43844. import { Animatable } from "babylonjs/Animations/animatable";
  43845. import { Animation } from "babylonjs/Animations/animation";
  43846. import { Scene, IDisposable } from "babylonjs/scene";
  43847. import { Observable } from "babylonjs/Misc/observable";
  43848. import { Nullable } from "babylonjs/types";
  43849. import "babylonjs/Animations/animatable";
  43850. /**
  43851. * This class defines the direct association between an animation and a target
  43852. */
  43853. export class TargetedAnimation {
  43854. /**
  43855. * Animation to perform
  43856. */
  43857. animation: Animation;
  43858. /**
  43859. * Target to animate
  43860. */
  43861. target: any;
  43862. /**
  43863. * Returns the string "TargetedAnimation"
  43864. * @returns "TargetedAnimation"
  43865. */
  43866. getClassName(): string;
  43867. /**
  43868. * Serialize the object
  43869. * @returns the JSON object representing the current entity
  43870. */
  43871. serialize(): any;
  43872. }
  43873. /**
  43874. * Use this class to create coordinated animations on multiple targets
  43875. */
  43876. export class AnimationGroup implements IDisposable {
  43877. /** The name of the animation group */
  43878. name: string;
  43879. private _scene;
  43880. private _targetedAnimations;
  43881. private _animatables;
  43882. private _from;
  43883. private _to;
  43884. private _isStarted;
  43885. private _isPaused;
  43886. private _speedRatio;
  43887. private _loopAnimation;
  43888. private _isAdditive;
  43889. /**
  43890. * Gets or sets the unique id of the node
  43891. */
  43892. uniqueId: number;
  43893. /**
  43894. * This observable will notify when one animation have ended
  43895. */
  43896. onAnimationEndObservable: Observable<TargetedAnimation>;
  43897. /**
  43898. * Observer raised when one animation loops
  43899. */
  43900. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43901. /**
  43902. * Observer raised when all animations have looped
  43903. */
  43904. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43905. /**
  43906. * This observable will notify when all animations have ended.
  43907. */
  43908. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43909. /**
  43910. * This observable will notify when all animations have paused.
  43911. */
  43912. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43913. /**
  43914. * This observable will notify when all animations are playing.
  43915. */
  43916. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43917. /**
  43918. * Gets the first frame
  43919. */
  43920. get from(): number;
  43921. /**
  43922. * Gets the last frame
  43923. */
  43924. get to(): number;
  43925. /**
  43926. * Define if the animations are started
  43927. */
  43928. get isStarted(): boolean;
  43929. /**
  43930. * Gets a value indicating that the current group is playing
  43931. */
  43932. get isPlaying(): boolean;
  43933. /**
  43934. * Gets or sets the speed ratio to use for all animations
  43935. */
  43936. get speedRatio(): number;
  43937. /**
  43938. * Gets or sets the speed ratio to use for all animations
  43939. */
  43940. set speedRatio(value: number);
  43941. /**
  43942. * Gets or sets if all animations should loop or not
  43943. */
  43944. get loopAnimation(): boolean;
  43945. set loopAnimation(value: boolean);
  43946. /**
  43947. * Gets or sets if all animations should be evaluated additively
  43948. */
  43949. get isAdditive(): boolean;
  43950. set isAdditive(value: boolean);
  43951. /**
  43952. * Gets the targeted animations for this animation group
  43953. */
  43954. get targetedAnimations(): Array<TargetedAnimation>;
  43955. /**
  43956. * returning the list of animatables controlled by this animation group.
  43957. */
  43958. get animatables(): Array<Animatable>;
  43959. /**
  43960. * Gets the list of target animations
  43961. */
  43962. get children(): TargetedAnimation[];
  43963. /**
  43964. * Instantiates a new Animation Group.
  43965. * This helps managing several animations at once.
  43966. * @see https://doc.babylonjs.com/how_to/group
  43967. * @param name Defines the name of the group
  43968. * @param scene Defines the scene the group belongs to
  43969. */
  43970. constructor(
  43971. /** The name of the animation group */
  43972. name: string, scene?: Nullable<Scene>);
  43973. /**
  43974. * Add an animation (with its target) in the group
  43975. * @param animation defines the animation we want to add
  43976. * @param target defines the target of the animation
  43977. * @returns the TargetedAnimation object
  43978. */
  43979. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43980. /**
  43981. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43982. * It can add constant keys at begin or end
  43983. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43984. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43985. * @returns the animation group
  43986. */
  43987. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43988. private _animationLoopCount;
  43989. private _animationLoopFlags;
  43990. private _processLoop;
  43991. /**
  43992. * Start all animations on given targets
  43993. * @param loop defines if animations must loop
  43994. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43995. * @param from defines the from key (optional)
  43996. * @param to defines the to key (optional)
  43997. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43998. * @returns the current animation group
  43999. */
  44000. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44001. /**
  44002. * Pause all animations
  44003. * @returns the animation group
  44004. */
  44005. pause(): AnimationGroup;
  44006. /**
  44007. * Play all animations to initial state
  44008. * This function will start() the animations if they were not started or will restart() them if they were paused
  44009. * @param loop defines if animations must loop
  44010. * @returns the animation group
  44011. */
  44012. play(loop?: boolean): AnimationGroup;
  44013. /**
  44014. * Reset all animations to initial state
  44015. * @returns the animation group
  44016. */
  44017. reset(): AnimationGroup;
  44018. /**
  44019. * Restart animations from key 0
  44020. * @returns the animation group
  44021. */
  44022. restart(): AnimationGroup;
  44023. /**
  44024. * Stop all animations
  44025. * @returns the animation group
  44026. */
  44027. stop(): AnimationGroup;
  44028. /**
  44029. * Set animation weight for all animatables
  44030. * @param weight defines the weight to use
  44031. * @return the animationGroup
  44032. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44033. */
  44034. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44035. /**
  44036. * Synchronize and normalize all animatables with a source animatable
  44037. * @param root defines the root animatable to synchronize with
  44038. * @return the animationGroup
  44039. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44040. */
  44041. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44042. /**
  44043. * Goes to a specific frame in this animation group
  44044. * @param frame the frame number to go to
  44045. * @return the animationGroup
  44046. */
  44047. goToFrame(frame: number): AnimationGroup;
  44048. /**
  44049. * Dispose all associated resources
  44050. */
  44051. dispose(): void;
  44052. private _checkAnimationGroupEnded;
  44053. /**
  44054. * Clone the current animation group and returns a copy
  44055. * @param newName defines the name of the new group
  44056. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44057. * @returns the new aniamtion group
  44058. */
  44059. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44060. /**
  44061. * Serializes the animationGroup to an object
  44062. * @returns Serialized object
  44063. */
  44064. serialize(): any;
  44065. /**
  44066. * Returns a new AnimationGroup object parsed from the source provided.
  44067. * @param parsedAnimationGroup defines the source
  44068. * @param scene defines the scene that will receive the animationGroup
  44069. * @returns a new AnimationGroup
  44070. */
  44071. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44072. /**
  44073. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44074. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44075. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44076. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44077. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44078. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44079. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44080. */
  44081. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44082. /**
  44083. * Returns the string "AnimationGroup"
  44084. * @returns "AnimationGroup"
  44085. */
  44086. getClassName(): string;
  44087. /**
  44088. * Creates a detailled string about the object
  44089. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44090. * @returns a string representing the object
  44091. */
  44092. toString(fullDetails?: boolean): string;
  44093. }
  44094. }
  44095. declare module "babylonjs/scene" {
  44096. import { Nullable } from "babylonjs/types";
  44097. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  44098. import { Observable } from "babylonjs/Misc/observable";
  44099. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44100. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  44101. import { Geometry } from "babylonjs/Meshes/geometry";
  44102. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44103. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44105. import { Mesh } from "babylonjs/Meshes/mesh";
  44106. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44107. import { Bone } from "babylonjs/Bones/bone";
  44108. import { Skeleton } from "babylonjs/Bones/skeleton";
  44109. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  44110. import { Camera } from "babylonjs/Cameras/camera";
  44111. import { AbstractScene } from "babylonjs/abstractScene";
  44112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44113. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44114. import { Material } from "babylonjs/Materials/material";
  44115. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44116. import { Effect } from "babylonjs/Materials/effect";
  44117. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44118. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  44119. import { Light } from "babylonjs/Lights/light";
  44120. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44121. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  44122. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  44123. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  44124. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  44125. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44126. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  44127. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  44128. import { Engine } from "babylonjs/Engines/engine";
  44129. import { Node } from "babylonjs/node";
  44130. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  44131. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  44132. import { WebRequest } from "babylonjs/Misc/webRequest";
  44133. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  44134. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  44135. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44136. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  44137. import { Plane } from "babylonjs/Maths/math.plane";
  44138. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  44139. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  44140. import { Ray } from "babylonjs/Culling/ray";
  44141. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  44142. import { Animation } from "babylonjs/Animations/animation";
  44143. import { Animatable } from "babylonjs/Animations/animatable";
  44144. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44145. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  44146. import { Collider } from "babylonjs/Collisions/collider";
  44147. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44148. /**
  44149. * Define an interface for all classes that will hold resources
  44150. */
  44151. export interface IDisposable {
  44152. /**
  44153. * Releases all held resources
  44154. */
  44155. dispose(): void;
  44156. }
  44157. /** Interface defining initialization parameters for Scene class */
  44158. export interface SceneOptions {
  44159. /**
  44160. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  44161. * It will improve performance when the number of geometries becomes important.
  44162. */
  44163. useGeometryUniqueIdsMap?: boolean;
  44164. /**
  44165. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  44166. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44167. */
  44168. useMaterialMeshMap?: boolean;
  44169. /**
  44170. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  44171. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44172. */
  44173. useClonedMeshMap?: boolean;
  44174. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  44175. virtual?: boolean;
  44176. }
  44177. /**
  44178. * Represents a scene to be rendered by the engine.
  44179. * @see https://doc.babylonjs.com/features/scene
  44180. */
  44181. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  44182. /** The fog is deactivated */
  44183. static readonly FOGMODE_NONE: number;
  44184. /** The fog density is following an exponential function */
  44185. static readonly FOGMODE_EXP: number;
  44186. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  44187. static readonly FOGMODE_EXP2: number;
  44188. /** The fog density is following a linear function. */
  44189. static readonly FOGMODE_LINEAR: number;
  44190. /**
  44191. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  44192. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44193. */
  44194. static MinDeltaTime: number;
  44195. /**
  44196. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  44197. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44198. */
  44199. static MaxDeltaTime: number;
  44200. /**
  44201. * Factory used to create the default material.
  44202. * @param name The name of the material to create
  44203. * @param scene The scene to create the material for
  44204. * @returns The default material
  44205. */
  44206. static DefaultMaterialFactory(scene: Scene): Material;
  44207. /**
  44208. * Factory used to create the a collision coordinator.
  44209. * @returns The collision coordinator
  44210. */
  44211. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  44212. /** @hidden */
  44213. _inputManager: InputManager;
  44214. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  44215. cameraToUseForPointers: Nullable<Camera>;
  44216. /** @hidden */
  44217. readonly _isScene: boolean;
  44218. /** @hidden */
  44219. _blockEntityCollection: boolean;
  44220. /**
  44221. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  44222. */
  44223. autoClear: boolean;
  44224. /**
  44225. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44226. */
  44227. autoClearDepthAndStencil: boolean;
  44228. /**
  44229. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44230. */
  44231. clearColor: Color4;
  44232. /**
  44233. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44234. */
  44235. ambientColor: Color3;
  44236. /**
  44237. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44238. * It should only be one of the following (if not the default embedded one):
  44239. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44240. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44241. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44242. * The material properties need to be setup according to the type of texture in use.
  44243. */
  44244. environmentBRDFTexture: BaseTexture;
  44245. /**
  44246. * Texture used in all pbr material as the reflection texture.
  44247. * As in the majority of the scene they are the same (exception for multi room and so on),
  44248. * this is easier to reference from here than from all the materials.
  44249. */
  44250. get environmentTexture(): Nullable<BaseTexture>;
  44251. /**
  44252. * Texture used in all pbr material as the reflection texture.
  44253. * As in the majority of the scene they are the same (exception for multi room and so on),
  44254. * this is easier to set here than in all the materials.
  44255. */
  44256. set environmentTexture(value: Nullable<BaseTexture>);
  44257. /** @hidden */
  44258. protected _environmentIntensity: number;
  44259. /**
  44260. * Intensity of the environment in all pbr material.
  44261. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44262. * As in the majority of the scene they are the same (exception for multi room and so on),
  44263. * this is easier to reference from here than from all the materials.
  44264. */
  44265. get environmentIntensity(): number;
  44266. /**
  44267. * Intensity of the environment in all pbr material.
  44268. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44269. * As in the majority of the scene they are the same (exception for multi room and so on),
  44270. * this is easier to set here than in all the materials.
  44271. */
  44272. set environmentIntensity(value: number);
  44273. /** @hidden */
  44274. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44275. /**
  44276. * Default image processing configuration used either in the rendering
  44277. * Forward main pass or through the imageProcessingPostProcess if present.
  44278. * As in the majority of the scene they are the same (exception for multi camera),
  44279. * this is easier to reference from here than from all the materials and post process.
  44280. *
  44281. * No setter as we it is a shared configuration, you can set the values instead.
  44282. */
  44283. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44284. private _forceWireframe;
  44285. /**
  44286. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44287. */
  44288. set forceWireframe(value: boolean);
  44289. get forceWireframe(): boolean;
  44290. private _skipFrustumClipping;
  44291. /**
  44292. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44293. */
  44294. set skipFrustumClipping(value: boolean);
  44295. get skipFrustumClipping(): boolean;
  44296. private _forcePointsCloud;
  44297. /**
  44298. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44299. */
  44300. set forcePointsCloud(value: boolean);
  44301. get forcePointsCloud(): boolean;
  44302. /**
  44303. * Gets or sets the active clipplane 1
  44304. */
  44305. clipPlane: Nullable<Plane>;
  44306. /**
  44307. * Gets or sets the active clipplane 2
  44308. */
  44309. clipPlane2: Nullable<Plane>;
  44310. /**
  44311. * Gets or sets the active clipplane 3
  44312. */
  44313. clipPlane3: Nullable<Plane>;
  44314. /**
  44315. * Gets or sets the active clipplane 4
  44316. */
  44317. clipPlane4: Nullable<Plane>;
  44318. /**
  44319. * Gets or sets the active clipplane 5
  44320. */
  44321. clipPlane5: Nullable<Plane>;
  44322. /**
  44323. * Gets or sets the active clipplane 6
  44324. */
  44325. clipPlane6: Nullable<Plane>;
  44326. /**
  44327. * Gets or sets a boolean indicating if animations are enabled
  44328. */
  44329. animationsEnabled: boolean;
  44330. private _animationPropertiesOverride;
  44331. /**
  44332. * Gets or sets the animation properties override
  44333. */
  44334. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44335. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44336. /**
  44337. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44338. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44339. */
  44340. useConstantAnimationDeltaTime: boolean;
  44341. /**
  44342. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44343. * Please note that it requires to run a ray cast through the scene on every frame
  44344. */
  44345. constantlyUpdateMeshUnderPointer: boolean;
  44346. /**
  44347. * Defines the HTML cursor to use when hovering over interactive elements
  44348. */
  44349. hoverCursor: string;
  44350. /**
  44351. * Defines the HTML default cursor to use (empty by default)
  44352. */
  44353. defaultCursor: string;
  44354. /**
  44355. * Defines whether cursors are handled by the scene.
  44356. */
  44357. doNotHandleCursors: boolean;
  44358. /**
  44359. * This is used to call preventDefault() on pointer down
  44360. * in order to block unwanted artifacts like system double clicks
  44361. */
  44362. preventDefaultOnPointerDown: boolean;
  44363. /**
  44364. * This is used to call preventDefault() on pointer up
  44365. * in order to block unwanted artifacts like system double clicks
  44366. */
  44367. preventDefaultOnPointerUp: boolean;
  44368. /**
  44369. * Gets or sets user defined metadata
  44370. */
  44371. metadata: any;
  44372. /**
  44373. * For internal use only. Please do not use.
  44374. */
  44375. reservedDataStore: any;
  44376. /**
  44377. * Gets the name of the plugin used to load this scene (null by default)
  44378. */
  44379. loadingPluginName: string;
  44380. /**
  44381. * Use this array to add regular expressions used to disable offline support for specific urls
  44382. */
  44383. disableOfflineSupportExceptionRules: RegExp[];
  44384. /**
  44385. * An event triggered when the scene is disposed.
  44386. */
  44387. onDisposeObservable: Observable<Scene>;
  44388. private _onDisposeObserver;
  44389. /** Sets a function to be executed when this scene is disposed. */
  44390. set onDispose(callback: () => void);
  44391. /**
  44392. * An event triggered before rendering the scene (right after animations and physics)
  44393. */
  44394. onBeforeRenderObservable: Observable<Scene>;
  44395. private _onBeforeRenderObserver;
  44396. /** Sets a function to be executed before rendering this scene */
  44397. set beforeRender(callback: Nullable<() => void>);
  44398. /**
  44399. * An event triggered after rendering the scene
  44400. */
  44401. onAfterRenderObservable: Observable<Scene>;
  44402. /**
  44403. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44404. */
  44405. onAfterRenderCameraObservable: Observable<Camera>;
  44406. private _onAfterRenderObserver;
  44407. /** Sets a function to be executed after rendering this scene */
  44408. set afterRender(callback: Nullable<() => void>);
  44409. /**
  44410. * An event triggered before animating the scene
  44411. */
  44412. onBeforeAnimationsObservable: Observable<Scene>;
  44413. /**
  44414. * An event triggered after animations processing
  44415. */
  44416. onAfterAnimationsObservable: Observable<Scene>;
  44417. /**
  44418. * An event triggered before draw calls are ready to be sent
  44419. */
  44420. onBeforeDrawPhaseObservable: Observable<Scene>;
  44421. /**
  44422. * An event triggered after draw calls have been sent
  44423. */
  44424. onAfterDrawPhaseObservable: Observable<Scene>;
  44425. /**
  44426. * An event triggered when the scene is ready
  44427. */
  44428. onReadyObservable: Observable<Scene>;
  44429. /**
  44430. * An event triggered before rendering a camera
  44431. */
  44432. onBeforeCameraRenderObservable: Observable<Camera>;
  44433. private _onBeforeCameraRenderObserver;
  44434. /** Sets a function to be executed before rendering a camera*/
  44435. set beforeCameraRender(callback: () => void);
  44436. /**
  44437. * An event triggered after rendering a camera
  44438. */
  44439. onAfterCameraRenderObservable: Observable<Camera>;
  44440. private _onAfterCameraRenderObserver;
  44441. /** Sets a function to be executed after rendering a camera*/
  44442. set afterCameraRender(callback: () => void);
  44443. /**
  44444. * An event triggered when active meshes evaluation is about to start
  44445. */
  44446. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44447. /**
  44448. * An event triggered when active meshes evaluation is done
  44449. */
  44450. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44451. /**
  44452. * An event triggered when particles rendering is about to start
  44453. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44454. */
  44455. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44456. /**
  44457. * An event triggered when particles rendering is done
  44458. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44459. */
  44460. onAfterParticlesRenderingObservable: Observable<Scene>;
  44461. /**
  44462. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44463. */
  44464. onDataLoadedObservable: Observable<Scene>;
  44465. /**
  44466. * An event triggered when a camera is created
  44467. */
  44468. onNewCameraAddedObservable: Observable<Camera>;
  44469. /**
  44470. * An event triggered when a camera is removed
  44471. */
  44472. onCameraRemovedObservable: Observable<Camera>;
  44473. /**
  44474. * An event triggered when a light is created
  44475. */
  44476. onNewLightAddedObservable: Observable<Light>;
  44477. /**
  44478. * An event triggered when a light is removed
  44479. */
  44480. onLightRemovedObservable: Observable<Light>;
  44481. /**
  44482. * An event triggered when a geometry is created
  44483. */
  44484. onNewGeometryAddedObservable: Observable<Geometry>;
  44485. /**
  44486. * An event triggered when a geometry is removed
  44487. */
  44488. onGeometryRemovedObservable: Observable<Geometry>;
  44489. /**
  44490. * An event triggered when a transform node is created
  44491. */
  44492. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44493. /**
  44494. * An event triggered when a transform node is removed
  44495. */
  44496. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44497. /**
  44498. * An event triggered when a mesh is created
  44499. */
  44500. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44501. /**
  44502. * An event triggered when a mesh is removed
  44503. */
  44504. onMeshRemovedObservable: Observable<AbstractMesh>;
  44505. /**
  44506. * An event triggered when a skeleton is created
  44507. */
  44508. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44509. /**
  44510. * An event triggered when a skeleton is removed
  44511. */
  44512. onSkeletonRemovedObservable: Observable<Skeleton>;
  44513. /**
  44514. * An event triggered when a material is created
  44515. */
  44516. onNewMaterialAddedObservable: Observable<Material>;
  44517. /**
  44518. * An event triggered when a material is removed
  44519. */
  44520. onMaterialRemovedObservable: Observable<Material>;
  44521. /**
  44522. * An event triggered when a texture is created
  44523. */
  44524. onNewTextureAddedObservable: Observable<BaseTexture>;
  44525. /**
  44526. * An event triggered when a texture is removed
  44527. */
  44528. onTextureRemovedObservable: Observable<BaseTexture>;
  44529. /**
  44530. * An event triggered when render targets are about to be rendered
  44531. * Can happen multiple times per frame.
  44532. */
  44533. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44534. /**
  44535. * An event triggered when render targets were rendered.
  44536. * Can happen multiple times per frame.
  44537. */
  44538. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44539. /**
  44540. * An event triggered before calculating deterministic simulation step
  44541. */
  44542. onBeforeStepObservable: Observable<Scene>;
  44543. /**
  44544. * An event triggered after calculating deterministic simulation step
  44545. */
  44546. onAfterStepObservable: Observable<Scene>;
  44547. /**
  44548. * An event triggered when the activeCamera property is updated
  44549. */
  44550. onActiveCameraChanged: Observable<Scene>;
  44551. /**
  44552. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44553. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44554. * 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)
  44555. */
  44556. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44557. /**
  44558. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44559. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44560. * 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)
  44561. */
  44562. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44563. /**
  44564. * This Observable will when a mesh has been imported into the scene.
  44565. */
  44566. onMeshImportedObservable: Observable<AbstractMesh>;
  44567. /**
  44568. * This Observable will when an animation file has been imported into the scene.
  44569. */
  44570. onAnimationFileImportedObservable: Observable<Scene>;
  44571. /**
  44572. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44573. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44574. */
  44575. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44576. /** @hidden */
  44577. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44578. /**
  44579. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44580. */
  44581. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44582. /**
  44583. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44584. */
  44585. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44586. /**
  44587. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44588. */
  44589. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44590. /** Callback called when a pointer move is detected */
  44591. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44592. /** Callback called when a pointer down is detected */
  44593. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44594. /** Callback called when a pointer up is detected */
  44595. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44596. /** Callback called when a pointer pick is detected */
  44597. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44598. /**
  44599. * 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).
  44600. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44601. */
  44602. onPrePointerObservable: Observable<PointerInfoPre>;
  44603. /**
  44604. * Observable event triggered each time an input event is received from the rendering canvas
  44605. */
  44606. onPointerObservable: Observable<PointerInfo>;
  44607. /**
  44608. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44609. */
  44610. get unTranslatedPointer(): Vector2;
  44611. /**
  44612. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44613. */
  44614. static get DragMovementThreshold(): number;
  44615. static set DragMovementThreshold(value: number);
  44616. /**
  44617. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44618. */
  44619. static get LongPressDelay(): number;
  44620. static set LongPressDelay(value: number);
  44621. /**
  44622. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44623. */
  44624. static get DoubleClickDelay(): number;
  44625. static set DoubleClickDelay(value: number);
  44626. /** If you need to check double click without raising a single click at first click, enable this flag */
  44627. static get ExclusiveDoubleClickMode(): boolean;
  44628. static set ExclusiveDoubleClickMode(value: boolean);
  44629. /** @hidden */
  44630. _mirroredCameraPosition: Nullable<Vector3>;
  44631. /**
  44632. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44633. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44634. */
  44635. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44636. /**
  44637. * Observable event triggered each time an keyboard event is received from the hosting window
  44638. */
  44639. onKeyboardObservable: Observable<KeyboardInfo>;
  44640. private _useRightHandedSystem;
  44641. /**
  44642. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44643. */
  44644. set useRightHandedSystem(value: boolean);
  44645. get useRightHandedSystem(): boolean;
  44646. private _timeAccumulator;
  44647. private _currentStepId;
  44648. private _currentInternalStep;
  44649. /**
  44650. * Sets the step Id used by deterministic lock step
  44651. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44652. * @param newStepId defines the step Id
  44653. */
  44654. setStepId(newStepId: number): void;
  44655. /**
  44656. * Gets the step Id used by deterministic lock step
  44657. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44658. * @returns the step Id
  44659. */
  44660. getStepId(): number;
  44661. /**
  44662. * Gets the internal step used by deterministic lock step
  44663. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44664. * @returns the internal step
  44665. */
  44666. getInternalStep(): number;
  44667. private _fogEnabled;
  44668. /**
  44669. * Gets or sets a boolean indicating if fog is enabled on this scene
  44670. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44671. * (Default is true)
  44672. */
  44673. set fogEnabled(value: boolean);
  44674. get fogEnabled(): boolean;
  44675. private _fogMode;
  44676. /**
  44677. * Gets or sets the fog mode to use
  44678. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44679. * | mode | value |
  44680. * | --- | --- |
  44681. * | FOGMODE_NONE | 0 |
  44682. * | FOGMODE_EXP | 1 |
  44683. * | FOGMODE_EXP2 | 2 |
  44684. * | FOGMODE_LINEAR | 3 |
  44685. */
  44686. set fogMode(value: number);
  44687. get fogMode(): number;
  44688. /**
  44689. * Gets or sets the fog color to use
  44690. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44691. * (Default is Color3(0.2, 0.2, 0.3))
  44692. */
  44693. fogColor: Color3;
  44694. /**
  44695. * Gets or sets the fog density to use
  44696. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44697. * (Default is 0.1)
  44698. */
  44699. fogDensity: number;
  44700. /**
  44701. * Gets or sets the fog start distance to use
  44702. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44703. * (Default is 0)
  44704. */
  44705. fogStart: number;
  44706. /**
  44707. * Gets or sets the fog end distance to use
  44708. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44709. * (Default is 1000)
  44710. */
  44711. fogEnd: number;
  44712. /**
  44713. * Flag indicating that the frame buffer binding is handled by another component
  44714. */
  44715. prePass: boolean;
  44716. private _shadowsEnabled;
  44717. /**
  44718. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44719. */
  44720. set shadowsEnabled(value: boolean);
  44721. get shadowsEnabled(): boolean;
  44722. private _lightsEnabled;
  44723. /**
  44724. * Gets or sets a boolean indicating if lights are enabled on this scene
  44725. */
  44726. set lightsEnabled(value: boolean);
  44727. get lightsEnabled(): boolean;
  44728. /** All of the active cameras added to this scene. */
  44729. activeCameras: Camera[];
  44730. /** @hidden */
  44731. _activeCamera: Nullable<Camera>;
  44732. /** Gets or sets the current active camera */
  44733. get activeCamera(): Nullable<Camera>;
  44734. set activeCamera(value: Nullable<Camera>);
  44735. private _defaultMaterial;
  44736. /** The default material used on meshes when no material is affected */
  44737. get defaultMaterial(): Material;
  44738. /** The default material used on meshes when no material is affected */
  44739. set defaultMaterial(value: Material);
  44740. private _texturesEnabled;
  44741. /**
  44742. * Gets or sets a boolean indicating if textures are enabled on this scene
  44743. */
  44744. set texturesEnabled(value: boolean);
  44745. get texturesEnabled(): boolean;
  44746. /**
  44747. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  44748. */
  44749. physicsEnabled: boolean;
  44750. /**
  44751. * Gets or sets a boolean indicating if particles are enabled on this scene
  44752. */
  44753. particlesEnabled: boolean;
  44754. /**
  44755. * Gets or sets a boolean indicating if sprites are enabled on this scene
  44756. */
  44757. spritesEnabled: boolean;
  44758. private _skeletonsEnabled;
  44759. /**
  44760. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  44761. */
  44762. set skeletonsEnabled(value: boolean);
  44763. get skeletonsEnabled(): boolean;
  44764. /**
  44765. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  44766. */
  44767. lensFlaresEnabled: boolean;
  44768. /**
  44769. * Gets or sets a boolean indicating if collisions are enabled on this scene
  44770. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44771. */
  44772. collisionsEnabled: boolean;
  44773. private _collisionCoordinator;
  44774. /** @hidden */
  44775. get collisionCoordinator(): ICollisionCoordinator;
  44776. /**
  44777. * Defines the gravity applied to this scene (used only for collisions)
  44778. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44779. */
  44780. gravity: Vector3;
  44781. /**
  44782. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  44783. */
  44784. postProcessesEnabled: boolean;
  44785. /**
  44786. * Gets the current postprocess manager
  44787. */
  44788. postProcessManager: PostProcessManager;
  44789. /**
  44790. * Gets or sets a boolean indicating if render targets are enabled on this scene
  44791. */
  44792. renderTargetsEnabled: boolean;
  44793. /**
  44794. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  44795. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  44796. */
  44797. dumpNextRenderTargets: boolean;
  44798. /**
  44799. * The list of user defined render targets added to the scene
  44800. */
  44801. customRenderTargets: RenderTargetTexture[];
  44802. /**
  44803. * Defines if texture loading must be delayed
  44804. * If true, textures will only be loaded when they need to be rendered
  44805. */
  44806. useDelayedTextureLoading: boolean;
  44807. /**
  44808. * Gets the list of meshes imported to the scene through SceneLoader
  44809. */
  44810. importedMeshesFiles: String[];
  44811. /**
  44812. * Gets or sets a boolean indicating if probes are enabled on this scene
  44813. */
  44814. probesEnabled: boolean;
  44815. /**
  44816. * Gets or sets the current offline provider to use to store scene data
  44817. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  44818. */
  44819. offlineProvider: IOfflineProvider;
  44820. /**
  44821. * Gets or sets the action manager associated with the scene
  44822. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44823. */
  44824. actionManager: AbstractActionManager;
  44825. private _meshesForIntersections;
  44826. /**
  44827. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  44828. */
  44829. proceduralTexturesEnabled: boolean;
  44830. private _engine;
  44831. private _totalVertices;
  44832. /** @hidden */
  44833. _activeIndices: PerfCounter;
  44834. /** @hidden */
  44835. _activeParticles: PerfCounter;
  44836. /** @hidden */
  44837. _activeBones: PerfCounter;
  44838. private _animationRatio;
  44839. /** @hidden */
  44840. _animationTimeLast: number;
  44841. /** @hidden */
  44842. _animationTime: number;
  44843. /**
  44844. * Gets or sets a general scale for animation speed
  44845. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  44846. */
  44847. animationTimeScale: number;
  44848. /** @hidden */
  44849. _cachedMaterial: Nullable<Material>;
  44850. /** @hidden */
  44851. _cachedEffect: Nullable<Effect>;
  44852. /** @hidden */
  44853. _cachedVisibility: Nullable<number>;
  44854. private _renderId;
  44855. private _frameId;
  44856. private _executeWhenReadyTimeoutId;
  44857. private _intermediateRendering;
  44858. private _viewUpdateFlag;
  44859. private _projectionUpdateFlag;
  44860. /** @hidden */
  44861. _toBeDisposed: Nullable<IDisposable>[];
  44862. private _activeRequests;
  44863. /** @hidden */
  44864. _pendingData: any[];
  44865. private _isDisposed;
  44866. /**
  44867. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  44868. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  44869. */
  44870. dispatchAllSubMeshesOfActiveMeshes: boolean;
  44871. private _activeMeshes;
  44872. private _processedMaterials;
  44873. private _renderTargets;
  44874. /** @hidden */
  44875. _activeParticleSystems: SmartArray<IParticleSystem>;
  44876. private _activeSkeletons;
  44877. private _softwareSkinnedMeshes;
  44878. private _renderingManager;
  44879. /** @hidden */
  44880. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  44881. private _transformMatrix;
  44882. private _sceneUbo;
  44883. /** @hidden */
  44884. _viewMatrix: Matrix;
  44885. private _projectionMatrix;
  44886. /** @hidden */
  44887. _forcedViewPosition: Nullable<Vector3>;
  44888. /** @hidden */
  44889. _frustumPlanes: Plane[];
  44890. /**
  44891. * Gets the list of frustum planes (built from the active camera)
  44892. */
  44893. get frustumPlanes(): Plane[];
  44894. /**
  44895. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  44896. * This is useful if there are more lights that the maximum simulteanous authorized
  44897. */
  44898. requireLightSorting: boolean;
  44899. /** @hidden */
  44900. readonly useMaterialMeshMap: boolean;
  44901. /** @hidden */
  44902. readonly useClonedMeshMap: boolean;
  44903. private _externalData;
  44904. private _uid;
  44905. /**
  44906. * @hidden
  44907. * Backing store of defined scene components.
  44908. */
  44909. _components: ISceneComponent[];
  44910. /**
  44911. * @hidden
  44912. * Backing store of defined scene components.
  44913. */
  44914. _serializableComponents: ISceneSerializableComponent[];
  44915. /**
  44916. * List of components to register on the next registration step.
  44917. */
  44918. private _transientComponents;
  44919. /**
  44920. * Registers the transient components if needed.
  44921. */
  44922. private _registerTransientComponents;
  44923. /**
  44924. * @hidden
  44925. * Add a component to the scene.
  44926. * Note that the ccomponent could be registered on th next frame if this is called after
  44927. * the register component stage.
  44928. * @param component Defines the component to add to the scene
  44929. */
  44930. _addComponent(component: ISceneComponent): void;
  44931. /**
  44932. * @hidden
  44933. * Gets a component from the scene.
  44934. * @param name defines the name of the component to retrieve
  44935. * @returns the component or null if not present
  44936. */
  44937. _getComponent(name: string): Nullable<ISceneComponent>;
  44938. /**
  44939. * @hidden
  44940. * Defines the actions happening before camera updates.
  44941. */
  44942. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  44943. /**
  44944. * @hidden
  44945. * Defines the actions happening before clear the canvas.
  44946. */
  44947. _beforeClearStage: Stage<SimpleStageAction>;
  44948. /**
  44949. * @hidden
  44950. * Defines the actions when collecting render targets for the frame.
  44951. */
  44952. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44953. /**
  44954. * @hidden
  44955. * Defines the actions happening for one camera in the frame.
  44956. */
  44957. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44958. /**
  44959. * @hidden
  44960. * Defines the actions happening during the per mesh ready checks.
  44961. */
  44962. _isReadyForMeshStage: Stage<MeshStageAction>;
  44963. /**
  44964. * @hidden
  44965. * Defines the actions happening before evaluate active mesh checks.
  44966. */
  44967. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  44968. /**
  44969. * @hidden
  44970. * Defines the actions happening during the evaluate sub mesh checks.
  44971. */
  44972. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  44973. /**
  44974. * @hidden
  44975. * Defines the actions happening during the active mesh stage.
  44976. */
  44977. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  44978. /**
  44979. * @hidden
  44980. * Defines the actions happening during the per camera render target step.
  44981. */
  44982. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  44983. /**
  44984. * @hidden
  44985. * Defines the actions happening just before the active camera is drawing.
  44986. */
  44987. _beforeCameraDrawStage: Stage<CameraStageAction>;
  44988. /**
  44989. * @hidden
  44990. * Defines the actions happening just before a render target is drawing.
  44991. */
  44992. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44993. /**
  44994. * @hidden
  44995. * Defines the actions happening just before a rendering group is drawing.
  44996. */
  44997. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44998. /**
  44999. * @hidden
  45000. * Defines the actions happening just before a mesh is drawing.
  45001. */
  45002. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45003. /**
  45004. * @hidden
  45005. * Defines the actions happening just after a mesh has been drawn.
  45006. */
  45007. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45008. /**
  45009. * @hidden
  45010. * Defines the actions happening just after a rendering group has been drawn.
  45011. */
  45012. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45013. /**
  45014. * @hidden
  45015. * Defines the actions happening just after the active camera has been drawn.
  45016. */
  45017. _afterCameraDrawStage: Stage<CameraStageAction>;
  45018. /**
  45019. * @hidden
  45020. * Defines the actions happening just after a render target has been drawn.
  45021. */
  45022. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45023. /**
  45024. * @hidden
  45025. * Defines the actions happening just after rendering all cameras and computing intersections.
  45026. */
  45027. _afterRenderStage: Stage<SimpleStageAction>;
  45028. /**
  45029. * @hidden
  45030. * Defines the actions happening when a pointer move event happens.
  45031. */
  45032. _pointerMoveStage: Stage<PointerMoveStageAction>;
  45033. /**
  45034. * @hidden
  45035. * Defines the actions happening when a pointer down event happens.
  45036. */
  45037. _pointerDownStage: Stage<PointerUpDownStageAction>;
  45038. /**
  45039. * @hidden
  45040. * Defines the actions happening when a pointer up event happens.
  45041. */
  45042. _pointerUpStage: Stage<PointerUpDownStageAction>;
  45043. /**
  45044. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  45045. */
  45046. private geometriesByUniqueId;
  45047. /**
  45048. * Creates a new Scene
  45049. * @param engine defines the engine to use to render this scene
  45050. * @param options defines the scene options
  45051. */
  45052. constructor(engine: Engine, options?: SceneOptions);
  45053. /**
  45054. * Gets a string identifying the name of the class
  45055. * @returns "Scene" string
  45056. */
  45057. getClassName(): string;
  45058. private _defaultMeshCandidates;
  45059. /**
  45060. * @hidden
  45061. */
  45062. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45063. private _defaultSubMeshCandidates;
  45064. /**
  45065. * @hidden
  45066. */
  45067. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45068. /**
  45069. * Sets the default candidate providers for the scene.
  45070. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  45071. * and getCollidingSubMeshCandidates to their default function
  45072. */
  45073. setDefaultCandidateProviders(): void;
  45074. /**
  45075. * Gets the mesh that is currently under the pointer
  45076. */
  45077. get meshUnderPointer(): Nullable<AbstractMesh>;
  45078. /**
  45079. * Gets or sets the current on-screen X position of the pointer
  45080. */
  45081. get pointerX(): number;
  45082. set pointerX(value: number);
  45083. /**
  45084. * Gets or sets the current on-screen Y position of the pointer
  45085. */
  45086. get pointerY(): number;
  45087. set pointerY(value: number);
  45088. /**
  45089. * Gets the cached material (ie. the latest rendered one)
  45090. * @returns the cached material
  45091. */
  45092. getCachedMaterial(): Nullable<Material>;
  45093. /**
  45094. * Gets the cached effect (ie. the latest rendered one)
  45095. * @returns the cached effect
  45096. */
  45097. getCachedEffect(): Nullable<Effect>;
  45098. /**
  45099. * Gets the cached visibility state (ie. the latest rendered one)
  45100. * @returns the cached visibility state
  45101. */
  45102. getCachedVisibility(): Nullable<number>;
  45103. /**
  45104. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  45105. * @param material defines the current material
  45106. * @param effect defines the current effect
  45107. * @param visibility defines the current visibility state
  45108. * @returns true if one parameter is not cached
  45109. */
  45110. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  45111. /**
  45112. * Gets the engine associated with the scene
  45113. * @returns an Engine
  45114. */
  45115. getEngine(): Engine;
  45116. /**
  45117. * Gets the total number of vertices rendered per frame
  45118. * @returns the total number of vertices rendered per frame
  45119. */
  45120. getTotalVertices(): number;
  45121. /**
  45122. * Gets the performance counter for total vertices
  45123. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45124. */
  45125. get totalVerticesPerfCounter(): PerfCounter;
  45126. /**
  45127. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  45128. * @returns the total number of active indices rendered per frame
  45129. */
  45130. getActiveIndices(): number;
  45131. /**
  45132. * Gets the performance counter for active indices
  45133. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45134. */
  45135. get totalActiveIndicesPerfCounter(): PerfCounter;
  45136. /**
  45137. * Gets the total number of active particles rendered per frame
  45138. * @returns the total number of active particles rendered per frame
  45139. */
  45140. getActiveParticles(): number;
  45141. /**
  45142. * Gets the performance counter for active particles
  45143. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45144. */
  45145. get activeParticlesPerfCounter(): PerfCounter;
  45146. /**
  45147. * Gets the total number of active bones rendered per frame
  45148. * @returns the total number of active bones rendered per frame
  45149. */
  45150. getActiveBones(): number;
  45151. /**
  45152. * Gets the performance counter for active bones
  45153. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45154. */
  45155. get activeBonesPerfCounter(): PerfCounter;
  45156. /**
  45157. * Gets the array of active meshes
  45158. * @returns an array of AbstractMesh
  45159. */
  45160. getActiveMeshes(): SmartArray<AbstractMesh>;
  45161. /**
  45162. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  45163. * @returns a number
  45164. */
  45165. getAnimationRatio(): number;
  45166. /**
  45167. * Gets an unique Id for the current render phase
  45168. * @returns a number
  45169. */
  45170. getRenderId(): number;
  45171. /**
  45172. * Gets an unique Id for the current frame
  45173. * @returns a number
  45174. */
  45175. getFrameId(): number;
  45176. /** Call this function if you want to manually increment the render Id*/
  45177. incrementRenderId(): void;
  45178. private _createUbo;
  45179. /**
  45180. * Use this method to simulate a pointer move on a mesh
  45181. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45182. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45183. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45184. * @returns the current scene
  45185. */
  45186. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45187. /**
  45188. * Use this method to simulate a pointer down on a mesh
  45189. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45190. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45191. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45192. * @returns the current scene
  45193. */
  45194. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45195. /**
  45196. * Use this method to simulate a pointer up on a mesh
  45197. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45198. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45199. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45200. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45201. * @returns the current scene
  45202. */
  45203. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  45204. /**
  45205. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45206. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45207. * @returns true if the pointer was captured
  45208. */
  45209. isPointerCaptured(pointerId?: number): boolean;
  45210. /**
  45211. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45212. * @param attachUp defines if you want to attach events to pointerup
  45213. * @param attachDown defines if you want to attach events to pointerdown
  45214. * @param attachMove defines if you want to attach events to pointermove
  45215. */
  45216. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  45217. /** Detaches all event handlers*/
  45218. detachControl(): void;
  45219. /**
  45220. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  45221. * Delay loaded resources are not taking in account
  45222. * @return true if all required resources are ready
  45223. */
  45224. isReady(): boolean;
  45225. /** Resets all cached information relative to material (including effect and visibility) */
  45226. resetCachedMaterial(): void;
  45227. /**
  45228. * Registers a function to be called before every frame render
  45229. * @param func defines the function to register
  45230. */
  45231. registerBeforeRender(func: () => void): void;
  45232. /**
  45233. * Unregisters a function called before every frame render
  45234. * @param func defines the function to unregister
  45235. */
  45236. unregisterBeforeRender(func: () => void): void;
  45237. /**
  45238. * Registers a function to be called after every frame render
  45239. * @param func defines the function to register
  45240. */
  45241. registerAfterRender(func: () => void): void;
  45242. /**
  45243. * Unregisters a function called after every frame render
  45244. * @param func defines the function to unregister
  45245. */
  45246. unregisterAfterRender(func: () => void): void;
  45247. private _executeOnceBeforeRender;
  45248. /**
  45249. * The provided function will run before render once and will be disposed afterwards.
  45250. * A timeout delay can be provided so that the function will be executed in N ms.
  45251. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45252. * @param func The function to be executed.
  45253. * @param timeout optional delay in ms
  45254. */
  45255. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45256. /** @hidden */
  45257. _addPendingData(data: any): void;
  45258. /** @hidden */
  45259. _removePendingData(data: any): void;
  45260. /**
  45261. * Returns the number of items waiting to be loaded
  45262. * @returns the number of items waiting to be loaded
  45263. */
  45264. getWaitingItemsCount(): number;
  45265. /**
  45266. * Returns a boolean indicating if the scene is still loading data
  45267. */
  45268. get isLoading(): boolean;
  45269. /**
  45270. * Registers a function to be executed when the scene is ready
  45271. * @param {Function} func - the function to be executed
  45272. */
  45273. executeWhenReady(func: () => void): void;
  45274. /**
  45275. * Returns a promise that resolves when the scene is ready
  45276. * @returns A promise that resolves when the scene is ready
  45277. */
  45278. whenReadyAsync(): Promise<void>;
  45279. /** @hidden */
  45280. _checkIsReady(): void;
  45281. /**
  45282. * Gets all animatable attached to the scene
  45283. */
  45284. get animatables(): Animatable[];
  45285. /**
  45286. * Resets the last animation time frame.
  45287. * Useful to override when animations start running when loading a scene for the first time.
  45288. */
  45289. resetLastAnimationTimeFrame(): void;
  45290. /**
  45291. * Gets the current view matrix
  45292. * @returns a Matrix
  45293. */
  45294. getViewMatrix(): Matrix;
  45295. /**
  45296. * Gets the current projection matrix
  45297. * @returns a Matrix
  45298. */
  45299. getProjectionMatrix(): Matrix;
  45300. /**
  45301. * Gets the current transform matrix
  45302. * @returns a Matrix made of View * Projection
  45303. */
  45304. getTransformMatrix(): Matrix;
  45305. /**
  45306. * Sets the current transform matrix
  45307. * @param viewL defines the View matrix to use
  45308. * @param projectionL defines the Projection matrix to use
  45309. * @param viewR defines the right View matrix to use (if provided)
  45310. * @param projectionR defines the right Projection matrix to use (if provided)
  45311. */
  45312. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45313. /**
  45314. * Gets the uniform buffer used to store scene data
  45315. * @returns a UniformBuffer
  45316. */
  45317. getSceneUniformBuffer(): UniformBuffer;
  45318. /**
  45319. * Gets an unique (relatively to the current scene) Id
  45320. * @returns an unique number for the scene
  45321. */
  45322. getUniqueId(): number;
  45323. /**
  45324. * Add a mesh to the list of scene's meshes
  45325. * @param newMesh defines the mesh to add
  45326. * @param recursive if all child meshes should also be added to the scene
  45327. */
  45328. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45329. /**
  45330. * Remove a mesh for the list of scene's meshes
  45331. * @param toRemove defines the mesh to remove
  45332. * @param recursive if all child meshes should also be removed from the scene
  45333. * @returns the index where the mesh was in the mesh list
  45334. */
  45335. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45336. /**
  45337. * Add a transform node to the list of scene's transform nodes
  45338. * @param newTransformNode defines the transform node to add
  45339. */
  45340. addTransformNode(newTransformNode: TransformNode): void;
  45341. /**
  45342. * Remove a transform node for the list of scene's transform nodes
  45343. * @param toRemove defines the transform node to remove
  45344. * @returns the index where the transform node was in the transform node list
  45345. */
  45346. removeTransformNode(toRemove: TransformNode): number;
  45347. /**
  45348. * Remove a skeleton for the list of scene's skeletons
  45349. * @param toRemove defines the skeleton to remove
  45350. * @returns the index where the skeleton was in the skeleton list
  45351. */
  45352. removeSkeleton(toRemove: Skeleton): number;
  45353. /**
  45354. * Remove a morph target for the list of scene's morph targets
  45355. * @param toRemove defines the morph target to remove
  45356. * @returns the index where the morph target was in the morph target list
  45357. */
  45358. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45359. /**
  45360. * Remove a light for the list of scene's lights
  45361. * @param toRemove defines the light to remove
  45362. * @returns the index where the light was in the light list
  45363. */
  45364. removeLight(toRemove: Light): number;
  45365. /**
  45366. * Remove a camera for the list of scene's cameras
  45367. * @param toRemove defines the camera to remove
  45368. * @returns the index where the camera was in the camera list
  45369. */
  45370. removeCamera(toRemove: Camera): number;
  45371. /**
  45372. * Remove a particle system for the list of scene's particle systems
  45373. * @param toRemove defines the particle system to remove
  45374. * @returns the index where the particle system was in the particle system list
  45375. */
  45376. removeParticleSystem(toRemove: IParticleSystem): number;
  45377. /**
  45378. * Remove a animation for the list of scene's animations
  45379. * @param toRemove defines the animation to remove
  45380. * @returns the index where the animation was in the animation list
  45381. */
  45382. removeAnimation(toRemove: Animation): number;
  45383. /**
  45384. * Will stop the animation of the given target
  45385. * @param target - the target
  45386. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45387. * @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)
  45388. */
  45389. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45390. /**
  45391. * Removes the given animation group from this scene.
  45392. * @param toRemove The animation group to remove
  45393. * @returns The index of the removed animation group
  45394. */
  45395. removeAnimationGroup(toRemove: AnimationGroup): number;
  45396. /**
  45397. * Removes the given multi-material from this scene.
  45398. * @param toRemove The multi-material to remove
  45399. * @returns The index of the removed multi-material
  45400. */
  45401. removeMultiMaterial(toRemove: MultiMaterial): number;
  45402. /**
  45403. * Removes the given material from this scene.
  45404. * @param toRemove The material to remove
  45405. * @returns The index of the removed material
  45406. */
  45407. removeMaterial(toRemove: Material): number;
  45408. /**
  45409. * Removes the given action manager from this scene.
  45410. * @param toRemove The action manager to remove
  45411. * @returns The index of the removed action manager
  45412. */
  45413. removeActionManager(toRemove: AbstractActionManager): number;
  45414. /**
  45415. * Removes the given texture from this scene.
  45416. * @param toRemove The texture to remove
  45417. * @returns The index of the removed texture
  45418. */
  45419. removeTexture(toRemove: BaseTexture): number;
  45420. /**
  45421. * Adds the given light to this scene
  45422. * @param newLight The light to add
  45423. */
  45424. addLight(newLight: Light): void;
  45425. /**
  45426. * Sorts the list list based on light priorities
  45427. */
  45428. sortLightsByPriority(): void;
  45429. /**
  45430. * Adds the given camera to this scene
  45431. * @param newCamera The camera to add
  45432. */
  45433. addCamera(newCamera: Camera): void;
  45434. /**
  45435. * Adds the given skeleton to this scene
  45436. * @param newSkeleton The skeleton to add
  45437. */
  45438. addSkeleton(newSkeleton: Skeleton): void;
  45439. /**
  45440. * Adds the given particle system to this scene
  45441. * @param newParticleSystem The particle system to add
  45442. */
  45443. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45444. /**
  45445. * Adds the given animation to this scene
  45446. * @param newAnimation The animation to add
  45447. */
  45448. addAnimation(newAnimation: Animation): void;
  45449. /**
  45450. * Adds the given animation group to this scene.
  45451. * @param newAnimationGroup The animation group to add
  45452. */
  45453. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45454. /**
  45455. * Adds the given multi-material to this scene
  45456. * @param newMultiMaterial The multi-material to add
  45457. */
  45458. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45459. /**
  45460. * Adds the given material to this scene
  45461. * @param newMaterial The material to add
  45462. */
  45463. addMaterial(newMaterial: Material): void;
  45464. /**
  45465. * Adds the given morph target to this scene
  45466. * @param newMorphTargetManager The morph target to add
  45467. */
  45468. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45469. /**
  45470. * Adds the given geometry to this scene
  45471. * @param newGeometry The geometry to add
  45472. */
  45473. addGeometry(newGeometry: Geometry): void;
  45474. /**
  45475. * Adds the given action manager to this scene
  45476. * @param newActionManager The action manager to add
  45477. */
  45478. addActionManager(newActionManager: AbstractActionManager): void;
  45479. /**
  45480. * Adds the given texture to this scene.
  45481. * @param newTexture The texture to add
  45482. */
  45483. addTexture(newTexture: BaseTexture): void;
  45484. /**
  45485. * Switch active camera
  45486. * @param newCamera defines the new active camera
  45487. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45488. */
  45489. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45490. /**
  45491. * sets the active camera of the scene using its ID
  45492. * @param id defines the camera's ID
  45493. * @return the new active camera or null if none found.
  45494. */
  45495. setActiveCameraByID(id: string): Nullable<Camera>;
  45496. /**
  45497. * sets the active camera of the scene using its name
  45498. * @param name defines the camera's name
  45499. * @returns the new active camera or null if none found.
  45500. */
  45501. setActiveCameraByName(name: string): Nullable<Camera>;
  45502. /**
  45503. * get an animation group using its name
  45504. * @param name defines the material's name
  45505. * @return the animation group or null if none found.
  45506. */
  45507. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45508. /**
  45509. * Get a material using its unique id
  45510. * @param uniqueId defines the material's unique id
  45511. * @return the material or null if none found.
  45512. */
  45513. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45514. /**
  45515. * get a material using its id
  45516. * @param id defines the material's ID
  45517. * @return the material or null if none found.
  45518. */
  45519. getMaterialByID(id: string): Nullable<Material>;
  45520. /**
  45521. * Gets a the last added material using a given id
  45522. * @param id defines the material's ID
  45523. * @return the last material with the given id or null if none found.
  45524. */
  45525. getLastMaterialByID(id: string): Nullable<Material>;
  45526. /**
  45527. * Gets a material using its name
  45528. * @param name defines the material's name
  45529. * @return the material or null if none found.
  45530. */
  45531. getMaterialByName(name: string): Nullable<Material>;
  45532. /**
  45533. * Get a texture using its unique id
  45534. * @param uniqueId defines the texture's unique id
  45535. * @return the texture or null if none found.
  45536. */
  45537. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45538. /**
  45539. * Gets a camera using its id
  45540. * @param id defines the id to look for
  45541. * @returns the camera or null if not found
  45542. */
  45543. getCameraByID(id: string): Nullable<Camera>;
  45544. /**
  45545. * Gets a camera using its unique id
  45546. * @param uniqueId defines the unique id to look for
  45547. * @returns the camera or null if not found
  45548. */
  45549. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45550. /**
  45551. * Gets a camera using its name
  45552. * @param name defines the camera's name
  45553. * @return the camera or null if none found.
  45554. */
  45555. getCameraByName(name: string): Nullable<Camera>;
  45556. /**
  45557. * Gets a bone using its id
  45558. * @param id defines the bone's id
  45559. * @return the bone or null if not found
  45560. */
  45561. getBoneByID(id: string): Nullable<Bone>;
  45562. /**
  45563. * Gets a bone using its id
  45564. * @param name defines the bone's name
  45565. * @return the bone or null if not found
  45566. */
  45567. getBoneByName(name: string): Nullable<Bone>;
  45568. /**
  45569. * Gets a light node using its name
  45570. * @param name defines the the light's name
  45571. * @return the light or null if none found.
  45572. */
  45573. getLightByName(name: string): Nullable<Light>;
  45574. /**
  45575. * Gets a light node using its id
  45576. * @param id defines the light's id
  45577. * @return the light or null if none found.
  45578. */
  45579. getLightByID(id: string): Nullable<Light>;
  45580. /**
  45581. * Gets a light node using its scene-generated unique ID
  45582. * @param uniqueId defines the light's unique id
  45583. * @return the light or null if none found.
  45584. */
  45585. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45586. /**
  45587. * Gets a particle system by id
  45588. * @param id defines the particle system id
  45589. * @return the corresponding system or null if none found
  45590. */
  45591. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45592. /**
  45593. * Gets a geometry using its ID
  45594. * @param id defines the geometry's id
  45595. * @return the geometry or null if none found.
  45596. */
  45597. getGeometryByID(id: string): Nullable<Geometry>;
  45598. private _getGeometryByUniqueID;
  45599. /**
  45600. * Add a new geometry to this scene
  45601. * @param geometry defines the geometry to be added to the scene.
  45602. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45603. * @return a boolean defining if the geometry was added or not
  45604. */
  45605. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45606. /**
  45607. * Removes an existing geometry
  45608. * @param geometry defines the geometry to be removed from the scene
  45609. * @return a boolean defining if the geometry was removed or not
  45610. */
  45611. removeGeometry(geometry: Geometry): boolean;
  45612. /**
  45613. * Gets the list of geometries attached to the scene
  45614. * @returns an array of Geometry
  45615. */
  45616. getGeometries(): Geometry[];
  45617. /**
  45618. * Gets the first added mesh found of a given ID
  45619. * @param id defines the id to search for
  45620. * @return the mesh found or null if not found at all
  45621. */
  45622. getMeshByID(id: string): Nullable<AbstractMesh>;
  45623. /**
  45624. * Gets a list of meshes using their id
  45625. * @param id defines the id to search for
  45626. * @returns a list of meshes
  45627. */
  45628. getMeshesByID(id: string): Array<AbstractMesh>;
  45629. /**
  45630. * Gets the first added transform node found of a given ID
  45631. * @param id defines the id to search for
  45632. * @return the found transform node or null if not found at all.
  45633. */
  45634. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45635. /**
  45636. * Gets a transform node with its auto-generated unique id
  45637. * @param uniqueId efines the unique id to search for
  45638. * @return the found transform node or null if not found at all.
  45639. */
  45640. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45641. /**
  45642. * Gets a list of transform nodes using their id
  45643. * @param id defines the id to search for
  45644. * @returns a list of transform nodes
  45645. */
  45646. getTransformNodesByID(id: string): Array<TransformNode>;
  45647. /**
  45648. * Gets a mesh with its auto-generated unique id
  45649. * @param uniqueId defines the unique id to search for
  45650. * @return the found mesh or null if not found at all.
  45651. */
  45652. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45653. /**
  45654. * Gets a the last added mesh using a given id
  45655. * @param id defines the id to search for
  45656. * @return the found mesh or null if not found at all.
  45657. */
  45658. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45659. /**
  45660. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45661. * @param id defines the id to search for
  45662. * @return the found node or null if not found at all
  45663. */
  45664. getLastEntryByID(id: string): Nullable<Node>;
  45665. /**
  45666. * Gets a node (Mesh, Camera, Light) using a given id
  45667. * @param id defines the id to search for
  45668. * @return the found node or null if not found at all
  45669. */
  45670. getNodeByID(id: string): Nullable<Node>;
  45671. /**
  45672. * Gets a node (Mesh, Camera, Light) using a given name
  45673. * @param name defines the name to search for
  45674. * @return the found node or null if not found at all.
  45675. */
  45676. getNodeByName(name: string): Nullable<Node>;
  45677. /**
  45678. * Gets a mesh using a given name
  45679. * @param name defines the name to search for
  45680. * @return the found mesh or null if not found at all.
  45681. */
  45682. getMeshByName(name: string): Nullable<AbstractMesh>;
  45683. /**
  45684. * Gets a transform node using a given name
  45685. * @param name defines the name to search for
  45686. * @return the found transform node or null if not found at all.
  45687. */
  45688. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45689. /**
  45690. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45691. * @param id defines the id to search for
  45692. * @return the found skeleton or null if not found at all.
  45693. */
  45694. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45695. /**
  45696. * Gets a skeleton using a given auto generated unique id
  45697. * @param uniqueId defines the unique id to search for
  45698. * @return the found skeleton or null if not found at all.
  45699. */
  45700. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45701. /**
  45702. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45703. * @param id defines the id to search for
  45704. * @return the found skeleton or null if not found at all.
  45705. */
  45706. getSkeletonById(id: string): Nullable<Skeleton>;
  45707. /**
  45708. * Gets a skeleton using a given name
  45709. * @param name defines the name to search for
  45710. * @return the found skeleton or null if not found at all.
  45711. */
  45712. getSkeletonByName(name: string): Nullable<Skeleton>;
  45713. /**
  45714. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45715. * @param id defines the id to search for
  45716. * @return the found morph target manager or null if not found at all.
  45717. */
  45718. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45719. /**
  45720. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45721. * @param id defines the id to search for
  45722. * @return the found morph target or null if not found at all.
  45723. */
  45724. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45725. /**
  45726. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45727. * @param name defines the name to search for
  45728. * @return the found morph target or null if not found at all.
  45729. */
  45730. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45731. /**
  45732. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45733. * @param name defines the name to search for
  45734. * @return the found post process or null if not found at all.
  45735. */
  45736. getPostProcessByName(name: string): Nullable<PostProcess>;
  45737. /**
  45738. * Gets a boolean indicating if the given mesh is active
  45739. * @param mesh defines the mesh to look for
  45740. * @returns true if the mesh is in the active list
  45741. */
  45742. isActiveMesh(mesh: AbstractMesh): boolean;
  45743. /**
  45744. * Return a unique id as a string which can serve as an identifier for the scene
  45745. */
  45746. get uid(): string;
  45747. /**
  45748. * Add an externaly attached data from its key.
  45749. * This method call will fail and return false, if such key already exists.
  45750. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  45751. * @param key the unique key that identifies the data
  45752. * @param data the data object to associate to the key for this Engine instance
  45753. * @return true if no such key were already present and the data was added successfully, false otherwise
  45754. */
  45755. addExternalData<T>(key: string, data: T): boolean;
  45756. /**
  45757. * Get an externaly attached data from its key
  45758. * @param key the unique key that identifies the data
  45759. * @return the associated data, if present (can be null), or undefined if not present
  45760. */
  45761. getExternalData<T>(key: string): Nullable<T>;
  45762. /**
  45763. * Get an externaly attached data from its key, create it using a factory if it's not already present
  45764. * @param key the unique key that identifies the data
  45765. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  45766. * @return the associated data, can be null if the factory returned null.
  45767. */
  45768. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  45769. /**
  45770. * Remove an externaly attached data from the Engine instance
  45771. * @param key the unique key that identifies the data
  45772. * @return true if the data was successfully removed, false if it doesn't exist
  45773. */
  45774. removeExternalData(key: string): boolean;
  45775. private _evaluateSubMesh;
  45776. /**
  45777. * Clear the processed materials smart array preventing retention point in material dispose.
  45778. */
  45779. freeProcessedMaterials(): void;
  45780. private _preventFreeActiveMeshesAndRenderingGroups;
  45781. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  45782. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  45783. * when disposing several meshes in a row or a hierarchy of meshes.
  45784. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  45785. */
  45786. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  45787. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  45788. /**
  45789. * Clear the active meshes smart array preventing retention point in mesh dispose.
  45790. */
  45791. freeActiveMeshes(): void;
  45792. /**
  45793. * Clear the info related to rendering groups preventing retention points during dispose.
  45794. */
  45795. freeRenderingGroups(): void;
  45796. /** @hidden */
  45797. _isInIntermediateRendering(): boolean;
  45798. /**
  45799. * Lambda returning the list of potentially active meshes.
  45800. */
  45801. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  45802. /**
  45803. * Lambda returning the list of potentially active sub meshes.
  45804. */
  45805. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  45806. /**
  45807. * Lambda returning the list of potentially intersecting sub meshes.
  45808. */
  45809. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  45810. /**
  45811. * Lambda returning the list of potentially colliding sub meshes.
  45812. */
  45813. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  45814. private _activeMeshesFrozen;
  45815. private _skipEvaluateActiveMeshesCompletely;
  45816. /**
  45817. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  45818. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  45819. * @param onSuccess optional success callback
  45820. * @param onError optional error callback
  45821. * @returns the current scene
  45822. */
  45823. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  45824. /**
  45825. * Use this function to restart evaluating active meshes on every frame
  45826. * @returns the current scene
  45827. */
  45828. unfreezeActiveMeshes(): Scene;
  45829. private _evaluateActiveMeshes;
  45830. private _activeMesh;
  45831. /**
  45832. * Update the transform matrix to update from the current active camera
  45833. * @param force defines a boolean used to force the update even if cache is up to date
  45834. */
  45835. updateTransformMatrix(force?: boolean): void;
  45836. private _bindFrameBuffer;
  45837. /** @hidden */
  45838. _allowPostProcessClearColor: boolean;
  45839. /** @hidden */
  45840. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  45841. private _processSubCameras;
  45842. private _checkIntersections;
  45843. /** @hidden */
  45844. _advancePhysicsEngineStep(step: number): void;
  45845. /**
  45846. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  45847. */
  45848. getDeterministicFrameTime: () => number;
  45849. /** @hidden */
  45850. _animate(): void;
  45851. /** Execute all animations (for a frame) */
  45852. animate(): void;
  45853. /**
  45854. * Render the scene
  45855. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  45856. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  45857. */
  45858. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  45859. /**
  45860. * Freeze all materials
  45861. * A frozen material will not be updatable but should be faster to render
  45862. */
  45863. freezeMaterials(): void;
  45864. /**
  45865. * Unfreeze all materials
  45866. * A frozen material will not be updatable but should be faster to render
  45867. */
  45868. unfreezeMaterials(): void;
  45869. /**
  45870. * Releases all held ressources
  45871. */
  45872. dispose(): void;
  45873. /**
  45874. * Gets if the scene is already disposed
  45875. */
  45876. get isDisposed(): boolean;
  45877. /**
  45878. * Call this function to reduce memory footprint of the scene.
  45879. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  45880. */
  45881. clearCachedVertexData(): void;
  45882. /**
  45883. * This function will remove the local cached buffer data from texture.
  45884. * It will save memory but will prevent the texture from being rebuilt
  45885. */
  45886. cleanCachedTextureBuffer(): void;
  45887. /**
  45888. * Get the world extend vectors with an optional filter
  45889. *
  45890. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  45891. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  45892. */
  45893. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  45894. min: Vector3;
  45895. max: Vector3;
  45896. };
  45897. /**
  45898. * Creates a ray that can be used to pick in the scene
  45899. * @param x defines the x coordinate of the origin (on-screen)
  45900. * @param y defines the y coordinate of the origin (on-screen)
  45901. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45902. * @param camera defines the camera to use for the picking
  45903. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45904. * @returns a Ray
  45905. */
  45906. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  45907. /**
  45908. * Creates a ray that can be used to pick in the scene
  45909. * @param x defines the x coordinate of the origin (on-screen)
  45910. * @param y defines the y coordinate of the origin (on-screen)
  45911. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45912. * @param result defines the ray where to store the picking ray
  45913. * @param camera defines the camera to use for the picking
  45914. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45915. * @returns the current scene
  45916. */
  45917. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  45918. /**
  45919. * Creates a ray that can be used to pick in the scene
  45920. * @param x defines the x coordinate of the origin (on-screen)
  45921. * @param y defines the y coordinate of the origin (on-screen)
  45922. * @param camera defines the camera to use for the picking
  45923. * @returns a Ray
  45924. */
  45925. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  45926. /**
  45927. * Creates a ray that can be used to pick in the scene
  45928. * @param x defines the x coordinate of the origin (on-screen)
  45929. * @param y defines the y coordinate of the origin (on-screen)
  45930. * @param result defines the ray where to store the picking ray
  45931. * @param camera defines the camera to use for the picking
  45932. * @returns the current scene
  45933. */
  45934. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  45935. /** Launch a ray to try to pick a mesh in the scene
  45936. * @param x position on screen
  45937. * @param y position on screen
  45938. * @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
  45939. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45940. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45941. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45942. * @returns a PickingInfo
  45943. */
  45944. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45945. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  45946. * @param x position on screen
  45947. * @param y position on screen
  45948. * @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
  45949. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45950. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45951. * @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)
  45952. */
  45953. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  45954. /** Use the given ray to pick a mesh in the scene
  45955. * @param ray The ray to use to pick meshes
  45956. * @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
  45957. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45958. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45959. * @returns a PickingInfo
  45960. */
  45961. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45962. /**
  45963. * Launch a ray to try to pick a mesh in the scene
  45964. * @param x X position on screen
  45965. * @param y Y position on screen
  45966. * @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
  45967. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45968. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45969. * @returns an array of PickingInfo
  45970. */
  45971. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45972. /**
  45973. * Launch a ray to try to pick a mesh in the scene
  45974. * @param ray Ray to use
  45975. * @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
  45976. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45977. * @returns an array of PickingInfo
  45978. */
  45979. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45980. /**
  45981. * Force the value of meshUnderPointer
  45982. * @param mesh defines the mesh to use
  45983. * @param pointerId optional pointer id when using more than one pointer
  45984. */
  45985. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45986. /**
  45987. * Gets the mesh under the pointer
  45988. * @returns a Mesh or null if no mesh is under the pointer
  45989. */
  45990. getPointerOverMesh(): Nullable<AbstractMesh>;
  45991. /** @hidden */
  45992. _rebuildGeometries(): void;
  45993. /** @hidden */
  45994. _rebuildTextures(): void;
  45995. private _getByTags;
  45996. /**
  45997. * Get a list of meshes by tags
  45998. * @param tagsQuery defines the tags query to use
  45999. * @param forEach defines a predicate used to filter results
  46000. * @returns an array of Mesh
  46001. */
  46002. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  46003. /**
  46004. * Get a list of cameras by tags
  46005. * @param tagsQuery defines the tags query to use
  46006. * @param forEach defines a predicate used to filter results
  46007. * @returns an array of Camera
  46008. */
  46009. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  46010. /**
  46011. * Get a list of lights by tags
  46012. * @param tagsQuery defines the tags query to use
  46013. * @param forEach defines a predicate used to filter results
  46014. * @returns an array of Light
  46015. */
  46016. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  46017. /**
  46018. * Get a list of materials by tags
  46019. * @param tagsQuery defines the tags query to use
  46020. * @param forEach defines a predicate used to filter results
  46021. * @returns an array of Material
  46022. */
  46023. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  46024. /**
  46025. * Get a list of transform nodes by tags
  46026. * @param tagsQuery defines the tags query to use
  46027. * @param forEach defines a predicate used to filter results
  46028. * @returns an array of TransformNode
  46029. */
  46030. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  46031. /**
  46032. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  46033. * This allowed control for front to back rendering or reversly depending of the special needs.
  46034. *
  46035. * @param renderingGroupId The rendering group id corresponding to its index
  46036. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  46037. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  46038. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  46039. */
  46040. 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;
  46041. /**
  46042. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  46043. *
  46044. * @param renderingGroupId The rendering group id corresponding to its index
  46045. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46046. * @param depth Automatically clears depth between groups if true and autoClear is true.
  46047. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  46048. */
  46049. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  46050. /**
  46051. * Gets the current auto clear configuration for one rendering group of the rendering
  46052. * manager.
  46053. * @param index the rendering group index to get the information for
  46054. * @returns The auto clear setup for the requested rendering group
  46055. */
  46056. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  46057. private _blockMaterialDirtyMechanism;
  46058. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  46059. get blockMaterialDirtyMechanism(): boolean;
  46060. set blockMaterialDirtyMechanism(value: boolean);
  46061. /**
  46062. * Will flag all materials as dirty to trigger new shader compilation
  46063. * @param flag defines the flag used to specify which material part must be marked as dirty
  46064. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  46065. */
  46066. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  46067. /** @hidden */
  46068. _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;
  46069. /** @hidden */
  46070. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46071. /** @hidden */
  46072. _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;
  46073. /** @hidden */
  46074. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  46075. /** @hidden */
  46076. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  46077. /** @hidden */
  46078. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46079. }
  46080. }
  46081. declare module "babylonjs/assetContainer" {
  46082. import { AbstractScene } from "babylonjs/abstractScene";
  46083. import { Scene } from "babylonjs/scene";
  46084. import { Mesh } from "babylonjs/Meshes/mesh";
  46085. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46086. import { Skeleton } from "babylonjs/Bones/skeleton";
  46087. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46088. import { Animatable } from "babylonjs/Animations/animatable";
  46089. import { Nullable } from "babylonjs/types";
  46090. import { Node } from "babylonjs/node";
  46091. /**
  46092. * Set of assets to keep when moving a scene into an asset container.
  46093. */
  46094. export class KeepAssets extends AbstractScene {
  46095. }
  46096. /**
  46097. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  46098. */
  46099. export class InstantiatedEntries {
  46100. /**
  46101. * List of new root nodes (eg. nodes with no parent)
  46102. */
  46103. rootNodes: TransformNode[];
  46104. /**
  46105. * List of new skeletons
  46106. */
  46107. skeletons: Skeleton[];
  46108. /**
  46109. * List of new animation groups
  46110. */
  46111. animationGroups: AnimationGroup[];
  46112. }
  46113. /**
  46114. * Container with a set of assets that can be added or removed from a scene.
  46115. */
  46116. export class AssetContainer extends AbstractScene {
  46117. private _wasAddedToScene;
  46118. /**
  46119. * The scene the AssetContainer belongs to.
  46120. */
  46121. scene: Scene;
  46122. /**
  46123. * Instantiates an AssetContainer.
  46124. * @param scene The scene the AssetContainer belongs to.
  46125. */
  46126. constructor(scene: Scene);
  46127. /**
  46128. * Instantiate or clone all meshes and add the new ones to the scene.
  46129. * Skeletons and animation groups will all be cloned
  46130. * @param nameFunction defines an optional function used to get new names for clones
  46131. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  46132. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  46133. */
  46134. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  46135. /**
  46136. * Adds all the assets from the container to the scene.
  46137. */
  46138. addAllToScene(): void;
  46139. /**
  46140. * Removes all the assets in the container from the scene
  46141. */
  46142. removeAllFromScene(): void;
  46143. /**
  46144. * Disposes all the assets in the container
  46145. */
  46146. dispose(): void;
  46147. private _moveAssets;
  46148. /**
  46149. * Removes all the assets contained in the scene and adds them to the container.
  46150. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  46151. */
  46152. moveAllFromScene(keepAssets?: KeepAssets): void;
  46153. /**
  46154. * 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.
  46155. * @returns the root mesh
  46156. */
  46157. createRootMesh(): Mesh;
  46158. /**
  46159. * Merge animations (direct and animation groups) from this asset container into a scene
  46160. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46161. * @param animatables set of animatables to retarget to a node from the scene
  46162. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  46163. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  46164. */
  46165. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  46166. }
  46167. }
  46168. declare module "babylonjs/abstractScene" {
  46169. import { Scene } from "babylonjs/scene";
  46170. import { Nullable } from "babylonjs/types";
  46171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46172. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46173. import { Geometry } from "babylonjs/Meshes/geometry";
  46174. import { Skeleton } from "babylonjs/Bones/skeleton";
  46175. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  46176. import { AssetContainer } from "babylonjs/assetContainer";
  46177. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  46178. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46180. import { Material } from "babylonjs/Materials/material";
  46181. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  46182. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  46183. import { Camera } from "babylonjs/Cameras/camera";
  46184. import { Light } from "babylonjs/Lights/light";
  46185. import { Node } from "babylonjs/node";
  46186. import { Animation } from "babylonjs/Animations/animation";
  46187. /**
  46188. * Defines how the parser contract is defined.
  46189. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  46190. */
  46191. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  46192. /**
  46193. * Defines how the individual parser contract is defined.
  46194. * These parser can parse an individual asset
  46195. */
  46196. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  46197. /**
  46198. * Base class of the scene acting as a container for the different elements composing a scene.
  46199. * This class is dynamically extended by the different components of the scene increasing
  46200. * flexibility and reducing coupling
  46201. */
  46202. export abstract class AbstractScene {
  46203. /**
  46204. * Stores the list of available parsers in the application.
  46205. */
  46206. private static _BabylonFileParsers;
  46207. /**
  46208. * Stores the list of available individual parsers in the application.
  46209. */
  46210. private static _IndividualBabylonFileParsers;
  46211. /**
  46212. * Adds a parser in the list of available ones
  46213. * @param name Defines the name of the parser
  46214. * @param parser Defines the parser to add
  46215. */
  46216. static AddParser(name: string, parser: BabylonFileParser): void;
  46217. /**
  46218. * Gets a general parser from the list of avaialble ones
  46219. * @param name Defines the name of the parser
  46220. * @returns the requested parser or null
  46221. */
  46222. static GetParser(name: string): Nullable<BabylonFileParser>;
  46223. /**
  46224. * Adds n individual parser in the list of available ones
  46225. * @param name Defines the name of the parser
  46226. * @param parser Defines the parser to add
  46227. */
  46228. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46229. /**
  46230. * Gets an individual parser from the list of avaialble ones
  46231. * @param name Defines the name of the parser
  46232. * @returns the requested parser or null
  46233. */
  46234. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46235. /**
  46236. * Parser json data and populate both a scene and its associated container object
  46237. * @param jsonData Defines the data to parse
  46238. * @param scene Defines the scene to parse the data for
  46239. * @param container Defines the container attached to the parsing sequence
  46240. * @param rootUrl Defines the root url of the data
  46241. */
  46242. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46243. /**
  46244. * Gets the list of root nodes (ie. nodes with no parent)
  46245. */
  46246. rootNodes: Node[];
  46247. /** All of the cameras added to this scene
  46248. * @see https://doc.babylonjs.com/babylon101/cameras
  46249. */
  46250. cameras: Camera[];
  46251. /**
  46252. * All of the lights added to this scene
  46253. * @see https://doc.babylonjs.com/babylon101/lights
  46254. */
  46255. lights: Light[];
  46256. /**
  46257. * All of the (abstract) meshes added to this scene
  46258. */
  46259. meshes: AbstractMesh[];
  46260. /**
  46261. * The list of skeletons added to the scene
  46262. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46263. */
  46264. skeletons: Skeleton[];
  46265. /**
  46266. * All of the particle systems added to this scene
  46267. * @see https://doc.babylonjs.com/babylon101/particles
  46268. */
  46269. particleSystems: IParticleSystem[];
  46270. /**
  46271. * Gets a list of Animations associated with the scene
  46272. */
  46273. animations: Animation[];
  46274. /**
  46275. * All of the animation groups added to this scene
  46276. * @see https://doc.babylonjs.com/how_to/group
  46277. */
  46278. animationGroups: AnimationGroup[];
  46279. /**
  46280. * All of the multi-materials added to this scene
  46281. * @see https://doc.babylonjs.com/how_to/multi_materials
  46282. */
  46283. multiMaterials: MultiMaterial[];
  46284. /**
  46285. * All of the materials added to this scene
  46286. * In the context of a Scene, it is not supposed to be modified manually.
  46287. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46288. * Note also that the order of the Material within the array is not significant and might change.
  46289. * @see https://doc.babylonjs.com/babylon101/materials
  46290. */
  46291. materials: Material[];
  46292. /**
  46293. * The list of morph target managers added to the scene
  46294. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46295. */
  46296. morphTargetManagers: MorphTargetManager[];
  46297. /**
  46298. * The list of geometries used in the scene.
  46299. */
  46300. geometries: Geometry[];
  46301. /**
  46302. * All of the tranform nodes added to this scene
  46303. * In the context of a Scene, it is not supposed to be modified manually.
  46304. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46305. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46306. * @see https://doc.babylonjs.com/how_to/transformnode
  46307. */
  46308. transformNodes: TransformNode[];
  46309. /**
  46310. * ActionManagers available on the scene.
  46311. */
  46312. actionManagers: AbstractActionManager[];
  46313. /**
  46314. * Textures to keep.
  46315. */
  46316. textures: BaseTexture[];
  46317. /** @hidden */
  46318. protected _environmentTexture: Nullable<BaseTexture>;
  46319. /**
  46320. * Texture used in all pbr material as the reflection texture.
  46321. * As in the majority of the scene they are the same (exception for multi room and so on),
  46322. * this is easier to reference from here than from all the materials.
  46323. */
  46324. get environmentTexture(): Nullable<BaseTexture>;
  46325. set environmentTexture(value: Nullable<BaseTexture>);
  46326. /**
  46327. * The list of postprocesses added to the scene
  46328. */
  46329. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46330. /**
  46331. * @returns all meshes, lights, cameras, transformNodes and bones
  46332. */
  46333. getNodes(): Array<Node>;
  46334. }
  46335. }
  46336. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  46337. /**
  46338. * Interface used to define options for Sound class
  46339. */
  46340. export interface ISoundOptions {
  46341. /**
  46342. * Does the sound autoplay once loaded.
  46343. */
  46344. autoplay?: boolean;
  46345. /**
  46346. * Does the sound loop after it finishes playing once.
  46347. */
  46348. loop?: boolean;
  46349. /**
  46350. * Sound's volume
  46351. */
  46352. volume?: number;
  46353. /**
  46354. * Is it a spatial sound?
  46355. */
  46356. spatialSound?: boolean;
  46357. /**
  46358. * Maximum distance to hear that sound
  46359. */
  46360. maxDistance?: number;
  46361. /**
  46362. * Uses user defined attenuation function
  46363. */
  46364. useCustomAttenuation?: boolean;
  46365. /**
  46366. * Define the roll off factor of spatial sounds.
  46367. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46368. */
  46369. rolloffFactor?: number;
  46370. /**
  46371. * Define the reference distance the sound should be heard perfectly.
  46372. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46373. */
  46374. refDistance?: number;
  46375. /**
  46376. * Define the distance attenuation model the sound will follow.
  46377. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46378. */
  46379. distanceModel?: string;
  46380. /**
  46381. * Defines the playback speed (1 by default)
  46382. */
  46383. playbackRate?: number;
  46384. /**
  46385. * Defines if the sound is from a streaming source
  46386. */
  46387. streaming?: boolean;
  46388. /**
  46389. * Defines an optional length (in seconds) inside the sound file
  46390. */
  46391. length?: number;
  46392. /**
  46393. * Defines an optional offset (in seconds) inside the sound file
  46394. */
  46395. offset?: number;
  46396. /**
  46397. * If true, URLs will not be required to state the audio file codec to use.
  46398. */
  46399. skipCodecCheck?: boolean;
  46400. }
  46401. }
  46402. declare module "babylonjs/Audio/sound" {
  46403. import { Observable } from "babylonjs/Misc/observable";
  46404. import { Vector3 } from "babylonjs/Maths/math.vector";
  46405. import { Nullable } from "babylonjs/types";
  46406. import { Scene } from "babylonjs/scene";
  46407. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46408. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  46409. /**
  46410. * Defines a sound that can be played in the application.
  46411. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46412. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46413. */
  46414. export class Sound {
  46415. /**
  46416. * The name of the sound in the scene.
  46417. */
  46418. name: string;
  46419. /**
  46420. * Does the sound autoplay once loaded.
  46421. */
  46422. autoplay: boolean;
  46423. /**
  46424. * Does the sound loop after it finishes playing once.
  46425. */
  46426. loop: boolean;
  46427. /**
  46428. * Does the sound use a custom attenuation curve to simulate the falloff
  46429. * happening when the source gets further away from the camera.
  46430. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46431. */
  46432. useCustomAttenuation: boolean;
  46433. /**
  46434. * The sound track id this sound belongs to.
  46435. */
  46436. soundTrackId: number;
  46437. /**
  46438. * Is this sound currently played.
  46439. */
  46440. isPlaying: boolean;
  46441. /**
  46442. * Is this sound currently paused.
  46443. */
  46444. isPaused: boolean;
  46445. /**
  46446. * Does this sound enables spatial sound.
  46447. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46448. */
  46449. spatialSound: boolean;
  46450. /**
  46451. * Define the reference distance the sound should be heard perfectly.
  46452. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46453. */
  46454. refDistance: number;
  46455. /**
  46456. * Define the roll off factor of spatial sounds.
  46457. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46458. */
  46459. rolloffFactor: number;
  46460. /**
  46461. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46462. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46463. */
  46464. maxDistance: number;
  46465. /**
  46466. * Define the distance attenuation model the sound will follow.
  46467. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46468. */
  46469. distanceModel: string;
  46470. /**
  46471. * @hidden
  46472. * Back Compat
  46473. **/
  46474. onended: () => any;
  46475. /**
  46476. * Gets or sets an object used to store user defined information for the sound.
  46477. */
  46478. metadata: any;
  46479. /**
  46480. * Observable event when the current playing sound finishes.
  46481. */
  46482. onEndedObservable: Observable<Sound>;
  46483. /**
  46484. * Gets the current time for the sound.
  46485. */
  46486. get currentTime(): number;
  46487. private _panningModel;
  46488. private _playbackRate;
  46489. private _streaming;
  46490. private _startTime;
  46491. private _startOffset;
  46492. private _position;
  46493. /** @hidden */
  46494. _positionInEmitterSpace: boolean;
  46495. private _localDirection;
  46496. private _volume;
  46497. private _isReadyToPlay;
  46498. private _isDirectional;
  46499. private _readyToPlayCallback;
  46500. private _audioBuffer;
  46501. private _soundSource;
  46502. private _streamingSource;
  46503. private _soundPanner;
  46504. private _soundGain;
  46505. private _inputAudioNode;
  46506. private _outputAudioNode;
  46507. private _coneInnerAngle;
  46508. private _coneOuterAngle;
  46509. private _coneOuterGain;
  46510. private _scene;
  46511. private _connectedTransformNode;
  46512. private _customAttenuationFunction;
  46513. private _registerFunc;
  46514. private _isOutputConnected;
  46515. private _htmlAudioElement;
  46516. private _urlType;
  46517. private _length?;
  46518. private _offset?;
  46519. /** @hidden */
  46520. static _SceneComponentInitialization: (scene: Scene) => void;
  46521. /**
  46522. * Create a sound and attach it to a scene
  46523. * @param name Name of your sound
  46524. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46525. * @param scene defines the scene the sound belongs to
  46526. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46527. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46528. */
  46529. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46530. /**
  46531. * Release the sound and its associated resources
  46532. */
  46533. dispose(): void;
  46534. /**
  46535. * Gets if the sounds is ready to be played or not.
  46536. * @returns true if ready, otherwise false
  46537. */
  46538. isReady(): boolean;
  46539. private _soundLoaded;
  46540. /**
  46541. * Sets the data of the sound from an audiobuffer
  46542. * @param audioBuffer The audioBuffer containing the data
  46543. */
  46544. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46545. /**
  46546. * Updates the current sounds options such as maxdistance, loop...
  46547. * @param options A JSON object containing values named as the object properties
  46548. */
  46549. updateOptions(options: ISoundOptions): void;
  46550. private _createSpatialParameters;
  46551. private _updateSpatialParameters;
  46552. /**
  46553. * Switch the panning model to HRTF:
  46554. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46555. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46556. */
  46557. switchPanningModelToHRTF(): void;
  46558. /**
  46559. * Switch the panning model to Equal Power:
  46560. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46561. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46562. */
  46563. switchPanningModelToEqualPower(): void;
  46564. private _switchPanningModel;
  46565. /**
  46566. * Connect this sound to a sound track audio node like gain...
  46567. * @param soundTrackAudioNode the sound track audio node to connect to
  46568. */
  46569. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46570. /**
  46571. * Transform this sound into a directional source
  46572. * @param coneInnerAngle Size of the inner cone in degree
  46573. * @param coneOuterAngle Size of the outer cone in degree
  46574. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46575. */
  46576. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46577. /**
  46578. * Gets or sets the inner angle for the directional cone.
  46579. */
  46580. get directionalConeInnerAngle(): number;
  46581. /**
  46582. * Gets or sets the inner angle for the directional cone.
  46583. */
  46584. set directionalConeInnerAngle(value: number);
  46585. /**
  46586. * Gets or sets the outer angle for the directional cone.
  46587. */
  46588. get directionalConeOuterAngle(): number;
  46589. /**
  46590. * Gets or sets the outer angle for the directional cone.
  46591. */
  46592. set directionalConeOuterAngle(value: number);
  46593. /**
  46594. * Sets the position of the emitter if spatial sound is enabled
  46595. * @param newPosition Defines the new posisiton
  46596. */
  46597. setPosition(newPosition: Vector3): void;
  46598. /**
  46599. * Sets the local direction of the emitter if spatial sound is enabled
  46600. * @param newLocalDirection Defines the new local direction
  46601. */
  46602. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46603. private _updateDirection;
  46604. /** @hidden */
  46605. updateDistanceFromListener(): void;
  46606. /**
  46607. * Sets a new custom attenuation function for the sound.
  46608. * @param callback Defines the function used for the attenuation
  46609. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46610. */
  46611. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46612. /**
  46613. * Play the sound
  46614. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46615. * @param offset (optional) Start the sound at a specific time in seconds
  46616. * @param length (optional) Sound duration (in seconds)
  46617. */
  46618. play(time?: number, offset?: number, length?: number): void;
  46619. private _onended;
  46620. /**
  46621. * Stop the sound
  46622. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46623. */
  46624. stop(time?: number): void;
  46625. /**
  46626. * Put the sound in pause
  46627. */
  46628. pause(): void;
  46629. /**
  46630. * Sets a dedicated volume for this sounds
  46631. * @param newVolume Define the new volume of the sound
  46632. * @param time Define time for gradual change to new volume
  46633. */
  46634. setVolume(newVolume: number, time?: number): void;
  46635. /**
  46636. * Set the sound play back rate
  46637. * @param newPlaybackRate Define the playback rate the sound should be played at
  46638. */
  46639. setPlaybackRate(newPlaybackRate: number): void;
  46640. /**
  46641. * Gets the volume of the sound.
  46642. * @returns the volume of the sound
  46643. */
  46644. getVolume(): number;
  46645. /**
  46646. * Attach the sound to a dedicated mesh
  46647. * @param transformNode The transform node to connect the sound with
  46648. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46649. */
  46650. attachToMesh(transformNode: TransformNode): void;
  46651. /**
  46652. * Detach the sound from the previously attached mesh
  46653. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46654. */
  46655. detachFromMesh(): void;
  46656. private _onRegisterAfterWorldMatrixUpdate;
  46657. /**
  46658. * Clone the current sound in the scene.
  46659. * @returns the new sound clone
  46660. */
  46661. clone(): Nullable<Sound>;
  46662. /**
  46663. * Gets the current underlying audio buffer containing the data
  46664. * @returns the audio buffer
  46665. */
  46666. getAudioBuffer(): Nullable<AudioBuffer>;
  46667. /**
  46668. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46669. * @returns the source node
  46670. */
  46671. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46672. /**
  46673. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46674. * @returns the gain node
  46675. */
  46676. getSoundGain(): Nullable<GainNode>;
  46677. /**
  46678. * Serializes the Sound in a JSON representation
  46679. * @returns the JSON representation of the sound
  46680. */
  46681. serialize(): any;
  46682. /**
  46683. * Parse a JSON representation of a sound to innstantiate in a given scene
  46684. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46685. * @param scene Define the scene the new parsed sound should be created in
  46686. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46687. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46688. * @returns the newly parsed sound
  46689. */
  46690. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46691. }
  46692. }
  46693. declare module "babylonjs/Actions/directAudioActions" {
  46694. import { Action } from "babylonjs/Actions/action";
  46695. import { Condition } from "babylonjs/Actions/condition";
  46696. import { Sound } from "babylonjs/Audio/sound";
  46697. /**
  46698. * This defines an action helpful to play a defined sound on a triggered action.
  46699. */
  46700. export class PlaySoundAction extends Action {
  46701. private _sound;
  46702. /**
  46703. * Instantiate the action
  46704. * @param triggerOptions defines the trigger options
  46705. * @param sound defines the sound to play
  46706. * @param condition defines the trigger related conditions
  46707. */
  46708. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46709. /** @hidden */
  46710. _prepare(): void;
  46711. /**
  46712. * Execute the action and play the sound.
  46713. */
  46714. execute(): void;
  46715. /**
  46716. * Serializes the actions and its related information.
  46717. * @param parent defines the object to serialize in
  46718. * @returns the serialized object
  46719. */
  46720. serialize(parent: any): any;
  46721. }
  46722. /**
  46723. * This defines an action helpful to stop a defined sound on a triggered action.
  46724. */
  46725. export class StopSoundAction extends Action {
  46726. private _sound;
  46727. /**
  46728. * Instantiate the action
  46729. * @param triggerOptions defines the trigger options
  46730. * @param sound defines the sound to stop
  46731. * @param condition defines the trigger related conditions
  46732. */
  46733. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46734. /** @hidden */
  46735. _prepare(): void;
  46736. /**
  46737. * Execute the action and stop the sound.
  46738. */
  46739. execute(): void;
  46740. /**
  46741. * Serializes the actions and its related information.
  46742. * @param parent defines the object to serialize in
  46743. * @returns the serialized object
  46744. */
  46745. serialize(parent: any): any;
  46746. }
  46747. }
  46748. declare module "babylonjs/Actions/interpolateValueAction" {
  46749. import { Action } from "babylonjs/Actions/action";
  46750. import { Condition } from "babylonjs/Actions/condition";
  46751. import { Observable } from "babylonjs/Misc/observable";
  46752. /**
  46753. * This defines an action responsible to change the value of a property
  46754. * by interpolating between its current value and the newly set one once triggered.
  46755. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46756. */
  46757. export class InterpolateValueAction extends Action {
  46758. /**
  46759. * Defines the path of the property where the value should be interpolated
  46760. */
  46761. propertyPath: string;
  46762. /**
  46763. * Defines the target value at the end of the interpolation.
  46764. */
  46765. value: any;
  46766. /**
  46767. * Defines the time it will take for the property to interpolate to the value.
  46768. */
  46769. duration: number;
  46770. /**
  46771. * Defines if the other scene animations should be stopped when the action has been triggered
  46772. */
  46773. stopOtherAnimations?: boolean;
  46774. /**
  46775. * Defines a callback raised once the interpolation animation has been done.
  46776. */
  46777. onInterpolationDone?: () => void;
  46778. /**
  46779. * Observable triggered once the interpolation animation has been done.
  46780. */
  46781. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  46782. private _target;
  46783. private _effectiveTarget;
  46784. private _property;
  46785. /**
  46786. * Instantiate the action
  46787. * @param triggerOptions defines the trigger options
  46788. * @param target defines the object containing the value to interpolate
  46789. * @param propertyPath defines the path to the property in the target object
  46790. * @param value defines the target value at the end of the interpolation
  46791. * @param duration deines the time it will take for the property to interpolate to the value.
  46792. * @param condition defines the trigger related conditions
  46793. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  46794. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  46795. */
  46796. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  46797. /** @hidden */
  46798. _prepare(): void;
  46799. /**
  46800. * Execute the action starts the value interpolation.
  46801. */
  46802. execute(): void;
  46803. /**
  46804. * Serializes the actions and its related information.
  46805. * @param parent defines the object to serialize in
  46806. * @returns the serialized object
  46807. */
  46808. serialize(parent: any): any;
  46809. }
  46810. }
  46811. declare module "babylonjs/Actions/index" {
  46812. export * from "babylonjs/Actions/abstractActionManager";
  46813. export * from "babylonjs/Actions/action";
  46814. export * from "babylonjs/Actions/actionEvent";
  46815. export * from "babylonjs/Actions/actionManager";
  46816. export * from "babylonjs/Actions/condition";
  46817. export * from "babylonjs/Actions/directActions";
  46818. export * from "babylonjs/Actions/directAudioActions";
  46819. export * from "babylonjs/Actions/interpolateValueAction";
  46820. }
  46821. declare module "babylonjs/Animations/index" {
  46822. export * from "babylonjs/Animations/animatable";
  46823. export * from "babylonjs/Animations/animation";
  46824. export * from "babylonjs/Animations/animationGroup";
  46825. export * from "babylonjs/Animations/animationPropertiesOverride";
  46826. export * from "babylonjs/Animations/easing";
  46827. export * from "babylonjs/Animations/runtimeAnimation";
  46828. export * from "babylonjs/Animations/animationEvent";
  46829. export * from "babylonjs/Animations/animationGroup";
  46830. export * from "babylonjs/Animations/animationKey";
  46831. export * from "babylonjs/Animations/animationRange";
  46832. export * from "babylonjs/Animations/animatable.interface";
  46833. }
  46834. declare module "babylonjs/Audio/audioEngine" {
  46835. import { Analyser } from "babylonjs/Audio/analyser";
  46836. import { Nullable } from "babylonjs/types";
  46837. import { Observable } from "babylonjs/Misc/observable";
  46838. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  46839. /**
  46840. * This represents the default audio engine used in babylon.
  46841. * It is responsible to play, synchronize and analyse sounds throughout the application.
  46842. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46843. */
  46844. export class AudioEngine implements IAudioEngine {
  46845. private _audioContext;
  46846. private _audioContextInitialized;
  46847. private _muteButton;
  46848. private _hostElement;
  46849. /**
  46850. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  46851. */
  46852. canUseWebAudio: boolean;
  46853. /**
  46854. * The master gain node defines the global audio volume of your audio engine.
  46855. */
  46856. masterGain: GainNode;
  46857. /**
  46858. * Defines if Babylon should emit a warning if WebAudio is not supported.
  46859. * @ignoreNaming
  46860. */
  46861. WarnedWebAudioUnsupported: boolean;
  46862. /**
  46863. * Gets whether or not mp3 are supported by your browser.
  46864. */
  46865. isMP3supported: boolean;
  46866. /**
  46867. * Gets whether or not ogg are supported by your browser.
  46868. */
  46869. isOGGsupported: boolean;
  46870. /**
  46871. * Gets whether audio has been unlocked on the device.
  46872. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  46873. * a user interaction has happened.
  46874. */
  46875. unlocked: boolean;
  46876. /**
  46877. * Defines if the audio engine relies on a custom unlocked button.
  46878. * In this case, the embedded button will not be displayed.
  46879. */
  46880. useCustomUnlockedButton: boolean;
  46881. /**
  46882. * Event raised when audio has been unlocked on the browser.
  46883. */
  46884. onAudioUnlockedObservable: Observable<IAudioEngine>;
  46885. /**
  46886. * Event raised when audio has been locked on the browser.
  46887. */
  46888. onAudioLockedObservable: Observable<IAudioEngine>;
  46889. /**
  46890. * Gets the current AudioContext if available.
  46891. */
  46892. get audioContext(): Nullable<AudioContext>;
  46893. private _connectedAnalyser;
  46894. /**
  46895. * Instantiates a new audio engine.
  46896. *
  46897. * There should be only one per page as some browsers restrict the number
  46898. * of audio contexts you can create.
  46899. * @param hostElement defines the host element where to display the mute icon if necessary
  46900. */
  46901. constructor(hostElement?: Nullable<HTMLElement>);
  46902. /**
  46903. * Flags the audio engine in Locked state.
  46904. * This happens due to new browser policies preventing audio to autoplay.
  46905. */
  46906. lock(): void;
  46907. /**
  46908. * Unlocks the audio engine once a user action has been done on the dom.
  46909. * This is helpful to resume play once browser policies have been satisfied.
  46910. */
  46911. unlock(): void;
  46912. private _resumeAudioContext;
  46913. private _initializeAudioContext;
  46914. private _tryToRun;
  46915. private _triggerRunningState;
  46916. private _triggerSuspendedState;
  46917. private _displayMuteButton;
  46918. private _moveButtonToTopLeft;
  46919. private _onResize;
  46920. private _hideMuteButton;
  46921. /**
  46922. * Destroy and release the resources associated with the audio ccontext.
  46923. */
  46924. dispose(): void;
  46925. /**
  46926. * Gets the global volume sets on the master gain.
  46927. * @returns the global volume if set or -1 otherwise
  46928. */
  46929. getGlobalVolume(): number;
  46930. /**
  46931. * Sets the global volume of your experience (sets on the master gain).
  46932. * @param newVolume Defines the new global volume of the application
  46933. */
  46934. setGlobalVolume(newVolume: number): void;
  46935. /**
  46936. * Connect the audio engine to an audio analyser allowing some amazing
  46937. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46938. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46939. * @param analyser The analyser to connect to the engine
  46940. */
  46941. connectToAnalyser(analyser: Analyser): void;
  46942. }
  46943. }
  46944. declare module "babylonjs/Audio/soundTrack" {
  46945. import { Sound } from "babylonjs/Audio/sound";
  46946. import { Analyser } from "babylonjs/Audio/analyser";
  46947. import { Scene } from "babylonjs/scene";
  46948. /**
  46949. * Options allowed during the creation of a sound track.
  46950. */
  46951. export interface ISoundTrackOptions {
  46952. /**
  46953. * The volume the sound track should take during creation
  46954. */
  46955. volume?: number;
  46956. /**
  46957. * Define if the sound track is the main sound track of the scene
  46958. */
  46959. mainTrack?: boolean;
  46960. }
  46961. /**
  46962. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  46963. * It will be also used in a future release to apply effects on a specific track.
  46964. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46965. */
  46966. export class SoundTrack {
  46967. /**
  46968. * The unique identifier of the sound track in the scene.
  46969. */
  46970. id: number;
  46971. /**
  46972. * The list of sounds included in the sound track.
  46973. */
  46974. soundCollection: Array<Sound>;
  46975. private _outputAudioNode;
  46976. private _scene;
  46977. private _connectedAnalyser;
  46978. private _options;
  46979. private _isInitialized;
  46980. /**
  46981. * Creates a new sound track.
  46982. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46983. * @param scene Define the scene the sound track belongs to
  46984. * @param options
  46985. */
  46986. constructor(scene: Scene, options?: ISoundTrackOptions);
  46987. private _initializeSoundTrackAudioGraph;
  46988. /**
  46989. * Release the sound track and its associated resources
  46990. */
  46991. dispose(): void;
  46992. /**
  46993. * Adds a sound to this sound track
  46994. * @param sound define the cound to add
  46995. * @ignoreNaming
  46996. */
  46997. addSound(sound: Sound): void;
  46998. /**
  46999. * Removes a sound to this sound track
  47000. * @param sound define the cound to remove
  47001. * @ignoreNaming
  47002. */
  47003. removeSound(sound: Sound): void;
  47004. /**
  47005. * Set a global volume for the full sound track.
  47006. * @param newVolume Define the new volume of the sound track
  47007. */
  47008. setVolume(newVolume: number): void;
  47009. /**
  47010. * Switch the panning model to HRTF:
  47011. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  47012. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47013. */
  47014. switchPanningModelToHRTF(): void;
  47015. /**
  47016. * Switch the panning model to Equal Power:
  47017. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  47018. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47019. */
  47020. switchPanningModelToEqualPower(): void;
  47021. /**
  47022. * Connect the sound track to an audio analyser allowing some amazing
  47023. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47024. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47025. * @param analyser The analyser to connect to the engine
  47026. */
  47027. connectToAnalyser(analyser: Analyser): void;
  47028. }
  47029. }
  47030. declare module "babylonjs/Audio/audioSceneComponent" {
  47031. import { Sound } from "babylonjs/Audio/sound";
  47032. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  47033. import { Nullable } from "babylonjs/types";
  47034. import { Vector3 } from "babylonjs/Maths/math.vector";
  47035. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47036. import { Scene } from "babylonjs/scene";
  47037. import { AbstractScene } from "babylonjs/abstractScene";
  47038. import "babylonjs/Audio/audioEngine";
  47039. module "babylonjs/abstractScene" {
  47040. interface AbstractScene {
  47041. /**
  47042. * The list of sounds used in the scene.
  47043. */
  47044. sounds: Nullable<Array<Sound>>;
  47045. }
  47046. }
  47047. module "babylonjs/scene" {
  47048. interface Scene {
  47049. /**
  47050. * @hidden
  47051. * Backing field
  47052. */
  47053. _mainSoundTrack: SoundTrack;
  47054. /**
  47055. * The main sound track played by the scene.
  47056. * It cotains your primary collection of sounds.
  47057. */
  47058. mainSoundTrack: SoundTrack;
  47059. /**
  47060. * The list of sound tracks added to the scene
  47061. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47062. */
  47063. soundTracks: Nullable<Array<SoundTrack>>;
  47064. /**
  47065. * Gets a sound using a given name
  47066. * @param name defines the name to search for
  47067. * @return the found sound or null if not found at all.
  47068. */
  47069. getSoundByName(name: string): Nullable<Sound>;
  47070. /**
  47071. * Gets or sets if audio support is enabled
  47072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47073. */
  47074. audioEnabled: boolean;
  47075. /**
  47076. * Gets or sets if audio will be output to headphones
  47077. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47078. */
  47079. headphone: boolean;
  47080. /**
  47081. * Gets or sets custom audio listener position provider
  47082. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47083. */
  47084. audioListenerPositionProvider: Nullable<() => Vector3>;
  47085. /**
  47086. * Gets or sets a refresh rate when using 3D audio positioning
  47087. */
  47088. audioPositioningRefreshRate: number;
  47089. }
  47090. }
  47091. /**
  47092. * Defines the sound scene component responsible to manage any sounds
  47093. * in a given scene.
  47094. */
  47095. export class AudioSceneComponent implements ISceneSerializableComponent {
  47096. private static _CameraDirectionLH;
  47097. private static _CameraDirectionRH;
  47098. /**
  47099. * The component name helpfull to identify the component in the list of scene components.
  47100. */
  47101. readonly name: string;
  47102. /**
  47103. * The scene the component belongs to.
  47104. */
  47105. scene: Scene;
  47106. private _audioEnabled;
  47107. /**
  47108. * Gets whether audio is enabled or not.
  47109. * Please use related enable/disable method to switch state.
  47110. */
  47111. get audioEnabled(): boolean;
  47112. private _headphone;
  47113. /**
  47114. * Gets whether audio is outputing to headphone or not.
  47115. * Please use the according Switch methods to change output.
  47116. */
  47117. get headphone(): boolean;
  47118. /**
  47119. * Gets or sets a refresh rate when using 3D audio positioning
  47120. */
  47121. audioPositioningRefreshRate: number;
  47122. private _audioListenerPositionProvider;
  47123. /**
  47124. * Gets the current audio listener position provider
  47125. */
  47126. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  47127. /**
  47128. * Sets a custom listener position for all sounds in the scene
  47129. * By default, this is the position of the first active camera
  47130. */
  47131. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  47132. /**
  47133. * Creates a new instance of the component for the given scene
  47134. * @param scene Defines the scene to register the component in
  47135. */
  47136. constructor(scene: Scene);
  47137. /**
  47138. * Registers the component in a given scene
  47139. */
  47140. register(): void;
  47141. /**
  47142. * Rebuilds the elements related to this component in case of
  47143. * context lost for instance.
  47144. */
  47145. rebuild(): void;
  47146. /**
  47147. * Serializes the component data to the specified json object
  47148. * @param serializationObject The object to serialize to
  47149. */
  47150. serialize(serializationObject: any): void;
  47151. /**
  47152. * Adds all the elements from the container to the scene
  47153. * @param container the container holding the elements
  47154. */
  47155. addFromContainer(container: AbstractScene): void;
  47156. /**
  47157. * Removes all the elements in the container from the scene
  47158. * @param container contains the elements to remove
  47159. * @param dispose if the removed element should be disposed (default: false)
  47160. */
  47161. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47162. /**
  47163. * Disposes the component and the associated ressources.
  47164. */
  47165. dispose(): void;
  47166. /**
  47167. * Disables audio in the associated scene.
  47168. */
  47169. disableAudio(): void;
  47170. /**
  47171. * Enables audio in the associated scene.
  47172. */
  47173. enableAudio(): void;
  47174. /**
  47175. * Switch audio to headphone output.
  47176. */
  47177. switchAudioModeForHeadphones(): void;
  47178. /**
  47179. * Switch audio to normal speakers.
  47180. */
  47181. switchAudioModeForNormalSpeakers(): void;
  47182. private _cachedCameraDirection;
  47183. private _cachedCameraPosition;
  47184. private _lastCheck;
  47185. private _afterRender;
  47186. }
  47187. }
  47188. declare module "babylonjs/Audio/weightedsound" {
  47189. import { Sound } from "babylonjs/Audio/sound";
  47190. /**
  47191. * Wraps one or more Sound objects and selects one with random weight for playback.
  47192. */
  47193. export class WeightedSound {
  47194. /** When true a Sound will be selected and played when the current playing Sound completes. */
  47195. loop: boolean;
  47196. private _coneInnerAngle;
  47197. private _coneOuterAngle;
  47198. private _volume;
  47199. /** A Sound is currently playing. */
  47200. isPlaying: boolean;
  47201. /** A Sound is currently paused. */
  47202. isPaused: boolean;
  47203. private _sounds;
  47204. private _weights;
  47205. private _currentIndex?;
  47206. /**
  47207. * Creates a new WeightedSound from the list of sounds given.
  47208. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  47209. * @param sounds Array of Sounds that will be selected from.
  47210. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  47211. */
  47212. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  47213. /**
  47214. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  47215. */
  47216. get directionalConeInnerAngle(): number;
  47217. /**
  47218. * The size of cone in degress for a directional sound in which there will be no attenuation.
  47219. */
  47220. set directionalConeInnerAngle(value: number);
  47221. /**
  47222. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47223. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47224. */
  47225. get directionalConeOuterAngle(): number;
  47226. /**
  47227. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47228. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47229. */
  47230. set directionalConeOuterAngle(value: number);
  47231. /**
  47232. * Playback volume.
  47233. */
  47234. get volume(): number;
  47235. /**
  47236. * Playback volume.
  47237. */
  47238. set volume(value: number);
  47239. private _onended;
  47240. /**
  47241. * Suspend playback
  47242. */
  47243. pause(): void;
  47244. /**
  47245. * Stop playback
  47246. */
  47247. stop(): void;
  47248. /**
  47249. * Start playback.
  47250. * @param startOffset Position the clip head at a specific time in seconds.
  47251. */
  47252. play(startOffset?: number): void;
  47253. }
  47254. }
  47255. declare module "babylonjs/Audio/index" {
  47256. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  47257. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  47258. export * from "babylonjs/Audio/analyser";
  47259. export * from "babylonjs/Audio/audioEngine";
  47260. export * from "babylonjs/Audio/audioSceneComponent";
  47261. export * from "babylonjs/Audio/sound";
  47262. export * from "babylonjs/Audio/soundTrack";
  47263. export * from "babylonjs/Audio/weightedsound";
  47264. }
  47265. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  47266. import { Behavior } from "babylonjs/Behaviors/behavior";
  47267. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47268. import { BackEase } from "babylonjs/Animations/easing";
  47269. /**
  47270. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  47271. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47272. */
  47273. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  47274. /**
  47275. * Gets the name of the behavior.
  47276. */
  47277. get name(): string;
  47278. /**
  47279. * The easing function used by animations
  47280. */
  47281. static EasingFunction: BackEase;
  47282. /**
  47283. * The easing mode used by animations
  47284. */
  47285. static EasingMode: number;
  47286. /**
  47287. * The duration of the animation, in milliseconds
  47288. */
  47289. transitionDuration: number;
  47290. /**
  47291. * Length of the distance animated by the transition when lower radius is reached
  47292. */
  47293. lowerRadiusTransitionRange: number;
  47294. /**
  47295. * Length of the distance animated by the transition when upper radius is reached
  47296. */
  47297. upperRadiusTransitionRange: number;
  47298. private _autoTransitionRange;
  47299. /**
  47300. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47301. */
  47302. get autoTransitionRange(): boolean;
  47303. /**
  47304. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47305. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  47306. */
  47307. set autoTransitionRange(value: boolean);
  47308. private _attachedCamera;
  47309. private _onAfterCheckInputsObserver;
  47310. private _onMeshTargetChangedObserver;
  47311. /**
  47312. * Initializes the behavior.
  47313. */
  47314. init(): void;
  47315. /**
  47316. * Attaches the behavior to its arc rotate camera.
  47317. * @param camera Defines the camera to attach the behavior to
  47318. */
  47319. attach(camera: ArcRotateCamera): void;
  47320. /**
  47321. * Detaches the behavior from its current arc rotate camera.
  47322. */
  47323. detach(): void;
  47324. private _radiusIsAnimating;
  47325. private _radiusBounceTransition;
  47326. private _animatables;
  47327. private _cachedWheelPrecision;
  47328. /**
  47329. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  47330. * @param radiusLimit The limit to check against.
  47331. * @return Bool to indicate if at limit.
  47332. */
  47333. private _isRadiusAtLimit;
  47334. /**
  47335. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  47336. * @param radiusDelta The delta by which to animate to. Can be negative.
  47337. */
  47338. private _applyBoundRadiusAnimation;
  47339. /**
  47340. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  47341. */
  47342. protected _clearAnimationLocks(): void;
  47343. /**
  47344. * Stops and removes all animations that have been applied to the camera
  47345. */
  47346. stopAllAnimations(): void;
  47347. }
  47348. }
  47349. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47350. import { Behavior } from "babylonjs/Behaviors/behavior";
  47351. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47352. import { ExponentialEase } from "babylonjs/Animations/easing";
  47353. import { Nullable } from "babylonjs/types";
  47354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47355. import { Vector3 } from "babylonjs/Maths/math.vector";
  47356. /**
  47357. * 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.
  47358. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47359. */
  47360. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47361. /**
  47362. * Gets the name of the behavior.
  47363. */
  47364. get name(): string;
  47365. private _mode;
  47366. private _radiusScale;
  47367. private _positionScale;
  47368. private _defaultElevation;
  47369. private _elevationReturnTime;
  47370. private _elevationReturnWaitTime;
  47371. private _zoomStopsAnimation;
  47372. private _framingTime;
  47373. /**
  47374. * The easing function used by animations
  47375. */
  47376. static EasingFunction: ExponentialEase;
  47377. /**
  47378. * The easing mode used by animations
  47379. */
  47380. static EasingMode: number;
  47381. /**
  47382. * Sets the current mode used by the behavior
  47383. */
  47384. set mode(mode: number);
  47385. /**
  47386. * Gets current mode used by the behavior.
  47387. */
  47388. get mode(): number;
  47389. /**
  47390. * Sets the scale applied to the radius (1 by default)
  47391. */
  47392. set radiusScale(radius: number);
  47393. /**
  47394. * Gets the scale applied to the radius
  47395. */
  47396. get radiusScale(): number;
  47397. /**
  47398. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47399. */
  47400. set positionScale(scale: number);
  47401. /**
  47402. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47403. */
  47404. get positionScale(): number;
  47405. /**
  47406. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47407. * behaviour is triggered, in radians.
  47408. */
  47409. set defaultElevation(elevation: number);
  47410. /**
  47411. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47412. * behaviour is triggered, in radians.
  47413. */
  47414. get defaultElevation(): number;
  47415. /**
  47416. * Sets the time (in milliseconds) taken to return to the default beta position.
  47417. * Negative value indicates camera should not return to default.
  47418. */
  47419. set elevationReturnTime(speed: number);
  47420. /**
  47421. * Gets the time (in milliseconds) taken to return to the default beta position.
  47422. * Negative value indicates camera should not return to default.
  47423. */
  47424. get elevationReturnTime(): number;
  47425. /**
  47426. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47427. */
  47428. set elevationReturnWaitTime(time: number);
  47429. /**
  47430. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47431. */
  47432. get elevationReturnWaitTime(): number;
  47433. /**
  47434. * Sets the flag that indicates if user zooming should stop animation.
  47435. */
  47436. set zoomStopsAnimation(flag: boolean);
  47437. /**
  47438. * Gets the flag that indicates if user zooming should stop animation.
  47439. */
  47440. get zoomStopsAnimation(): boolean;
  47441. /**
  47442. * Sets the transition time when framing the mesh, in milliseconds
  47443. */
  47444. set framingTime(time: number);
  47445. /**
  47446. * Gets the transition time when framing the mesh, in milliseconds
  47447. */
  47448. get framingTime(): number;
  47449. /**
  47450. * Define if the behavior should automatically change the configured
  47451. * camera limits and sensibilities.
  47452. */
  47453. autoCorrectCameraLimitsAndSensibility: boolean;
  47454. private _onPrePointerObservableObserver;
  47455. private _onAfterCheckInputsObserver;
  47456. private _onMeshTargetChangedObserver;
  47457. private _attachedCamera;
  47458. private _isPointerDown;
  47459. private _lastInteractionTime;
  47460. /**
  47461. * Initializes the behavior.
  47462. */
  47463. init(): void;
  47464. /**
  47465. * Attaches the behavior to its arc rotate camera.
  47466. * @param camera Defines the camera to attach the behavior to
  47467. */
  47468. attach(camera: ArcRotateCamera): void;
  47469. /**
  47470. * Detaches the behavior from its current arc rotate camera.
  47471. */
  47472. detach(): void;
  47473. private _animatables;
  47474. private _betaIsAnimating;
  47475. private _betaTransition;
  47476. private _radiusTransition;
  47477. private _vectorTransition;
  47478. /**
  47479. * Targets the given mesh and updates zoom level accordingly.
  47480. * @param mesh The mesh to target.
  47481. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47482. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47483. */
  47484. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47485. /**
  47486. * Targets the given mesh with its children and updates zoom level accordingly.
  47487. * @param mesh The mesh to target.
  47488. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47489. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47490. */
  47491. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47492. /**
  47493. * Targets the given meshes with their children and updates zoom level accordingly.
  47494. * @param meshes The mesh to target.
  47495. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47496. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47497. */
  47498. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47499. /**
  47500. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47501. * @param minimumWorld Determines the smaller position of the bounding box extend
  47502. * @param maximumWorld Determines the bigger position of the bounding box extend
  47503. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47504. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47505. */
  47506. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47507. /**
  47508. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47509. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47510. * frustum width.
  47511. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47512. * to fully enclose the mesh in the viewing frustum.
  47513. */
  47514. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47515. /**
  47516. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47517. * is automatically returned to its default position (expected to be above ground plane).
  47518. */
  47519. private _maintainCameraAboveGround;
  47520. /**
  47521. * Returns the frustum slope based on the canvas ratio and camera FOV
  47522. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47523. */
  47524. private _getFrustumSlope;
  47525. /**
  47526. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47527. */
  47528. private _clearAnimationLocks;
  47529. /**
  47530. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47531. */
  47532. private _applyUserInteraction;
  47533. /**
  47534. * Stops and removes all animations that have been applied to the camera
  47535. */
  47536. stopAllAnimations(): void;
  47537. /**
  47538. * Gets a value indicating if the user is moving the camera
  47539. */
  47540. get isUserIsMoving(): boolean;
  47541. /**
  47542. * The camera can move all the way towards the mesh.
  47543. */
  47544. static IgnoreBoundsSizeMode: number;
  47545. /**
  47546. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47547. */
  47548. static FitFrustumSidesMode: number;
  47549. }
  47550. }
  47551. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47552. import { Nullable } from "babylonjs/types";
  47553. import { Camera } from "babylonjs/Cameras/camera";
  47554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47555. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47556. /**
  47557. * Base class for Camera Pointer Inputs.
  47558. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47559. * for example usage.
  47560. */
  47561. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47562. /**
  47563. * Defines the camera the input is attached to.
  47564. */
  47565. abstract camera: Camera;
  47566. /**
  47567. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47568. */
  47569. protected _altKey: boolean;
  47570. protected _ctrlKey: boolean;
  47571. protected _metaKey: boolean;
  47572. protected _shiftKey: boolean;
  47573. /**
  47574. * Which mouse buttons were pressed at time of last mouse event.
  47575. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47576. */
  47577. protected _buttonsPressed: number;
  47578. /**
  47579. * Defines the buttons associated with the input to handle camera move.
  47580. */
  47581. buttons: number[];
  47582. /**
  47583. * Attach the input controls to a specific dom element to get the input from.
  47584. * @param element Defines the element the controls should be listened from
  47585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47586. */
  47587. attachControl(noPreventDefault?: boolean): void;
  47588. /**
  47589. * Detach the current controls from the specified dom element.
  47590. */
  47591. detachControl(): void;
  47592. /**
  47593. * Gets the class name of the current input.
  47594. * @returns the class name
  47595. */
  47596. getClassName(): string;
  47597. /**
  47598. * Get the friendly name associated with the input class.
  47599. * @returns the input friendly name
  47600. */
  47601. getSimpleName(): string;
  47602. /**
  47603. * Called on pointer POINTERDOUBLETAP event.
  47604. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47605. */
  47606. protected onDoubleTap(type: string): void;
  47607. /**
  47608. * Called on pointer POINTERMOVE event if only a single touch is active.
  47609. * Override this method to provide functionality.
  47610. */
  47611. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47612. /**
  47613. * Called on pointer POINTERMOVE event if multiple touches are active.
  47614. * Override this method to provide functionality.
  47615. */
  47616. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47617. /**
  47618. * Called on JS contextmenu event.
  47619. * Override this method to provide functionality.
  47620. */
  47621. protected onContextMenu(evt: PointerEvent): void;
  47622. /**
  47623. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47624. * press.
  47625. * Override this method to provide functionality.
  47626. */
  47627. protected onButtonDown(evt: PointerEvent): void;
  47628. /**
  47629. * Called each time a new POINTERUP event occurs. Ie, for each button
  47630. * release.
  47631. * Override this method to provide functionality.
  47632. */
  47633. protected onButtonUp(evt: PointerEvent): void;
  47634. /**
  47635. * Called when window becomes inactive.
  47636. * Override this method to provide functionality.
  47637. */
  47638. protected onLostFocus(): void;
  47639. private _pointerInput;
  47640. private _observer;
  47641. private _onLostFocus;
  47642. private pointA;
  47643. private pointB;
  47644. }
  47645. }
  47646. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47647. import { Nullable } from "babylonjs/types";
  47648. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47649. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47650. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47651. /**
  47652. * Manage the pointers inputs to control an arc rotate camera.
  47653. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47654. */
  47655. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47656. /**
  47657. * Defines the camera the input is attached to.
  47658. */
  47659. camera: ArcRotateCamera;
  47660. /**
  47661. * Gets the class name of the current input.
  47662. * @returns the class name
  47663. */
  47664. getClassName(): string;
  47665. /**
  47666. * Defines the buttons associated with the input to handle camera move.
  47667. */
  47668. buttons: number[];
  47669. /**
  47670. * Defines the pointer angular sensibility along the X axis or how fast is
  47671. * the camera rotating.
  47672. */
  47673. angularSensibilityX: number;
  47674. /**
  47675. * Defines the pointer angular sensibility along the Y axis or how fast is
  47676. * the camera rotating.
  47677. */
  47678. angularSensibilityY: number;
  47679. /**
  47680. * Defines the pointer pinch precision or how fast is the camera zooming.
  47681. */
  47682. pinchPrecision: number;
  47683. /**
  47684. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47685. * from 0.
  47686. * It defines the percentage of current camera.radius to use as delta when
  47687. * pinch zoom is used.
  47688. */
  47689. pinchDeltaPercentage: number;
  47690. /**
  47691. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47692. * that any object in the plane at the camera's target point will scale
  47693. * perfectly with finger motion.
  47694. * Overrides pinchDeltaPercentage and pinchPrecision.
  47695. */
  47696. useNaturalPinchZoom: boolean;
  47697. /**
  47698. * Defines the pointer panning sensibility or how fast is the camera moving.
  47699. */
  47700. panningSensibility: number;
  47701. /**
  47702. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47703. */
  47704. multiTouchPanning: boolean;
  47705. /**
  47706. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47707. * zoom (pinch) through multitouch.
  47708. */
  47709. multiTouchPanAndZoom: boolean;
  47710. /**
  47711. * Revers pinch action direction.
  47712. */
  47713. pinchInwards: boolean;
  47714. private _isPanClick;
  47715. private _twoFingerActivityCount;
  47716. private _isPinching;
  47717. /**
  47718. * Called on pointer POINTERMOVE event if only a single touch is active.
  47719. */
  47720. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47721. /**
  47722. * Called on pointer POINTERDOUBLETAP event.
  47723. */
  47724. protected onDoubleTap(type: string): void;
  47725. /**
  47726. * Called on pointer POINTERMOVE event if multiple touches are active.
  47727. */
  47728. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47729. /**
  47730. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47731. * press.
  47732. */
  47733. protected onButtonDown(evt: PointerEvent): void;
  47734. /**
  47735. * Called each time a new POINTERUP event occurs. Ie, for each button
  47736. * release.
  47737. */
  47738. protected onButtonUp(evt: PointerEvent): void;
  47739. /**
  47740. * Called when window becomes inactive.
  47741. */
  47742. protected onLostFocus(): void;
  47743. }
  47744. }
  47745. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  47746. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47747. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47748. /**
  47749. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  47750. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47751. */
  47752. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  47753. /**
  47754. * Defines the camera the input is attached to.
  47755. */
  47756. camera: ArcRotateCamera;
  47757. /**
  47758. * Defines the list of key codes associated with the up action (increase alpha)
  47759. */
  47760. keysUp: number[];
  47761. /**
  47762. * Defines the list of key codes associated with the down action (decrease alpha)
  47763. */
  47764. keysDown: number[];
  47765. /**
  47766. * Defines the list of key codes associated with the left action (increase beta)
  47767. */
  47768. keysLeft: number[];
  47769. /**
  47770. * Defines the list of key codes associated with the right action (decrease beta)
  47771. */
  47772. keysRight: number[];
  47773. /**
  47774. * Defines the list of key codes associated with the reset action.
  47775. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  47776. */
  47777. keysReset: number[];
  47778. /**
  47779. * Defines the panning sensibility of the inputs.
  47780. * (How fast is the camera panning)
  47781. */
  47782. panningSensibility: number;
  47783. /**
  47784. * Defines the zooming sensibility of the inputs.
  47785. * (How fast is the camera zooming)
  47786. */
  47787. zoomingSensibility: number;
  47788. /**
  47789. * Defines whether maintaining the alt key down switch the movement mode from
  47790. * orientation to zoom.
  47791. */
  47792. useAltToZoom: boolean;
  47793. /**
  47794. * Rotation speed of the camera
  47795. */
  47796. angularSpeed: number;
  47797. private _keys;
  47798. private _ctrlPressed;
  47799. private _altPressed;
  47800. private _onCanvasBlurObserver;
  47801. private _onKeyboardObserver;
  47802. private _engine;
  47803. private _scene;
  47804. /**
  47805. * Attach the input controls to a specific dom element to get the input from.
  47806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47807. */
  47808. attachControl(noPreventDefault?: boolean): void;
  47809. /**
  47810. * Detach the current controls from the specified dom element.
  47811. */
  47812. detachControl(): void;
  47813. /**
  47814. * Update the current camera state depending on the inputs that have been used this frame.
  47815. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47816. */
  47817. checkInputs(): void;
  47818. /**
  47819. * Gets the class name of the current intput.
  47820. * @returns the class name
  47821. */
  47822. getClassName(): string;
  47823. /**
  47824. * Get the friendly name associated with the input class.
  47825. * @returns the input friendly name
  47826. */
  47827. getSimpleName(): string;
  47828. }
  47829. }
  47830. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  47831. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47832. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47833. /**
  47834. * Manage the mouse wheel inputs to control an arc rotate camera.
  47835. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47836. */
  47837. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  47838. /**
  47839. * Defines the camera the input is attached to.
  47840. */
  47841. camera: ArcRotateCamera;
  47842. /**
  47843. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47844. */
  47845. wheelPrecision: number;
  47846. /**
  47847. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47848. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47849. */
  47850. wheelDeltaPercentage: number;
  47851. private _wheel;
  47852. private _observer;
  47853. private computeDeltaFromMouseWheelLegacyEvent;
  47854. /**
  47855. * Attach the input controls to a specific dom element to get the input from.
  47856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47857. */
  47858. attachControl(noPreventDefault?: boolean): void;
  47859. /**
  47860. * Detach the current controls from the specified dom element.
  47861. */
  47862. detachControl(): void;
  47863. /**
  47864. * Gets the class name of the current intput.
  47865. * @returns the class name
  47866. */
  47867. getClassName(): string;
  47868. /**
  47869. * Get the friendly name associated with the input class.
  47870. * @returns the input friendly name
  47871. */
  47872. getSimpleName(): string;
  47873. }
  47874. }
  47875. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47876. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47877. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  47878. /**
  47879. * Default Inputs manager for the ArcRotateCamera.
  47880. * It groups all the default supported inputs for ease of use.
  47881. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47882. */
  47883. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  47884. /**
  47885. * Instantiates a new ArcRotateCameraInputsManager.
  47886. * @param camera Defines the camera the inputs belong to
  47887. */
  47888. constructor(camera: ArcRotateCamera);
  47889. /**
  47890. * Add mouse wheel input support to the input manager.
  47891. * @returns the current input manager
  47892. */
  47893. addMouseWheel(): ArcRotateCameraInputsManager;
  47894. /**
  47895. * Add pointers input support to the input manager.
  47896. * @returns the current input manager
  47897. */
  47898. addPointers(): ArcRotateCameraInputsManager;
  47899. /**
  47900. * Add keyboard input support to the input manager.
  47901. * @returns the current input manager
  47902. */
  47903. addKeyboard(): ArcRotateCameraInputsManager;
  47904. }
  47905. }
  47906. declare module "babylonjs/Cameras/arcRotateCamera" {
  47907. import { Observable } from "babylonjs/Misc/observable";
  47908. import { Nullable } from "babylonjs/types";
  47909. import { Scene } from "babylonjs/scene";
  47910. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47912. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47913. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47914. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  47915. import { Camera } from "babylonjs/Cameras/camera";
  47916. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  47917. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47918. import { Collider } from "babylonjs/Collisions/collider";
  47919. /**
  47920. * This represents an orbital type of camera.
  47921. *
  47922. * 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.
  47923. * 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.
  47924. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  47925. */
  47926. export class ArcRotateCamera extends TargetCamera {
  47927. /**
  47928. * Defines the rotation angle of the camera along the longitudinal axis.
  47929. */
  47930. alpha: number;
  47931. /**
  47932. * Defines the rotation angle of the camera along the latitudinal axis.
  47933. */
  47934. beta: number;
  47935. /**
  47936. * Defines the radius of the camera from it s target point.
  47937. */
  47938. radius: number;
  47939. protected _target: Vector3;
  47940. protected _targetHost: Nullable<AbstractMesh>;
  47941. /**
  47942. * Defines the target point of the camera.
  47943. * The camera looks towards it form the radius distance.
  47944. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  47945. */
  47946. get target(): Vector3;
  47947. set target(value: Vector3);
  47948. /**
  47949. * Define the current local position of the camera in the scene
  47950. */
  47951. get position(): Vector3;
  47952. set position(newPosition: Vector3);
  47953. protected _upToYMatrix: Matrix;
  47954. protected _YToUpMatrix: Matrix;
  47955. /**
  47956. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  47957. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  47958. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  47959. */
  47960. set upVector(vec: Vector3);
  47961. get upVector(): Vector3;
  47962. /**
  47963. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  47964. */
  47965. setMatUp(): void;
  47966. /**
  47967. * Current inertia value on the longitudinal axis.
  47968. * The bigger this number the longer it will take for the camera to stop.
  47969. */
  47970. inertialAlphaOffset: number;
  47971. /**
  47972. * Current inertia value on the latitudinal axis.
  47973. * The bigger this number the longer it will take for the camera to stop.
  47974. */
  47975. inertialBetaOffset: number;
  47976. /**
  47977. * Current inertia value on the radius axis.
  47978. * The bigger this number the longer it will take for the camera to stop.
  47979. */
  47980. inertialRadiusOffset: number;
  47981. /**
  47982. * Minimum allowed angle on the longitudinal axis.
  47983. * This can help limiting how the Camera is able to move in the scene.
  47984. */
  47985. lowerAlphaLimit: Nullable<number>;
  47986. /**
  47987. * Maximum allowed angle on the longitudinal axis.
  47988. * This can help limiting how the Camera is able to move in the scene.
  47989. */
  47990. upperAlphaLimit: Nullable<number>;
  47991. /**
  47992. * Minimum allowed angle on the latitudinal axis.
  47993. * This can help limiting how the Camera is able to move in the scene.
  47994. */
  47995. lowerBetaLimit: number;
  47996. /**
  47997. * Maximum allowed angle on the latitudinal axis.
  47998. * This can help limiting how the Camera is able to move in the scene.
  47999. */
  48000. upperBetaLimit: number;
  48001. /**
  48002. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  48003. * This can help limiting how the Camera is able to move in the scene.
  48004. */
  48005. lowerRadiusLimit: Nullable<number>;
  48006. /**
  48007. * Maximum allowed distance of the camera to the target (The camera can not get further).
  48008. * This can help limiting how the Camera is able to move in the scene.
  48009. */
  48010. upperRadiusLimit: Nullable<number>;
  48011. /**
  48012. * Defines the current inertia value used during panning of the camera along the X axis.
  48013. */
  48014. inertialPanningX: number;
  48015. /**
  48016. * Defines the current inertia value used during panning of the camera along the Y axis.
  48017. */
  48018. inertialPanningY: number;
  48019. /**
  48020. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  48021. * Basically if your fingers moves away from more than this distance you will be considered
  48022. * in pinch mode.
  48023. */
  48024. pinchToPanMaxDistance: number;
  48025. /**
  48026. * Defines the maximum distance the camera can pan.
  48027. * This could help keeping the cammera always in your scene.
  48028. */
  48029. panningDistanceLimit: Nullable<number>;
  48030. /**
  48031. * Defines the target of the camera before paning.
  48032. */
  48033. panningOriginTarget: Vector3;
  48034. /**
  48035. * Defines the value of the inertia used during panning.
  48036. * 0 would mean stop inertia and one would mean no decelleration at all.
  48037. */
  48038. panningInertia: number;
  48039. /**
  48040. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  48041. */
  48042. get angularSensibilityX(): number;
  48043. set angularSensibilityX(value: number);
  48044. /**
  48045. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  48046. */
  48047. get angularSensibilityY(): number;
  48048. set angularSensibilityY(value: number);
  48049. /**
  48050. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  48051. */
  48052. get pinchPrecision(): number;
  48053. set pinchPrecision(value: number);
  48054. /**
  48055. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  48056. * It will be used instead of pinchDeltaPrecision if different from 0.
  48057. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48058. */
  48059. get pinchDeltaPercentage(): number;
  48060. set pinchDeltaPercentage(value: number);
  48061. /**
  48062. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  48063. * and pinch delta percentage.
  48064. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  48065. * that any object in the plane at the camera's target point will scale
  48066. * perfectly with finger motion.
  48067. */
  48068. get useNaturalPinchZoom(): boolean;
  48069. set useNaturalPinchZoom(value: boolean);
  48070. /**
  48071. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  48072. */
  48073. get panningSensibility(): number;
  48074. set panningSensibility(value: number);
  48075. /**
  48076. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  48077. */
  48078. get keysUp(): number[];
  48079. set keysUp(value: number[]);
  48080. /**
  48081. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  48082. */
  48083. get keysDown(): number[];
  48084. set keysDown(value: number[]);
  48085. /**
  48086. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  48087. */
  48088. get keysLeft(): number[];
  48089. set keysLeft(value: number[]);
  48090. /**
  48091. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  48092. */
  48093. get keysRight(): number[];
  48094. set keysRight(value: number[]);
  48095. /**
  48096. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48097. */
  48098. get wheelPrecision(): number;
  48099. set wheelPrecision(value: number);
  48100. /**
  48101. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  48102. * It will be used instead of pinchDeltaPrecision if different from 0.
  48103. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48104. */
  48105. get wheelDeltaPercentage(): number;
  48106. set wheelDeltaPercentage(value: number);
  48107. /**
  48108. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  48109. */
  48110. zoomOnFactor: number;
  48111. /**
  48112. * Defines a screen offset for the camera position.
  48113. */
  48114. targetScreenOffset: Vector2;
  48115. /**
  48116. * Allows the camera to be completely reversed.
  48117. * If false the camera can not arrive upside down.
  48118. */
  48119. allowUpsideDown: boolean;
  48120. /**
  48121. * Define if double tap/click is used to restore the previously saved state of the camera.
  48122. */
  48123. useInputToRestoreState: boolean;
  48124. /** @hidden */
  48125. _viewMatrix: Matrix;
  48126. /** @hidden */
  48127. _useCtrlForPanning: boolean;
  48128. /** @hidden */
  48129. _panningMouseButton: number;
  48130. /**
  48131. * Defines the input associated to the camera.
  48132. */
  48133. inputs: ArcRotateCameraInputsManager;
  48134. /** @hidden */
  48135. _reset: () => void;
  48136. /**
  48137. * Defines the allowed panning axis.
  48138. */
  48139. panningAxis: Vector3;
  48140. protected _localDirection: Vector3;
  48141. protected _transformedDirection: Vector3;
  48142. private _bouncingBehavior;
  48143. /**
  48144. * Gets the bouncing behavior of the camera if it has been enabled.
  48145. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48146. */
  48147. get bouncingBehavior(): Nullable<BouncingBehavior>;
  48148. /**
  48149. * Defines if the bouncing behavior of the camera is enabled on the camera.
  48150. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48151. */
  48152. get useBouncingBehavior(): boolean;
  48153. set useBouncingBehavior(value: boolean);
  48154. private _framingBehavior;
  48155. /**
  48156. * Gets the framing behavior of the camera if it has been enabled.
  48157. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48158. */
  48159. get framingBehavior(): Nullable<FramingBehavior>;
  48160. /**
  48161. * Defines if the framing behavior of the camera is enabled on the camera.
  48162. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48163. */
  48164. get useFramingBehavior(): boolean;
  48165. set useFramingBehavior(value: boolean);
  48166. private _autoRotationBehavior;
  48167. /**
  48168. * Gets the auto rotation behavior of the camera if it has been enabled.
  48169. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48170. */
  48171. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  48172. /**
  48173. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  48174. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48175. */
  48176. get useAutoRotationBehavior(): boolean;
  48177. set useAutoRotationBehavior(value: boolean);
  48178. /**
  48179. * Observable triggered when the mesh target has been changed on the camera.
  48180. */
  48181. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  48182. /**
  48183. * Event raised when the camera is colliding with a mesh.
  48184. */
  48185. onCollide: (collidedMesh: AbstractMesh) => void;
  48186. /**
  48187. * Defines whether the camera should check collision with the objects oh the scene.
  48188. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  48189. */
  48190. checkCollisions: boolean;
  48191. /**
  48192. * Defines the collision radius of the camera.
  48193. * This simulates a sphere around the camera.
  48194. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48195. */
  48196. collisionRadius: Vector3;
  48197. protected _collider: Collider;
  48198. protected _previousPosition: Vector3;
  48199. protected _collisionVelocity: Vector3;
  48200. protected _newPosition: Vector3;
  48201. protected _previousAlpha: number;
  48202. protected _previousBeta: number;
  48203. protected _previousRadius: number;
  48204. protected _collisionTriggered: boolean;
  48205. protected _targetBoundingCenter: Nullable<Vector3>;
  48206. private _computationVector;
  48207. /**
  48208. * Instantiates a new ArcRotateCamera in a given scene
  48209. * @param name Defines the name of the camera
  48210. * @param alpha Defines the camera rotation along the logitudinal axis
  48211. * @param beta Defines the camera rotation along the latitudinal axis
  48212. * @param radius Defines the camera distance from its target
  48213. * @param target Defines the camera target
  48214. * @param scene Defines the scene the camera belongs to
  48215. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  48216. */
  48217. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48218. /** @hidden */
  48219. _initCache(): void;
  48220. /** @hidden */
  48221. _updateCache(ignoreParentClass?: boolean): void;
  48222. protected _getTargetPosition(): Vector3;
  48223. private _storedAlpha;
  48224. private _storedBeta;
  48225. private _storedRadius;
  48226. private _storedTarget;
  48227. private _storedTargetScreenOffset;
  48228. /**
  48229. * Stores the current state of the camera (alpha, beta, radius and target)
  48230. * @returns the camera itself
  48231. */
  48232. storeState(): Camera;
  48233. /**
  48234. * @hidden
  48235. * Restored camera state. You must call storeState() first
  48236. */
  48237. _restoreStateValues(): boolean;
  48238. /** @hidden */
  48239. _isSynchronizedViewMatrix(): boolean;
  48240. /**
  48241. * Attach the input controls to a specific dom element to get the input from.
  48242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48243. */
  48244. attachControl(noPreventDefault?: boolean): void;
  48245. /**
  48246. * Attach the input controls to a specific dom element to get the input from.
  48247. * @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
  48248. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48249. */
  48250. attachControl(ignored: any, noPreventDefault?: boolean): void;
  48251. /**
  48252. * Attached controls to the current camera.
  48253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48254. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48255. */
  48256. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48257. /**
  48258. * Attached controls to the current camera.
  48259. * @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
  48260. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48261. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48262. */
  48263. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48264. /**
  48265. * Attached controls to the current camera.
  48266. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48267. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48268. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  48269. */
  48270. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  48271. /**
  48272. * Detach the current controls from the camera.
  48273. * The camera will stop reacting to inputs.
  48274. */
  48275. detachControl(): void;
  48276. /** @hidden */
  48277. _checkInputs(): void;
  48278. protected _checkLimits(): void;
  48279. /**
  48280. * Rebuilds angles (alpha, beta) and radius from the give position and target
  48281. */
  48282. rebuildAnglesAndRadius(): void;
  48283. /**
  48284. * Use a position to define the current camera related information like alpha, beta and radius
  48285. * @param position Defines the position to set the camera at
  48286. */
  48287. setPosition(position: Vector3): void;
  48288. /**
  48289. * Defines the target the camera should look at.
  48290. * This will automatically adapt alpha beta and radius to fit within the new target.
  48291. * @param target Defines the new target as a Vector or a mesh
  48292. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  48293. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  48294. */
  48295. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  48296. /** @hidden */
  48297. _getViewMatrix(): Matrix;
  48298. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  48299. /**
  48300. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  48301. * @param meshes Defines the mesh to zoom on
  48302. * @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)
  48303. */
  48304. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  48305. /**
  48306. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  48307. * The target will be changed but the radius
  48308. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  48309. * @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)
  48310. */
  48311. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  48312. min: Vector3;
  48313. max: Vector3;
  48314. distance: number;
  48315. }, doNotUpdateMaxZ?: boolean): void;
  48316. /**
  48317. * @override
  48318. * Override Camera.createRigCamera
  48319. */
  48320. createRigCamera(name: string, cameraIndex: number): Camera;
  48321. /**
  48322. * @hidden
  48323. * @override
  48324. * Override Camera._updateRigCameras
  48325. */
  48326. _updateRigCameras(): void;
  48327. /**
  48328. * Destroy the camera and release the current resources hold by it.
  48329. */
  48330. dispose(): void;
  48331. /**
  48332. * Gets the current object class name.
  48333. * @return the class name
  48334. */
  48335. getClassName(): string;
  48336. }
  48337. }
  48338. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  48339. import { Behavior } from "babylonjs/Behaviors/behavior";
  48340. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48341. /**
  48342. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  48343. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48344. */
  48345. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  48346. /**
  48347. * Gets the name of the behavior.
  48348. */
  48349. get name(): string;
  48350. private _zoomStopsAnimation;
  48351. private _idleRotationSpeed;
  48352. private _idleRotationWaitTime;
  48353. private _idleRotationSpinupTime;
  48354. /**
  48355. * Sets the flag that indicates if user zooming should stop animation.
  48356. */
  48357. set zoomStopsAnimation(flag: boolean);
  48358. /**
  48359. * Gets the flag that indicates if user zooming should stop animation.
  48360. */
  48361. get zoomStopsAnimation(): boolean;
  48362. /**
  48363. * Sets the default speed at which the camera rotates around the model.
  48364. */
  48365. set idleRotationSpeed(speed: number);
  48366. /**
  48367. * Gets the default speed at which the camera rotates around the model.
  48368. */
  48369. get idleRotationSpeed(): number;
  48370. /**
  48371. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48372. */
  48373. set idleRotationWaitTime(time: number);
  48374. /**
  48375. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48376. */
  48377. get idleRotationWaitTime(): number;
  48378. /**
  48379. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48380. */
  48381. set idleRotationSpinupTime(time: number);
  48382. /**
  48383. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48384. */
  48385. get idleRotationSpinupTime(): number;
  48386. /**
  48387. * Gets a value indicating if the camera is currently rotating because of this behavior
  48388. */
  48389. get rotationInProgress(): boolean;
  48390. private _onPrePointerObservableObserver;
  48391. private _onAfterCheckInputsObserver;
  48392. private _attachedCamera;
  48393. private _isPointerDown;
  48394. private _lastFrameTime;
  48395. private _lastInteractionTime;
  48396. private _cameraRotationSpeed;
  48397. /**
  48398. * Initializes the behavior.
  48399. */
  48400. init(): void;
  48401. /**
  48402. * Attaches the behavior to its arc rotate camera.
  48403. * @param camera Defines the camera to attach the behavior to
  48404. */
  48405. attach(camera: ArcRotateCamera): void;
  48406. /**
  48407. * Detaches the behavior from its current arc rotate camera.
  48408. */
  48409. detach(): void;
  48410. /**
  48411. * Returns true if user is scrolling.
  48412. * @return true if user is scrolling.
  48413. */
  48414. private _userIsZooming;
  48415. private _lastFrameRadius;
  48416. private _shouldAnimationStopForInteraction;
  48417. /**
  48418. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48419. */
  48420. private _applyUserInteraction;
  48421. private _userIsMoving;
  48422. }
  48423. }
  48424. declare module "babylonjs/Behaviors/Cameras/index" {
  48425. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48426. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48427. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48428. }
  48429. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48430. import { Mesh } from "babylonjs/Meshes/mesh";
  48431. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48432. import { Behavior } from "babylonjs/Behaviors/behavior";
  48433. /**
  48434. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48435. */
  48436. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48437. private ui;
  48438. /**
  48439. * The name of the behavior
  48440. */
  48441. name: string;
  48442. /**
  48443. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48444. */
  48445. distanceAwayFromFace: number;
  48446. /**
  48447. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48448. */
  48449. distanceAwayFromBottomOfFace: number;
  48450. private _faceVectors;
  48451. private _target;
  48452. private _scene;
  48453. private _onRenderObserver;
  48454. private _tmpMatrix;
  48455. private _tmpVector;
  48456. /**
  48457. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48458. * @param ui The transform node that should be attched to the mesh
  48459. */
  48460. constructor(ui: TransformNode);
  48461. /**
  48462. * Initializes the behavior
  48463. */
  48464. init(): void;
  48465. private _closestFace;
  48466. private _zeroVector;
  48467. private _lookAtTmpMatrix;
  48468. private _lookAtToRef;
  48469. /**
  48470. * Attaches the AttachToBoxBehavior to the passed in mesh
  48471. * @param target The mesh that the specified node will be attached to
  48472. */
  48473. attach(target: Mesh): void;
  48474. /**
  48475. * Detaches the behavior from the mesh
  48476. */
  48477. detach(): void;
  48478. }
  48479. }
  48480. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48481. import { Behavior } from "babylonjs/Behaviors/behavior";
  48482. import { Mesh } from "babylonjs/Meshes/mesh";
  48483. /**
  48484. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48485. */
  48486. export class FadeInOutBehavior implements Behavior<Mesh> {
  48487. /**
  48488. * Time in milliseconds to delay before fading in (Default: 0)
  48489. */
  48490. delay: number;
  48491. /**
  48492. * Time in milliseconds for the mesh to fade in (Default: 300)
  48493. */
  48494. fadeInTime: number;
  48495. private _millisecondsPerFrame;
  48496. private _hovered;
  48497. private _hoverValue;
  48498. private _ownerNode;
  48499. /**
  48500. * Instatiates the FadeInOutBehavior
  48501. */
  48502. constructor();
  48503. /**
  48504. * The name of the behavior
  48505. */
  48506. get name(): string;
  48507. /**
  48508. * Initializes the behavior
  48509. */
  48510. init(): void;
  48511. /**
  48512. * Attaches the fade behavior on the passed in mesh
  48513. * @param ownerNode The mesh that will be faded in/out once attached
  48514. */
  48515. attach(ownerNode: Mesh): void;
  48516. /**
  48517. * Detaches the behavior from the mesh
  48518. */
  48519. detach(): void;
  48520. /**
  48521. * Triggers the mesh to begin fading in or out
  48522. * @param value if the object should fade in or out (true to fade in)
  48523. */
  48524. fadeIn(value: boolean): void;
  48525. private _update;
  48526. private _setAllVisibility;
  48527. }
  48528. }
  48529. declare module "babylonjs/Misc/pivotTools" {
  48530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48531. /**
  48532. * Class containing a set of static utilities functions for managing Pivots
  48533. * @hidden
  48534. */
  48535. export class PivotTools {
  48536. private static _PivotCached;
  48537. private static _OldPivotPoint;
  48538. private static _PivotTranslation;
  48539. private static _PivotTmpVector;
  48540. private static _PivotPostMultiplyPivotMatrix;
  48541. /** @hidden */
  48542. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48543. /** @hidden */
  48544. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48545. }
  48546. }
  48547. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48548. import { Scene } from "babylonjs/scene";
  48549. import { Vector4 } from "babylonjs/Maths/math.vector";
  48550. import { Mesh } from "babylonjs/Meshes/mesh";
  48551. import { Nullable } from "babylonjs/types";
  48552. import { Plane } from "babylonjs/Maths/math.plane";
  48553. /**
  48554. * Class containing static functions to help procedurally build meshes
  48555. */
  48556. export class PlaneBuilder {
  48557. /**
  48558. * Creates a plane mesh
  48559. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48560. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48561. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48565. * @param name defines the name of the mesh
  48566. * @param options defines the options used to create the mesh
  48567. * @param scene defines the hosting scene
  48568. * @returns the plane mesh
  48569. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48570. */
  48571. static CreatePlane(name: string, options: {
  48572. size?: number;
  48573. width?: number;
  48574. height?: number;
  48575. sideOrientation?: number;
  48576. frontUVs?: Vector4;
  48577. backUVs?: Vector4;
  48578. updatable?: boolean;
  48579. sourcePlane?: Plane;
  48580. }, scene?: Nullable<Scene>): Mesh;
  48581. }
  48582. }
  48583. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48584. import { Behavior } from "babylonjs/Behaviors/behavior";
  48585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48586. import { Observable } from "babylonjs/Misc/observable";
  48587. import { Vector3 } from "babylonjs/Maths/math.vector";
  48588. import { Ray } from "babylonjs/Culling/ray";
  48589. import "babylonjs/Meshes/Builders/planeBuilder";
  48590. /**
  48591. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48592. */
  48593. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48594. private static _AnyMouseID;
  48595. /**
  48596. * Abstract mesh the behavior is set on
  48597. */
  48598. attachedNode: AbstractMesh;
  48599. private _dragPlane;
  48600. private _scene;
  48601. private _pointerObserver;
  48602. private _beforeRenderObserver;
  48603. private static _planeScene;
  48604. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48605. /**
  48606. * 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)
  48607. */
  48608. maxDragAngle: number;
  48609. /**
  48610. * @hidden
  48611. */
  48612. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48613. /**
  48614. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48615. */
  48616. currentDraggingPointerID: number;
  48617. /**
  48618. * The last position where the pointer hit the drag plane in world space
  48619. */
  48620. lastDragPosition: Vector3;
  48621. /**
  48622. * If the behavior is currently in a dragging state
  48623. */
  48624. dragging: boolean;
  48625. /**
  48626. * 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)
  48627. */
  48628. dragDeltaRatio: number;
  48629. /**
  48630. * If the drag plane orientation should be updated during the dragging (Default: true)
  48631. */
  48632. updateDragPlane: boolean;
  48633. private _debugMode;
  48634. private _moving;
  48635. /**
  48636. * Fires each time the attached mesh is dragged with the pointer
  48637. * * delta between last drag position and current drag position in world space
  48638. * * dragDistance along the drag axis
  48639. * * dragPlaneNormal normal of the current drag plane used during the drag
  48640. * * dragPlanePoint in world space where the drag intersects the drag plane
  48641. */
  48642. onDragObservable: Observable<{
  48643. delta: Vector3;
  48644. dragPlanePoint: Vector3;
  48645. dragPlaneNormal: Vector3;
  48646. dragDistance: number;
  48647. pointerId: number;
  48648. }>;
  48649. /**
  48650. * Fires each time a drag begins (eg. mouse down on mesh)
  48651. */
  48652. onDragStartObservable: Observable<{
  48653. dragPlanePoint: Vector3;
  48654. pointerId: number;
  48655. }>;
  48656. /**
  48657. * Fires each time a drag ends (eg. mouse release after drag)
  48658. */
  48659. onDragEndObservable: Observable<{
  48660. dragPlanePoint: Vector3;
  48661. pointerId: number;
  48662. }>;
  48663. /**
  48664. * If the attached mesh should be moved when dragged
  48665. */
  48666. moveAttached: boolean;
  48667. /**
  48668. * If the drag behavior will react to drag events (Default: true)
  48669. */
  48670. enabled: boolean;
  48671. /**
  48672. * If pointer events should start and release the drag (Default: true)
  48673. */
  48674. startAndReleaseDragOnPointerEvents: boolean;
  48675. /**
  48676. * If camera controls should be detached during the drag
  48677. */
  48678. detachCameraControls: boolean;
  48679. /**
  48680. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48681. */
  48682. useObjectOrientationForDragging: boolean;
  48683. private _options;
  48684. /**
  48685. * Gets the options used by the behavior
  48686. */
  48687. get options(): {
  48688. dragAxis?: Vector3;
  48689. dragPlaneNormal?: Vector3;
  48690. };
  48691. /**
  48692. * Sets the options used by the behavior
  48693. */
  48694. set options(options: {
  48695. dragAxis?: Vector3;
  48696. dragPlaneNormal?: Vector3;
  48697. });
  48698. /**
  48699. * Creates a pointer drag behavior that can be attached to a mesh
  48700. * @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)
  48701. */
  48702. constructor(options?: {
  48703. dragAxis?: Vector3;
  48704. dragPlaneNormal?: Vector3;
  48705. });
  48706. /**
  48707. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48708. */
  48709. validateDrag: (targetPosition: Vector3) => boolean;
  48710. /**
  48711. * The name of the behavior
  48712. */
  48713. get name(): string;
  48714. /**
  48715. * Initializes the behavior
  48716. */
  48717. init(): void;
  48718. private _tmpVector;
  48719. private _alternatePickedPoint;
  48720. private _worldDragAxis;
  48721. private _targetPosition;
  48722. private _attachedToElement;
  48723. /**
  48724. * Attaches the drag behavior the passed in mesh
  48725. * @param ownerNode The mesh that will be dragged around once attached
  48726. * @param predicate Predicate to use for pick filtering
  48727. */
  48728. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48729. /**
  48730. * Force relase the drag action by code.
  48731. */
  48732. releaseDrag(): void;
  48733. private _startDragRay;
  48734. private _lastPointerRay;
  48735. /**
  48736. * Simulates the start of a pointer drag event on the behavior
  48737. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48738. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48739. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48740. */
  48741. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48742. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48743. private _dragDelta;
  48744. protected _moveDrag(ray: Ray): void;
  48745. private _pickWithRayOnDragPlane;
  48746. private _pointA;
  48747. private _pointC;
  48748. private _localAxis;
  48749. private _lookAt;
  48750. private _updateDragPlanePosition;
  48751. /**
  48752. * Detaches the behavior from the mesh
  48753. */
  48754. detach(): void;
  48755. }
  48756. }
  48757. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  48758. import { Mesh } from "babylonjs/Meshes/mesh";
  48759. import { Behavior } from "babylonjs/Behaviors/behavior";
  48760. /**
  48761. * A behavior that when attached to a mesh will allow the mesh to be scaled
  48762. */
  48763. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  48764. private _dragBehaviorA;
  48765. private _dragBehaviorB;
  48766. private _startDistance;
  48767. private _initialScale;
  48768. private _targetScale;
  48769. private _ownerNode;
  48770. private _sceneRenderObserver;
  48771. /**
  48772. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  48773. */
  48774. constructor();
  48775. /**
  48776. * The name of the behavior
  48777. */
  48778. get name(): string;
  48779. /**
  48780. * Initializes the behavior
  48781. */
  48782. init(): void;
  48783. private _getCurrentDistance;
  48784. /**
  48785. * Attaches the scale behavior the passed in mesh
  48786. * @param ownerNode The mesh that will be scaled around once attached
  48787. */
  48788. attach(ownerNode: Mesh): void;
  48789. /**
  48790. * Detaches the behavior from the mesh
  48791. */
  48792. detach(): void;
  48793. }
  48794. }
  48795. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  48796. import { Behavior } from "babylonjs/Behaviors/behavior";
  48797. import { Mesh } from "babylonjs/Meshes/mesh";
  48798. import { Observable } from "babylonjs/Misc/observable";
  48799. /**
  48800. * 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
  48801. */
  48802. export class SixDofDragBehavior implements Behavior<Mesh> {
  48803. private static _virtualScene;
  48804. private _ownerNode;
  48805. private _sceneRenderObserver;
  48806. private _scene;
  48807. private _targetPosition;
  48808. private _virtualOriginMesh;
  48809. private _virtualDragMesh;
  48810. private _pointerObserver;
  48811. private _moving;
  48812. private _startingOrientation;
  48813. private _attachedToElement;
  48814. /**
  48815. * 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)
  48816. */
  48817. private zDragFactor;
  48818. /**
  48819. * If the object should rotate to face the drag origin
  48820. */
  48821. rotateDraggedObject: boolean;
  48822. /**
  48823. * If the behavior is currently in a dragging state
  48824. */
  48825. dragging: boolean;
  48826. /**
  48827. * 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)
  48828. */
  48829. dragDeltaRatio: number;
  48830. /**
  48831. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48832. */
  48833. currentDraggingPointerID: number;
  48834. /**
  48835. * If camera controls should be detached during the drag
  48836. */
  48837. detachCameraControls: boolean;
  48838. /**
  48839. * Fires each time a drag starts
  48840. */
  48841. onDragStartObservable: Observable<{}>;
  48842. /**
  48843. * Fires each time a drag ends (eg. mouse release after drag)
  48844. */
  48845. onDragEndObservable: Observable<{}>;
  48846. /**
  48847. * 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
  48848. */
  48849. constructor();
  48850. /**
  48851. * The name of the behavior
  48852. */
  48853. get name(): string;
  48854. /**
  48855. * Initializes the behavior
  48856. */
  48857. init(): void;
  48858. /**
  48859. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  48860. */
  48861. private get _pointerCamera();
  48862. /**
  48863. * Attaches the scale behavior the passed in mesh
  48864. * @param ownerNode The mesh that will be scaled around once attached
  48865. */
  48866. attach(ownerNode: Mesh): void;
  48867. /**
  48868. * Detaches the behavior from the mesh
  48869. */
  48870. detach(): void;
  48871. }
  48872. }
  48873. declare module "babylonjs/Behaviors/Meshes/index" {
  48874. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  48875. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  48876. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  48877. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48878. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48879. }
  48880. declare module "babylonjs/Behaviors/index" {
  48881. export * from "babylonjs/Behaviors/behavior";
  48882. export * from "babylonjs/Behaviors/Cameras/index";
  48883. export * from "babylonjs/Behaviors/Meshes/index";
  48884. }
  48885. declare module "babylonjs/Bones/boneIKController" {
  48886. import { Bone } from "babylonjs/Bones/bone";
  48887. import { Vector3 } from "babylonjs/Maths/math.vector";
  48888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48889. import { Nullable } from "babylonjs/types";
  48890. /**
  48891. * Class used to apply inverse kinematics to bones
  48892. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  48893. */
  48894. export class BoneIKController {
  48895. private static _tmpVecs;
  48896. private static _tmpQuat;
  48897. private static _tmpMats;
  48898. /**
  48899. * Gets or sets the target mesh
  48900. */
  48901. targetMesh: AbstractMesh;
  48902. /** Gets or sets the mesh used as pole */
  48903. poleTargetMesh: AbstractMesh;
  48904. /**
  48905. * Gets or sets the bone used as pole
  48906. */
  48907. poleTargetBone: Nullable<Bone>;
  48908. /**
  48909. * Gets or sets the target position
  48910. */
  48911. targetPosition: Vector3;
  48912. /**
  48913. * Gets or sets the pole target position
  48914. */
  48915. poleTargetPosition: Vector3;
  48916. /**
  48917. * Gets or sets the pole target local offset
  48918. */
  48919. poleTargetLocalOffset: Vector3;
  48920. /**
  48921. * Gets or sets the pole angle
  48922. */
  48923. poleAngle: number;
  48924. /**
  48925. * Gets or sets the mesh associated with the controller
  48926. */
  48927. mesh: AbstractMesh;
  48928. /**
  48929. * 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)
  48930. */
  48931. slerpAmount: number;
  48932. private _bone1Quat;
  48933. private _bone1Mat;
  48934. private _bone2Ang;
  48935. private _bone1;
  48936. private _bone2;
  48937. private _bone1Length;
  48938. private _bone2Length;
  48939. private _maxAngle;
  48940. private _maxReach;
  48941. private _rightHandedSystem;
  48942. private _bendAxis;
  48943. private _slerping;
  48944. private _adjustRoll;
  48945. /**
  48946. * Gets or sets maximum allowed angle
  48947. */
  48948. get maxAngle(): number;
  48949. set maxAngle(value: number);
  48950. /**
  48951. * Creates a new BoneIKController
  48952. * @param mesh defines the mesh to control
  48953. * @param bone defines the bone to control
  48954. * @param options defines options to set up the controller
  48955. */
  48956. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  48957. targetMesh?: AbstractMesh;
  48958. poleTargetMesh?: AbstractMesh;
  48959. poleTargetBone?: Bone;
  48960. poleTargetLocalOffset?: Vector3;
  48961. poleAngle?: number;
  48962. bendAxis?: Vector3;
  48963. maxAngle?: number;
  48964. slerpAmount?: number;
  48965. });
  48966. private _setMaxAngle;
  48967. /**
  48968. * Force the controller to update the bones
  48969. */
  48970. update(): void;
  48971. }
  48972. }
  48973. declare module "babylonjs/Bones/boneLookController" {
  48974. import { Vector3 } from "babylonjs/Maths/math.vector";
  48975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48976. import { Bone } from "babylonjs/Bones/bone";
  48977. import { Space } from "babylonjs/Maths/math.axis";
  48978. /**
  48979. * Class used to make a bone look toward a point in space
  48980. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  48981. */
  48982. export class BoneLookController {
  48983. private static _tmpVecs;
  48984. private static _tmpQuat;
  48985. private static _tmpMats;
  48986. /**
  48987. * The target Vector3 that the bone will look at
  48988. */
  48989. target: Vector3;
  48990. /**
  48991. * The mesh that the bone is attached to
  48992. */
  48993. mesh: AbstractMesh;
  48994. /**
  48995. * The bone that will be looking to the target
  48996. */
  48997. bone: Bone;
  48998. /**
  48999. * The up axis of the coordinate system that is used when the bone is rotated
  49000. */
  49001. upAxis: Vector3;
  49002. /**
  49003. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  49004. */
  49005. upAxisSpace: Space;
  49006. /**
  49007. * Used to make an adjustment to the yaw of the bone
  49008. */
  49009. adjustYaw: number;
  49010. /**
  49011. * Used to make an adjustment to the pitch of the bone
  49012. */
  49013. adjustPitch: number;
  49014. /**
  49015. * Used to make an adjustment to the roll of the bone
  49016. */
  49017. adjustRoll: number;
  49018. /**
  49019. * 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)
  49020. */
  49021. slerpAmount: number;
  49022. private _minYaw;
  49023. private _maxYaw;
  49024. private _minPitch;
  49025. private _maxPitch;
  49026. private _minYawSin;
  49027. private _minYawCos;
  49028. private _maxYawSin;
  49029. private _maxYawCos;
  49030. private _midYawConstraint;
  49031. private _minPitchTan;
  49032. private _maxPitchTan;
  49033. private _boneQuat;
  49034. private _slerping;
  49035. private _transformYawPitch;
  49036. private _transformYawPitchInv;
  49037. private _firstFrameSkipped;
  49038. private _yawRange;
  49039. private _fowardAxis;
  49040. /**
  49041. * Gets or sets the minimum yaw angle that the bone can look to
  49042. */
  49043. get minYaw(): number;
  49044. set minYaw(value: number);
  49045. /**
  49046. * Gets or sets the maximum yaw angle that the bone can look to
  49047. */
  49048. get maxYaw(): number;
  49049. set maxYaw(value: number);
  49050. /**
  49051. * Gets or sets the minimum pitch angle that the bone can look to
  49052. */
  49053. get minPitch(): number;
  49054. set minPitch(value: number);
  49055. /**
  49056. * Gets or sets the maximum pitch angle that the bone can look to
  49057. */
  49058. get maxPitch(): number;
  49059. set maxPitch(value: number);
  49060. /**
  49061. * Create a BoneLookController
  49062. * @param mesh the mesh that the bone belongs to
  49063. * @param bone the bone that will be looking to the target
  49064. * @param target the target Vector3 to look at
  49065. * @param options optional settings:
  49066. * * maxYaw: the maximum angle the bone will yaw to
  49067. * * minYaw: the minimum angle the bone will yaw to
  49068. * * maxPitch: the maximum angle the bone will pitch to
  49069. * * minPitch: the minimum angle the bone will yaw to
  49070. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  49071. * * upAxis: the up axis of the coordinate system
  49072. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  49073. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  49074. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  49075. * * adjustYaw: used to make an adjustment to the yaw of the bone
  49076. * * adjustPitch: used to make an adjustment to the pitch of the bone
  49077. * * adjustRoll: used to make an adjustment to the roll of the bone
  49078. **/
  49079. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  49080. maxYaw?: number;
  49081. minYaw?: number;
  49082. maxPitch?: number;
  49083. minPitch?: number;
  49084. slerpAmount?: number;
  49085. upAxis?: Vector3;
  49086. upAxisSpace?: Space;
  49087. yawAxis?: Vector3;
  49088. pitchAxis?: Vector3;
  49089. adjustYaw?: number;
  49090. adjustPitch?: number;
  49091. adjustRoll?: number;
  49092. });
  49093. /**
  49094. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  49095. */
  49096. update(): void;
  49097. private _getAngleDiff;
  49098. private _getAngleBetween;
  49099. private _isAngleBetween;
  49100. }
  49101. }
  49102. declare module "babylonjs/Bones/index" {
  49103. export * from "babylonjs/Bones/bone";
  49104. export * from "babylonjs/Bones/boneIKController";
  49105. export * from "babylonjs/Bones/boneLookController";
  49106. export * from "babylonjs/Bones/skeleton";
  49107. }
  49108. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  49109. import { Nullable } from "babylonjs/types";
  49110. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49111. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49112. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49113. /**
  49114. * Manage the gamepad inputs to control an arc rotate camera.
  49115. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49116. */
  49117. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  49118. /**
  49119. * Defines the camera the input is attached to.
  49120. */
  49121. camera: ArcRotateCamera;
  49122. /**
  49123. * Defines the gamepad the input is gathering event from.
  49124. */
  49125. gamepad: Nullable<Gamepad>;
  49126. /**
  49127. * Defines the gamepad rotation sensiblity.
  49128. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49129. */
  49130. gamepadRotationSensibility: number;
  49131. /**
  49132. * Defines the gamepad move sensiblity.
  49133. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49134. */
  49135. gamepadMoveSensibility: number;
  49136. private _yAxisScale;
  49137. /**
  49138. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49139. */
  49140. get invertYAxis(): boolean;
  49141. set invertYAxis(value: boolean);
  49142. private _onGamepadConnectedObserver;
  49143. private _onGamepadDisconnectedObserver;
  49144. /**
  49145. * Attach the input controls to a specific dom element to get the input from.
  49146. */
  49147. attachControl(): void;
  49148. /**
  49149. * Detach the current controls from the specified dom element.
  49150. * @param element Defines the element to stop listening the inputs from
  49151. */
  49152. detachControl(): void;
  49153. /**
  49154. * Update the current camera state depending on the inputs that have been used this frame.
  49155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49156. */
  49157. checkInputs(): void;
  49158. /**
  49159. * Gets the class name of the current intput.
  49160. * @returns the class name
  49161. */
  49162. getClassName(): string;
  49163. /**
  49164. * Get the friendly name associated with the input class.
  49165. * @returns the input friendly name
  49166. */
  49167. getSimpleName(): string;
  49168. }
  49169. }
  49170. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  49171. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49172. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49173. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  49174. interface ArcRotateCameraInputsManager {
  49175. /**
  49176. * Add orientation input support to the input manager.
  49177. * @returns the current input manager
  49178. */
  49179. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  49180. }
  49181. }
  49182. /**
  49183. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  49184. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49185. */
  49186. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  49187. /**
  49188. * Defines the camera the input is attached to.
  49189. */
  49190. camera: ArcRotateCamera;
  49191. /**
  49192. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  49193. */
  49194. alphaCorrection: number;
  49195. /**
  49196. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  49197. */
  49198. gammaCorrection: number;
  49199. private _alpha;
  49200. private _gamma;
  49201. private _dirty;
  49202. private _deviceOrientationHandler;
  49203. /**
  49204. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  49205. */
  49206. constructor();
  49207. /**
  49208. * Attach the input controls to a specific dom element to get the input from.
  49209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49210. */
  49211. attachControl(noPreventDefault?: boolean): void;
  49212. /** @hidden */
  49213. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  49214. /**
  49215. * Update the current camera state depending on the inputs that have been used this frame.
  49216. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49217. */
  49218. checkInputs(): void;
  49219. /**
  49220. * Detach the current controls from the specified dom element.
  49221. */
  49222. detachControl(): void;
  49223. /**
  49224. * Gets the class name of the current intput.
  49225. * @returns the class name
  49226. */
  49227. getClassName(): string;
  49228. /**
  49229. * Get the friendly name associated with the input class.
  49230. * @returns the input friendly name
  49231. */
  49232. getSimpleName(): string;
  49233. }
  49234. }
  49235. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  49236. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49237. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49238. /**
  49239. * Listen to mouse events to control the camera.
  49240. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49241. */
  49242. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  49243. /**
  49244. * Defines the camera the input is attached to.
  49245. */
  49246. camera: FlyCamera;
  49247. /**
  49248. * Defines if touch is enabled. (Default is true.)
  49249. */
  49250. touchEnabled: boolean;
  49251. /**
  49252. * Defines the buttons associated with the input to handle camera rotation.
  49253. */
  49254. buttons: number[];
  49255. /**
  49256. * Assign buttons for Yaw control.
  49257. */
  49258. buttonsYaw: number[];
  49259. /**
  49260. * Assign buttons for Pitch control.
  49261. */
  49262. buttonsPitch: number[];
  49263. /**
  49264. * Assign buttons for Roll control.
  49265. */
  49266. buttonsRoll: number[];
  49267. /**
  49268. * Detect if any button is being pressed while mouse is moved.
  49269. * -1 = Mouse locked.
  49270. * 0 = Left button.
  49271. * 1 = Middle Button.
  49272. * 2 = Right Button.
  49273. */
  49274. activeButton: number;
  49275. /**
  49276. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  49277. * Higher values reduce its sensitivity.
  49278. */
  49279. angularSensibility: number;
  49280. private _observer;
  49281. private _rollObserver;
  49282. private previousPosition;
  49283. private noPreventDefault;
  49284. private element;
  49285. /**
  49286. * Listen to mouse events to control the camera.
  49287. * @param touchEnabled Define if touch is enabled. (Default is true.)
  49288. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49289. */
  49290. constructor(touchEnabled?: boolean);
  49291. /**
  49292. * Attach the mouse control to the HTML DOM element.
  49293. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  49294. */
  49295. attachControl(noPreventDefault?: boolean): void;
  49296. /**
  49297. * Detach the current controls from the specified dom element.
  49298. */
  49299. detachControl(): void;
  49300. /**
  49301. * Gets the class name of the current input.
  49302. * @returns the class name.
  49303. */
  49304. getClassName(): string;
  49305. /**
  49306. * Get the friendly name associated with the input class.
  49307. * @returns the input's friendly name.
  49308. */
  49309. getSimpleName(): string;
  49310. private _pointerInput;
  49311. private _onMouseMove;
  49312. /**
  49313. * Rotate camera by mouse offset.
  49314. */
  49315. private rotateCamera;
  49316. }
  49317. }
  49318. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  49319. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49320. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49321. /**
  49322. * Default Inputs manager for the FlyCamera.
  49323. * It groups all the default supported inputs for ease of use.
  49324. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49325. */
  49326. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  49327. /**
  49328. * Instantiates a new FlyCameraInputsManager.
  49329. * @param camera Defines the camera the inputs belong to.
  49330. */
  49331. constructor(camera: FlyCamera);
  49332. /**
  49333. * Add keyboard input support to the input manager.
  49334. * @returns the new FlyCameraKeyboardMoveInput().
  49335. */
  49336. addKeyboard(): FlyCameraInputsManager;
  49337. /**
  49338. * Add mouse input support to the input manager.
  49339. * @param touchEnabled Enable touch screen support.
  49340. * @returns the new FlyCameraMouseInput().
  49341. */
  49342. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  49343. }
  49344. }
  49345. declare module "babylonjs/Cameras/flyCamera" {
  49346. import { Scene } from "babylonjs/scene";
  49347. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  49348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49349. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49350. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49351. /**
  49352. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49353. * such as in a 3D Space Shooter or a Flight Simulator.
  49354. */
  49355. export class FlyCamera extends TargetCamera {
  49356. /**
  49357. * Define the collision ellipsoid of the camera.
  49358. * This is helpful for simulating a camera body, like a player's body.
  49359. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49360. */
  49361. ellipsoid: Vector3;
  49362. /**
  49363. * Define an offset for the position of the ellipsoid around the camera.
  49364. * This can be helpful if the camera is attached away from the player's body center,
  49365. * such as at its head.
  49366. */
  49367. ellipsoidOffset: Vector3;
  49368. /**
  49369. * Enable or disable collisions of the camera with the rest of the scene objects.
  49370. */
  49371. checkCollisions: boolean;
  49372. /**
  49373. * Enable or disable gravity on the camera.
  49374. */
  49375. applyGravity: boolean;
  49376. /**
  49377. * Define the current direction the camera is moving to.
  49378. */
  49379. cameraDirection: Vector3;
  49380. /**
  49381. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49382. * This overrides and empties cameraRotation.
  49383. */
  49384. rotationQuaternion: Quaternion;
  49385. /**
  49386. * Track Roll to maintain the wanted Rolling when looking around.
  49387. */
  49388. _trackRoll: number;
  49389. /**
  49390. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49391. */
  49392. rollCorrect: number;
  49393. /**
  49394. * Mimic a banked turn, Rolling the camera when Yawing.
  49395. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49396. */
  49397. bankedTurn: boolean;
  49398. /**
  49399. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49400. */
  49401. bankedTurnLimit: number;
  49402. /**
  49403. * Value of 0 disables the banked Roll.
  49404. * Value of 1 is equal to the Yaw angle in radians.
  49405. */
  49406. bankedTurnMultiplier: number;
  49407. /**
  49408. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49409. */
  49410. inputs: FlyCameraInputsManager;
  49411. /**
  49412. * Gets the input sensibility for mouse input.
  49413. * Higher values reduce sensitivity.
  49414. */
  49415. get angularSensibility(): number;
  49416. /**
  49417. * Sets the input sensibility for a mouse input.
  49418. * Higher values reduce sensitivity.
  49419. */
  49420. set angularSensibility(value: number);
  49421. /**
  49422. * Get the keys for camera movement forward.
  49423. */
  49424. get keysForward(): number[];
  49425. /**
  49426. * Set the keys for camera movement forward.
  49427. */
  49428. set keysForward(value: number[]);
  49429. /**
  49430. * Get the keys for camera movement backward.
  49431. */
  49432. get keysBackward(): number[];
  49433. set keysBackward(value: number[]);
  49434. /**
  49435. * Get the keys for camera movement up.
  49436. */
  49437. get keysUp(): number[];
  49438. /**
  49439. * Set the keys for camera movement up.
  49440. */
  49441. set keysUp(value: number[]);
  49442. /**
  49443. * Get the keys for camera movement down.
  49444. */
  49445. get keysDown(): number[];
  49446. /**
  49447. * Set the keys for camera movement down.
  49448. */
  49449. set keysDown(value: number[]);
  49450. /**
  49451. * Get the keys for camera movement left.
  49452. */
  49453. get keysLeft(): number[];
  49454. /**
  49455. * Set the keys for camera movement left.
  49456. */
  49457. set keysLeft(value: number[]);
  49458. /**
  49459. * Set the keys for camera movement right.
  49460. */
  49461. get keysRight(): number[];
  49462. /**
  49463. * Set the keys for camera movement right.
  49464. */
  49465. set keysRight(value: number[]);
  49466. /**
  49467. * Event raised when the camera collides with a mesh in the scene.
  49468. */
  49469. onCollide: (collidedMesh: AbstractMesh) => void;
  49470. private _collider;
  49471. private _needMoveForGravity;
  49472. private _oldPosition;
  49473. private _diffPosition;
  49474. private _newPosition;
  49475. /** @hidden */
  49476. _localDirection: Vector3;
  49477. /** @hidden */
  49478. _transformedDirection: Vector3;
  49479. /**
  49480. * Instantiates a FlyCamera.
  49481. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49482. * such as in a 3D Space Shooter or a Flight Simulator.
  49483. * @param name Define the name of the camera in the scene.
  49484. * @param position Define the starting position of the camera in the scene.
  49485. * @param scene Define the scene the camera belongs to.
  49486. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49487. */
  49488. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49489. /**
  49490. * Attach a control to the HTML DOM element.
  49491. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  49492. */
  49493. attachControl(noPreventDefault?: boolean): void;
  49494. /**
  49495. * Detach a control from the HTML DOM element.
  49496. * The camera will stop reacting to that input.
  49497. */
  49498. detachControl(): void;
  49499. private _collisionMask;
  49500. /**
  49501. * Get the mask that the camera ignores in collision events.
  49502. */
  49503. get collisionMask(): number;
  49504. /**
  49505. * Set the mask that the camera ignores in collision events.
  49506. */
  49507. set collisionMask(mask: number);
  49508. /** @hidden */
  49509. _collideWithWorld(displacement: Vector3): void;
  49510. /** @hidden */
  49511. private _onCollisionPositionChange;
  49512. /** @hidden */
  49513. _checkInputs(): void;
  49514. /** @hidden */
  49515. _decideIfNeedsToMove(): boolean;
  49516. /** @hidden */
  49517. _updatePosition(): void;
  49518. /**
  49519. * Restore the Roll to its target value at the rate specified.
  49520. * @param rate - Higher means slower restoring.
  49521. * @hidden
  49522. */
  49523. restoreRoll(rate: number): void;
  49524. /**
  49525. * Destroy the camera and release the current resources held by it.
  49526. */
  49527. dispose(): void;
  49528. /**
  49529. * Get the current object class name.
  49530. * @returns the class name.
  49531. */
  49532. getClassName(): string;
  49533. }
  49534. }
  49535. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49536. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49537. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49538. /**
  49539. * Listen to keyboard events to control the camera.
  49540. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49541. */
  49542. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49543. /**
  49544. * Defines the camera the input is attached to.
  49545. */
  49546. camera: FlyCamera;
  49547. /**
  49548. * The list of keyboard keys used to control the forward move of the camera.
  49549. */
  49550. keysForward: number[];
  49551. /**
  49552. * The list of keyboard keys used to control the backward move of the camera.
  49553. */
  49554. keysBackward: number[];
  49555. /**
  49556. * The list of keyboard keys used to control the forward move of the camera.
  49557. */
  49558. keysUp: number[];
  49559. /**
  49560. * The list of keyboard keys used to control the backward move of the camera.
  49561. */
  49562. keysDown: number[];
  49563. /**
  49564. * The list of keyboard keys used to control the right strafe move of the camera.
  49565. */
  49566. keysRight: number[];
  49567. /**
  49568. * The list of keyboard keys used to control the left strafe move of the camera.
  49569. */
  49570. keysLeft: number[];
  49571. private _keys;
  49572. private _onCanvasBlurObserver;
  49573. private _onKeyboardObserver;
  49574. private _engine;
  49575. private _scene;
  49576. /**
  49577. * Attach the input controls to a specific dom element to get the input from.
  49578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49579. */
  49580. attachControl(noPreventDefault?: boolean): void;
  49581. /**
  49582. * Detach the current controls from the specified dom element.
  49583. */
  49584. detachControl(): void;
  49585. /**
  49586. * Gets the class name of the current intput.
  49587. * @returns the class name
  49588. */
  49589. getClassName(): string;
  49590. /** @hidden */
  49591. _onLostFocus(e: FocusEvent): void;
  49592. /**
  49593. * Get the friendly name associated with the input class.
  49594. * @returns the input friendly name
  49595. */
  49596. getSimpleName(): string;
  49597. /**
  49598. * Update the current camera state depending on the inputs that have been used this frame.
  49599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49600. */
  49601. checkInputs(): void;
  49602. }
  49603. }
  49604. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49605. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49606. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49607. /**
  49608. * Manage the mouse wheel inputs to control a follow camera.
  49609. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49610. */
  49611. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49612. /**
  49613. * Defines the camera the input is attached to.
  49614. */
  49615. camera: FollowCamera;
  49616. /**
  49617. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49618. */
  49619. axisControlRadius: boolean;
  49620. /**
  49621. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49622. */
  49623. axisControlHeight: boolean;
  49624. /**
  49625. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49626. */
  49627. axisControlRotation: boolean;
  49628. /**
  49629. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49630. * relation to mouseWheel events.
  49631. */
  49632. wheelPrecision: number;
  49633. /**
  49634. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49635. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49636. */
  49637. wheelDeltaPercentage: number;
  49638. private _wheel;
  49639. private _observer;
  49640. /**
  49641. * Attach the input controls to a specific dom element to get the input from.
  49642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49643. */
  49644. attachControl(noPreventDefault?: boolean): void;
  49645. /**
  49646. * Detach the current controls from the specified dom element.
  49647. */
  49648. detachControl(): void;
  49649. /**
  49650. * Gets the class name of the current intput.
  49651. * @returns the class name
  49652. */
  49653. getClassName(): string;
  49654. /**
  49655. * Get the friendly name associated with the input class.
  49656. * @returns the input friendly name
  49657. */
  49658. getSimpleName(): string;
  49659. }
  49660. }
  49661. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49662. import { Nullable } from "babylonjs/types";
  49663. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49664. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49665. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49666. /**
  49667. * Manage the pointers inputs to control an follow camera.
  49668. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49669. */
  49670. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49671. /**
  49672. * Defines the camera the input is attached to.
  49673. */
  49674. camera: FollowCamera;
  49675. /**
  49676. * Gets the class name of the current input.
  49677. * @returns the class name
  49678. */
  49679. getClassName(): string;
  49680. /**
  49681. * Defines the pointer angular sensibility along the X axis or how fast is
  49682. * the camera rotating.
  49683. * A negative number will reverse the axis direction.
  49684. */
  49685. angularSensibilityX: number;
  49686. /**
  49687. * Defines the pointer angular sensibility along the Y axis or how fast is
  49688. * the camera rotating.
  49689. * A negative number will reverse the axis direction.
  49690. */
  49691. angularSensibilityY: number;
  49692. /**
  49693. * Defines the pointer pinch precision or how fast is the camera zooming.
  49694. * A negative number will reverse the axis direction.
  49695. */
  49696. pinchPrecision: number;
  49697. /**
  49698. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49699. * from 0.
  49700. * It defines the percentage of current camera.radius to use as delta when
  49701. * pinch zoom is used.
  49702. */
  49703. pinchDeltaPercentage: number;
  49704. /**
  49705. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49706. */
  49707. axisXControlRadius: boolean;
  49708. /**
  49709. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49710. */
  49711. axisXControlHeight: boolean;
  49712. /**
  49713. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49714. */
  49715. axisXControlRotation: boolean;
  49716. /**
  49717. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49718. */
  49719. axisYControlRadius: boolean;
  49720. /**
  49721. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49722. */
  49723. axisYControlHeight: boolean;
  49724. /**
  49725. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49726. */
  49727. axisYControlRotation: boolean;
  49728. /**
  49729. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49730. */
  49731. axisPinchControlRadius: boolean;
  49732. /**
  49733. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49734. */
  49735. axisPinchControlHeight: boolean;
  49736. /**
  49737. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49738. */
  49739. axisPinchControlRotation: boolean;
  49740. /**
  49741. * Log error messages if basic misconfiguration has occurred.
  49742. */
  49743. warningEnable: boolean;
  49744. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49745. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49746. private _warningCounter;
  49747. private _warning;
  49748. }
  49749. }
  49750. declare module "babylonjs/Cameras/followCameraInputsManager" {
  49751. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49752. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49753. /**
  49754. * Default Inputs manager for the FollowCamera.
  49755. * It groups all the default supported inputs for ease of use.
  49756. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49757. */
  49758. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  49759. /**
  49760. * Instantiates a new FollowCameraInputsManager.
  49761. * @param camera Defines the camera the inputs belong to
  49762. */
  49763. constructor(camera: FollowCamera);
  49764. /**
  49765. * Add keyboard input support to the input manager.
  49766. * @returns the current input manager
  49767. */
  49768. addKeyboard(): FollowCameraInputsManager;
  49769. /**
  49770. * Add mouse wheel input support to the input manager.
  49771. * @returns the current input manager
  49772. */
  49773. addMouseWheel(): FollowCameraInputsManager;
  49774. /**
  49775. * Add pointers input support to the input manager.
  49776. * @returns the current input manager
  49777. */
  49778. addPointers(): FollowCameraInputsManager;
  49779. /**
  49780. * Add orientation input support to the input manager.
  49781. * @returns the current input manager
  49782. */
  49783. addVRDeviceOrientation(): FollowCameraInputsManager;
  49784. }
  49785. }
  49786. declare module "babylonjs/Cameras/followCamera" {
  49787. import { Nullable } from "babylonjs/types";
  49788. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49789. import { Scene } from "babylonjs/scene";
  49790. import { Vector3 } from "babylonjs/Maths/math.vector";
  49791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49792. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  49793. /**
  49794. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  49795. * an arc rotate version arcFollowCamera are available.
  49796. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49797. */
  49798. export class FollowCamera extends TargetCamera {
  49799. /**
  49800. * Distance the follow camera should follow an object at
  49801. */
  49802. radius: number;
  49803. /**
  49804. * Minimum allowed distance of the camera to the axis of rotation
  49805. * (The camera can not get closer).
  49806. * This can help limiting how the Camera is able to move in the scene.
  49807. */
  49808. lowerRadiusLimit: Nullable<number>;
  49809. /**
  49810. * Maximum allowed distance of the camera to the axis of rotation
  49811. * (The camera can not get further).
  49812. * This can help limiting how the Camera is able to move in the scene.
  49813. */
  49814. upperRadiusLimit: Nullable<number>;
  49815. /**
  49816. * Define a rotation offset between the camera and the object it follows
  49817. */
  49818. rotationOffset: number;
  49819. /**
  49820. * Minimum allowed angle to camera position relative to target object.
  49821. * This can help limiting how the Camera is able to move in the scene.
  49822. */
  49823. lowerRotationOffsetLimit: Nullable<number>;
  49824. /**
  49825. * Maximum allowed angle to camera position relative to target object.
  49826. * This can help limiting how the Camera is able to move in the scene.
  49827. */
  49828. upperRotationOffsetLimit: Nullable<number>;
  49829. /**
  49830. * Define a height offset between the camera and the object it follows.
  49831. * It can help following an object from the top (like a car chaing a plane)
  49832. */
  49833. heightOffset: number;
  49834. /**
  49835. * Minimum allowed height of camera position relative to target object.
  49836. * This can help limiting how the Camera is able to move in the scene.
  49837. */
  49838. lowerHeightOffsetLimit: Nullable<number>;
  49839. /**
  49840. * Maximum allowed height of camera position relative to target object.
  49841. * This can help limiting how the Camera is able to move in the scene.
  49842. */
  49843. upperHeightOffsetLimit: Nullable<number>;
  49844. /**
  49845. * Define how fast the camera can accelerate to follow it s target.
  49846. */
  49847. cameraAcceleration: number;
  49848. /**
  49849. * Define the speed limit of the camera following an object.
  49850. */
  49851. maxCameraSpeed: number;
  49852. /**
  49853. * Define the target of the camera.
  49854. */
  49855. lockedTarget: Nullable<AbstractMesh>;
  49856. /**
  49857. * Defines the input associated with the camera.
  49858. */
  49859. inputs: FollowCameraInputsManager;
  49860. /**
  49861. * Instantiates the follow camera.
  49862. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49863. * @param name Define the name of the camera in the scene
  49864. * @param position Define the position of the camera
  49865. * @param scene Define the scene the camera belong to
  49866. * @param lockedTarget Define the target of the camera
  49867. */
  49868. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  49869. private _follow;
  49870. /**
  49871. * Attached controls to the current camera.
  49872. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49873. */
  49874. attachControl(noPreventDefault?: boolean): void;
  49875. /**
  49876. * Detach the current controls from the camera.
  49877. * The camera will stop reacting to inputs.
  49878. */
  49879. detachControl(): void;
  49880. /** @hidden */
  49881. _checkInputs(): void;
  49882. private _checkLimits;
  49883. /**
  49884. * Gets the camera class name.
  49885. * @returns the class name
  49886. */
  49887. getClassName(): string;
  49888. }
  49889. /**
  49890. * Arc Rotate version of the follow camera.
  49891. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  49892. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49893. */
  49894. export class ArcFollowCamera extends TargetCamera {
  49895. /** The longitudinal angle of the camera */
  49896. alpha: number;
  49897. /** The latitudinal angle of the camera */
  49898. beta: number;
  49899. /** The radius of the camera from its target */
  49900. radius: number;
  49901. private _cartesianCoordinates;
  49902. /** Define the camera target (the mesh it should follow) */
  49903. private _meshTarget;
  49904. /**
  49905. * Instantiates a new ArcFollowCamera
  49906. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49907. * @param name Define the name of the camera
  49908. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  49909. * @param beta Define the rotation angle of the camera around the elevation axis
  49910. * @param radius Define the radius of the camera from its target point
  49911. * @param target Define the target of the camera
  49912. * @param scene Define the scene the camera belongs to
  49913. */
  49914. constructor(name: string,
  49915. /** The longitudinal angle of the camera */
  49916. alpha: number,
  49917. /** The latitudinal angle of the camera */
  49918. beta: number,
  49919. /** The radius of the camera from its target */
  49920. radius: number,
  49921. /** Define the camera target (the mesh it should follow) */
  49922. target: Nullable<AbstractMesh>, scene: Scene);
  49923. private _follow;
  49924. /** @hidden */
  49925. _checkInputs(): void;
  49926. /**
  49927. * Returns the class name of the object.
  49928. * It is mostly used internally for serialization purposes.
  49929. */
  49930. getClassName(): string;
  49931. }
  49932. }
  49933. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  49934. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49935. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49936. /**
  49937. * Manage the keyboard inputs to control the movement of a follow camera.
  49938. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49939. */
  49940. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  49941. /**
  49942. * Defines the camera the input is attached to.
  49943. */
  49944. camera: FollowCamera;
  49945. /**
  49946. * Defines the list of key codes associated with the up action (increase heightOffset)
  49947. */
  49948. keysHeightOffsetIncr: number[];
  49949. /**
  49950. * Defines the list of key codes associated with the down action (decrease heightOffset)
  49951. */
  49952. keysHeightOffsetDecr: number[];
  49953. /**
  49954. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  49955. */
  49956. keysHeightOffsetModifierAlt: boolean;
  49957. /**
  49958. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  49959. */
  49960. keysHeightOffsetModifierCtrl: boolean;
  49961. /**
  49962. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  49963. */
  49964. keysHeightOffsetModifierShift: boolean;
  49965. /**
  49966. * Defines the list of key codes associated with the left action (increase rotationOffset)
  49967. */
  49968. keysRotationOffsetIncr: number[];
  49969. /**
  49970. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  49971. */
  49972. keysRotationOffsetDecr: number[];
  49973. /**
  49974. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  49975. */
  49976. keysRotationOffsetModifierAlt: boolean;
  49977. /**
  49978. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  49979. */
  49980. keysRotationOffsetModifierCtrl: boolean;
  49981. /**
  49982. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  49983. */
  49984. keysRotationOffsetModifierShift: boolean;
  49985. /**
  49986. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  49987. */
  49988. keysRadiusIncr: number[];
  49989. /**
  49990. * Defines the list of key codes associated with the zoom-out action (increase radius)
  49991. */
  49992. keysRadiusDecr: number[];
  49993. /**
  49994. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  49995. */
  49996. keysRadiusModifierAlt: boolean;
  49997. /**
  49998. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  49999. */
  50000. keysRadiusModifierCtrl: boolean;
  50001. /**
  50002. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  50003. */
  50004. keysRadiusModifierShift: boolean;
  50005. /**
  50006. * Defines the rate of change of heightOffset.
  50007. */
  50008. heightSensibility: number;
  50009. /**
  50010. * Defines the rate of change of rotationOffset.
  50011. */
  50012. rotationSensibility: number;
  50013. /**
  50014. * Defines the rate of change of radius.
  50015. */
  50016. radiusSensibility: number;
  50017. private _keys;
  50018. private _ctrlPressed;
  50019. private _altPressed;
  50020. private _shiftPressed;
  50021. private _onCanvasBlurObserver;
  50022. private _onKeyboardObserver;
  50023. private _engine;
  50024. private _scene;
  50025. /**
  50026. * Attach the input controls to a specific dom element to get the input from.
  50027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50028. */
  50029. attachControl(noPreventDefault?: boolean): void;
  50030. /**
  50031. * Detach the current controls from the specified dom element.
  50032. */
  50033. detachControl(): void;
  50034. /**
  50035. * Update the current camera state depending on the inputs that have been used this frame.
  50036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50037. */
  50038. checkInputs(): void;
  50039. /**
  50040. * Gets the class name of the current input.
  50041. * @returns the class name
  50042. */
  50043. getClassName(): string;
  50044. /**
  50045. * Get the friendly name associated with the input class.
  50046. * @returns the input friendly name
  50047. */
  50048. getSimpleName(): string;
  50049. /**
  50050. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50051. * allow modification of the heightOffset value.
  50052. */
  50053. private _modifierHeightOffset;
  50054. /**
  50055. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50056. * allow modification of the rotationOffset value.
  50057. */
  50058. private _modifierRotationOffset;
  50059. /**
  50060. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50061. * allow modification of the radius value.
  50062. */
  50063. private _modifierRadius;
  50064. }
  50065. }
  50066. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  50067. import { Nullable } from "babylonjs/types";
  50068. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50069. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50070. import { Observable } from "babylonjs/Misc/observable";
  50071. module "babylonjs/Cameras/freeCameraInputsManager" {
  50072. interface FreeCameraInputsManager {
  50073. /**
  50074. * @hidden
  50075. */
  50076. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  50077. /**
  50078. * Add orientation input support to the input manager.
  50079. * @returns the current input manager
  50080. */
  50081. addDeviceOrientation(): FreeCameraInputsManager;
  50082. }
  50083. }
  50084. /**
  50085. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  50086. * Screen rotation is taken into account.
  50087. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50088. */
  50089. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  50090. private _camera;
  50091. private _screenOrientationAngle;
  50092. private _constantTranform;
  50093. private _screenQuaternion;
  50094. private _alpha;
  50095. private _beta;
  50096. private _gamma;
  50097. /**
  50098. * Can be used to detect if a device orientation sensor is available on a device
  50099. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  50100. * @returns a promise that will resolve on orientation change
  50101. */
  50102. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  50103. /**
  50104. * @hidden
  50105. */
  50106. _onDeviceOrientationChangedObservable: Observable<void>;
  50107. /**
  50108. * Instantiates a new input
  50109. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50110. */
  50111. constructor();
  50112. /**
  50113. * Define the camera controlled by the input.
  50114. */
  50115. get camera(): FreeCamera;
  50116. set camera(camera: FreeCamera);
  50117. /**
  50118. * Attach the input controls to a specific dom element to get the input from.
  50119. */
  50120. attachControl(): void;
  50121. private _orientationChanged;
  50122. private _deviceOrientation;
  50123. /**
  50124. * Detach the current controls from the specified dom element.
  50125. */
  50126. detachControl(): void;
  50127. /**
  50128. * Update the current camera state depending on the inputs that have been used this frame.
  50129. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50130. */
  50131. checkInputs(): void;
  50132. /**
  50133. * Gets the class name of the current intput.
  50134. * @returns the class name
  50135. */
  50136. getClassName(): string;
  50137. /**
  50138. * Get the friendly name associated with the input class.
  50139. * @returns the input friendly name
  50140. */
  50141. getSimpleName(): string;
  50142. }
  50143. }
  50144. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  50145. import { Nullable } from "babylonjs/types";
  50146. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50147. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50148. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50149. /**
  50150. * Manage the gamepad inputs to control a free camera.
  50151. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50152. */
  50153. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  50154. /**
  50155. * Define the camera the input is attached to.
  50156. */
  50157. camera: FreeCamera;
  50158. /**
  50159. * Define the Gamepad controlling the input
  50160. */
  50161. gamepad: Nullable<Gamepad>;
  50162. /**
  50163. * Defines the gamepad rotation sensiblity.
  50164. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50165. */
  50166. gamepadAngularSensibility: number;
  50167. /**
  50168. * Defines the gamepad move sensiblity.
  50169. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50170. */
  50171. gamepadMoveSensibility: number;
  50172. private _yAxisScale;
  50173. /**
  50174. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50175. */
  50176. get invertYAxis(): boolean;
  50177. set invertYAxis(value: boolean);
  50178. private _onGamepadConnectedObserver;
  50179. private _onGamepadDisconnectedObserver;
  50180. private _cameraTransform;
  50181. private _deltaTransform;
  50182. private _vector3;
  50183. private _vector2;
  50184. /**
  50185. * Attach the input controls to a specific dom element to get the input from.
  50186. */
  50187. attachControl(): void;
  50188. /**
  50189. * Detach the current controls from the specified dom element.
  50190. */
  50191. detachControl(): void;
  50192. /**
  50193. * Update the current camera state depending on the inputs that have been used this frame.
  50194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50195. */
  50196. checkInputs(): void;
  50197. /**
  50198. * Gets the class name of the current intput.
  50199. * @returns the class name
  50200. */
  50201. getClassName(): string;
  50202. /**
  50203. * Get the friendly name associated with the input class.
  50204. * @returns the input friendly name
  50205. */
  50206. getSimpleName(): string;
  50207. }
  50208. }
  50209. declare module "babylonjs/Misc/virtualJoystick" {
  50210. import { Nullable } from "babylonjs/types";
  50211. import { Vector3 } from "babylonjs/Maths/math.vector";
  50212. /**
  50213. * Defines the potential axis of a Joystick
  50214. */
  50215. export enum JoystickAxis {
  50216. /** X axis */
  50217. X = 0,
  50218. /** Y axis */
  50219. Y = 1,
  50220. /** Z axis */
  50221. Z = 2
  50222. }
  50223. /**
  50224. * Represents the different customization options available
  50225. * for VirtualJoystick
  50226. */
  50227. interface VirtualJoystickCustomizations {
  50228. /**
  50229. * Size of the joystick's puck
  50230. */
  50231. puckSize: number;
  50232. /**
  50233. * Size of the joystick's container
  50234. */
  50235. containerSize: number;
  50236. /**
  50237. * Color of the joystick && puck
  50238. */
  50239. color: string;
  50240. /**
  50241. * Image URL for the joystick's puck
  50242. */
  50243. puckImage?: string;
  50244. /**
  50245. * Image URL for the joystick's container
  50246. */
  50247. containerImage?: string;
  50248. /**
  50249. * Defines the unmoving position of the joystick container
  50250. */
  50251. position?: {
  50252. x: number;
  50253. y: number;
  50254. };
  50255. /**
  50256. * Defines whether or not the joystick container is always visible
  50257. */
  50258. alwaysVisible: boolean;
  50259. /**
  50260. * Defines whether or not to limit the movement of the puck to the joystick's container
  50261. */
  50262. limitToContainer: boolean;
  50263. }
  50264. /**
  50265. * Class used to define virtual joystick (used in touch mode)
  50266. */
  50267. export class VirtualJoystick {
  50268. /**
  50269. * Gets or sets a boolean indicating that left and right values must be inverted
  50270. */
  50271. reverseLeftRight: boolean;
  50272. /**
  50273. * Gets or sets a boolean indicating that up and down values must be inverted
  50274. */
  50275. reverseUpDown: boolean;
  50276. /**
  50277. * Gets the offset value for the position (ie. the change of the position value)
  50278. */
  50279. deltaPosition: Vector3;
  50280. /**
  50281. * Gets a boolean indicating if the virtual joystick was pressed
  50282. */
  50283. pressed: boolean;
  50284. /**
  50285. * Canvas the virtual joystick will render onto, default z-index of this is 5
  50286. */
  50287. static Canvas: Nullable<HTMLCanvasElement>;
  50288. /**
  50289. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  50290. */
  50291. limitToContainer: boolean;
  50292. private static _globalJoystickIndex;
  50293. private static _alwaysVisibleSticks;
  50294. private static vjCanvasContext;
  50295. private static vjCanvasWidth;
  50296. private static vjCanvasHeight;
  50297. private static halfWidth;
  50298. private static _GetDefaultOptions;
  50299. private _action;
  50300. private _axisTargetedByLeftAndRight;
  50301. private _axisTargetedByUpAndDown;
  50302. private _joystickSensibility;
  50303. private _inversedSensibility;
  50304. private _joystickPointerID;
  50305. private _joystickColor;
  50306. private _joystickPointerPos;
  50307. private _joystickPreviousPointerPos;
  50308. private _joystickPointerStartPos;
  50309. private _deltaJoystickVector;
  50310. private _leftJoystick;
  50311. private _touches;
  50312. private _joystickPosition;
  50313. private _alwaysVisible;
  50314. private _puckImage;
  50315. private _containerImage;
  50316. private _joystickPuckSize;
  50317. private _joystickContainerSize;
  50318. private _clearPuckSize;
  50319. private _clearContainerSize;
  50320. private _clearPuckSizeOffset;
  50321. private _clearContainerSizeOffset;
  50322. private _onPointerDownHandlerRef;
  50323. private _onPointerMoveHandlerRef;
  50324. private _onPointerUpHandlerRef;
  50325. private _onResize;
  50326. /**
  50327. * Creates a new virtual joystick
  50328. * @param leftJoystick defines that the joystick is for left hand (false by default)
  50329. * @param customizations Defines the options we want to customize the VirtualJoystick
  50330. */
  50331. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50332. /**
  50333. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50334. * @param newJoystickSensibility defines the new sensibility
  50335. */
  50336. setJoystickSensibility(newJoystickSensibility: number): void;
  50337. private _onPointerDown;
  50338. private _onPointerMove;
  50339. private _onPointerUp;
  50340. /**
  50341. * Change the color of the virtual joystick
  50342. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50343. */
  50344. setJoystickColor(newColor: string): void;
  50345. /**
  50346. * Size of the joystick's container
  50347. */
  50348. set containerSize(newSize: number);
  50349. get containerSize(): number;
  50350. /**
  50351. * Size of the joystick's puck
  50352. */
  50353. set puckSize(newSize: number);
  50354. get puckSize(): number;
  50355. /**
  50356. * Clears the set position of the joystick
  50357. */
  50358. clearPosition(): void;
  50359. /**
  50360. * Defines whether or not the joystick container is always visible
  50361. */
  50362. set alwaysVisible(value: boolean);
  50363. get alwaysVisible(): boolean;
  50364. /**
  50365. * Sets the constant position of the Joystick container
  50366. * @param x X axis coordinate
  50367. * @param y Y axis coordinate
  50368. */
  50369. setPosition(x: number, y: number): void;
  50370. /**
  50371. * Defines a callback to call when the joystick is touched
  50372. * @param action defines the callback
  50373. */
  50374. setActionOnTouch(action: () => any): void;
  50375. /**
  50376. * Defines which axis you'd like to control for left & right
  50377. * @param axis defines the axis to use
  50378. */
  50379. setAxisForLeftRight(axis: JoystickAxis): void;
  50380. /**
  50381. * Defines which axis you'd like to control for up & down
  50382. * @param axis defines the axis to use
  50383. */
  50384. setAxisForUpDown(axis: JoystickAxis): void;
  50385. /**
  50386. * Clears the canvas from the previous puck / container draw
  50387. */
  50388. private _clearPreviousDraw;
  50389. /**
  50390. * Loads `urlPath` to be used for the container's image
  50391. * @param urlPath defines the urlPath of an image to use
  50392. */
  50393. setContainerImage(urlPath: string): void;
  50394. /**
  50395. * Loads `urlPath` to be used for the puck's image
  50396. * @param urlPath defines the urlPath of an image to use
  50397. */
  50398. setPuckImage(urlPath: string): void;
  50399. /**
  50400. * Draws the Virtual Joystick's container
  50401. */
  50402. private _drawContainer;
  50403. /**
  50404. * Draws the Virtual Joystick's puck
  50405. */
  50406. private _drawPuck;
  50407. private _drawVirtualJoystick;
  50408. /**
  50409. * Release internal HTML canvas
  50410. */
  50411. releaseCanvas(): void;
  50412. }
  50413. }
  50414. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50415. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50416. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50417. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50418. module "babylonjs/Cameras/freeCameraInputsManager" {
  50419. interface FreeCameraInputsManager {
  50420. /**
  50421. * Add virtual joystick input support to the input manager.
  50422. * @returns the current input manager
  50423. */
  50424. addVirtualJoystick(): FreeCameraInputsManager;
  50425. }
  50426. }
  50427. /**
  50428. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50429. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50430. */
  50431. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50432. /**
  50433. * Defines the camera the input is attached to.
  50434. */
  50435. camera: FreeCamera;
  50436. private _leftjoystick;
  50437. private _rightjoystick;
  50438. /**
  50439. * Gets the left stick of the virtual joystick.
  50440. * @returns The virtual Joystick
  50441. */
  50442. getLeftJoystick(): VirtualJoystick;
  50443. /**
  50444. * Gets the right stick of the virtual joystick.
  50445. * @returns The virtual Joystick
  50446. */
  50447. getRightJoystick(): VirtualJoystick;
  50448. /**
  50449. * Update the current camera state depending on the inputs that have been used this frame.
  50450. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50451. */
  50452. checkInputs(): void;
  50453. /**
  50454. * Attach the input controls to a specific dom element to get the input from.
  50455. */
  50456. attachControl(): void;
  50457. /**
  50458. * Detach the current controls from the specified dom element.
  50459. */
  50460. detachControl(): void;
  50461. /**
  50462. * Gets the class name of the current intput.
  50463. * @returns the class name
  50464. */
  50465. getClassName(): string;
  50466. /**
  50467. * Get the friendly name associated with the input class.
  50468. * @returns the input friendly name
  50469. */
  50470. getSimpleName(): string;
  50471. }
  50472. }
  50473. declare module "babylonjs/Cameras/Inputs/index" {
  50474. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50475. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50476. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50477. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50478. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50479. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50480. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50481. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50482. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50483. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50484. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50485. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50486. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50487. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50488. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  50489. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50490. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50491. }
  50492. declare module "babylonjs/Cameras/touchCamera" {
  50493. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50494. import { Scene } from "babylonjs/scene";
  50495. import { Vector3 } from "babylonjs/Maths/math.vector";
  50496. /**
  50497. * This represents a FPS type of camera controlled by touch.
  50498. * This is like a universal camera minus the Gamepad controls.
  50499. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50500. */
  50501. export class TouchCamera extends FreeCamera {
  50502. /**
  50503. * Defines the touch sensibility for rotation.
  50504. * The higher the faster.
  50505. */
  50506. get touchAngularSensibility(): number;
  50507. set touchAngularSensibility(value: number);
  50508. /**
  50509. * Defines the touch sensibility for move.
  50510. * The higher the faster.
  50511. */
  50512. get touchMoveSensibility(): number;
  50513. set touchMoveSensibility(value: number);
  50514. /**
  50515. * Instantiates a new touch camera.
  50516. * This represents a FPS type of camera controlled by touch.
  50517. * This is like a universal camera minus the Gamepad controls.
  50518. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50519. * @param name Define the name of the camera in the scene
  50520. * @param position Define the start position of the camera in the scene
  50521. * @param scene Define the scene the camera belongs to
  50522. */
  50523. constructor(name: string, position: Vector3, scene: Scene);
  50524. /**
  50525. * Gets the current object class name.
  50526. * @return the class name
  50527. */
  50528. getClassName(): string;
  50529. /** @hidden */
  50530. _setupInputs(): void;
  50531. }
  50532. }
  50533. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50534. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50535. import { Scene } from "babylonjs/scene";
  50536. import { Vector3 } from "babylonjs/Maths/math.vector";
  50537. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50538. import { Axis } from "babylonjs/Maths/math.axis";
  50539. /**
  50540. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50541. * being tilted forward or back and left or right.
  50542. */
  50543. export class DeviceOrientationCamera extends FreeCamera {
  50544. private _initialQuaternion;
  50545. private _quaternionCache;
  50546. private _tmpDragQuaternion;
  50547. private _disablePointerInputWhenUsingDeviceOrientation;
  50548. /**
  50549. * Creates a new device orientation camera
  50550. * @param name The name of the camera
  50551. * @param position The start position camera
  50552. * @param scene The scene the camera belongs to
  50553. */
  50554. constructor(name: string, position: Vector3, scene: Scene);
  50555. /**
  50556. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50557. */
  50558. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50559. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50560. private _dragFactor;
  50561. /**
  50562. * Enabled turning on the y axis when the orientation sensor is active
  50563. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50564. */
  50565. enableHorizontalDragging(dragFactor?: number): void;
  50566. /**
  50567. * Gets the current instance class name ("DeviceOrientationCamera").
  50568. * This helps avoiding instanceof at run time.
  50569. * @returns the class name
  50570. */
  50571. getClassName(): string;
  50572. /**
  50573. * @hidden
  50574. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50575. */
  50576. _checkInputs(): void;
  50577. /**
  50578. * Reset the camera to its default orientation on the specified axis only.
  50579. * @param axis The axis to reset
  50580. */
  50581. resetToCurrentRotation(axis?: Axis): void;
  50582. }
  50583. }
  50584. declare module "babylonjs/Gamepads/xboxGamepad" {
  50585. import { Observable } from "babylonjs/Misc/observable";
  50586. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50587. /**
  50588. * Defines supported buttons for XBox360 compatible gamepads
  50589. */
  50590. export enum Xbox360Button {
  50591. /** A */
  50592. A = 0,
  50593. /** B */
  50594. B = 1,
  50595. /** X */
  50596. X = 2,
  50597. /** Y */
  50598. Y = 3,
  50599. /** Left button */
  50600. LB = 4,
  50601. /** Right button */
  50602. RB = 5,
  50603. /** Back */
  50604. Back = 8,
  50605. /** Start */
  50606. Start = 9,
  50607. /** Left stick */
  50608. LeftStick = 10,
  50609. /** Right stick */
  50610. RightStick = 11
  50611. }
  50612. /** Defines values for XBox360 DPad */
  50613. export enum Xbox360Dpad {
  50614. /** Up */
  50615. Up = 12,
  50616. /** Down */
  50617. Down = 13,
  50618. /** Left */
  50619. Left = 14,
  50620. /** Right */
  50621. Right = 15
  50622. }
  50623. /**
  50624. * Defines a XBox360 gamepad
  50625. */
  50626. export class Xbox360Pad extends Gamepad {
  50627. private _leftTrigger;
  50628. private _rightTrigger;
  50629. private _onlefttriggerchanged;
  50630. private _onrighttriggerchanged;
  50631. private _onbuttondown;
  50632. private _onbuttonup;
  50633. private _ondpaddown;
  50634. private _ondpadup;
  50635. /** Observable raised when a button is pressed */
  50636. onButtonDownObservable: Observable<Xbox360Button>;
  50637. /** Observable raised when a button is released */
  50638. onButtonUpObservable: Observable<Xbox360Button>;
  50639. /** Observable raised when a pad is pressed */
  50640. onPadDownObservable: Observable<Xbox360Dpad>;
  50641. /** Observable raised when a pad is released */
  50642. onPadUpObservable: Observable<Xbox360Dpad>;
  50643. private _buttonA;
  50644. private _buttonB;
  50645. private _buttonX;
  50646. private _buttonY;
  50647. private _buttonBack;
  50648. private _buttonStart;
  50649. private _buttonLB;
  50650. private _buttonRB;
  50651. private _buttonLeftStick;
  50652. private _buttonRightStick;
  50653. private _dPadUp;
  50654. private _dPadDown;
  50655. private _dPadLeft;
  50656. private _dPadRight;
  50657. private _isXboxOnePad;
  50658. /**
  50659. * Creates a new XBox360 gamepad object
  50660. * @param id defines the id of this gamepad
  50661. * @param index defines its index
  50662. * @param gamepad defines the internal HTML gamepad object
  50663. * @param xboxOne defines if it is a XBox One gamepad
  50664. */
  50665. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50666. /**
  50667. * Defines the callback to call when left trigger is pressed
  50668. * @param callback defines the callback to use
  50669. */
  50670. onlefttriggerchanged(callback: (value: number) => void): void;
  50671. /**
  50672. * Defines the callback to call when right trigger is pressed
  50673. * @param callback defines the callback to use
  50674. */
  50675. onrighttriggerchanged(callback: (value: number) => void): void;
  50676. /**
  50677. * Gets the left trigger value
  50678. */
  50679. get leftTrigger(): number;
  50680. /**
  50681. * Sets the left trigger value
  50682. */
  50683. set leftTrigger(newValue: number);
  50684. /**
  50685. * Gets the right trigger value
  50686. */
  50687. get rightTrigger(): number;
  50688. /**
  50689. * Sets the right trigger value
  50690. */
  50691. set rightTrigger(newValue: number);
  50692. /**
  50693. * Defines the callback to call when a button is pressed
  50694. * @param callback defines the callback to use
  50695. */
  50696. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50697. /**
  50698. * Defines the callback to call when a button is released
  50699. * @param callback defines the callback to use
  50700. */
  50701. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50702. /**
  50703. * Defines the callback to call when a pad is pressed
  50704. * @param callback defines the callback to use
  50705. */
  50706. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50707. /**
  50708. * Defines the callback to call when a pad is released
  50709. * @param callback defines the callback to use
  50710. */
  50711. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50712. private _setButtonValue;
  50713. private _setDPadValue;
  50714. /**
  50715. * Gets the value of the `A` button
  50716. */
  50717. get buttonA(): number;
  50718. /**
  50719. * Sets the value of the `A` button
  50720. */
  50721. set buttonA(value: number);
  50722. /**
  50723. * Gets the value of the `B` button
  50724. */
  50725. get buttonB(): number;
  50726. /**
  50727. * Sets the value of the `B` button
  50728. */
  50729. set buttonB(value: number);
  50730. /**
  50731. * Gets the value of the `X` button
  50732. */
  50733. get buttonX(): number;
  50734. /**
  50735. * Sets the value of the `X` button
  50736. */
  50737. set buttonX(value: number);
  50738. /**
  50739. * Gets the value of the `Y` button
  50740. */
  50741. get buttonY(): number;
  50742. /**
  50743. * Sets the value of the `Y` button
  50744. */
  50745. set buttonY(value: number);
  50746. /**
  50747. * Gets the value of the `Start` button
  50748. */
  50749. get buttonStart(): number;
  50750. /**
  50751. * Sets the value of the `Start` button
  50752. */
  50753. set buttonStart(value: number);
  50754. /**
  50755. * Gets the value of the `Back` button
  50756. */
  50757. get buttonBack(): number;
  50758. /**
  50759. * Sets the value of the `Back` button
  50760. */
  50761. set buttonBack(value: number);
  50762. /**
  50763. * Gets the value of the `Left` button
  50764. */
  50765. get buttonLB(): number;
  50766. /**
  50767. * Sets the value of the `Left` button
  50768. */
  50769. set buttonLB(value: number);
  50770. /**
  50771. * Gets the value of the `Right` button
  50772. */
  50773. get buttonRB(): number;
  50774. /**
  50775. * Sets the value of the `Right` button
  50776. */
  50777. set buttonRB(value: number);
  50778. /**
  50779. * Gets the value of the Left joystick
  50780. */
  50781. get buttonLeftStick(): number;
  50782. /**
  50783. * Sets the value of the Left joystick
  50784. */
  50785. set buttonLeftStick(value: number);
  50786. /**
  50787. * Gets the value of the Right joystick
  50788. */
  50789. get buttonRightStick(): number;
  50790. /**
  50791. * Sets the value of the Right joystick
  50792. */
  50793. set buttonRightStick(value: number);
  50794. /**
  50795. * Gets the value of D-pad up
  50796. */
  50797. get dPadUp(): number;
  50798. /**
  50799. * Sets the value of D-pad up
  50800. */
  50801. set dPadUp(value: number);
  50802. /**
  50803. * Gets the value of D-pad down
  50804. */
  50805. get dPadDown(): number;
  50806. /**
  50807. * Sets the value of D-pad down
  50808. */
  50809. set dPadDown(value: number);
  50810. /**
  50811. * Gets the value of D-pad left
  50812. */
  50813. get dPadLeft(): number;
  50814. /**
  50815. * Sets the value of D-pad left
  50816. */
  50817. set dPadLeft(value: number);
  50818. /**
  50819. * Gets the value of D-pad right
  50820. */
  50821. get dPadRight(): number;
  50822. /**
  50823. * Sets the value of D-pad right
  50824. */
  50825. set dPadRight(value: number);
  50826. /**
  50827. * Force the gamepad to synchronize with device values
  50828. */
  50829. update(): void;
  50830. /**
  50831. * Disposes the gamepad
  50832. */
  50833. dispose(): void;
  50834. }
  50835. }
  50836. declare module "babylonjs/Gamepads/dualShockGamepad" {
  50837. import { Observable } from "babylonjs/Misc/observable";
  50838. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50839. /**
  50840. * Defines supported buttons for DualShock compatible gamepads
  50841. */
  50842. export enum DualShockButton {
  50843. /** Cross */
  50844. Cross = 0,
  50845. /** Circle */
  50846. Circle = 1,
  50847. /** Square */
  50848. Square = 2,
  50849. /** Triangle */
  50850. Triangle = 3,
  50851. /** L1 */
  50852. L1 = 4,
  50853. /** R1 */
  50854. R1 = 5,
  50855. /** Share */
  50856. Share = 8,
  50857. /** Options */
  50858. Options = 9,
  50859. /** Left stick */
  50860. LeftStick = 10,
  50861. /** Right stick */
  50862. RightStick = 11
  50863. }
  50864. /** Defines values for DualShock DPad */
  50865. export enum DualShockDpad {
  50866. /** Up */
  50867. Up = 12,
  50868. /** Down */
  50869. Down = 13,
  50870. /** Left */
  50871. Left = 14,
  50872. /** Right */
  50873. Right = 15
  50874. }
  50875. /**
  50876. * Defines a DualShock gamepad
  50877. */
  50878. export class DualShockPad extends Gamepad {
  50879. private _leftTrigger;
  50880. private _rightTrigger;
  50881. private _onlefttriggerchanged;
  50882. private _onrighttriggerchanged;
  50883. private _onbuttondown;
  50884. private _onbuttonup;
  50885. private _ondpaddown;
  50886. private _ondpadup;
  50887. /** Observable raised when a button is pressed */
  50888. onButtonDownObservable: Observable<DualShockButton>;
  50889. /** Observable raised when a button is released */
  50890. onButtonUpObservable: Observable<DualShockButton>;
  50891. /** Observable raised when a pad is pressed */
  50892. onPadDownObservable: Observable<DualShockDpad>;
  50893. /** Observable raised when a pad is released */
  50894. onPadUpObservable: Observable<DualShockDpad>;
  50895. private _buttonCross;
  50896. private _buttonCircle;
  50897. private _buttonSquare;
  50898. private _buttonTriangle;
  50899. private _buttonShare;
  50900. private _buttonOptions;
  50901. private _buttonL1;
  50902. private _buttonR1;
  50903. private _buttonLeftStick;
  50904. private _buttonRightStick;
  50905. private _dPadUp;
  50906. private _dPadDown;
  50907. private _dPadLeft;
  50908. private _dPadRight;
  50909. /**
  50910. * Creates a new DualShock gamepad object
  50911. * @param id defines the id of this gamepad
  50912. * @param index defines its index
  50913. * @param gamepad defines the internal HTML gamepad object
  50914. */
  50915. constructor(id: string, index: number, gamepad: any);
  50916. /**
  50917. * Defines the callback to call when left trigger is pressed
  50918. * @param callback defines the callback to use
  50919. */
  50920. onlefttriggerchanged(callback: (value: number) => void): void;
  50921. /**
  50922. * Defines the callback to call when right trigger is pressed
  50923. * @param callback defines the callback to use
  50924. */
  50925. onrighttriggerchanged(callback: (value: number) => void): void;
  50926. /**
  50927. * Gets the left trigger value
  50928. */
  50929. get leftTrigger(): number;
  50930. /**
  50931. * Sets the left trigger value
  50932. */
  50933. set leftTrigger(newValue: number);
  50934. /**
  50935. * Gets the right trigger value
  50936. */
  50937. get rightTrigger(): number;
  50938. /**
  50939. * Sets the right trigger value
  50940. */
  50941. set rightTrigger(newValue: number);
  50942. /**
  50943. * Defines the callback to call when a button is pressed
  50944. * @param callback defines the callback to use
  50945. */
  50946. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  50947. /**
  50948. * Defines the callback to call when a button is released
  50949. * @param callback defines the callback to use
  50950. */
  50951. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  50952. /**
  50953. * Defines the callback to call when a pad is pressed
  50954. * @param callback defines the callback to use
  50955. */
  50956. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  50957. /**
  50958. * Defines the callback to call when a pad is released
  50959. * @param callback defines the callback to use
  50960. */
  50961. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  50962. private _setButtonValue;
  50963. private _setDPadValue;
  50964. /**
  50965. * Gets the value of the `Cross` button
  50966. */
  50967. get buttonCross(): number;
  50968. /**
  50969. * Sets the value of the `Cross` button
  50970. */
  50971. set buttonCross(value: number);
  50972. /**
  50973. * Gets the value of the `Circle` button
  50974. */
  50975. get buttonCircle(): number;
  50976. /**
  50977. * Sets the value of the `Circle` button
  50978. */
  50979. set buttonCircle(value: number);
  50980. /**
  50981. * Gets the value of the `Square` button
  50982. */
  50983. get buttonSquare(): number;
  50984. /**
  50985. * Sets the value of the `Square` button
  50986. */
  50987. set buttonSquare(value: number);
  50988. /**
  50989. * Gets the value of the `Triangle` button
  50990. */
  50991. get buttonTriangle(): number;
  50992. /**
  50993. * Sets the value of the `Triangle` button
  50994. */
  50995. set buttonTriangle(value: number);
  50996. /**
  50997. * Gets the value of the `Options` button
  50998. */
  50999. get buttonOptions(): number;
  51000. /**
  51001. * Sets the value of the `Options` button
  51002. */
  51003. set buttonOptions(value: number);
  51004. /**
  51005. * Gets the value of the `Share` button
  51006. */
  51007. get buttonShare(): number;
  51008. /**
  51009. * Sets the value of the `Share` button
  51010. */
  51011. set buttonShare(value: number);
  51012. /**
  51013. * Gets the value of the `L1` button
  51014. */
  51015. get buttonL1(): number;
  51016. /**
  51017. * Sets the value of the `L1` button
  51018. */
  51019. set buttonL1(value: number);
  51020. /**
  51021. * Gets the value of the `R1` button
  51022. */
  51023. get buttonR1(): number;
  51024. /**
  51025. * Sets the value of the `R1` button
  51026. */
  51027. set buttonR1(value: number);
  51028. /**
  51029. * Gets the value of the Left joystick
  51030. */
  51031. get buttonLeftStick(): number;
  51032. /**
  51033. * Sets the value of the Left joystick
  51034. */
  51035. set buttonLeftStick(value: number);
  51036. /**
  51037. * Gets the value of the Right joystick
  51038. */
  51039. get buttonRightStick(): number;
  51040. /**
  51041. * Sets the value of the Right joystick
  51042. */
  51043. set buttonRightStick(value: number);
  51044. /**
  51045. * Gets the value of D-pad up
  51046. */
  51047. get dPadUp(): number;
  51048. /**
  51049. * Sets the value of D-pad up
  51050. */
  51051. set dPadUp(value: number);
  51052. /**
  51053. * Gets the value of D-pad down
  51054. */
  51055. get dPadDown(): number;
  51056. /**
  51057. * Sets the value of D-pad down
  51058. */
  51059. set dPadDown(value: number);
  51060. /**
  51061. * Gets the value of D-pad left
  51062. */
  51063. get dPadLeft(): number;
  51064. /**
  51065. * Sets the value of D-pad left
  51066. */
  51067. set dPadLeft(value: number);
  51068. /**
  51069. * Gets the value of D-pad right
  51070. */
  51071. get dPadRight(): number;
  51072. /**
  51073. * Sets the value of D-pad right
  51074. */
  51075. set dPadRight(value: number);
  51076. /**
  51077. * Force the gamepad to synchronize with device values
  51078. */
  51079. update(): void;
  51080. /**
  51081. * Disposes the gamepad
  51082. */
  51083. dispose(): void;
  51084. }
  51085. }
  51086. declare module "babylonjs/Gamepads/gamepadManager" {
  51087. import { Observable } from "babylonjs/Misc/observable";
  51088. import { Nullable } from "babylonjs/types";
  51089. import { Scene } from "babylonjs/scene";
  51090. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51091. /**
  51092. * Manager for handling gamepads
  51093. */
  51094. export class GamepadManager {
  51095. private _scene?;
  51096. private _babylonGamepads;
  51097. private _oneGamepadConnected;
  51098. /** @hidden */
  51099. _isMonitoring: boolean;
  51100. private _gamepadEventSupported;
  51101. private _gamepadSupport?;
  51102. /**
  51103. * observable to be triggered when the gamepad controller has been connected
  51104. */
  51105. onGamepadConnectedObservable: Observable<Gamepad>;
  51106. /**
  51107. * observable to be triggered when the gamepad controller has been disconnected
  51108. */
  51109. onGamepadDisconnectedObservable: Observable<Gamepad>;
  51110. private _onGamepadConnectedEvent;
  51111. private _onGamepadDisconnectedEvent;
  51112. /**
  51113. * Initializes the gamepad manager
  51114. * @param _scene BabylonJS scene
  51115. */
  51116. constructor(_scene?: Scene | undefined);
  51117. /**
  51118. * The gamepads in the game pad manager
  51119. */
  51120. get gamepads(): Gamepad[];
  51121. /**
  51122. * Get the gamepad controllers based on type
  51123. * @param type The type of gamepad controller
  51124. * @returns Nullable gamepad
  51125. */
  51126. getGamepadByType(type?: number): Nullable<Gamepad>;
  51127. /**
  51128. * Disposes the gamepad manager
  51129. */
  51130. dispose(): void;
  51131. private _addNewGamepad;
  51132. private _startMonitoringGamepads;
  51133. private _stopMonitoringGamepads;
  51134. /** @hidden */
  51135. _checkGamepadsStatus(): void;
  51136. private _updateGamepadObjects;
  51137. }
  51138. }
  51139. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  51140. import { Nullable } from "babylonjs/types";
  51141. import { Scene } from "babylonjs/scene";
  51142. import { ISceneComponent } from "babylonjs/sceneComponent";
  51143. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  51144. module "babylonjs/scene" {
  51145. interface Scene {
  51146. /** @hidden */
  51147. _gamepadManager: Nullable<GamepadManager>;
  51148. /**
  51149. * Gets the gamepad manager associated with the scene
  51150. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  51151. */
  51152. gamepadManager: GamepadManager;
  51153. }
  51154. }
  51155. module "babylonjs/Cameras/freeCameraInputsManager" {
  51156. /**
  51157. * Interface representing a free camera inputs manager
  51158. */
  51159. interface FreeCameraInputsManager {
  51160. /**
  51161. * Adds gamepad input support to the FreeCameraInputsManager.
  51162. * @returns the FreeCameraInputsManager
  51163. */
  51164. addGamepad(): FreeCameraInputsManager;
  51165. }
  51166. }
  51167. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51168. /**
  51169. * Interface representing an arc rotate camera inputs manager
  51170. */
  51171. interface ArcRotateCameraInputsManager {
  51172. /**
  51173. * Adds gamepad input support to the ArcRotateCamera InputManager.
  51174. * @returns the camera inputs manager
  51175. */
  51176. addGamepad(): ArcRotateCameraInputsManager;
  51177. }
  51178. }
  51179. /**
  51180. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  51181. */
  51182. export class GamepadSystemSceneComponent implements ISceneComponent {
  51183. /**
  51184. * The component name helpfull to identify the component in the list of scene components.
  51185. */
  51186. readonly name: string;
  51187. /**
  51188. * The scene the component belongs to.
  51189. */
  51190. scene: Scene;
  51191. /**
  51192. * Creates a new instance of the component for the given scene
  51193. * @param scene Defines the scene to register the component in
  51194. */
  51195. constructor(scene: Scene);
  51196. /**
  51197. * Registers the component in a given scene
  51198. */
  51199. register(): void;
  51200. /**
  51201. * Rebuilds the elements related to this component in case of
  51202. * context lost for instance.
  51203. */
  51204. rebuild(): void;
  51205. /**
  51206. * Disposes the component and the associated ressources
  51207. */
  51208. dispose(): void;
  51209. private _beforeCameraUpdate;
  51210. }
  51211. }
  51212. declare module "babylonjs/Cameras/universalCamera" {
  51213. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  51214. import { Scene } from "babylonjs/scene";
  51215. import { Vector3 } from "babylonjs/Maths/math.vector";
  51216. import "babylonjs/Gamepads/gamepadSceneComponent";
  51217. /**
  51218. * 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,
  51219. * which still works and will still be found in many Playgrounds.
  51220. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51221. */
  51222. export class UniversalCamera extends TouchCamera {
  51223. /**
  51224. * Defines the gamepad rotation sensiblity.
  51225. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51226. */
  51227. get gamepadAngularSensibility(): number;
  51228. set gamepadAngularSensibility(value: number);
  51229. /**
  51230. * Defines the gamepad move sensiblity.
  51231. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51232. */
  51233. get gamepadMoveSensibility(): number;
  51234. set gamepadMoveSensibility(value: number);
  51235. /**
  51236. * 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,
  51237. * which still works and will still be found in many Playgrounds.
  51238. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51239. * @param name Define the name of the camera in the scene
  51240. * @param position Define the start position of the camera in the scene
  51241. * @param scene Define the scene the camera belongs to
  51242. */
  51243. constructor(name: string, position: Vector3, scene: Scene);
  51244. /**
  51245. * Gets the current object class name.
  51246. * @return the class name
  51247. */
  51248. getClassName(): string;
  51249. }
  51250. }
  51251. declare module "babylonjs/Cameras/gamepadCamera" {
  51252. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51253. import { Scene } from "babylonjs/scene";
  51254. import { Vector3 } from "babylonjs/Maths/math.vector";
  51255. /**
  51256. * This represents a FPS type of camera. This is only here for back compat purpose.
  51257. * Please use the UniversalCamera instead as both are identical.
  51258. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51259. */
  51260. export class GamepadCamera extends UniversalCamera {
  51261. /**
  51262. * Instantiates a new Gamepad Camera
  51263. * This represents a FPS type of camera. This is only here for back compat purpose.
  51264. * Please use the UniversalCamera instead as both are identical.
  51265. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51266. * @param name Define the name of the camera in the scene
  51267. * @param position Define the start position of the camera in the scene
  51268. * @param scene Define the scene the camera belongs to
  51269. */
  51270. constructor(name: string, position: Vector3, scene: Scene);
  51271. /**
  51272. * Gets the current object class name.
  51273. * @return the class name
  51274. */
  51275. getClassName(): string;
  51276. }
  51277. }
  51278. declare module "babylonjs/Shaders/pass.fragment" {
  51279. /** @hidden */
  51280. export var passPixelShader: {
  51281. name: string;
  51282. shader: string;
  51283. };
  51284. }
  51285. declare module "babylonjs/Shaders/passCube.fragment" {
  51286. /** @hidden */
  51287. export var passCubePixelShader: {
  51288. name: string;
  51289. shader: string;
  51290. };
  51291. }
  51292. declare module "babylonjs/PostProcesses/passPostProcess" {
  51293. import { Nullable } from "babylonjs/types";
  51294. import { Camera } from "babylonjs/Cameras/camera";
  51295. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51296. import { Engine } from "babylonjs/Engines/engine";
  51297. import "babylonjs/Shaders/pass.fragment";
  51298. import "babylonjs/Shaders/passCube.fragment";
  51299. import { Scene } from "babylonjs/scene";
  51300. /**
  51301. * PassPostProcess which produces an output the same as it's input
  51302. */
  51303. export class PassPostProcess extends PostProcess {
  51304. /**
  51305. * Gets a string identifying the name of the class
  51306. * @returns "PassPostProcess" string
  51307. */
  51308. getClassName(): string;
  51309. /**
  51310. * Creates the PassPostProcess
  51311. * @param name The name of the effect.
  51312. * @param options The required width/height ratio to downsize to before computing the render pass.
  51313. * @param camera The camera to apply the render pass to.
  51314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51315. * @param engine The engine which the post process will be applied. (default: current engine)
  51316. * @param reusable If the post process can be reused on the same frame. (default: false)
  51317. * @param textureType The type of texture to be used when performing the post processing.
  51318. * @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)
  51319. */
  51320. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51321. /** @hidden */
  51322. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  51323. }
  51324. /**
  51325. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  51326. */
  51327. export class PassCubePostProcess extends PostProcess {
  51328. private _face;
  51329. /**
  51330. * Gets or sets the cube face to display.
  51331. * * 0 is +X
  51332. * * 1 is -X
  51333. * * 2 is +Y
  51334. * * 3 is -Y
  51335. * * 4 is +Z
  51336. * * 5 is -Z
  51337. */
  51338. get face(): number;
  51339. set face(value: number);
  51340. /**
  51341. * Gets a string identifying the name of the class
  51342. * @returns "PassCubePostProcess" string
  51343. */
  51344. getClassName(): string;
  51345. /**
  51346. * Creates the PassCubePostProcess
  51347. * @param name The name of the effect.
  51348. * @param options The required width/height ratio to downsize to before computing the render pass.
  51349. * @param camera The camera to apply the render pass to.
  51350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51351. * @param engine The engine which the post process will be applied. (default: current engine)
  51352. * @param reusable If the post process can be reused on the same frame. (default: false)
  51353. * @param textureType The type of texture to be used when performing the post processing.
  51354. * @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)
  51355. */
  51356. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51357. /** @hidden */
  51358. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51359. }
  51360. }
  51361. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51362. /** @hidden */
  51363. export var anaglyphPixelShader: {
  51364. name: string;
  51365. shader: string;
  51366. };
  51367. }
  51368. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51369. import { Engine } from "babylonjs/Engines/engine";
  51370. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51371. import { Camera } from "babylonjs/Cameras/camera";
  51372. import "babylonjs/Shaders/anaglyph.fragment";
  51373. /**
  51374. * Postprocess used to generate anaglyphic rendering
  51375. */
  51376. export class AnaglyphPostProcess extends PostProcess {
  51377. private _passedProcess;
  51378. /**
  51379. * Gets a string identifying the name of the class
  51380. * @returns "AnaglyphPostProcess" string
  51381. */
  51382. getClassName(): string;
  51383. /**
  51384. * Creates a new AnaglyphPostProcess
  51385. * @param name defines postprocess name
  51386. * @param options defines creation options or target ratio scale
  51387. * @param rigCameras defines cameras using this postprocess
  51388. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51389. * @param engine defines hosting engine
  51390. * @param reusable defines if the postprocess will be reused multiple times per frame
  51391. */
  51392. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51393. }
  51394. }
  51395. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51396. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51397. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51398. import { Scene } from "babylonjs/scene";
  51399. import { Vector3 } from "babylonjs/Maths/math.vector";
  51400. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51401. /**
  51402. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51403. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51404. */
  51405. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51406. /**
  51407. * Creates a new AnaglyphArcRotateCamera
  51408. * @param name defines camera name
  51409. * @param alpha defines alpha angle (in radians)
  51410. * @param beta defines beta angle (in radians)
  51411. * @param radius defines radius
  51412. * @param target defines camera target
  51413. * @param interaxialDistance defines distance between each color axis
  51414. * @param scene defines the hosting scene
  51415. */
  51416. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51417. /**
  51418. * Gets camera class name
  51419. * @returns AnaglyphArcRotateCamera
  51420. */
  51421. getClassName(): string;
  51422. }
  51423. }
  51424. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51425. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51426. import { Scene } from "babylonjs/scene";
  51427. import { Vector3 } from "babylonjs/Maths/math.vector";
  51428. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51429. /**
  51430. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51431. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51432. */
  51433. export class AnaglyphFreeCamera extends FreeCamera {
  51434. /**
  51435. * Creates a new AnaglyphFreeCamera
  51436. * @param name defines camera name
  51437. * @param position defines initial position
  51438. * @param interaxialDistance defines distance between each color axis
  51439. * @param scene defines the hosting scene
  51440. */
  51441. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51442. /**
  51443. * Gets camera class name
  51444. * @returns AnaglyphFreeCamera
  51445. */
  51446. getClassName(): string;
  51447. }
  51448. }
  51449. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51450. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51451. import { Scene } from "babylonjs/scene";
  51452. import { Vector3 } from "babylonjs/Maths/math.vector";
  51453. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51454. /**
  51455. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51456. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51457. */
  51458. export class AnaglyphGamepadCamera extends GamepadCamera {
  51459. /**
  51460. * Creates a new AnaglyphGamepadCamera
  51461. * @param name defines camera name
  51462. * @param position defines initial position
  51463. * @param interaxialDistance defines distance between each color axis
  51464. * @param scene defines the hosting scene
  51465. */
  51466. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51467. /**
  51468. * Gets camera class name
  51469. * @returns AnaglyphGamepadCamera
  51470. */
  51471. getClassName(): string;
  51472. }
  51473. }
  51474. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51475. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51476. import { Scene } from "babylonjs/scene";
  51477. import { Vector3 } from "babylonjs/Maths/math.vector";
  51478. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51479. /**
  51480. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51481. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51482. */
  51483. export class AnaglyphUniversalCamera extends UniversalCamera {
  51484. /**
  51485. * Creates a new AnaglyphUniversalCamera
  51486. * @param name defines camera name
  51487. * @param position defines initial position
  51488. * @param interaxialDistance defines distance between each color axis
  51489. * @param scene defines the hosting scene
  51490. */
  51491. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51492. /**
  51493. * Gets camera class name
  51494. * @returns AnaglyphUniversalCamera
  51495. */
  51496. getClassName(): string;
  51497. }
  51498. }
  51499. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51500. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51501. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51502. import { Scene } from "babylonjs/scene";
  51503. import { Vector3 } from "babylonjs/Maths/math.vector";
  51504. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51505. /**
  51506. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51507. * @see https://doc.babylonjs.com/features/cameras
  51508. */
  51509. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51510. /**
  51511. * Creates a new StereoscopicArcRotateCamera
  51512. * @param name defines camera name
  51513. * @param alpha defines alpha angle (in radians)
  51514. * @param beta defines beta angle (in radians)
  51515. * @param radius defines radius
  51516. * @param target defines camera target
  51517. * @param interaxialDistance defines distance between each color axis
  51518. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51519. * @param scene defines the hosting scene
  51520. */
  51521. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51522. /**
  51523. * Gets camera class name
  51524. * @returns StereoscopicArcRotateCamera
  51525. */
  51526. getClassName(): string;
  51527. }
  51528. }
  51529. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51530. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51531. import { Scene } from "babylonjs/scene";
  51532. import { Vector3 } from "babylonjs/Maths/math.vector";
  51533. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51534. /**
  51535. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51536. * @see https://doc.babylonjs.com/features/cameras
  51537. */
  51538. export class StereoscopicFreeCamera extends FreeCamera {
  51539. /**
  51540. * Creates a new StereoscopicFreeCamera
  51541. * @param name defines camera name
  51542. * @param position defines initial position
  51543. * @param interaxialDistance defines distance between each color axis
  51544. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51545. * @param scene defines the hosting scene
  51546. */
  51547. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51548. /**
  51549. * Gets camera class name
  51550. * @returns StereoscopicFreeCamera
  51551. */
  51552. getClassName(): string;
  51553. }
  51554. }
  51555. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51556. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51557. import { Scene } from "babylonjs/scene";
  51558. import { Vector3 } from "babylonjs/Maths/math.vector";
  51559. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51560. /**
  51561. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51562. * @see https://doc.babylonjs.com/features/cameras
  51563. */
  51564. export class StereoscopicGamepadCamera extends GamepadCamera {
  51565. /**
  51566. * Creates a new StereoscopicGamepadCamera
  51567. * @param name defines camera name
  51568. * @param position defines initial position
  51569. * @param interaxialDistance defines distance between each color axis
  51570. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51571. * @param scene defines the hosting scene
  51572. */
  51573. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51574. /**
  51575. * Gets camera class name
  51576. * @returns StereoscopicGamepadCamera
  51577. */
  51578. getClassName(): string;
  51579. }
  51580. }
  51581. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51582. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51583. import { Scene } from "babylonjs/scene";
  51584. import { Vector3 } from "babylonjs/Maths/math.vector";
  51585. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51586. /**
  51587. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51588. * @see https://doc.babylonjs.com/features/cameras
  51589. */
  51590. export class StereoscopicUniversalCamera extends UniversalCamera {
  51591. /**
  51592. * Creates a new StereoscopicUniversalCamera
  51593. * @param name defines camera name
  51594. * @param position defines initial position
  51595. * @param interaxialDistance defines distance between each color axis
  51596. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51597. * @param scene defines the hosting scene
  51598. */
  51599. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51600. /**
  51601. * Gets camera class name
  51602. * @returns StereoscopicUniversalCamera
  51603. */
  51604. getClassName(): string;
  51605. }
  51606. }
  51607. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51608. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51609. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51610. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51611. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51612. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51613. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51614. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51615. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51616. }
  51617. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51618. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51619. import { Scene } from "babylonjs/scene";
  51620. import { Vector3 } from "babylonjs/Maths/math.vector";
  51621. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51622. /**
  51623. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51624. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51625. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51626. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51627. */
  51628. export class VirtualJoysticksCamera extends FreeCamera {
  51629. /**
  51630. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51631. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51632. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51633. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51634. * @param name Define the name of the camera in the scene
  51635. * @param position Define the start position of the camera in the scene
  51636. * @param scene Define the scene the camera belongs to
  51637. */
  51638. constructor(name: string, position: Vector3, scene: Scene);
  51639. /**
  51640. * Gets the current object class name.
  51641. * @return the class name
  51642. */
  51643. getClassName(): string;
  51644. }
  51645. }
  51646. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51647. import { Matrix } from "babylonjs/Maths/math.vector";
  51648. /**
  51649. * This represents all the required metrics to create a VR camera.
  51650. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51651. */
  51652. export class VRCameraMetrics {
  51653. /**
  51654. * Define the horizontal resolution off the screen.
  51655. */
  51656. hResolution: number;
  51657. /**
  51658. * Define the vertical resolution off the screen.
  51659. */
  51660. vResolution: number;
  51661. /**
  51662. * Define the horizontal screen size.
  51663. */
  51664. hScreenSize: number;
  51665. /**
  51666. * Define the vertical screen size.
  51667. */
  51668. vScreenSize: number;
  51669. /**
  51670. * Define the vertical screen center position.
  51671. */
  51672. vScreenCenter: number;
  51673. /**
  51674. * Define the distance of the eyes to the screen.
  51675. */
  51676. eyeToScreenDistance: number;
  51677. /**
  51678. * Define the distance between both lenses
  51679. */
  51680. lensSeparationDistance: number;
  51681. /**
  51682. * Define the distance between both viewer's eyes.
  51683. */
  51684. interpupillaryDistance: number;
  51685. /**
  51686. * Define the distortion factor of the VR postprocess.
  51687. * Please, touch with care.
  51688. */
  51689. distortionK: number[];
  51690. /**
  51691. * Define the chromatic aberration correction factors for the VR post process.
  51692. */
  51693. chromaAbCorrection: number[];
  51694. /**
  51695. * Define the scale factor of the post process.
  51696. * The smaller the better but the slower.
  51697. */
  51698. postProcessScaleFactor: number;
  51699. /**
  51700. * Define an offset for the lens center.
  51701. */
  51702. lensCenterOffset: number;
  51703. /**
  51704. * Define if the current vr camera should compensate the distortion of the lense or not.
  51705. */
  51706. compensateDistortion: boolean;
  51707. /**
  51708. * Defines if multiview should be enabled when rendering (Default: false)
  51709. */
  51710. multiviewEnabled: boolean;
  51711. /**
  51712. * Gets the rendering aspect ratio based on the provided resolutions.
  51713. */
  51714. get aspectRatio(): number;
  51715. /**
  51716. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51717. */
  51718. get aspectRatioFov(): number;
  51719. /**
  51720. * @hidden
  51721. */
  51722. get leftHMatrix(): Matrix;
  51723. /**
  51724. * @hidden
  51725. */
  51726. get rightHMatrix(): Matrix;
  51727. /**
  51728. * @hidden
  51729. */
  51730. get leftPreViewMatrix(): Matrix;
  51731. /**
  51732. * @hidden
  51733. */
  51734. get rightPreViewMatrix(): Matrix;
  51735. /**
  51736. * Get the default VRMetrics based on the most generic setup.
  51737. * @returns the default vr metrics
  51738. */
  51739. static GetDefault(): VRCameraMetrics;
  51740. }
  51741. }
  51742. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  51743. /** @hidden */
  51744. export var vrDistortionCorrectionPixelShader: {
  51745. name: string;
  51746. shader: string;
  51747. };
  51748. }
  51749. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  51750. import { Camera } from "babylonjs/Cameras/camera";
  51751. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51752. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51753. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  51754. /**
  51755. * VRDistortionCorrectionPostProcess used for mobile VR
  51756. */
  51757. export class VRDistortionCorrectionPostProcess extends PostProcess {
  51758. private _isRightEye;
  51759. private _distortionFactors;
  51760. private _postProcessScaleFactor;
  51761. private _lensCenterOffset;
  51762. private _scaleIn;
  51763. private _scaleFactor;
  51764. private _lensCenter;
  51765. /**
  51766. * Gets a string identifying the name of the class
  51767. * @returns "VRDistortionCorrectionPostProcess" string
  51768. */
  51769. getClassName(): string;
  51770. /**
  51771. * Initializes the VRDistortionCorrectionPostProcess
  51772. * @param name The name of the effect.
  51773. * @param camera The camera to apply the render pass to.
  51774. * @param isRightEye If this is for the right eye distortion
  51775. * @param vrMetrics All the required metrics for the VR camera
  51776. */
  51777. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  51778. }
  51779. }
  51780. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  51781. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  51782. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51783. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51784. import { Scene } from "babylonjs/scene";
  51785. import { Vector3 } from "babylonjs/Maths/math.vector";
  51786. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  51787. import "babylonjs/Cameras/RigModes/vrRigMode";
  51788. /**
  51789. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  51790. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51791. */
  51792. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  51793. /**
  51794. * Creates a new VRDeviceOrientationArcRotateCamera
  51795. * @param name defines camera name
  51796. * @param alpha defines the camera rotation along the logitudinal axis
  51797. * @param beta defines the camera rotation along the latitudinal axis
  51798. * @param radius defines the camera distance from its target
  51799. * @param target defines the camera target
  51800. * @param scene defines the scene the camera belongs to
  51801. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51802. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51803. */
  51804. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51805. /**
  51806. * Gets camera class name
  51807. * @returns VRDeviceOrientationArcRotateCamera
  51808. */
  51809. getClassName(): string;
  51810. }
  51811. }
  51812. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  51813. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51814. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51815. import { Scene } from "babylonjs/scene";
  51816. import { Vector3 } from "babylonjs/Maths/math.vector";
  51817. import "babylonjs/Cameras/RigModes/vrRigMode";
  51818. /**
  51819. * Camera used to simulate VR rendering (based on FreeCamera)
  51820. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51821. */
  51822. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  51823. /**
  51824. * Creates a new VRDeviceOrientationFreeCamera
  51825. * @param name defines camera name
  51826. * @param position defines the start position of the camera
  51827. * @param scene defines the scene the camera belongs to
  51828. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51829. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51830. */
  51831. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51832. /**
  51833. * Gets camera class name
  51834. * @returns VRDeviceOrientationFreeCamera
  51835. */
  51836. getClassName(): string;
  51837. }
  51838. }
  51839. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  51840. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51841. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51842. import { Scene } from "babylonjs/scene";
  51843. import { Vector3 } from "babylonjs/Maths/math.vector";
  51844. import "babylonjs/Gamepads/gamepadSceneComponent";
  51845. /**
  51846. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  51847. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51848. */
  51849. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  51850. /**
  51851. * Creates a new VRDeviceOrientationGamepadCamera
  51852. * @param name defines camera name
  51853. * @param position defines the start position of the camera
  51854. * @param scene defines the scene the camera belongs to
  51855. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51856. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51857. */
  51858. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51859. /**
  51860. * Gets camera class name
  51861. * @returns VRDeviceOrientationGamepadCamera
  51862. */
  51863. getClassName(): string;
  51864. }
  51865. }
  51866. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  51867. import { Scene } from "babylonjs/scene";
  51868. import { Texture } from "babylonjs/Materials/Textures/texture";
  51869. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  51870. /**
  51871. * A class extending Texture allowing drawing on a texture
  51872. * @see https://doc.babylonjs.com/how_to/dynamictexture
  51873. */
  51874. export class DynamicTexture extends Texture {
  51875. private _generateMipMaps;
  51876. private _canvas;
  51877. private _context;
  51878. /**
  51879. * Creates a DynamicTexture
  51880. * @param name defines the name of the texture
  51881. * @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
  51882. * @param scene defines the scene where you want the texture
  51883. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  51884. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51885. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  51886. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  51887. */
  51888. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  51889. /**
  51890. * Get the current class name of the texture useful for serialization or dynamic coding.
  51891. * @returns "DynamicTexture"
  51892. */
  51893. getClassName(): string;
  51894. /**
  51895. * Gets the current state of canRescale
  51896. */
  51897. get canRescale(): boolean;
  51898. private _recreate;
  51899. /**
  51900. * Scales the texture
  51901. * @param ratio the scale factor to apply to both width and height
  51902. */
  51903. scale(ratio: number): void;
  51904. /**
  51905. * Resizes the texture
  51906. * @param width the new width
  51907. * @param height the new height
  51908. */
  51909. scaleTo(width: number, height: number): void;
  51910. /**
  51911. * Gets the context of the canvas used by the texture
  51912. * @returns the canvas context of the dynamic texture
  51913. */
  51914. getContext(): CanvasRenderingContext2D;
  51915. /**
  51916. * Clears the texture
  51917. */
  51918. clear(): void;
  51919. /**
  51920. * Updates the texture
  51921. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51922. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  51923. */
  51924. update(invertY?: boolean, premulAlpha?: boolean): void;
  51925. /**
  51926. * Draws text onto the texture
  51927. * @param text defines the text to be drawn
  51928. * @param x defines the placement of the text from the left
  51929. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  51930. * @param font defines the font to be used with font-style, font-size, font-name
  51931. * @param color defines the color used for the text
  51932. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  51933. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51934. * @param update defines whether texture is immediately update (default is true)
  51935. */
  51936. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  51937. /**
  51938. * Clones the texture
  51939. * @returns the clone of the texture.
  51940. */
  51941. clone(): DynamicTexture;
  51942. /**
  51943. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  51944. * @returns a serialized dynamic texture object
  51945. */
  51946. serialize(): any;
  51947. private _IsCanvasElement;
  51948. /** @hidden */
  51949. _rebuild(): void;
  51950. }
  51951. }
  51952. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  51953. import { Scene } from "babylonjs/scene";
  51954. import { Color3 } from "babylonjs/Maths/math.color";
  51955. import { Mesh } from "babylonjs/Meshes/mesh";
  51956. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51957. import { Nullable } from "babylonjs/types";
  51958. /**
  51959. * Class containing static functions to help procedurally build meshes
  51960. */
  51961. export class GroundBuilder {
  51962. /**
  51963. * Creates a ground mesh
  51964. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51965. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51967. * @param name defines the name of the mesh
  51968. * @param options defines the options used to create the mesh
  51969. * @param scene defines the hosting scene
  51970. * @returns the ground mesh
  51971. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51972. */
  51973. static CreateGround(name: string, options: {
  51974. width?: number;
  51975. height?: number;
  51976. subdivisions?: number;
  51977. subdivisionsX?: number;
  51978. subdivisionsY?: number;
  51979. updatable?: boolean;
  51980. }, scene: any): Mesh;
  51981. /**
  51982. * Creates a tiled ground mesh
  51983. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51984. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51985. * * 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
  51986. * * 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
  51987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51988. * @param name defines the name of the mesh
  51989. * @param options defines the options used to create the mesh
  51990. * @param scene defines the hosting scene
  51991. * @returns the tiled ground mesh
  51992. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51993. */
  51994. static CreateTiledGround(name: string, options: {
  51995. xmin: number;
  51996. zmin: number;
  51997. xmax: number;
  51998. zmax: number;
  51999. subdivisions?: {
  52000. w: number;
  52001. h: number;
  52002. };
  52003. precision?: {
  52004. w: number;
  52005. h: number;
  52006. };
  52007. updatable?: boolean;
  52008. }, scene?: Nullable<Scene>): Mesh;
  52009. /**
  52010. * Creates a ground mesh from a height map
  52011. * * The parameter `url` sets the URL of the height map image resource.
  52012. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52013. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52014. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52015. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52016. * * 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.
  52017. * * 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).
  52018. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52020. * @param name defines the name of the mesh
  52021. * @param url defines the url to the height map
  52022. * @param options defines the options used to create the mesh
  52023. * @param scene defines the hosting scene
  52024. * @returns the ground mesh
  52025. * @see https://doc.babylonjs.com/babylon101/height_map
  52026. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52027. */
  52028. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52029. width?: number;
  52030. height?: number;
  52031. subdivisions?: number;
  52032. minHeight?: number;
  52033. maxHeight?: number;
  52034. colorFilter?: Color3;
  52035. alphaFilter?: number;
  52036. updatable?: boolean;
  52037. onReady?: (mesh: GroundMesh) => void;
  52038. }, scene?: Nullable<Scene>): GroundMesh;
  52039. }
  52040. }
  52041. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  52042. import { Vector4 } from "babylonjs/Maths/math.vector";
  52043. import { Mesh } from "babylonjs/Meshes/mesh";
  52044. /**
  52045. * Class containing static functions to help procedurally build meshes
  52046. */
  52047. export class TorusBuilder {
  52048. /**
  52049. * Creates a torus mesh
  52050. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52051. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52052. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52056. * @param name defines the name of the mesh
  52057. * @param options defines the options used to create the mesh
  52058. * @param scene defines the hosting scene
  52059. * @returns the torus mesh
  52060. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52061. */
  52062. static CreateTorus(name: string, options: {
  52063. diameter?: number;
  52064. thickness?: number;
  52065. tessellation?: number;
  52066. updatable?: boolean;
  52067. sideOrientation?: number;
  52068. frontUVs?: Vector4;
  52069. backUVs?: Vector4;
  52070. }, scene: any): Mesh;
  52071. }
  52072. }
  52073. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  52074. import { Vector4 } from "babylonjs/Maths/math.vector";
  52075. import { Color4 } from "babylonjs/Maths/math.color";
  52076. import { Mesh } from "babylonjs/Meshes/mesh";
  52077. /**
  52078. * Class containing static functions to help procedurally build meshes
  52079. */
  52080. export class CylinderBuilder {
  52081. /**
  52082. * Creates a cylinder or a cone mesh
  52083. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52084. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52085. * * 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.
  52086. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52087. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52088. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52089. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52090. * * 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).
  52091. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52092. * * 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).
  52093. * * 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
  52094. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52095. * * 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
  52096. * * 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.
  52097. * * If `enclose` is false, a ring surface is one element.
  52098. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52099. * * 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
  52100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52103. * @param name defines the name of the mesh
  52104. * @param options defines the options used to create the mesh
  52105. * @param scene defines the hosting scene
  52106. * @returns the cylinder mesh
  52107. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52108. */
  52109. static CreateCylinder(name: string, options: {
  52110. height?: number;
  52111. diameterTop?: number;
  52112. diameterBottom?: number;
  52113. diameter?: number;
  52114. tessellation?: number;
  52115. subdivisions?: number;
  52116. arc?: number;
  52117. faceColors?: Color4[];
  52118. faceUV?: Vector4[];
  52119. updatable?: boolean;
  52120. hasRings?: boolean;
  52121. enclose?: boolean;
  52122. cap?: number;
  52123. sideOrientation?: number;
  52124. frontUVs?: Vector4;
  52125. backUVs?: Vector4;
  52126. }, scene: any): Mesh;
  52127. }
  52128. }
  52129. declare module "babylonjs/XR/webXRTypes" {
  52130. import { Nullable } from "babylonjs/types";
  52131. import { IDisposable } from "babylonjs/scene";
  52132. /**
  52133. * States of the webXR experience
  52134. */
  52135. export enum WebXRState {
  52136. /**
  52137. * Transitioning to being in XR mode
  52138. */
  52139. ENTERING_XR = 0,
  52140. /**
  52141. * Transitioning to non XR mode
  52142. */
  52143. EXITING_XR = 1,
  52144. /**
  52145. * In XR mode and presenting
  52146. */
  52147. IN_XR = 2,
  52148. /**
  52149. * Not entered XR mode
  52150. */
  52151. NOT_IN_XR = 3
  52152. }
  52153. /**
  52154. * The state of the XR camera's tracking
  52155. */
  52156. export enum WebXRTrackingState {
  52157. /**
  52158. * No transformation received, device is not being tracked
  52159. */
  52160. NOT_TRACKING = 0,
  52161. /**
  52162. * Tracking lost - using emulated position
  52163. */
  52164. TRACKING_LOST = 1,
  52165. /**
  52166. * Transformation tracking works normally
  52167. */
  52168. TRACKING = 2
  52169. }
  52170. /**
  52171. * Abstraction of the XR render target
  52172. */
  52173. export interface WebXRRenderTarget extends IDisposable {
  52174. /**
  52175. * xrpresent context of the canvas which can be used to display/mirror xr content
  52176. */
  52177. canvasContext: WebGLRenderingContext;
  52178. /**
  52179. * xr layer for the canvas
  52180. */
  52181. xrLayer: Nullable<XRWebGLLayer>;
  52182. /**
  52183. * Initializes the xr layer for the session
  52184. * @param xrSession xr session
  52185. * @returns a promise that will resolve once the XR Layer has been created
  52186. */
  52187. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52188. }
  52189. }
  52190. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  52191. import { Nullable } from "babylonjs/types";
  52192. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  52193. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52194. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52195. import { Observable } from "babylonjs/Misc/observable";
  52196. /**
  52197. * COnfiguration object for WebXR output canvas
  52198. */
  52199. export class WebXRManagedOutputCanvasOptions {
  52200. /**
  52201. * An optional canvas in case you wish to create it yourself and provide it here.
  52202. * If not provided, a new canvas will be created
  52203. */
  52204. canvasElement?: HTMLCanvasElement;
  52205. /**
  52206. * Options for this XR Layer output
  52207. */
  52208. canvasOptions?: XRWebGLLayerInit;
  52209. /**
  52210. * CSS styling for a newly created canvas (if not provided)
  52211. */
  52212. newCanvasCssStyle?: string;
  52213. /**
  52214. * Get the default values of the configuration object
  52215. * @param engine defines the engine to use (can be null)
  52216. * @returns default values of this configuration object
  52217. */
  52218. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  52219. }
  52220. /**
  52221. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  52222. */
  52223. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  52224. private _options;
  52225. private _canvas;
  52226. private _engine;
  52227. private _originalCanvasSize;
  52228. /**
  52229. * Rendering context of the canvas which can be used to display/mirror xr content
  52230. */
  52231. canvasContext: WebGLRenderingContext;
  52232. /**
  52233. * xr layer for the canvas
  52234. */
  52235. xrLayer: Nullable<XRWebGLLayer>;
  52236. /**
  52237. * Obseervers registered here will be triggered when the xr layer was initialized
  52238. */
  52239. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  52240. /**
  52241. * Initializes the canvas to be added/removed upon entering/exiting xr
  52242. * @param _xrSessionManager The XR Session manager
  52243. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  52244. */
  52245. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  52246. /**
  52247. * Disposes of the object
  52248. */
  52249. dispose(): void;
  52250. /**
  52251. * Initializes the xr layer for the session
  52252. * @param xrSession xr session
  52253. * @returns a promise that will resolve once the XR Layer has been created
  52254. */
  52255. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52256. private _addCanvas;
  52257. private _removeCanvas;
  52258. private _setCanvasSize;
  52259. private _setManagedOutputCanvas;
  52260. }
  52261. }
  52262. declare module "babylonjs/XR/webXRSessionManager" {
  52263. import { Observable } from "babylonjs/Misc/observable";
  52264. import { Nullable } from "babylonjs/types";
  52265. import { IDisposable, Scene } from "babylonjs/scene";
  52266. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52267. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52268. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  52269. /**
  52270. * Manages an XRSession to work with Babylon's engine
  52271. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  52272. */
  52273. export class WebXRSessionManager implements IDisposable {
  52274. /** The scene which the session should be created for */
  52275. scene: Scene;
  52276. private _referenceSpace;
  52277. private _rttProvider;
  52278. private _sessionEnded;
  52279. private _xrNavigator;
  52280. private baseLayer;
  52281. /**
  52282. * The base reference space from which the session started. good if you want to reset your
  52283. * reference space
  52284. */
  52285. baseReferenceSpace: XRReferenceSpace;
  52286. /**
  52287. * Current XR frame
  52288. */
  52289. currentFrame: Nullable<XRFrame>;
  52290. /** WebXR timestamp updated every frame */
  52291. currentTimestamp: number;
  52292. /**
  52293. * Used just in case of a failure to initialize an immersive session.
  52294. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  52295. */
  52296. defaultHeightCompensation: number;
  52297. /**
  52298. * Fires every time a new xrFrame arrives which can be used to update the camera
  52299. */
  52300. onXRFrameObservable: Observable<XRFrame>;
  52301. /**
  52302. * Fires when the reference space changed
  52303. */
  52304. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  52305. /**
  52306. * Fires when the xr session is ended either by the device or manually done
  52307. */
  52308. onXRSessionEnded: Observable<any>;
  52309. /**
  52310. * Fires when the xr session is ended either by the device or manually done
  52311. */
  52312. onXRSessionInit: Observable<XRSession>;
  52313. /**
  52314. * Underlying xr session
  52315. */
  52316. session: XRSession;
  52317. /**
  52318. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  52319. * or get the offset the player is currently at.
  52320. */
  52321. viewerReferenceSpace: XRReferenceSpace;
  52322. /**
  52323. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  52324. * @param scene The scene which the session should be created for
  52325. */
  52326. constructor(
  52327. /** The scene which the session should be created for */
  52328. scene: Scene);
  52329. /**
  52330. * The current reference space used in this session. This reference space can constantly change!
  52331. * It is mainly used to offset the camera's position.
  52332. */
  52333. get referenceSpace(): XRReferenceSpace;
  52334. /**
  52335. * Set a new reference space and triggers the observable
  52336. */
  52337. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52338. /**
  52339. * Disposes of the session manager
  52340. */
  52341. dispose(): void;
  52342. /**
  52343. * Stops the xrSession and restores the render loop
  52344. * @returns Promise which resolves after it exits XR
  52345. */
  52346. exitXRAsync(): Promise<void>;
  52347. /**
  52348. * Gets the correct render target texture to be rendered this frame for this eye
  52349. * @param eye the eye for which to get the render target
  52350. * @returns the render target for the specified eye
  52351. */
  52352. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52353. /**
  52354. * Creates a WebXRRenderTarget object for the XR session
  52355. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52356. * @param options optional options to provide when creating a new render target
  52357. * @returns a WebXR render target to which the session can render
  52358. */
  52359. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52360. /**
  52361. * Initializes the manager
  52362. * After initialization enterXR can be called to start an XR session
  52363. * @returns Promise which resolves after it is initialized
  52364. */
  52365. initializeAsync(): Promise<void>;
  52366. /**
  52367. * Initializes an xr session
  52368. * @param xrSessionMode mode to initialize
  52369. * @param xrSessionInit defines optional and required values to pass to the session builder
  52370. * @returns a promise which will resolve once the session has been initialized
  52371. */
  52372. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52373. /**
  52374. * Checks if a session would be supported for the creation options specified
  52375. * @param sessionMode session mode to check if supported eg. immersive-vr
  52376. * @returns A Promise that resolves to true if supported and false if not
  52377. */
  52378. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52379. /**
  52380. * Resets the reference space to the one started the session
  52381. */
  52382. resetReferenceSpace(): void;
  52383. /**
  52384. * Starts rendering to the xr layer
  52385. */
  52386. runXRRenderLoop(): void;
  52387. /**
  52388. * Sets the reference space on the xr session
  52389. * @param referenceSpaceType space to set
  52390. * @returns a promise that will resolve once the reference space has been set
  52391. */
  52392. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52393. /**
  52394. * Updates the render state of the session
  52395. * @param state state to set
  52396. * @returns a promise that resolves once the render state has been updated
  52397. */
  52398. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52399. /**
  52400. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52401. * @param sessionMode defines the session to test
  52402. * @returns a promise with boolean as final value
  52403. */
  52404. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52405. private _createRenderTargetTexture;
  52406. }
  52407. }
  52408. declare module "babylonjs/XR/webXRCamera" {
  52409. import { Vector3 } from "babylonjs/Maths/math.vector";
  52410. import { Scene } from "babylonjs/scene";
  52411. import { Camera } from "babylonjs/Cameras/camera";
  52412. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52413. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52414. import { Observable } from "babylonjs/Misc/observable";
  52415. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52416. /**
  52417. * WebXR Camera which holds the views for the xrSession
  52418. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52419. */
  52420. export class WebXRCamera extends FreeCamera {
  52421. private _xrSessionManager;
  52422. private _firstFrame;
  52423. private _referenceQuaternion;
  52424. private _referencedPosition;
  52425. private _xrInvPositionCache;
  52426. private _xrInvQuaternionCache;
  52427. private _trackingState;
  52428. /**
  52429. * Observable raised before camera teleportation
  52430. */
  52431. onBeforeCameraTeleport: Observable<Vector3>;
  52432. /**
  52433. * Observable raised after camera teleportation
  52434. */
  52435. onAfterCameraTeleport: Observable<Vector3>;
  52436. /**
  52437. * Notifies when the camera's tracking state has changed.
  52438. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52439. */
  52440. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52441. /**
  52442. * Should position compensation execute on first frame.
  52443. * This is used when copying the position from a native (non XR) camera
  52444. */
  52445. compensateOnFirstFrame: boolean;
  52446. /**
  52447. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52448. * @param name the name of the camera
  52449. * @param scene the scene to add the camera to
  52450. * @param _xrSessionManager a constructed xr session manager
  52451. */
  52452. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52453. /**
  52454. * Get the current XR tracking state of the camera
  52455. */
  52456. get trackingState(): WebXRTrackingState;
  52457. private _setTrackingState;
  52458. /**
  52459. * Return the user's height, unrelated to the current ground.
  52460. * This will be the y position of this camera, when ground level is 0.
  52461. */
  52462. get realWorldHeight(): number;
  52463. /** @hidden */
  52464. _updateForDualEyeDebugging(): void;
  52465. /**
  52466. * Sets this camera's transformation based on a non-vr camera
  52467. * @param otherCamera the non-vr camera to copy the transformation from
  52468. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52469. */
  52470. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52471. /**
  52472. * Gets the current instance class name ("WebXRCamera").
  52473. * @returns the class name
  52474. */
  52475. getClassName(): string;
  52476. private _rotate180;
  52477. private _updateFromXRSession;
  52478. private _updateNumberOfRigCameras;
  52479. private _updateReferenceSpace;
  52480. private _updateReferenceSpaceOffset;
  52481. }
  52482. }
  52483. declare module "babylonjs/XR/webXRFeaturesManager" {
  52484. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52485. import { IDisposable } from "babylonjs/scene";
  52486. /**
  52487. * Defining the interface required for a (webxr) feature
  52488. */
  52489. export interface IWebXRFeature extends IDisposable {
  52490. /**
  52491. * Is this feature attached
  52492. */
  52493. attached: boolean;
  52494. /**
  52495. * Should auto-attach be disabled?
  52496. */
  52497. disableAutoAttach: boolean;
  52498. /**
  52499. * Attach the feature to the session
  52500. * Will usually be called by the features manager
  52501. *
  52502. * @param force should attachment be forced (even when already attached)
  52503. * @returns true if successful.
  52504. */
  52505. attach(force?: boolean): boolean;
  52506. /**
  52507. * Detach the feature from the session
  52508. * Will usually be called by the features manager
  52509. *
  52510. * @returns true if successful.
  52511. */
  52512. detach(): boolean;
  52513. /**
  52514. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52515. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52516. *
  52517. * @returns whether or not the feature is compatible in this environment
  52518. */
  52519. isCompatible(): boolean;
  52520. /**
  52521. * Was this feature disposed;
  52522. */
  52523. isDisposed: boolean;
  52524. /**
  52525. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52526. */
  52527. xrNativeFeatureName?: string;
  52528. /**
  52529. * A list of (Babylon WebXR) features this feature depends on
  52530. */
  52531. dependsOn?: string[];
  52532. }
  52533. /**
  52534. * A list of the currently available features without referencing them
  52535. */
  52536. export class WebXRFeatureName {
  52537. /**
  52538. * The name of the anchor system feature
  52539. */
  52540. static readonly ANCHOR_SYSTEM: string;
  52541. /**
  52542. * The name of the background remover feature
  52543. */
  52544. static readonly BACKGROUND_REMOVER: string;
  52545. /**
  52546. * The name of the hit test feature
  52547. */
  52548. static readonly HIT_TEST: string;
  52549. /**
  52550. * physics impostors for xr controllers feature
  52551. */
  52552. static readonly PHYSICS_CONTROLLERS: string;
  52553. /**
  52554. * The name of the plane detection feature
  52555. */
  52556. static readonly PLANE_DETECTION: string;
  52557. /**
  52558. * The name of the pointer selection feature
  52559. */
  52560. static readonly POINTER_SELECTION: string;
  52561. /**
  52562. * The name of the teleportation feature
  52563. */
  52564. static readonly TELEPORTATION: string;
  52565. /**
  52566. * The name of the feature points feature.
  52567. */
  52568. static readonly FEATURE_POINTS: string;
  52569. /**
  52570. * The name of the hand tracking feature.
  52571. */
  52572. static readonly HAND_TRACKING: string;
  52573. }
  52574. /**
  52575. * Defining the constructor of a feature. Used to register the modules.
  52576. */
  52577. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52578. /**
  52579. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52580. * It is mainly used in AR sessions.
  52581. *
  52582. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52583. */
  52584. export class WebXRFeaturesManager implements IDisposable {
  52585. private _xrSessionManager;
  52586. private static readonly _AvailableFeatures;
  52587. private _features;
  52588. /**
  52589. * constructs a new features manages.
  52590. *
  52591. * @param _xrSessionManager an instance of WebXRSessionManager
  52592. */
  52593. constructor(_xrSessionManager: WebXRSessionManager);
  52594. /**
  52595. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52596. * Mainly used internally.
  52597. *
  52598. * @param featureName the name of the feature to register
  52599. * @param constructorFunction the function used to construct the module
  52600. * @param version the (babylon) version of the module
  52601. * @param stable is that a stable version of this module
  52602. */
  52603. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52604. /**
  52605. * Returns a constructor of a specific feature.
  52606. *
  52607. * @param featureName the name of the feature to construct
  52608. * @param version the version of the feature to load
  52609. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52610. * @param options optional options provided to the module.
  52611. * @returns a function that, when called, will return a new instance of this feature
  52612. */
  52613. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52614. /**
  52615. * Can be used to return the list of features currently registered
  52616. *
  52617. * @returns an Array of available features
  52618. */
  52619. static GetAvailableFeatures(): string[];
  52620. /**
  52621. * Gets the versions available for a specific feature
  52622. * @param featureName the name of the feature
  52623. * @returns an array with the available versions
  52624. */
  52625. static GetAvailableVersions(featureName: string): string[];
  52626. /**
  52627. * Return the latest unstable version of this feature
  52628. * @param featureName the name of the feature to search
  52629. * @returns the version number. if not found will return -1
  52630. */
  52631. static GetLatestVersionOfFeature(featureName: string): number;
  52632. /**
  52633. * Return the latest stable version of this feature
  52634. * @param featureName the name of the feature to search
  52635. * @returns the version number. if not found will return -1
  52636. */
  52637. static GetStableVersionOfFeature(featureName: string): number;
  52638. /**
  52639. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52640. * Can be used during a session to start a feature
  52641. * @param featureName the name of feature to attach
  52642. */
  52643. attachFeature(featureName: string): void;
  52644. /**
  52645. * Can be used inside a session or when the session ends to detach a specific feature
  52646. * @param featureName the name of the feature to detach
  52647. */
  52648. detachFeature(featureName: string): void;
  52649. /**
  52650. * Used to disable an already-enabled feature
  52651. * The feature will be disposed and will be recreated once enabled.
  52652. * @param featureName the feature to disable
  52653. * @returns true if disable was successful
  52654. */
  52655. disableFeature(featureName: string | {
  52656. Name: string;
  52657. }): boolean;
  52658. /**
  52659. * dispose this features manager
  52660. */
  52661. dispose(): void;
  52662. /**
  52663. * 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.
  52664. * 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.
  52665. *
  52666. * @param featureName the name of the feature to load or the class of the feature
  52667. * @param version optional version to load. if not provided the latest version will be enabled
  52668. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52669. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52670. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52671. * @returns a new constructed feature or throws an error if feature not found.
  52672. */
  52673. enableFeature(featureName: string | {
  52674. Name: string;
  52675. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52676. /**
  52677. * get the implementation of an enabled feature.
  52678. * @param featureName the name of the feature to load
  52679. * @returns the feature class, if found
  52680. */
  52681. getEnabledFeature(featureName: string): IWebXRFeature;
  52682. /**
  52683. * Get the list of enabled features
  52684. * @returns an array of enabled features
  52685. */
  52686. getEnabledFeatures(): string[];
  52687. /**
  52688. * This function will exten the session creation configuration object with enabled features.
  52689. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52690. * according to the defined "required" variable, provided during enableFeature call
  52691. * @param xrSessionInit the xr Session init object to extend
  52692. *
  52693. * @returns an extended XRSessionInit object
  52694. */
  52695. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52696. }
  52697. }
  52698. declare module "babylonjs/XR/webXRExperienceHelper" {
  52699. import { Observable } from "babylonjs/Misc/observable";
  52700. import { IDisposable, Scene } from "babylonjs/scene";
  52701. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52702. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52703. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52704. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52705. /**
  52706. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52707. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52708. */
  52709. export class WebXRExperienceHelper implements IDisposable {
  52710. private scene;
  52711. private _nonVRCamera;
  52712. private _originalSceneAutoClear;
  52713. private _supported;
  52714. /**
  52715. * Camera used to render xr content
  52716. */
  52717. camera: WebXRCamera;
  52718. /** A features manager for this xr session */
  52719. featuresManager: WebXRFeaturesManager;
  52720. /**
  52721. * Observers registered here will be triggered after the camera's initial transformation is set
  52722. * This can be used to set a different ground level or an extra rotation.
  52723. *
  52724. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52725. * to the position set after this observable is done executing.
  52726. */
  52727. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52728. /**
  52729. * Fires when the state of the experience helper has changed
  52730. */
  52731. onStateChangedObservable: Observable<WebXRState>;
  52732. /** Session manager used to keep track of xr session */
  52733. sessionManager: WebXRSessionManager;
  52734. /**
  52735. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52736. */
  52737. state: WebXRState;
  52738. /**
  52739. * Creates a WebXRExperienceHelper
  52740. * @param scene The scene the helper should be created in
  52741. */
  52742. private constructor();
  52743. /**
  52744. * Creates the experience helper
  52745. * @param scene the scene to attach the experience helper to
  52746. * @returns a promise for the experience helper
  52747. */
  52748. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  52749. /**
  52750. * Disposes of the experience helper
  52751. */
  52752. dispose(): void;
  52753. /**
  52754. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  52755. * @param sessionMode options for the XR session
  52756. * @param referenceSpaceType frame of reference of the XR session
  52757. * @param renderTarget the output canvas that will be used to enter XR mode
  52758. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  52759. * @returns promise that resolves after xr mode has entered
  52760. */
  52761. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  52762. /**
  52763. * Exits XR mode and returns the scene to its original state
  52764. * @returns promise that resolves after xr mode has exited
  52765. */
  52766. exitXRAsync(): Promise<void>;
  52767. private _nonXRToXRCamera;
  52768. private _setState;
  52769. }
  52770. }
  52771. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  52772. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  52773. import { Observable } from "babylonjs/Misc/observable";
  52774. import { IDisposable } from "babylonjs/scene";
  52775. /**
  52776. * X-Y values for axes in WebXR
  52777. */
  52778. export interface IWebXRMotionControllerAxesValue {
  52779. /**
  52780. * The value of the x axis
  52781. */
  52782. x: number;
  52783. /**
  52784. * The value of the y-axis
  52785. */
  52786. y: number;
  52787. }
  52788. /**
  52789. * changed / previous values for the values of this component
  52790. */
  52791. export interface IWebXRMotionControllerComponentChangesValues<T> {
  52792. /**
  52793. * current (this frame) value
  52794. */
  52795. current: T;
  52796. /**
  52797. * previous (last change) value
  52798. */
  52799. previous: T;
  52800. }
  52801. /**
  52802. * Represents changes in the component between current frame and last values recorded
  52803. */
  52804. export interface IWebXRMotionControllerComponentChanges {
  52805. /**
  52806. * will be populated with previous and current values if axes changed
  52807. */
  52808. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  52809. /**
  52810. * will be populated with previous and current values if pressed changed
  52811. */
  52812. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52813. /**
  52814. * will be populated with previous and current values if touched changed
  52815. */
  52816. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52817. /**
  52818. * will be populated with previous and current values if value changed
  52819. */
  52820. value?: IWebXRMotionControllerComponentChangesValues<number>;
  52821. }
  52822. /**
  52823. * This class represents a single component (for example button or thumbstick) of a motion controller
  52824. */
  52825. export class WebXRControllerComponent implements IDisposable {
  52826. /**
  52827. * the id of this component
  52828. */
  52829. id: string;
  52830. /**
  52831. * the type of the component
  52832. */
  52833. type: MotionControllerComponentType;
  52834. private _buttonIndex;
  52835. private _axesIndices;
  52836. private _axes;
  52837. private _changes;
  52838. private _currentValue;
  52839. private _hasChanges;
  52840. private _pressed;
  52841. private _touched;
  52842. /**
  52843. * button component type
  52844. */
  52845. static BUTTON_TYPE: MotionControllerComponentType;
  52846. /**
  52847. * squeeze component type
  52848. */
  52849. static SQUEEZE_TYPE: MotionControllerComponentType;
  52850. /**
  52851. * Thumbstick component type
  52852. */
  52853. static THUMBSTICK_TYPE: MotionControllerComponentType;
  52854. /**
  52855. * Touchpad component type
  52856. */
  52857. static TOUCHPAD_TYPE: MotionControllerComponentType;
  52858. /**
  52859. * trigger component type
  52860. */
  52861. static TRIGGER_TYPE: MotionControllerComponentType;
  52862. /**
  52863. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  52864. * the axes data changes
  52865. */
  52866. onAxisValueChangedObservable: Observable<{
  52867. x: number;
  52868. y: number;
  52869. }>;
  52870. /**
  52871. * Observers registered here will be triggered when the state of a button changes
  52872. * State change is either pressed / touched / value
  52873. */
  52874. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  52875. /**
  52876. * Creates a new component for a motion controller.
  52877. * It is created by the motion controller itself
  52878. *
  52879. * @param id the id of this component
  52880. * @param type the type of the component
  52881. * @param _buttonIndex index in the buttons array of the gamepad
  52882. * @param _axesIndices indices of the values in the axes array of the gamepad
  52883. */
  52884. constructor(
  52885. /**
  52886. * the id of this component
  52887. */
  52888. id: string,
  52889. /**
  52890. * the type of the component
  52891. */
  52892. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  52893. /**
  52894. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  52895. */
  52896. get axes(): IWebXRMotionControllerAxesValue;
  52897. /**
  52898. * Get the changes. Elements will be populated only if they changed with their previous and current value
  52899. */
  52900. get changes(): IWebXRMotionControllerComponentChanges;
  52901. /**
  52902. * Return whether or not the component changed the last frame
  52903. */
  52904. get hasChanges(): boolean;
  52905. /**
  52906. * is the button currently pressed
  52907. */
  52908. get pressed(): boolean;
  52909. /**
  52910. * is the button currently touched
  52911. */
  52912. get touched(): boolean;
  52913. /**
  52914. * Get the current value of this component
  52915. */
  52916. get value(): number;
  52917. /**
  52918. * Dispose this component
  52919. */
  52920. dispose(): void;
  52921. /**
  52922. * Are there axes correlating to this component
  52923. * @return true is axes data is available
  52924. */
  52925. isAxes(): boolean;
  52926. /**
  52927. * Is this component a button (hence - pressable)
  52928. * @returns true if can be pressed
  52929. */
  52930. isButton(): boolean;
  52931. /**
  52932. * update this component using the gamepad object it is in. Called on every frame
  52933. * @param nativeController the native gamepad controller object
  52934. */
  52935. update(nativeController: IMinimalMotionControllerObject): void;
  52936. }
  52937. }
  52938. declare module "babylonjs/Loading/sceneLoader" {
  52939. import { Observable } from "babylonjs/Misc/observable";
  52940. import { Nullable } from "babylonjs/types";
  52941. import { Scene } from "babylonjs/scene";
  52942. import { Engine } from "babylonjs/Engines/engine";
  52943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52944. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  52945. import { AssetContainer } from "babylonjs/assetContainer";
  52946. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52947. import { Skeleton } from "babylonjs/Bones/skeleton";
  52948. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  52949. import { WebRequest } from "babylonjs/Misc/webRequest";
  52950. /**
  52951. * Interface used to represent data loading progression
  52952. */
  52953. export interface ISceneLoaderProgressEvent {
  52954. /**
  52955. * Defines if data length to load can be evaluated
  52956. */
  52957. readonly lengthComputable: boolean;
  52958. /**
  52959. * Defines the loaded data length
  52960. */
  52961. readonly loaded: number;
  52962. /**
  52963. * Defines the data length to load
  52964. */
  52965. readonly total: number;
  52966. }
  52967. /**
  52968. * Interface used by SceneLoader plugins to define supported file extensions
  52969. */
  52970. export interface ISceneLoaderPluginExtensions {
  52971. /**
  52972. * Defines the list of supported extensions
  52973. */
  52974. [extension: string]: {
  52975. isBinary: boolean;
  52976. };
  52977. }
  52978. /**
  52979. * Interface used by SceneLoader plugin factory
  52980. */
  52981. export interface ISceneLoaderPluginFactory {
  52982. /**
  52983. * Defines the name of the factory
  52984. */
  52985. name: string;
  52986. /**
  52987. * Function called to create a new plugin
  52988. * @return the new plugin
  52989. */
  52990. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  52991. /**
  52992. * The callback that returns true if the data can be directly loaded.
  52993. * @param data string containing the file data
  52994. * @returns if the data can be loaded directly
  52995. */
  52996. canDirectLoad?(data: string): boolean;
  52997. }
  52998. /**
  52999. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  53000. */
  53001. export interface ISceneLoaderPluginBase {
  53002. /**
  53003. * The friendly name of this plugin.
  53004. */
  53005. name: string;
  53006. /**
  53007. * The file extensions supported by this plugin.
  53008. */
  53009. extensions: string | ISceneLoaderPluginExtensions;
  53010. /**
  53011. * The callback called when loading from a url.
  53012. * @param scene scene loading this url
  53013. * @param url url to load
  53014. * @param onSuccess callback called when the file successfully loads
  53015. * @param onProgress callback called while file is loading (if the server supports this mode)
  53016. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  53017. * @param onError callback called when the file fails to load
  53018. * @returns a file request object
  53019. */
  53020. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53021. /**
  53022. * The callback called when loading from a file object.
  53023. * @param scene scene loading this file
  53024. * @param file defines the file to load
  53025. * @param onSuccess defines the callback to call when data is loaded
  53026. * @param onProgress defines the callback to call during loading process
  53027. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  53028. * @param onError defines the callback to call when an error occurs
  53029. * @returns a file request object
  53030. */
  53031. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53032. /**
  53033. * The callback that returns true if the data can be directly loaded.
  53034. * @param data string containing the file data
  53035. * @returns if the data can be loaded directly
  53036. */
  53037. canDirectLoad?(data: string): boolean;
  53038. /**
  53039. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  53040. * @param scene scene loading this data
  53041. * @param data string containing the data
  53042. * @returns data to pass to the plugin
  53043. */
  53044. directLoad?(scene: Scene, data: string): any;
  53045. /**
  53046. * The callback that allows custom handling of the root url based on the response url.
  53047. * @param rootUrl the original root url
  53048. * @param responseURL the response url if available
  53049. * @returns the new root url
  53050. */
  53051. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  53052. }
  53053. /**
  53054. * Interface used to define a SceneLoader plugin
  53055. */
  53056. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  53057. /**
  53058. * Import meshes into a scene.
  53059. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53060. * @param scene The scene to import into
  53061. * @param data The data to import
  53062. * @param rootUrl The root url for scene and resources
  53063. * @param meshes The meshes array to import into
  53064. * @param particleSystems The particle systems array to import into
  53065. * @param skeletons The skeletons array to import into
  53066. * @param onError The callback when import fails
  53067. * @returns True if successful or false otherwise
  53068. */
  53069. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  53070. /**
  53071. * Load into a scene.
  53072. * @param scene The scene to load into
  53073. * @param data The data to import
  53074. * @param rootUrl The root url for scene and resources
  53075. * @param onError The callback when import fails
  53076. * @returns True if successful or false otherwise
  53077. */
  53078. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  53079. /**
  53080. * Load into an asset container.
  53081. * @param scene The scene to load into
  53082. * @param data The data to import
  53083. * @param rootUrl The root url for scene and resources
  53084. * @param onError The callback when import fails
  53085. * @returns The loaded asset container
  53086. */
  53087. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  53088. }
  53089. /**
  53090. * Interface used to define an async SceneLoader plugin
  53091. */
  53092. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  53093. /**
  53094. * Import meshes into a scene.
  53095. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53096. * @param scene The scene to import into
  53097. * @param data The data to import
  53098. * @param rootUrl The root url for scene and resources
  53099. * @param onProgress The callback when the load progresses
  53100. * @param fileName Defines the name of the file to load
  53101. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  53102. */
  53103. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  53104. meshes: AbstractMesh[];
  53105. particleSystems: IParticleSystem[];
  53106. skeletons: Skeleton[];
  53107. animationGroups: AnimationGroup[];
  53108. }>;
  53109. /**
  53110. * Load into a scene.
  53111. * @param scene The scene to load into
  53112. * @param data The data to import
  53113. * @param rootUrl The root url for scene and resources
  53114. * @param onProgress The callback when the load progresses
  53115. * @param fileName Defines the name of the file to load
  53116. * @returns Nothing
  53117. */
  53118. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  53119. /**
  53120. * Load into an asset container.
  53121. * @param scene The scene to load into
  53122. * @param data The data to import
  53123. * @param rootUrl The root url for scene and resources
  53124. * @param onProgress The callback when the load progresses
  53125. * @param fileName Defines the name of the file to load
  53126. * @returns The loaded asset container
  53127. */
  53128. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  53129. }
  53130. /**
  53131. * Mode that determines how to handle old animation groups before loading new ones.
  53132. */
  53133. export enum SceneLoaderAnimationGroupLoadingMode {
  53134. /**
  53135. * Reset all old animations to initial state then dispose them.
  53136. */
  53137. Clean = 0,
  53138. /**
  53139. * Stop all old animations.
  53140. */
  53141. Stop = 1,
  53142. /**
  53143. * Restart old animations from first frame.
  53144. */
  53145. Sync = 2,
  53146. /**
  53147. * Old animations remains untouched.
  53148. */
  53149. NoSync = 3
  53150. }
  53151. /**
  53152. * Defines a plugin registered by the SceneLoader
  53153. */
  53154. interface IRegisteredPlugin {
  53155. /**
  53156. * Defines the plugin to use
  53157. */
  53158. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53159. /**
  53160. * Defines if the plugin supports binary data
  53161. */
  53162. isBinary: boolean;
  53163. }
  53164. /**
  53165. * Class used to load scene from various file formats using registered plugins
  53166. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  53167. */
  53168. export class SceneLoader {
  53169. /**
  53170. * No logging while loading
  53171. */
  53172. static readonly NO_LOGGING: number;
  53173. /**
  53174. * Minimal logging while loading
  53175. */
  53176. static readonly MINIMAL_LOGGING: number;
  53177. /**
  53178. * Summary logging while loading
  53179. */
  53180. static readonly SUMMARY_LOGGING: number;
  53181. /**
  53182. * Detailled logging while loading
  53183. */
  53184. static readonly DETAILED_LOGGING: number;
  53185. /**
  53186. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  53187. */
  53188. static get ForceFullSceneLoadingForIncremental(): boolean;
  53189. static set ForceFullSceneLoadingForIncremental(value: boolean);
  53190. /**
  53191. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  53192. */
  53193. static get ShowLoadingScreen(): boolean;
  53194. static set ShowLoadingScreen(value: boolean);
  53195. /**
  53196. * Defines the current logging level (while loading the scene)
  53197. * @ignorenaming
  53198. */
  53199. static get loggingLevel(): number;
  53200. static set loggingLevel(value: number);
  53201. /**
  53202. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  53203. */
  53204. static get CleanBoneMatrixWeights(): boolean;
  53205. static set CleanBoneMatrixWeights(value: boolean);
  53206. /**
  53207. * Event raised when a plugin is used to load a scene
  53208. */
  53209. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53210. private static _registeredPlugins;
  53211. private static _showingLoadingScreen;
  53212. /**
  53213. * Gets the default plugin (used to load Babylon files)
  53214. * @returns the .babylon plugin
  53215. */
  53216. static GetDefaultPlugin(): IRegisteredPlugin;
  53217. private static _GetPluginForExtension;
  53218. private static _GetPluginForDirectLoad;
  53219. private static _GetPluginForFilename;
  53220. private static _GetDirectLoad;
  53221. private static _LoadData;
  53222. private static _GetFileInfo;
  53223. /**
  53224. * Gets a plugin that can load the given extension
  53225. * @param extension defines the extension to load
  53226. * @returns a plugin or null if none works
  53227. */
  53228. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53229. /**
  53230. * Gets a boolean indicating that the given extension can be loaded
  53231. * @param extension defines the extension to load
  53232. * @returns true if the extension is supported
  53233. */
  53234. static IsPluginForExtensionAvailable(extension: string): boolean;
  53235. /**
  53236. * Adds a new plugin to the list of registered plugins
  53237. * @param plugin defines the plugin to add
  53238. */
  53239. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  53240. /**
  53241. * Import meshes into a scene
  53242. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53243. * @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)
  53244. * @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)
  53245. * @param scene the instance of BABYLON.Scene to append to
  53246. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  53247. * @param onProgress a callback with a progress event for each file being loaded
  53248. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53249. * @param pluginExtension the extension used to determine the plugin
  53250. * @returns The loaded plugin
  53251. */
  53252. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53253. /**
  53254. * Import meshes into a scene
  53255. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53256. * @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)
  53257. * @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)
  53258. * @param scene the instance of BABYLON.Scene to append to
  53259. * @param onProgress a callback with a progress event for each file being loaded
  53260. * @param pluginExtension the extension used to determine the plugin
  53261. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  53262. */
  53263. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  53264. meshes: AbstractMesh[];
  53265. particleSystems: IParticleSystem[];
  53266. skeletons: Skeleton[];
  53267. animationGroups: AnimationGroup[];
  53268. }>;
  53269. /**
  53270. * Load a scene
  53271. * @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)
  53272. * @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)
  53273. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53274. * @param onSuccess a callback with the scene when import succeeds
  53275. * @param onProgress a callback with a progress event for each file being loaded
  53276. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53277. * @param pluginExtension the extension used to determine the plugin
  53278. * @returns The loaded plugin
  53279. */
  53280. 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>;
  53281. /**
  53282. * Load a scene
  53283. * @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)
  53284. * @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)
  53285. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53286. * @param onProgress a callback with a progress event for each file being loaded
  53287. * @param pluginExtension the extension used to determine the plugin
  53288. * @returns The loaded scene
  53289. */
  53290. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53291. /**
  53292. * Append a scene
  53293. * @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)
  53294. * @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)
  53295. * @param scene is the instance of BABYLON.Scene to append to
  53296. * @param onSuccess a callback with the scene when import succeeds
  53297. * @param onProgress a callback with a progress event for each file being loaded
  53298. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53299. * @param pluginExtension the extension used to determine the plugin
  53300. * @returns The loaded plugin
  53301. */
  53302. 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>;
  53303. /**
  53304. * Append a scene
  53305. * @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)
  53306. * @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)
  53307. * @param scene is the instance of BABYLON.Scene to append to
  53308. * @param onProgress a callback with a progress event for each file being loaded
  53309. * @param pluginExtension the extension used to determine the plugin
  53310. * @returns The given scene
  53311. */
  53312. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53313. /**
  53314. * Load a scene into an asset container
  53315. * @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)
  53316. * @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)
  53317. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53318. * @param onSuccess a callback with the scene when import succeeds
  53319. * @param onProgress a callback with a progress event for each file being loaded
  53320. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53321. * @param pluginExtension the extension used to determine the plugin
  53322. * @returns The loaded plugin
  53323. */
  53324. 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>;
  53325. /**
  53326. * Load a scene into an asset container
  53327. * @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)
  53328. * @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)
  53329. * @param scene is the instance of Scene to append to
  53330. * @param onProgress a callback with a progress event for each file being loaded
  53331. * @param pluginExtension the extension used to determine the plugin
  53332. * @returns The loaded asset container
  53333. */
  53334. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53335. /**
  53336. * Import animations from a file into a scene
  53337. * @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)
  53338. * @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)
  53339. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53340. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53341. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53342. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53343. * @param onSuccess a callback with the scene when import succeeds
  53344. * @param onProgress a callback with a progress event for each file being loaded
  53345. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53346. * @param pluginExtension the extension used to determine the plugin
  53347. */
  53348. 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;
  53349. /**
  53350. * Import animations from a file into a scene
  53351. * @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)
  53352. * @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)
  53353. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53354. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53355. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53356. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53357. * @param onSuccess a callback with the scene when import succeeds
  53358. * @param onProgress a callback with a progress event for each file being loaded
  53359. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53360. * @param pluginExtension the extension used to determine the plugin
  53361. * @returns the updated scene with imported animations
  53362. */
  53363. 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>;
  53364. }
  53365. }
  53366. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53367. import { IDisposable, Scene } from "babylonjs/scene";
  53368. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53369. import { Observable } from "babylonjs/Misc/observable";
  53370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53371. import { Nullable } from "babylonjs/types";
  53372. /**
  53373. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53374. */
  53375. export type MotionControllerHandedness = "none" | "left" | "right";
  53376. /**
  53377. * The type of components available in motion controllers.
  53378. * This is not the name of the component.
  53379. */
  53380. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53381. /**
  53382. * The state of a controller component
  53383. */
  53384. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53385. /**
  53386. * The schema of motion controller layout.
  53387. * No object will be initialized using this interface
  53388. * This is used just to define the profile.
  53389. */
  53390. export interface IMotionControllerLayout {
  53391. /**
  53392. * Path to load the assets. Usually relative to the base path
  53393. */
  53394. assetPath: string;
  53395. /**
  53396. * Available components (unsorted)
  53397. */
  53398. components: {
  53399. /**
  53400. * A map of component Ids
  53401. */
  53402. [componentId: string]: {
  53403. /**
  53404. * The type of input the component outputs
  53405. */
  53406. type: MotionControllerComponentType;
  53407. /**
  53408. * The indices of this component in the gamepad object
  53409. */
  53410. gamepadIndices: {
  53411. /**
  53412. * Index of button
  53413. */
  53414. button?: number;
  53415. /**
  53416. * If available, index of x-axis
  53417. */
  53418. xAxis?: number;
  53419. /**
  53420. * If available, index of y-axis
  53421. */
  53422. yAxis?: number;
  53423. };
  53424. /**
  53425. * The mesh's root node name
  53426. */
  53427. rootNodeName: string;
  53428. /**
  53429. * Animation definitions for this model
  53430. */
  53431. visualResponses: {
  53432. [stateKey: string]: {
  53433. /**
  53434. * What property will be animated
  53435. */
  53436. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53437. /**
  53438. * What states influence this visual response
  53439. */
  53440. states: MotionControllerComponentStateType[];
  53441. /**
  53442. * Type of animation - movement or visibility
  53443. */
  53444. valueNodeProperty: "transform" | "visibility";
  53445. /**
  53446. * Base node name to move. Its position will be calculated according to the min and max nodes
  53447. */
  53448. valueNodeName?: string;
  53449. /**
  53450. * Minimum movement node
  53451. */
  53452. minNodeName?: string;
  53453. /**
  53454. * Max movement node
  53455. */
  53456. maxNodeName?: string;
  53457. };
  53458. };
  53459. /**
  53460. * If touch enabled, what is the name of node to display user feedback
  53461. */
  53462. touchPointNodeName?: string;
  53463. };
  53464. };
  53465. /**
  53466. * Is it xr standard mapping or not
  53467. */
  53468. gamepadMapping: "" | "xr-standard";
  53469. /**
  53470. * Base root node of this entire model
  53471. */
  53472. rootNodeName: string;
  53473. /**
  53474. * Defines the main button component id
  53475. */
  53476. selectComponentId: string;
  53477. }
  53478. /**
  53479. * A definition for the layout map in the input profile
  53480. */
  53481. export interface IMotionControllerLayoutMap {
  53482. /**
  53483. * Layouts with handedness type as a key
  53484. */
  53485. [handedness: string]: IMotionControllerLayout;
  53486. }
  53487. /**
  53488. * The XR Input profile schema
  53489. * Profiles can be found here:
  53490. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53491. */
  53492. export interface IMotionControllerProfile {
  53493. /**
  53494. * fallback profiles for this profileId
  53495. */
  53496. fallbackProfileIds: string[];
  53497. /**
  53498. * The layout map, with handedness as key
  53499. */
  53500. layouts: IMotionControllerLayoutMap;
  53501. /**
  53502. * The id of this profile
  53503. * correlates to the profile(s) in the xrInput.profiles array
  53504. */
  53505. profileId: string;
  53506. }
  53507. /**
  53508. * A helper-interface for the 3 meshes needed for controller button animation
  53509. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53510. */
  53511. export interface IMotionControllerButtonMeshMap {
  53512. /**
  53513. * the mesh that defines the pressed value mesh position.
  53514. * This is used to find the max-position of this button
  53515. */
  53516. pressedMesh: AbstractMesh;
  53517. /**
  53518. * the mesh that defines the unpressed value mesh position.
  53519. * This is used to find the min (or initial) position of this button
  53520. */
  53521. unpressedMesh: AbstractMesh;
  53522. /**
  53523. * The mesh that will be changed when value changes
  53524. */
  53525. valueMesh: AbstractMesh;
  53526. }
  53527. /**
  53528. * A helper-interface for the 3 meshes needed for controller axis animation.
  53529. * This will be expanded when touchpad animations are fully supported
  53530. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53531. */
  53532. export interface IMotionControllerMeshMap {
  53533. /**
  53534. * the mesh that defines the maximum value mesh position.
  53535. */
  53536. maxMesh?: AbstractMesh;
  53537. /**
  53538. * the mesh that defines the minimum value mesh position.
  53539. */
  53540. minMesh?: AbstractMesh;
  53541. /**
  53542. * The mesh that will be changed when axis value changes
  53543. */
  53544. valueMesh?: AbstractMesh;
  53545. }
  53546. /**
  53547. * The elements needed for change-detection of the gamepad objects in motion controllers
  53548. */
  53549. export interface IMinimalMotionControllerObject {
  53550. /**
  53551. * Available axes of this controller
  53552. */
  53553. axes: number[];
  53554. /**
  53555. * An array of available buttons
  53556. */
  53557. buttons: Array<{
  53558. /**
  53559. * Value of the button/trigger
  53560. */
  53561. value: number;
  53562. /**
  53563. * If the button/trigger is currently touched
  53564. */
  53565. touched: boolean;
  53566. /**
  53567. * If the button/trigger is currently pressed
  53568. */
  53569. pressed: boolean;
  53570. }>;
  53571. /**
  53572. * EXPERIMENTAL haptic support.
  53573. */
  53574. hapticActuators?: Array<{
  53575. pulse: (value: number, duration: number) => Promise<boolean>;
  53576. }>;
  53577. }
  53578. /**
  53579. * An Abstract Motion controller
  53580. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53581. * Each component has an observable to check for changes in value and state
  53582. */
  53583. export abstract class WebXRAbstractMotionController implements IDisposable {
  53584. protected scene: Scene;
  53585. protected layout: IMotionControllerLayout;
  53586. /**
  53587. * The gamepad object correlating to this controller
  53588. */
  53589. gamepadObject: IMinimalMotionControllerObject;
  53590. /**
  53591. * handedness (left/right/none) of this controller
  53592. */
  53593. handedness: MotionControllerHandedness;
  53594. private _initComponent;
  53595. private _modelReady;
  53596. /**
  53597. * A map of components (WebXRControllerComponent) in this motion controller
  53598. * Components have a ComponentType and can also have both button and axis definitions
  53599. */
  53600. readonly components: {
  53601. [id: string]: WebXRControllerComponent;
  53602. };
  53603. /**
  53604. * Disable the model's animation. Can be set at any time.
  53605. */
  53606. disableAnimation: boolean;
  53607. /**
  53608. * Observers registered here will be triggered when the model of this controller is done loading
  53609. */
  53610. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53611. /**
  53612. * The profile id of this motion controller
  53613. */
  53614. abstract profileId: string;
  53615. /**
  53616. * The root mesh of the model. It is null if the model was not yet initialized
  53617. */
  53618. rootMesh: Nullable<AbstractMesh>;
  53619. /**
  53620. * constructs a new abstract motion controller
  53621. * @param scene the scene to which the model of the controller will be added
  53622. * @param layout The profile layout to load
  53623. * @param gamepadObject The gamepad object correlating to this controller
  53624. * @param handedness handedness (left/right/none) of this controller
  53625. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53626. */
  53627. constructor(scene: Scene, layout: IMotionControllerLayout,
  53628. /**
  53629. * The gamepad object correlating to this controller
  53630. */
  53631. gamepadObject: IMinimalMotionControllerObject,
  53632. /**
  53633. * handedness (left/right/none) of this controller
  53634. */
  53635. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53636. /**
  53637. * Dispose this controller, the model mesh and all its components
  53638. */
  53639. dispose(): void;
  53640. /**
  53641. * Returns all components of specific type
  53642. * @param type the type to search for
  53643. * @return an array of components with this type
  53644. */
  53645. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53646. /**
  53647. * get a component based an its component id as defined in layout.components
  53648. * @param id the id of the component
  53649. * @returns the component correlates to the id or undefined if not found
  53650. */
  53651. getComponent(id: string): WebXRControllerComponent;
  53652. /**
  53653. * Get the list of components available in this motion controller
  53654. * @returns an array of strings correlating to available components
  53655. */
  53656. getComponentIds(): string[];
  53657. /**
  53658. * Get the first component of specific type
  53659. * @param type type of component to find
  53660. * @return a controller component or null if not found
  53661. */
  53662. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53663. /**
  53664. * Get the main (Select) component of this controller as defined in the layout
  53665. * @returns the main component of this controller
  53666. */
  53667. getMainComponent(): WebXRControllerComponent;
  53668. /**
  53669. * Loads the model correlating to this controller
  53670. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53671. * @returns A promise fulfilled with the result of the model loading
  53672. */
  53673. loadModel(): Promise<boolean>;
  53674. /**
  53675. * Update this model using the current XRFrame
  53676. * @param xrFrame the current xr frame to use and update the model
  53677. */
  53678. updateFromXRFrame(xrFrame: XRFrame): void;
  53679. /**
  53680. * Backwards compatibility due to a deeply-integrated typo
  53681. */
  53682. get handness(): XREye;
  53683. /**
  53684. * Pulse (vibrate) this controller
  53685. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53686. * Consecutive calls to this function will cancel the last pulse call
  53687. *
  53688. * @param value the strength of the pulse in 0.0...1.0 range
  53689. * @param duration Duration of the pulse in milliseconds
  53690. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53691. * @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
  53692. */
  53693. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53694. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53695. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53696. /**
  53697. * Moves the axis on the controller mesh based on its current state
  53698. * @param axis the index of the axis
  53699. * @param axisValue the value of the axis which determines the meshes new position
  53700. * @hidden
  53701. */
  53702. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53703. /**
  53704. * Update the model itself with the current frame data
  53705. * @param xrFrame the frame to use for updating the model mesh
  53706. */
  53707. protected updateModel(xrFrame: XRFrame): void;
  53708. /**
  53709. * Get the filename and path for this controller's model
  53710. * @returns a map of filename and path
  53711. */
  53712. protected abstract _getFilenameAndPath(): {
  53713. filename: string;
  53714. path: string;
  53715. };
  53716. /**
  53717. * This function is called before the mesh is loaded. It checks for loading constraints.
  53718. * For example, this function can check if the GLB loader is available
  53719. * If this function returns false, the generic controller will be loaded instead
  53720. * @returns Is the client ready to load the mesh
  53721. */
  53722. protected abstract _getModelLoadingConstraints(): boolean;
  53723. /**
  53724. * This function will be called after the model was successfully loaded and can be used
  53725. * for mesh transformations before it is available for the user
  53726. * @param meshes the loaded meshes
  53727. */
  53728. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53729. /**
  53730. * Set the root mesh for this controller. Important for the WebXR controller class
  53731. * @param meshes the loaded meshes
  53732. */
  53733. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53734. /**
  53735. * A function executed each frame that updates the mesh (if needed)
  53736. * @param xrFrame the current xrFrame
  53737. */
  53738. protected abstract _updateModel(xrFrame: XRFrame): void;
  53739. private _getGenericFilenameAndPath;
  53740. private _getGenericParentMesh;
  53741. }
  53742. }
  53743. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  53744. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53746. import { Scene } from "babylonjs/scene";
  53747. /**
  53748. * A generic trigger-only motion controller for WebXR
  53749. */
  53750. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  53751. /**
  53752. * Static version of the profile id of this controller
  53753. */
  53754. static ProfileId: string;
  53755. profileId: string;
  53756. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  53757. protected _getFilenameAndPath(): {
  53758. filename: string;
  53759. path: string;
  53760. };
  53761. protected _getModelLoadingConstraints(): boolean;
  53762. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  53763. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53764. protected _updateModel(): void;
  53765. }
  53766. }
  53767. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  53768. import { Vector4 } from "babylonjs/Maths/math.vector";
  53769. import { Mesh } from "babylonjs/Meshes/mesh";
  53770. import { Scene } from "babylonjs/scene";
  53771. import { Nullable } from "babylonjs/types";
  53772. /**
  53773. * Class containing static functions to help procedurally build meshes
  53774. */
  53775. export class SphereBuilder {
  53776. /**
  53777. * Creates a sphere mesh
  53778. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53779. * * 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`)
  53780. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53781. * * 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
  53782. * * 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)
  53783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53786. * @param name defines the name of the mesh
  53787. * @param options defines the options used to create the mesh
  53788. * @param scene defines the hosting scene
  53789. * @returns the sphere mesh
  53790. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53791. */
  53792. static CreateSphere(name: string, options: {
  53793. segments?: number;
  53794. diameter?: number;
  53795. diameterX?: number;
  53796. diameterY?: number;
  53797. diameterZ?: number;
  53798. arc?: number;
  53799. slice?: number;
  53800. sideOrientation?: number;
  53801. frontUVs?: Vector4;
  53802. backUVs?: Vector4;
  53803. updatable?: boolean;
  53804. }, scene?: Nullable<Scene>): Mesh;
  53805. }
  53806. }
  53807. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  53808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53809. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53810. import { Scene } from "babylonjs/scene";
  53811. /**
  53812. * A profiled motion controller has its profile loaded from an online repository.
  53813. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  53814. */
  53815. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  53816. private _repositoryUrl;
  53817. private _buttonMeshMapping;
  53818. private _touchDots;
  53819. /**
  53820. * The profile ID of this controller. Will be populated when the controller initializes.
  53821. */
  53822. profileId: string;
  53823. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  53824. dispose(): void;
  53825. protected _getFilenameAndPath(): {
  53826. filename: string;
  53827. path: string;
  53828. };
  53829. protected _getModelLoadingConstraints(): boolean;
  53830. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  53831. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53832. protected _updateModel(_xrFrame: XRFrame): void;
  53833. }
  53834. }
  53835. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  53836. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53837. import { Scene } from "babylonjs/scene";
  53838. /**
  53839. * A construction function type to create a new controller based on an xrInput object
  53840. */
  53841. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  53842. /**
  53843. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  53844. *
  53845. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  53846. * it should be replaced with auto-loaded controllers.
  53847. *
  53848. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  53849. */
  53850. export class WebXRMotionControllerManager {
  53851. private static _AvailableControllers;
  53852. private static _Fallbacks;
  53853. private static _ProfileLoadingPromises;
  53854. private static _ProfilesList;
  53855. /**
  53856. * The base URL of the online controller repository. Can be changed at any time.
  53857. */
  53858. static BaseRepositoryUrl: string;
  53859. /**
  53860. * Which repository gets priority - local or online
  53861. */
  53862. static PrioritizeOnlineRepository: boolean;
  53863. /**
  53864. * Use the online repository, or use only locally-defined controllers
  53865. */
  53866. static UseOnlineRepository: boolean;
  53867. /**
  53868. * Clear the cache used for profile loading and reload when requested again
  53869. */
  53870. static ClearProfilesCache(): void;
  53871. /**
  53872. * Register the default fallbacks.
  53873. * This function is called automatically when this file is imported.
  53874. */
  53875. static DefaultFallbacks(): void;
  53876. /**
  53877. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  53878. * @param profileId the profile to which a fallback needs to be found
  53879. * @return an array with corresponding fallback profiles
  53880. */
  53881. static FindFallbackWithProfileId(profileId: string): string[];
  53882. /**
  53883. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  53884. * The order of search:
  53885. *
  53886. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53887. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  53888. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  53889. * 4) return the generic trigger controller if none were found
  53890. *
  53891. * @param xrInput the xrInput to which a new controller is initialized
  53892. * @param scene the scene to which the model will be added
  53893. * @param forceProfile force a certain profile for this controller
  53894. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  53895. */
  53896. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  53897. /**
  53898. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  53899. *
  53900. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  53901. *
  53902. * @param type the profile type to register
  53903. * @param constructFunction the function to be called when loading this profile
  53904. */
  53905. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  53906. /**
  53907. * Register a fallback to a specific profile.
  53908. * @param profileId the profileId that will receive the fallbacks
  53909. * @param fallbacks A list of fallback profiles
  53910. */
  53911. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  53912. /**
  53913. * Will update the list of profiles available in the repository
  53914. * @return a promise that resolves to a map of profiles available online
  53915. */
  53916. static UpdateProfilesList(): Promise<{
  53917. [profile: string]: string;
  53918. }>;
  53919. private static _LoadProfileFromRepository;
  53920. private static _LoadProfilesFromAvailableControllers;
  53921. }
  53922. }
  53923. declare module "babylonjs/XR/webXRInputSource" {
  53924. import { Observable } from "babylonjs/Misc/observable";
  53925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53926. import { Ray } from "babylonjs/Culling/ray";
  53927. import { Scene } from "babylonjs/scene";
  53928. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53929. /**
  53930. * Configuration options for the WebXR controller creation
  53931. */
  53932. export interface IWebXRControllerOptions {
  53933. /**
  53934. * Should the controller mesh be animated when a user interacts with it
  53935. * The pressed buttons / thumbstick and touchpad animations will be disabled
  53936. */
  53937. disableMotionControllerAnimation?: boolean;
  53938. /**
  53939. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  53940. */
  53941. doNotLoadControllerMesh?: boolean;
  53942. /**
  53943. * Force a specific controller type for this controller.
  53944. * This can be used when creating your own profile or when testing different controllers
  53945. */
  53946. forceControllerProfile?: string;
  53947. /**
  53948. * Defines a rendering group ID for meshes that will be loaded.
  53949. * This is for the default controllers only.
  53950. */
  53951. renderingGroupId?: number;
  53952. }
  53953. /**
  53954. * Represents an XR controller
  53955. */
  53956. export class WebXRInputSource {
  53957. private _scene;
  53958. /** The underlying input source for the controller */
  53959. inputSource: XRInputSource;
  53960. private _options;
  53961. private _tmpVector;
  53962. private _uniqueId;
  53963. private _disposed;
  53964. /**
  53965. * 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
  53966. */
  53967. grip?: AbstractMesh;
  53968. /**
  53969. * If available, this is the gamepad object related to this controller.
  53970. * Using this object it is possible to get click events and trackpad changes of the
  53971. * webxr controller that is currently being used.
  53972. */
  53973. motionController?: WebXRAbstractMotionController;
  53974. /**
  53975. * Event that fires when the controller is removed/disposed.
  53976. * The object provided as event data is this controller, after associated assets were disposed.
  53977. * uniqueId is still available.
  53978. */
  53979. onDisposeObservable: Observable<WebXRInputSource>;
  53980. /**
  53981. * Will be triggered when the mesh associated with the motion controller is done loading.
  53982. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  53983. * A shortened version of controller -> motion controller -> on mesh loaded.
  53984. */
  53985. onMeshLoadedObservable: Observable<AbstractMesh>;
  53986. /**
  53987. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  53988. */
  53989. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  53990. /**
  53991. * Pointer which can be used to select objects or attach a visible laser to
  53992. */
  53993. pointer: AbstractMesh;
  53994. /**
  53995. * Creates the input source object
  53996. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  53997. * @param _scene the scene which the controller should be associated to
  53998. * @param inputSource the underlying input source for the controller
  53999. * @param _options options for this controller creation
  54000. */
  54001. constructor(_scene: Scene,
  54002. /** The underlying input source for the controller */
  54003. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  54004. /**
  54005. * Get this controllers unique id
  54006. */
  54007. get uniqueId(): string;
  54008. /**
  54009. * Disposes of the object
  54010. */
  54011. dispose(): void;
  54012. /**
  54013. * Gets a world space ray coming from the pointer or grip
  54014. * @param result the resulting ray
  54015. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  54016. */
  54017. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  54018. /**
  54019. * Updates the controller pose based on the given XRFrame
  54020. * @param xrFrame xr frame to update the pose with
  54021. * @param referenceSpace reference space to use
  54022. */
  54023. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  54024. }
  54025. }
  54026. declare module "babylonjs/XR/webXRInput" {
  54027. import { Observable } from "babylonjs/Misc/observable";
  54028. import { IDisposable } from "babylonjs/scene";
  54029. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  54030. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54031. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54032. /**
  54033. * The schema for initialization options of the XR Input class
  54034. */
  54035. export interface IWebXRInputOptions {
  54036. /**
  54037. * If set to true no model will be automatically loaded
  54038. */
  54039. doNotLoadControllerMeshes?: boolean;
  54040. /**
  54041. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  54042. * If not found, the xr input profile data will be used.
  54043. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  54044. */
  54045. forceInputProfile?: string;
  54046. /**
  54047. * Do not send a request to the controller repository to load the profile.
  54048. *
  54049. * Instead, use the controllers available in babylon itself.
  54050. */
  54051. disableOnlineControllerRepository?: boolean;
  54052. /**
  54053. * A custom URL for the controllers repository
  54054. */
  54055. customControllersRepositoryURL?: string;
  54056. /**
  54057. * Should the controller model's components not move according to the user input
  54058. */
  54059. disableControllerAnimation?: boolean;
  54060. /**
  54061. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  54062. */
  54063. controllerOptions?: IWebXRControllerOptions;
  54064. }
  54065. /**
  54066. * XR input used to track XR inputs such as controllers/rays
  54067. */
  54068. export class WebXRInput implements IDisposable {
  54069. /**
  54070. * the xr session manager for this session
  54071. */
  54072. xrSessionManager: WebXRSessionManager;
  54073. /**
  54074. * the WebXR camera for this session. Mainly used for teleportation
  54075. */
  54076. xrCamera: WebXRCamera;
  54077. private readonly options;
  54078. /**
  54079. * XR controllers being tracked
  54080. */
  54081. controllers: Array<WebXRInputSource>;
  54082. private _frameObserver;
  54083. private _sessionEndedObserver;
  54084. private _sessionInitObserver;
  54085. /**
  54086. * Event when a controller has been connected/added
  54087. */
  54088. onControllerAddedObservable: Observable<WebXRInputSource>;
  54089. /**
  54090. * Event when a controller has been removed/disconnected
  54091. */
  54092. onControllerRemovedObservable: Observable<WebXRInputSource>;
  54093. /**
  54094. * Initializes the WebXRInput
  54095. * @param xrSessionManager the xr session manager for this session
  54096. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  54097. * @param options = initialization options for this xr input
  54098. */
  54099. constructor(
  54100. /**
  54101. * the xr session manager for this session
  54102. */
  54103. xrSessionManager: WebXRSessionManager,
  54104. /**
  54105. * the WebXR camera for this session. Mainly used for teleportation
  54106. */
  54107. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  54108. private _onInputSourcesChange;
  54109. private _addAndRemoveControllers;
  54110. /**
  54111. * Disposes of the object
  54112. */
  54113. dispose(): void;
  54114. }
  54115. }
  54116. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  54117. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54118. import { Observable, EventState } from "babylonjs/Misc/observable";
  54119. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54120. /**
  54121. * This is the base class for all WebXR features.
  54122. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  54123. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  54124. */
  54125. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  54126. protected _xrSessionManager: WebXRSessionManager;
  54127. private _attached;
  54128. private _removeOnDetach;
  54129. /**
  54130. * Is this feature disposed?
  54131. */
  54132. isDisposed: boolean;
  54133. /**
  54134. * Should auto-attach be disabled?
  54135. */
  54136. disableAutoAttach: boolean;
  54137. /**
  54138. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  54139. */
  54140. xrNativeFeatureName: string;
  54141. /**
  54142. * Construct a new (abstract) WebXR feature
  54143. * @param _xrSessionManager the xr session manager for this feature
  54144. */
  54145. constructor(_xrSessionManager: WebXRSessionManager);
  54146. /**
  54147. * Is this feature attached
  54148. */
  54149. get attached(): boolean;
  54150. /**
  54151. * attach this feature
  54152. *
  54153. * @param force should attachment be forced (even when already attached)
  54154. * @returns true if successful, false is failed or already attached
  54155. */
  54156. attach(force?: boolean): boolean;
  54157. /**
  54158. * detach this feature.
  54159. *
  54160. * @returns true if successful, false if failed or already detached
  54161. */
  54162. detach(): boolean;
  54163. /**
  54164. * Dispose this feature and all of the resources attached
  54165. */
  54166. dispose(): void;
  54167. /**
  54168. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54169. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54170. *
  54171. * @returns whether or not the feature is compatible in this environment
  54172. */
  54173. isCompatible(): boolean;
  54174. /**
  54175. * This is used to register callbacks that will automatically be removed when detach is called.
  54176. * @param observable the observable to which the observer will be attached
  54177. * @param callback the callback to register
  54178. */
  54179. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  54180. /**
  54181. * Code in this function will be executed on each xrFrame received from the browser.
  54182. * This function will not execute after the feature is detached.
  54183. * @param _xrFrame the current frame
  54184. */
  54185. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  54186. }
  54187. }
  54188. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  54189. import { IDisposable, Scene } from "babylonjs/scene";
  54190. import { Nullable } from "babylonjs/types";
  54191. import { Observable } from "babylonjs/Misc/observable";
  54192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54193. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  54194. import { Camera } from "babylonjs/Cameras/camera";
  54195. /**
  54196. * Renders a layer on top of an existing scene
  54197. */
  54198. export class UtilityLayerRenderer implements IDisposable {
  54199. /** the original scene that will be rendered on top of */
  54200. originalScene: Scene;
  54201. private _pointerCaptures;
  54202. private _lastPointerEvents;
  54203. private static _DefaultUtilityLayer;
  54204. private static _DefaultKeepDepthUtilityLayer;
  54205. private _sharedGizmoLight;
  54206. private _renderCamera;
  54207. /**
  54208. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  54209. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  54210. * @returns the camera that is used when rendering the utility layer
  54211. */
  54212. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  54213. /**
  54214. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  54215. * @param cam the camera that should be used when rendering the utility layer
  54216. */
  54217. setRenderCamera(cam: Nullable<Camera>): void;
  54218. /**
  54219. * @hidden
  54220. * Light which used by gizmos to get light shading
  54221. */
  54222. _getSharedGizmoLight(): HemisphericLight;
  54223. /**
  54224. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  54225. */
  54226. pickUtilitySceneFirst: boolean;
  54227. /**
  54228. * 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)
  54229. */
  54230. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  54231. /**
  54232. * 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)
  54233. */
  54234. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  54235. /**
  54236. * The scene that is rendered on top of the original scene
  54237. */
  54238. utilityLayerScene: Scene;
  54239. /**
  54240. * If the utility layer should automatically be rendered on top of existing scene
  54241. */
  54242. shouldRender: boolean;
  54243. /**
  54244. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  54245. */
  54246. onlyCheckPointerDownEvents: boolean;
  54247. /**
  54248. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  54249. */
  54250. processAllEvents: boolean;
  54251. /**
  54252. * Observable raised when the pointer move from the utility layer scene to the main scene
  54253. */
  54254. onPointerOutObservable: Observable<number>;
  54255. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  54256. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  54257. private _afterRenderObserver;
  54258. private _sceneDisposeObserver;
  54259. private _originalPointerObserver;
  54260. /**
  54261. * Instantiates a UtilityLayerRenderer
  54262. * @param originalScene the original scene that will be rendered on top of
  54263. * @param handleEvents boolean indicating if the utility layer should handle events
  54264. */
  54265. constructor(
  54266. /** the original scene that will be rendered on top of */
  54267. originalScene: Scene, handleEvents?: boolean);
  54268. private _notifyObservers;
  54269. /**
  54270. * Renders the utility layers scene on top of the original scene
  54271. */
  54272. render(): void;
  54273. /**
  54274. * Disposes of the renderer
  54275. */
  54276. dispose(): void;
  54277. private _updateCamera;
  54278. }
  54279. }
  54280. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  54281. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54283. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54284. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  54285. import { Scene } from "babylonjs/scene";
  54286. import { Nullable } from "babylonjs/types";
  54287. import { Color3 } from "babylonjs/Maths/math.color";
  54288. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54289. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54290. /**
  54291. * Options interface for the pointer selection module
  54292. */
  54293. export interface IWebXRControllerPointerSelectionOptions {
  54294. /**
  54295. * if provided, this scene will be used to render meshes.
  54296. */
  54297. customUtilityLayerScene?: Scene;
  54298. /**
  54299. * 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)
  54300. * If not disabled, the last picked point will be used to execute a pointer up event
  54301. * If disabled, pointer up event will be triggered right after the pointer down event.
  54302. * Used in screen and gaze target ray mode only
  54303. */
  54304. disablePointerUpOnTouchOut: boolean;
  54305. /**
  54306. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  54307. */
  54308. forceGazeMode: boolean;
  54309. /**
  54310. * 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
  54311. * to start a new countdown to the pointer down event.
  54312. * Defaults to 1.
  54313. */
  54314. gazeModePointerMovedFactor?: number;
  54315. /**
  54316. * Different button type to use instead of the main component
  54317. */
  54318. overrideButtonId?: string;
  54319. /**
  54320. * use this rendering group id for the meshes (optional)
  54321. */
  54322. renderingGroupId?: number;
  54323. /**
  54324. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  54325. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  54326. * 3000 means 3 seconds between pointing at something and selecting it
  54327. */
  54328. timeToSelect?: number;
  54329. /**
  54330. * Should meshes created here be added to a utility layer or the main scene
  54331. */
  54332. useUtilityLayer?: boolean;
  54333. /**
  54334. * Optional WebXR camera to be used for gaze selection
  54335. */
  54336. gazeCamera?: WebXRCamera;
  54337. /**
  54338. * the xr input to use with this pointer selection
  54339. */
  54340. xrInput: WebXRInput;
  54341. /**
  54342. * Should the scene pointerX and pointerY update be disabled
  54343. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54344. * Disable in VR, if not needed.
  54345. * The first rig camera (left eye) will be used to calculate the projection
  54346. */
  54347. disableScenePointerVectorUpdate: boolean;
  54348. /**
  54349. * Enable pointer selection on all controllers instead of switching between them
  54350. */
  54351. enablePointerSelectionOnAllControllers?: boolean;
  54352. /**
  54353. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  54354. * If switch is enabled, it will still allow the user to switch between the different controllers
  54355. */
  54356. preferredHandedness?: XRHandedness;
  54357. /**
  54358. * Disable switching the pointer selection from one controller to the other.
  54359. * 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
  54360. */
  54361. disableSwitchOnClick?: boolean;
  54362. /**
  54363. * The maximum distance of the pointer selection feature. Defaults to 100.
  54364. */
  54365. maxPointerDistance?: number;
  54366. }
  54367. /**
  54368. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54369. */
  54370. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54371. private readonly _options;
  54372. private static _idCounter;
  54373. private _attachController;
  54374. private _controllers;
  54375. private _scene;
  54376. private _tmpVectorForPickCompare;
  54377. private _attachedController;
  54378. /**
  54379. * The module's name
  54380. */
  54381. static readonly Name: string;
  54382. /**
  54383. * The (Babylon) version of this module.
  54384. * This is an integer representing the implementation version.
  54385. * This number does not correspond to the WebXR specs version
  54386. */
  54387. static readonly Version: number;
  54388. /**
  54389. * Disable lighting on the laser pointer (so it will always be visible)
  54390. */
  54391. disablePointerLighting: boolean;
  54392. /**
  54393. * Disable lighting on the selection mesh (so it will always be visible)
  54394. */
  54395. disableSelectionMeshLighting: boolean;
  54396. /**
  54397. * Should the laser pointer be displayed
  54398. */
  54399. displayLaserPointer: boolean;
  54400. /**
  54401. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54402. */
  54403. displaySelectionMesh: boolean;
  54404. /**
  54405. * This color will be set to the laser pointer when selection is triggered
  54406. */
  54407. laserPointerPickedColor: Color3;
  54408. /**
  54409. * Default color of the laser pointer
  54410. */
  54411. laserPointerDefaultColor: Color3;
  54412. /**
  54413. * default color of the selection ring
  54414. */
  54415. selectionMeshDefaultColor: Color3;
  54416. /**
  54417. * This color will be applied to the selection ring when selection is triggered
  54418. */
  54419. selectionMeshPickedColor: Color3;
  54420. /**
  54421. * Optional filter to be used for ray selection. This predicate shares behavior with
  54422. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54423. */
  54424. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54425. /**
  54426. * constructs a new background remover module
  54427. * @param _xrSessionManager the session manager for this module
  54428. * @param _options read-only options to be used in this module
  54429. */
  54430. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54431. /**
  54432. * attach this feature
  54433. * Will usually be called by the features manager
  54434. *
  54435. * @returns true if successful.
  54436. */
  54437. attach(): boolean;
  54438. /**
  54439. * detach this feature.
  54440. * Will usually be called by the features manager
  54441. *
  54442. * @returns true if successful.
  54443. */
  54444. detach(): boolean;
  54445. /**
  54446. * Will get the mesh under a specific pointer.
  54447. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54448. * @param controllerId the controllerId to check
  54449. * @returns The mesh under pointer or null if no mesh is under the pointer
  54450. */
  54451. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54452. /**
  54453. * Get the xr controller that correlates to the pointer id in the pointer event
  54454. *
  54455. * @param id the pointer id to search for
  54456. * @returns the controller that correlates to this id or null if not found
  54457. */
  54458. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54459. private _identityMatrix;
  54460. private _screenCoordinatesRef;
  54461. private _viewportRef;
  54462. protected _onXRFrame(_xrFrame: XRFrame): void;
  54463. private _attachGazeMode;
  54464. private _attachScreenRayMode;
  54465. private _attachTrackedPointerRayMode;
  54466. private _convertNormalToDirectionOfRay;
  54467. private _detachController;
  54468. private _generateNewMeshPair;
  54469. private _pickingMoved;
  54470. private _updatePointerDistance;
  54471. /** @hidden */
  54472. get lasterPointerDefaultColor(): Color3;
  54473. }
  54474. }
  54475. declare module "babylonjs/XR/webXREnterExitUI" {
  54476. import { Nullable } from "babylonjs/types";
  54477. import { Observable } from "babylonjs/Misc/observable";
  54478. import { IDisposable, Scene } from "babylonjs/scene";
  54479. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54480. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54481. /**
  54482. * Button which can be used to enter a different mode of XR
  54483. */
  54484. export class WebXREnterExitUIButton {
  54485. /** button element */
  54486. element: HTMLElement;
  54487. /** XR initialization options for the button */
  54488. sessionMode: XRSessionMode;
  54489. /** Reference space type */
  54490. referenceSpaceType: XRReferenceSpaceType;
  54491. /**
  54492. * Creates a WebXREnterExitUIButton
  54493. * @param element button element
  54494. * @param sessionMode XR initialization session mode
  54495. * @param referenceSpaceType the type of reference space to be used
  54496. */
  54497. constructor(
  54498. /** button element */
  54499. element: HTMLElement,
  54500. /** XR initialization options for the button */
  54501. sessionMode: XRSessionMode,
  54502. /** Reference space type */
  54503. referenceSpaceType: XRReferenceSpaceType);
  54504. /**
  54505. * Extendable function which can be used to update the button's visuals when the state changes
  54506. * @param activeButton the current active button in the UI
  54507. */
  54508. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54509. }
  54510. /**
  54511. * Options to create the webXR UI
  54512. */
  54513. export class WebXREnterExitUIOptions {
  54514. /**
  54515. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54516. */
  54517. customButtons?: Array<WebXREnterExitUIButton>;
  54518. /**
  54519. * A reference space type to use when creating the default button.
  54520. * Default is local-floor
  54521. */
  54522. referenceSpaceType?: XRReferenceSpaceType;
  54523. /**
  54524. * Context to enter xr with
  54525. */
  54526. renderTarget?: Nullable<WebXRRenderTarget>;
  54527. /**
  54528. * A session mode to use when creating the default button.
  54529. * Default is immersive-vr
  54530. */
  54531. sessionMode?: XRSessionMode;
  54532. /**
  54533. * A list of optional features to init the session with
  54534. */
  54535. optionalFeatures?: string[];
  54536. /**
  54537. * A list of optional features to init the session with
  54538. */
  54539. requiredFeatures?: string[];
  54540. /**
  54541. * If defined, this function will be executed if the UI encounters an error when entering XR
  54542. */
  54543. onError?: (error: any) => void;
  54544. }
  54545. /**
  54546. * UI to allow the user to enter/exit XR mode
  54547. */
  54548. export class WebXREnterExitUI implements IDisposable {
  54549. private scene;
  54550. /** version of the options passed to this UI */
  54551. options: WebXREnterExitUIOptions;
  54552. private _activeButton;
  54553. private _buttons;
  54554. /**
  54555. * The HTML Div Element to which buttons are added.
  54556. */
  54557. readonly overlay: HTMLDivElement;
  54558. /**
  54559. * Fired every time the active button is changed.
  54560. *
  54561. * When xr is entered via a button that launches xr that button will be the callback parameter
  54562. *
  54563. * When exiting xr the callback parameter will be null)
  54564. */
  54565. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54566. /**
  54567. *
  54568. * @param scene babylon scene object to use
  54569. * @param options (read-only) version of the options passed to this UI
  54570. */
  54571. private constructor();
  54572. /**
  54573. * Creates UI to allow the user to enter/exit XR mode
  54574. * @param scene the scene to add the ui to
  54575. * @param helper the xr experience helper to enter/exit xr with
  54576. * @param options options to configure the UI
  54577. * @returns the created ui
  54578. */
  54579. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54580. /**
  54581. * Disposes of the XR UI component
  54582. */
  54583. dispose(): void;
  54584. private _updateButtons;
  54585. }
  54586. }
  54587. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54588. import { Vector3 } from "babylonjs/Maths/math.vector";
  54589. import { Color4 } from "babylonjs/Maths/math.color";
  54590. import { Nullable } from "babylonjs/types";
  54591. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54592. import { Scene } from "babylonjs/scene";
  54593. /**
  54594. * Class containing static functions to help procedurally build meshes
  54595. */
  54596. export class LinesBuilder {
  54597. /**
  54598. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54599. * * 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
  54600. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54601. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54602. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54603. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54604. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54605. * * 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
  54606. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54609. * @param name defines the name of the new line system
  54610. * @param options defines the options used to create the line system
  54611. * @param scene defines the hosting scene
  54612. * @returns a new line system mesh
  54613. */
  54614. static CreateLineSystem(name: string, options: {
  54615. lines: Vector3[][];
  54616. updatable?: boolean;
  54617. instance?: Nullable<LinesMesh>;
  54618. colors?: Nullable<Color4[][]>;
  54619. useVertexAlpha?: boolean;
  54620. }, scene: Nullable<Scene>): LinesMesh;
  54621. /**
  54622. * Creates a line mesh
  54623. * 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
  54624. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54625. * * The parameter `points` is an array successive Vector3
  54626. * * The 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
  54627. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54628. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54629. * * When updating an instance, remember that only point positions can change, not the number of points
  54630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54631. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54632. * @param name defines the name of the new line system
  54633. * @param options defines the options used to create the line system
  54634. * @param scene defines the hosting scene
  54635. * @returns a new line mesh
  54636. */
  54637. static CreateLines(name: string, options: {
  54638. points: Vector3[];
  54639. updatable?: boolean;
  54640. instance?: Nullable<LinesMesh>;
  54641. colors?: Color4[];
  54642. useVertexAlpha?: boolean;
  54643. }, scene?: Nullable<Scene>): LinesMesh;
  54644. /**
  54645. * Creates a dashed line mesh
  54646. * * 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
  54647. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54648. * * The parameter `points` is an array successive Vector3
  54649. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54650. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54651. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54652. * * 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
  54653. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54654. * * When updating an instance, remember that only point positions can change, not the number of points
  54655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54656. * @param name defines the name of the mesh
  54657. * @param options defines the options used to create the mesh
  54658. * @param scene defines the hosting scene
  54659. * @returns the dashed line mesh
  54660. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54661. */
  54662. static CreateDashedLines(name: string, options: {
  54663. points: Vector3[];
  54664. dashSize?: number;
  54665. gapSize?: number;
  54666. dashNb?: number;
  54667. updatable?: boolean;
  54668. instance?: LinesMesh;
  54669. useVertexAlpha?: boolean;
  54670. }, scene?: Nullable<Scene>): LinesMesh;
  54671. }
  54672. }
  54673. declare module "babylonjs/Misc/timer" {
  54674. import { Observable, Observer } from "babylonjs/Misc/observable";
  54675. import { Nullable } from "babylonjs/types";
  54676. import { IDisposable } from "babylonjs/scene";
  54677. /**
  54678. * Construction options for a timer
  54679. */
  54680. export interface ITimerOptions<T> {
  54681. /**
  54682. * Time-to-end
  54683. */
  54684. timeout: number;
  54685. /**
  54686. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54687. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54688. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54689. */
  54690. contextObservable: Observable<T>;
  54691. /**
  54692. * Optional parameters when adding an observer to the observable
  54693. */
  54694. observableParameters?: {
  54695. mask?: number;
  54696. insertFirst?: boolean;
  54697. scope?: any;
  54698. };
  54699. /**
  54700. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54701. */
  54702. breakCondition?: (data?: ITimerData<T>) => boolean;
  54703. /**
  54704. * Will be triggered when the time condition has met
  54705. */
  54706. onEnded?: (data: ITimerData<any>) => void;
  54707. /**
  54708. * Will be triggered when the break condition has met (prematurely ended)
  54709. */
  54710. onAborted?: (data: ITimerData<any>) => void;
  54711. /**
  54712. * Optional function to execute on each tick (or count)
  54713. */
  54714. onTick?: (data: ITimerData<any>) => void;
  54715. }
  54716. /**
  54717. * An interface defining the data sent by the timer
  54718. */
  54719. export interface ITimerData<T> {
  54720. /**
  54721. * When did it start
  54722. */
  54723. startTime: number;
  54724. /**
  54725. * Time now
  54726. */
  54727. currentTime: number;
  54728. /**
  54729. * Time passed since started
  54730. */
  54731. deltaTime: number;
  54732. /**
  54733. * How much is completed, in [0.0...1.0].
  54734. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54735. */
  54736. completeRate: number;
  54737. /**
  54738. * What the registered observable sent in the last count
  54739. */
  54740. payload: T;
  54741. }
  54742. /**
  54743. * The current state of the timer
  54744. */
  54745. export enum TimerState {
  54746. /**
  54747. * Timer initialized, not yet started
  54748. */
  54749. INIT = 0,
  54750. /**
  54751. * Timer started and counting
  54752. */
  54753. STARTED = 1,
  54754. /**
  54755. * Timer ended (whether aborted or time reached)
  54756. */
  54757. ENDED = 2
  54758. }
  54759. /**
  54760. * A simple version of the timer. Will take options and start the timer immediately after calling it
  54761. *
  54762. * @param options options with which to initialize this timer
  54763. */
  54764. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  54765. /**
  54766. * An advanced implementation of a timer class
  54767. */
  54768. export class AdvancedTimer<T = any> implements IDisposable {
  54769. /**
  54770. * Will notify each time the timer calculates the remaining time
  54771. */
  54772. onEachCountObservable: Observable<ITimerData<T>>;
  54773. /**
  54774. * Will trigger when the timer was aborted due to the break condition
  54775. */
  54776. onTimerAbortedObservable: Observable<ITimerData<T>>;
  54777. /**
  54778. * Will trigger when the timer ended successfully
  54779. */
  54780. onTimerEndedObservable: Observable<ITimerData<T>>;
  54781. /**
  54782. * Will trigger when the timer state has changed
  54783. */
  54784. onStateChangedObservable: Observable<TimerState>;
  54785. private _observer;
  54786. private _contextObservable;
  54787. private _observableParameters;
  54788. private _startTime;
  54789. private _timer;
  54790. private _state;
  54791. private _breakCondition;
  54792. private _timeToEnd;
  54793. private _breakOnNextTick;
  54794. /**
  54795. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  54796. * @param options construction options for this advanced timer
  54797. */
  54798. constructor(options: ITimerOptions<T>);
  54799. /**
  54800. * set a breaking condition for this timer. Default is to never break during count
  54801. * @param predicate the new break condition. Returns true to break, false otherwise
  54802. */
  54803. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  54804. /**
  54805. * Reset ALL associated observables in this advanced timer
  54806. */
  54807. clearObservables(): void;
  54808. /**
  54809. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  54810. *
  54811. * @param timeToEnd how much time to measure until timer ended
  54812. */
  54813. start(timeToEnd?: number): void;
  54814. /**
  54815. * Will force a stop on the next tick.
  54816. */
  54817. stop(): void;
  54818. /**
  54819. * Dispose this timer, clearing all resources
  54820. */
  54821. dispose(): void;
  54822. private _setState;
  54823. private _tick;
  54824. private _stop;
  54825. }
  54826. }
  54827. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  54828. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54829. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54830. import { Nullable } from "babylonjs/types";
  54831. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54833. import { Vector3 } from "babylonjs/Maths/math.vector";
  54834. import { Material } from "babylonjs/Materials/material";
  54835. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54836. import { Scene } from "babylonjs/scene";
  54837. /**
  54838. * The options container for the teleportation module
  54839. */
  54840. export interface IWebXRTeleportationOptions {
  54841. /**
  54842. * if provided, this scene will be used to render meshes.
  54843. */
  54844. customUtilityLayerScene?: Scene;
  54845. /**
  54846. * Values to configure the default target mesh
  54847. */
  54848. defaultTargetMeshOptions?: {
  54849. /**
  54850. * Fill color of the teleportation area
  54851. */
  54852. teleportationFillColor?: string;
  54853. /**
  54854. * Border color for the teleportation area
  54855. */
  54856. teleportationBorderColor?: string;
  54857. /**
  54858. * Disable the mesh's animation sequence
  54859. */
  54860. disableAnimation?: boolean;
  54861. /**
  54862. * Disable lighting on the material or the ring and arrow
  54863. */
  54864. disableLighting?: boolean;
  54865. /**
  54866. * Override the default material of the torus and arrow
  54867. */
  54868. torusArrowMaterial?: Material;
  54869. };
  54870. /**
  54871. * A list of meshes to use as floor meshes.
  54872. * Meshes can be added and removed after initializing the feature using the
  54873. * addFloorMesh and removeFloorMesh functions
  54874. * If empty, rotation will still work
  54875. */
  54876. floorMeshes?: AbstractMesh[];
  54877. /**
  54878. * use this rendering group id for the meshes (optional)
  54879. */
  54880. renderingGroupId?: number;
  54881. /**
  54882. * Should teleportation move only to snap points
  54883. */
  54884. snapPointsOnly?: boolean;
  54885. /**
  54886. * An array of points to which the teleportation will snap to.
  54887. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  54888. */
  54889. snapPositions?: Vector3[];
  54890. /**
  54891. * How close should the teleportation ray be in order to snap to position.
  54892. * Default to 0.8 units (meters)
  54893. */
  54894. snapToPositionRadius?: number;
  54895. /**
  54896. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  54897. * If you want to support rotation, make sure your mesh has a direction indicator.
  54898. *
  54899. * When left untouched, the default mesh will be initialized.
  54900. */
  54901. teleportationTargetMesh?: AbstractMesh;
  54902. /**
  54903. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  54904. */
  54905. timeToTeleport?: number;
  54906. /**
  54907. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  54908. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  54909. */
  54910. useMainComponentOnly?: boolean;
  54911. /**
  54912. * Should meshes created here be added to a utility layer or the main scene
  54913. */
  54914. useUtilityLayer?: boolean;
  54915. /**
  54916. * Babylon XR Input class for controller
  54917. */
  54918. xrInput: WebXRInput;
  54919. /**
  54920. * Meshes that the teleportation ray cannot go through
  54921. */
  54922. pickBlockerMeshes?: AbstractMesh[];
  54923. }
  54924. /**
  54925. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  54926. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  54927. * the input of the attached controllers.
  54928. */
  54929. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  54930. private _options;
  54931. private _controllers;
  54932. private _currentTeleportationControllerId;
  54933. private _floorMeshes;
  54934. private _quadraticBezierCurve;
  54935. private _selectionFeature;
  54936. private _snapToPositions;
  54937. private _snappedToPoint;
  54938. private _teleportationRingMaterial?;
  54939. private _tmpRay;
  54940. private _tmpVector;
  54941. private _tmpQuaternion;
  54942. /**
  54943. * The module's name
  54944. */
  54945. static readonly Name: string;
  54946. /**
  54947. * The (Babylon) version of this module.
  54948. * This is an integer representing the implementation version.
  54949. * This number does not correspond to the webxr specs version
  54950. */
  54951. static readonly Version: number;
  54952. /**
  54953. * Is movement backwards enabled
  54954. */
  54955. backwardsMovementEnabled: boolean;
  54956. /**
  54957. * Distance to travel when moving backwards
  54958. */
  54959. backwardsTeleportationDistance: number;
  54960. /**
  54961. * The distance from the user to the inspection point in the direction of the controller
  54962. * A higher number will allow the user to move further
  54963. * defaults to 5 (meters, in xr units)
  54964. */
  54965. parabolicCheckRadius: number;
  54966. /**
  54967. * Should the module support parabolic ray on top of direct ray
  54968. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  54969. * Very helpful when moving between floors / different heights
  54970. */
  54971. parabolicRayEnabled: boolean;
  54972. /**
  54973. * How much rotation should be applied when rotating right and left
  54974. */
  54975. rotationAngle: number;
  54976. /**
  54977. * Is rotation enabled when moving forward?
  54978. * Disabling this feature will prevent the user from deciding the direction when teleporting
  54979. */
  54980. rotationEnabled: boolean;
  54981. /**
  54982. * constructs a new anchor system
  54983. * @param _xrSessionManager an instance of WebXRSessionManager
  54984. * @param _options configuration object for this feature
  54985. */
  54986. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  54987. /**
  54988. * Get the snapPointsOnly flag
  54989. */
  54990. get snapPointsOnly(): boolean;
  54991. /**
  54992. * Sets the snapPointsOnly flag
  54993. * @param snapToPoints should teleportation be exclusively to snap points
  54994. */
  54995. set snapPointsOnly(snapToPoints: boolean);
  54996. /**
  54997. * Add a new mesh to the floor meshes array
  54998. * @param mesh the mesh to use as floor mesh
  54999. */
  55000. addFloorMesh(mesh: AbstractMesh): void;
  55001. /**
  55002. * Add a new snap-to point to fix teleportation to this position
  55003. * @param newSnapPoint The new Snap-To point
  55004. */
  55005. addSnapPoint(newSnapPoint: Vector3): void;
  55006. attach(): boolean;
  55007. detach(): boolean;
  55008. dispose(): void;
  55009. /**
  55010. * Remove a mesh from the floor meshes array
  55011. * @param mesh the mesh to remove
  55012. */
  55013. removeFloorMesh(mesh: AbstractMesh): void;
  55014. /**
  55015. * Remove a mesh from the floor meshes array using its name
  55016. * @param name the mesh name to remove
  55017. */
  55018. removeFloorMeshByName(name: string): void;
  55019. /**
  55020. * 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
  55021. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  55022. * @returns was the point found and removed or not
  55023. */
  55024. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  55025. /**
  55026. * This function sets a selection feature that will be disabled when
  55027. * the forward ray is shown and will be reattached when hidden.
  55028. * This is used to remove the selection rays when moving.
  55029. * @param selectionFeature the feature to disable when forward movement is enabled
  55030. */
  55031. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  55032. protected _onXRFrame(_xrFrame: XRFrame): void;
  55033. private _attachController;
  55034. private _createDefaultTargetMesh;
  55035. private _detachController;
  55036. private _findClosestSnapPointWithRadius;
  55037. private _setTargetMeshPosition;
  55038. private _setTargetMeshVisibility;
  55039. private _showParabolicPath;
  55040. private _teleportForward;
  55041. }
  55042. }
  55043. declare module "babylonjs/XR/webXRDefaultExperience" {
  55044. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  55045. import { Scene } from "babylonjs/scene";
  55046. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  55047. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  55048. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55049. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  55050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55051. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  55052. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  55053. /**
  55054. * Options for the default xr helper
  55055. */
  55056. export class WebXRDefaultExperienceOptions {
  55057. /**
  55058. * Enable or disable default UI to enter XR
  55059. */
  55060. disableDefaultUI?: boolean;
  55061. /**
  55062. * Should teleportation not initialize. defaults to false.
  55063. */
  55064. disableTeleportation?: boolean;
  55065. /**
  55066. * Floor meshes that will be used for teleport
  55067. */
  55068. floorMeshes?: Array<AbstractMesh>;
  55069. /**
  55070. * If set to true, the first frame will not be used to reset position
  55071. * The first frame is mainly used when copying transformation from the old camera
  55072. * Mainly used in AR
  55073. */
  55074. ignoreNativeCameraTransformation?: boolean;
  55075. /**
  55076. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  55077. */
  55078. inputOptions?: IWebXRInputOptions;
  55079. /**
  55080. * optional configuration for the output canvas
  55081. */
  55082. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  55083. /**
  55084. * optional UI options. This can be used among other to change session mode and reference space type
  55085. */
  55086. uiOptions?: WebXREnterExitUIOptions;
  55087. /**
  55088. * When loading teleportation and pointer select, use stable versions instead of latest.
  55089. */
  55090. useStablePlugins?: boolean;
  55091. /**
  55092. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  55093. */
  55094. renderingGroupId?: number;
  55095. /**
  55096. * A list of optional features to init the session with
  55097. * If set to true, all features we support will be added
  55098. */
  55099. optionalFeatures?: boolean | string[];
  55100. }
  55101. /**
  55102. * Default experience which provides a similar setup to the previous webVRExperience
  55103. */
  55104. export class WebXRDefaultExperience {
  55105. /**
  55106. * Base experience
  55107. */
  55108. baseExperience: WebXRExperienceHelper;
  55109. /**
  55110. * Enables ui for entering/exiting xr
  55111. */
  55112. enterExitUI: WebXREnterExitUI;
  55113. /**
  55114. * Input experience extension
  55115. */
  55116. input: WebXRInput;
  55117. /**
  55118. * Enables laser pointer and selection
  55119. */
  55120. pointerSelection: WebXRControllerPointerSelection;
  55121. /**
  55122. * Default target xr should render to
  55123. */
  55124. renderTarget: WebXRRenderTarget;
  55125. /**
  55126. * Enables teleportation
  55127. */
  55128. teleportation: WebXRMotionControllerTeleportation;
  55129. private constructor();
  55130. /**
  55131. * Creates the default xr experience
  55132. * @param scene scene
  55133. * @param options options for basic configuration
  55134. * @returns resulting WebXRDefaultExperience
  55135. */
  55136. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55137. /**
  55138. * DIsposes of the experience helper
  55139. */
  55140. dispose(): void;
  55141. }
  55142. }
  55143. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  55144. import { Observable } from "babylonjs/Misc/observable";
  55145. import { Nullable } from "babylonjs/types";
  55146. import { Camera } from "babylonjs/Cameras/camera";
  55147. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  55148. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55149. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  55150. import { Scene } from "babylonjs/scene";
  55151. import { Vector3 } from "babylonjs/Maths/math.vector";
  55152. import { Color3 } from "babylonjs/Maths/math.color";
  55153. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55155. import { Mesh } from "babylonjs/Meshes/mesh";
  55156. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  55157. import { EasingFunction } from "babylonjs/Animations/easing";
  55158. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55159. import "babylonjs/Meshes/Builders/groundBuilder";
  55160. import "babylonjs/Meshes/Builders/torusBuilder";
  55161. import "babylonjs/Meshes/Builders/cylinderBuilder";
  55162. import "babylonjs/Gamepads/gamepadSceneComponent";
  55163. import "babylonjs/Animations/animatable";
  55164. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  55165. /**
  55166. * Options to modify the vr teleportation behavior.
  55167. */
  55168. export interface VRTeleportationOptions {
  55169. /**
  55170. * The name of the mesh which should be used as the teleportation floor. (default: null)
  55171. */
  55172. floorMeshName?: string;
  55173. /**
  55174. * A list of meshes to be used as the teleportation floor. (default: empty)
  55175. */
  55176. floorMeshes?: Mesh[];
  55177. /**
  55178. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  55179. */
  55180. teleportationMode?: number;
  55181. /**
  55182. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  55183. */
  55184. teleportationTime?: number;
  55185. /**
  55186. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  55187. */
  55188. teleportationSpeed?: number;
  55189. /**
  55190. * The easing function used in the animation or null for Linear. (default CircleEase)
  55191. */
  55192. easingFunction?: EasingFunction;
  55193. }
  55194. /**
  55195. * Options to modify the vr experience helper's behavior.
  55196. */
  55197. export interface VRExperienceHelperOptions extends WebVROptions {
  55198. /**
  55199. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  55200. */
  55201. createDeviceOrientationCamera?: boolean;
  55202. /**
  55203. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  55204. */
  55205. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  55206. /**
  55207. * Uses the main button on the controller to toggle the laser casted. (default: true)
  55208. */
  55209. laserToggle?: boolean;
  55210. /**
  55211. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  55212. */
  55213. floorMeshes?: Mesh[];
  55214. /**
  55215. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  55216. */
  55217. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  55218. /**
  55219. * Defines if WebXR should be used instead of WebVR (if available)
  55220. */
  55221. useXR?: boolean;
  55222. }
  55223. /**
  55224. * Event containing information after VR has been entered
  55225. */
  55226. export class OnAfterEnteringVRObservableEvent {
  55227. /**
  55228. * If entering vr was successful
  55229. */
  55230. success: boolean;
  55231. }
  55232. /**
  55233. * Helps to quickly add VR support to an existing scene.
  55234. * See https://doc.babylonjs.com/how_to/webvr_helper
  55235. */
  55236. export class VRExperienceHelper {
  55237. /** Options to modify the vr experience helper's behavior. */
  55238. webVROptions: VRExperienceHelperOptions;
  55239. private _scene;
  55240. private _position;
  55241. private _btnVR;
  55242. private _btnVRDisplayed;
  55243. private _webVRsupported;
  55244. private _webVRready;
  55245. private _webVRrequesting;
  55246. private _webVRpresenting;
  55247. private _hasEnteredVR;
  55248. private _fullscreenVRpresenting;
  55249. private _inputElement;
  55250. private _webVRCamera;
  55251. private _vrDeviceOrientationCamera;
  55252. private _deviceOrientationCamera;
  55253. private _existingCamera;
  55254. private _onKeyDown;
  55255. private _onVrDisplayPresentChange;
  55256. private _onVRDisplayChanged;
  55257. private _onVRRequestPresentStart;
  55258. private _onVRRequestPresentComplete;
  55259. /**
  55260. * 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)
  55261. */
  55262. enableGazeEvenWhenNoPointerLock: boolean;
  55263. /**
  55264. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  55265. */
  55266. exitVROnDoubleTap: boolean;
  55267. /**
  55268. * Observable raised right before entering VR.
  55269. */
  55270. onEnteringVRObservable: Observable<VRExperienceHelper>;
  55271. /**
  55272. * Observable raised when entering VR has completed.
  55273. */
  55274. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  55275. /**
  55276. * Observable raised when exiting VR.
  55277. */
  55278. onExitingVRObservable: Observable<VRExperienceHelper>;
  55279. /**
  55280. * Observable raised when controller mesh is loaded.
  55281. */
  55282. onControllerMeshLoadedObservable: Observable<WebVRController>;
  55283. /** Return this.onEnteringVRObservable
  55284. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  55285. */
  55286. get onEnteringVR(): Observable<VRExperienceHelper>;
  55287. /** Return this.onExitingVRObservable
  55288. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  55289. */
  55290. get onExitingVR(): Observable<VRExperienceHelper>;
  55291. /** Return this.onControllerMeshLoadedObservable
  55292. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  55293. */
  55294. get onControllerMeshLoaded(): Observable<WebVRController>;
  55295. private _rayLength;
  55296. private _useCustomVRButton;
  55297. private _teleportationRequested;
  55298. private _teleportActive;
  55299. private _floorMeshName;
  55300. private _floorMeshesCollection;
  55301. private _teleportationMode;
  55302. private _teleportationTime;
  55303. private _teleportationSpeed;
  55304. private _teleportationEasing;
  55305. private _rotationAllowed;
  55306. private _teleportBackwardsVector;
  55307. private _teleportationTarget;
  55308. private _isDefaultTeleportationTarget;
  55309. private _postProcessMove;
  55310. private _teleportationFillColor;
  55311. private _teleportationBorderColor;
  55312. private _rotationAngle;
  55313. private _haloCenter;
  55314. private _cameraGazer;
  55315. private _padSensibilityUp;
  55316. private _padSensibilityDown;
  55317. private _leftController;
  55318. private _rightController;
  55319. private _gazeColor;
  55320. private _laserColor;
  55321. private _pickedLaserColor;
  55322. private _pickedGazeColor;
  55323. /**
  55324. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  55325. */
  55326. onNewMeshSelected: Observable<AbstractMesh>;
  55327. /**
  55328. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  55329. * This observable will provide the mesh and the controller used to select the mesh
  55330. */
  55331. onMeshSelectedWithController: Observable<{
  55332. mesh: AbstractMesh;
  55333. controller: WebVRController;
  55334. }>;
  55335. /**
  55336. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  55337. */
  55338. onNewMeshPicked: Observable<PickingInfo>;
  55339. private _circleEase;
  55340. /**
  55341. * Observable raised before camera teleportation
  55342. */
  55343. onBeforeCameraTeleport: Observable<Vector3>;
  55344. /**
  55345. * Observable raised after camera teleportation
  55346. */
  55347. onAfterCameraTeleport: Observable<Vector3>;
  55348. /**
  55349. * Observable raised when current selected mesh gets unselected
  55350. */
  55351. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55352. private _raySelectionPredicate;
  55353. /**
  55354. * To be optionaly changed by user to define custom ray selection
  55355. */
  55356. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55357. /**
  55358. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55359. */
  55360. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55361. /**
  55362. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55363. */
  55364. teleportationEnabled: boolean;
  55365. private _defaultHeight;
  55366. private _teleportationInitialized;
  55367. private _interactionsEnabled;
  55368. private _interactionsRequested;
  55369. private _displayGaze;
  55370. private _displayLaserPointer;
  55371. /**
  55372. * The mesh used to display where the user is going to teleport.
  55373. */
  55374. get teleportationTarget(): Mesh;
  55375. /**
  55376. * Sets the mesh to be used to display where the user is going to teleport.
  55377. */
  55378. set teleportationTarget(value: Mesh);
  55379. /**
  55380. * 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
  55381. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55382. * See https://doc.babylonjs.com/resources/baking_transformations
  55383. */
  55384. get gazeTrackerMesh(): Mesh;
  55385. set gazeTrackerMesh(value: Mesh);
  55386. /**
  55387. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55388. */
  55389. updateGazeTrackerScale: boolean;
  55390. /**
  55391. * If the gaze trackers color should be updated when selecting meshes
  55392. */
  55393. updateGazeTrackerColor: boolean;
  55394. /**
  55395. * If the controller laser color should be updated when selecting meshes
  55396. */
  55397. updateControllerLaserColor: boolean;
  55398. /**
  55399. * The gaze tracking mesh corresponding to the left controller
  55400. */
  55401. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55402. /**
  55403. * The gaze tracking mesh corresponding to the right controller
  55404. */
  55405. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55406. /**
  55407. * If the ray of the gaze should be displayed.
  55408. */
  55409. get displayGaze(): boolean;
  55410. /**
  55411. * Sets if the ray of the gaze should be displayed.
  55412. */
  55413. set displayGaze(value: boolean);
  55414. /**
  55415. * If the ray of the LaserPointer should be displayed.
  55416. */
  55417. get displayLaserPointer(): boolean;
  55418. /**
  55419. * Sets if the ray of the LaserPointer should be displayed.
  55420. */
  55421. set displayLaserPointer(value: boolean);
  55422. /**
  55423. * The deviceOrientationCamera used as the camera when not in VR.
  55424. */
  55425. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55426. /**
  55427. * Based on the current WebVR support, returns the current VR camera used.
  55428. */
  55429. get currentVRCamera(): Nullable<Camera>;
  55430. /**
  55431. * The webVRCamera which is used when in VR.
  55432. */
  55433. get webVRCamera(): WebVRFreeCamera;
  55434. /**
  55435. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55436. */
  55437. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55438. /**
  55439. * The html button that is used to trigger entering into VR.
  55440. */
  55441. get vrButton(): Nullable<HTMLButtonElement>;
  55442. private get _teleportationRequestInitiated();
  55443. /**
  55444. * Defines whether or not Pointer lock should be requested when switching to
  55445. * full screen.
  55446. */
  55447. requestPointerLockOnFullScreen: boolean;
  55448. /**
  55449. * If asking to force XR, this will be populated with the default xr experience
  55450. */
  55451. xr: WebXRDefaultExperience;
  55452. /**
  55453. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55454. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55455. */
  55456. xrTestDone: boolean;
  55457. /**
  55458. * Instantiates a VRExperienceHelper.
  55459. * Helps to quickly add VR support to an existing scene.
  55460. * @param scene The scene the VRExperienceHelper belongs to.
  55461. * @param webVROptions Options to modify the vr experience helper's behavior.
  55462. */
  55463. constructor(scene: Scene,
  55464. /** Options to modify the vr experience helper's behavior. */
  55465. webVROptions?: VRExperienceHelperOptions);
  55466. private completeVRInit;
  55467. private _onDefaultMeshLoaded;
  55468. private _onResize;
  55469. private _onFullscreenChange;
  55470. /**
  55471. * Gets a value indicating if we are currently in VR mode.
  55472. */
  55473. get isInVRMode(): boolean;
  55474. private onVrDisplayPresentChange;
  55475. private onVRDisplayChanged;
  55476. private moveButtonToBottomRight;
  55477. private displayVRButton;
  55478. private updateButtonVisibility;
  55479. private _cachedAngularSensibility;
  55480. /**
  55481. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55482. * Otherwise, will use the fullscreen API.
  55483. */
  55484. enterVR(): void;
  55485. /**
  55486. * Attempt to exit VR, or fullscreen.
  55487. */
  55488. exitVR(): void;
  55489. /**
  55490. * The position of the vr experience helper.
  55491. */
  55492. get position(): Vector3;
  55493. /**
  55494. * Sets the position of the vr experience helper.
  55495. */
  55496. set position(value: Vector3);
  55497. /**
  55498. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55499. */
  55500. enableInteractions(): void;
  55501. private get _noControllerIsActive();
  55502. private beforeRender;
  55503. private _isTeleportationFloor;
  55504. /**
  55505. * Adds a floor mesh to be used for teleportation.
  55506. * @param floorMesh the mesh to be used for teleportation.
  55507. */
  55508. addFloorMesh(floorMesh: Mesh): void;
  55509. /**
  55510. * Removes a floor mesh from being used for teleportation.
  55511. * @param floorMesh the mesh to be removed.
  55512. */
  55513. removeFloorMesh(floorMesh: Mesh): void;
  55514. /**
  55515. * Enables interactions and teleportation using the VR controllers and gaze.
  55516. * @param vrTeleportationOptions options to modify teleportation behavior.
  55517. */
  55518. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55519. private _onNewGamepadConnected;
  55520. private _tryEnableInteractionOnController;
  55521. private _onNewGamepadDisconnected;
  55522. private _enableInteractionOnController;
  55523. private _checkTeleportWithRay;
  55524. private _checkRotate;
  55525. private _checkTeleportBackwards;
  55526. private _enableTeleportationOnController;
  55527. private _createTeleportationCircles;
  55528. private _displayTeleportationTarget;
  55529. private _hideTeleportationTarget;
  55530. private _rotateCamera;
  55531. private _moveTeleportationSelectorTo;
  55532. private _workingVector;
  55533. private _workingQuaternion;
  55534. private _workingMatrix;
  55535. /**
  55536. * Time Constant Teleportation Mode
  55537. */
  55538. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55539. /**
  55540. * Speed Constant Teleportation Mode
  55541. */
  55542. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55543. /**
  55544. * Teleports the users feet to the desired location
  55545. * @param location The location where the user's feet should be placed
  55546. */
  55547. teleportCamera(location: Vector3): void;
  55548. private _convertNormalToDirectionOfRay;
  55549. private _castRayAndSelectObject;
  55550. private _notifySelectedMeshUnselected;
  55551. /**
  55552. * Permanently set new colors for the laser pointer
  55553. * @param color the new laser color
  55554. * @param pickedColor the new laser color when picked mesh detected
  55555. */
  55556. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55557. /**
  55558. * Set lighting enabled / disabled on the laser pointer of both controllers
  55559. * @param enabled should the lighting be enabled on the laser pointer
  55560. */
  55561. setLaserLightingState(enabled?: boolean): void;
  55562. /**
  55563. * Permanently set new colors for the gaze pointer
  55564. * @param color the new gaze color
  55565. * @param pickedColor the new gaze color when picked mesh detected
  55566. */
  55567. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55568. /**
  55569. * Sets the color of the laser ray from the vr controllers.
  55570. * @param color new color for the ray.
  55571. */
  55572. changeLaserColor(color: Color3): void;
  55573. /**
  55574. * Sets the color of the ray from the vr headsets gaze.
  55575. * @param color new color for the ray.
  55576. */
  55577. changeGazeColor(color: Color3): void;
  55578. /**
  55579. * Exits VR and disposes of the vr experience helper
  55580. */
  55581. dispose(): void;
  55582. /**
  55583. * Gets the name of the VRExperienceHelper class
  55584. * @returns "VRExperienceHelper"
  55585. */
  55586. getClassName(): string;
  55587. }
  55588. }
  55589. declare module "babylonjs/Cameras/VR/index" {
  55590. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55591. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55592. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55593. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55594. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55595. export * from "babylonjs/Cameras/VR/webVRCamera";
  55596. }
  55597. declare module "babylonjs/Cameras/RigModes/index" {
  55598. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55599. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55600. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55601. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55602. }
  55603. declare module "babylonjs/Cameras/index" {
  55604. export * from "babylonjs/Cameras/Inputs/index";
  55605. export * from "babylonjs/Cameras/cameraInputsManager";
  55606. export * from "babylonjs/Cameras/camera";
  55607. export * from "babylonjs/Cameras/targetCamera";
  55608. export * from "babylonjs/Cameras/freeCamera";
  55609. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55610. export * from "babylonjs/Cameras/touchCamera";
  55611. export * from "babylonjs/Cameras/arcRotateCamera";
  55612. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55613. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55614. export * from "babylonjs/Cameras/flyCamera";
  55615. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55616. export * from "babylonjs/Cameras/followCamera";
  55617. export * from "babylonjs/Cameras/followCameraInputsManager";
  55618. export * from "babylonjs/Cameras/gamepadCamera";
  55619. export * from "babylonjs/Cameras/Stereoscopic/index";
  55620. export * from "babylonjs/Cameras/universalCamera";
  55621. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55622. export * from "babylonjs/Cameras/VR/index";
  55623. export * from "babylonjs/Cameras/RigModes/index";
  55624. }
  55625. declare module "babylonjs/Collisions/index" {
  55626. export * from "babylonjs/Collisions/collider";
  55627. export * from "babylonjs/Collisions/collisionCoordinator";
  55628. export * from "babylonjs/Collisions/pickingInfo";
  55629. export * from "babylonjs/Collisions/intersectionInfo";
  55630. export * from "babylonjs/Collisions/meshCollisionData";
  55631. }
  55632. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55633. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55634. import { Vector3 } from "babylonjs/Maths/math.vector";
  55635. import { Ray } from "babylonjs/Culling/ray";
  55636. import { Plane } from "babylonjs/Maths/math.plane";
  55637. /**
  55638. * Contains an array of blocks representing the octree
  55639. */
  55640. export interface IOctreeContainer<T> {
  55641. /**
  55642. * Blocks within the octree
  55643. */
  55644. blocks: Array<OctreeBlock<T>>;
  55645. }
  55646. /**
  55647. * Class used to store a cell in an octree
  55648. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55649. */
  55650. export class OctreeBlock<T> {
  55651. /**
  55652. * Gets the content of the current block
  55653. */
  55654. entries: T[];
  55655. /**
  55656. * Gets the list of block children
  55657. */
  55658. blocks: Array<OctreeBlock<T>>;
  55659. private _depth;
  55660. private _maxDepth;
  55661. private _capacity;
  55662. private _minPoint;
  55663. private _maxPoint;
  55664. private _boundingVectors;
  55665. private _creationFunc;
  55666. /**
  55667. * Creates a new block
  55668. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55669. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55670. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55671. * @param depth defines the current depth of this block in the octree
  55672. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55673. * @param creationFunc defines a callback to call when an element is added to the block
  55674. */
  55675. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55676. /**
  55677. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55678. */
  55679. get capacity(): number;
  55680. /**
  55681. * Gets the minimum vector (in world space) of the block's bounding box
  55682. */
  55683. get minPoint(): Vector3;
  55684. /**
  55685. * Gets the maximum vector (in world space) of the block's bounding box
  55686. */
  55687. get maxPoint(): Vector3;
  55688. /**
  55689. * Add a new element to this block
  55690. * @param entry defines the element to add
  55691. */
  55692. addEntry(entry: T): void;
  55693. /**
  55694. * Remove an element from this block
  55695. * @param entry defines the element to remove
  55696. */
  55697. removeEntry(entry: T): void;
  55698. /**
  55699. * Add an array of elements to this block
  55700. * @param entries defines the array of elements to add
  55701. */
  55702. addEntries(entries: T[]): void;
  55703. /**
  55704. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55705. * @param frustumPlanes defines the frustum planes to test
  55706. * @param selection defines the array to store current content if selection is positive
  55707. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55708. */
  55709. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55710. /**
  55711. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55712. * @param sphereCenter defines the bounding sphere center
  55713. * @param sphereRadius defines the bounding sphere radius
  55714. * @param selection defines the array to store current content if selection is positive
  55715. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55716. */
  55717. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55718. /**
  55719. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55720. * @param ray defines the ray to test with
  55721. * @param selection defines the array to store current content if selection is positive
  55722. */
  55723. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55724. /**
  55725. * Subdivide the content into child blocks (this block will then be empty)
  55726. */
  55727. createInnerBlocks(): void;
  55728. /**
  55729. * @hidden
  55730. */
  55731. 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;
  55732. }
  55733. }
  55734. declare module "babylonjs/Culling/Octrees/octree" {
  55735. import { SmartArray } from "babylonjs/Misc/smartArray";
  55736. import { Vector3 } from "babylonjs/Maths/math.vector";
  55737. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55739. import { Ray } from "babylonjs/Culling/ray";
  55740. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55741. import { Plane } from "babylonjs/Maths/math.plane";
  55742. /**
  55743. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  55744. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55745. */
  55746. export class Octree<T> {
  55747. /** 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.) */
  55748. maxDepth: number;
  55749. /**
  55750. * Blocks within the octree containing objects
  55751. */
  55752. blocks: Array<OctreeBlock<T>>;
  55753. /**
  55754. * Content stored in the octree
  55755. */
  55756. dynamicContent: T[];
  55757. private _maxBlockCapacity;
  55758. private _selectionContent;
  55759. private _creationFunc;
  55760. /**
  55761. * Creates a octree
  55762. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55763. * @param creationFunc function to be used to instatiate the octree
  55764. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  55765. * @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.)
  55766. */
  55767. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  55768. /** 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.) */
  55769. maxDepth?: number);
  55770. /**
  55771. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  55772. * @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);
  55773. * @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);
  55774. * @param entries meshes to be added to the octree blocks
  55775. */
  55776. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  55777. /**
  55778. * Adds a mesh to the octree
  55779. * @param entry Mesh to add to the octree
  55780. */
  55781. addMesh(entry: T): void;
  55782. /**
  55783. * Remove an element from the octree
  55784. * @param entry defines the element to remove
  55785. */
  55786. removeMesh(entry: T): void;
  55787. /**
  55788. * Selects an array of meshes within the frustum
  55789. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  55790. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  55791. * @returns array of meshes within the frustum
  55792. */
  55793. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  55794. /**
  55795. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  55796. * @param sphereCenter defines the bounding sphere center
  55797. * @param sphereRadius defines the bounding sphere radius
  55798. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55799. * @returns an array of objects that intersect the sphere
  55800. */
  55801. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  55802. /**
  55803. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  55804. * @param ray defines the ray to test with
  55805. * @returns array of intersected objects
  55806. */
  55807. intersectsRay(ray: Ray): SmartArray<T>;
  55808. /**
  55809. * Adds a mesh into the octree block if it intersects the block
  55810. */
  55811. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  55812. /**
  55813. * Adds a submesh into the octree block if it intersects the block
  55814. */
  55815. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  55816. }
  55817. }
  55818. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  55819. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  55820. import { Scene } from "babylonjs/scene";
  55821. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55823. import { Ray } from "babylonjs/Culling/ray";
  55824. import { Octree } from "babylonjs/Culling/Octrees/octree";
  55825. import { Collider } from "babylonjs/Collisions/collider";
  55826. module "babylonjs/scene" {
  55827. interface Scene {
  55828. /**
  55829. * @hidden
  55830. * Backing Filed
  55831. */
  55832. _selectionOctree: Octree<AbstractMesh>;
  55833. /**
  55834. * Gets the octree used to boost mesh selection (picking)
  55835. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55836. */
  55837. selectionOctree: Octree<AbstractMesh>;
  55838. /**
  55839. * Creates or updates the octree used to boost selection (picking)
  55840. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55841. * @param maxCapacity defines the maximum capacity per leaf
  55842. * @param maxDepth defines the maximum depth of the octree
  55843. * @returns an octree of AbstractMesh
  55844. */
  55845. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  55846. }
  55847. }
  55848. module "babylonjs/Meshes/abstractMesh" {
  55849. interface AbstractMesh {
  55850. /**
  55851. * @hidden
  55852. * Backing Field
  55853. */
  55854. _submeshesOctree: Octree<SubMesh>;
  55855. /**
  55856. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  55857. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  55858. * @param maxCapacity defines the maximum size of each block (64 by default)
  55859. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  55860. * @returns the new octree
  55861. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  55862. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55863. */
  55864. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  55865. }
  55866. }
  55867. /**
  55868. * Defines the octree scene component responsible to manage any octrees
  55869. * in a given scene.
  55870. */
  55871. export class OctreeSceneComponent {
  55872. /**
  55873. * The component name help to identify the component in the list of scene components.
  55874. */
  55875. readonly name: string;
  55876. /**
  55877. * The scene the component belongs to.
  55878. */
  55879. scene: Scene;
  55880. /**
  55881. * Indicates if the meshes have been checked to make sure they are isEnabled()
  55882. */
  55883. readonly checksIsEnabled: boolean;
  55884. /**
  55885. * Creates a new instance of the component for the given scene
  55886. * @param scene Defines the scene to register the component in
  55887. */
  55888. constructor(scene: Scene);
  55889. /**
  55890. * Registers the component in a given scene
  55891. */
  55892. register(): void;
  55893. /**
  55894. * Return the list of active meshes
  55895. * @returns the list of active meshes
  55896. */
  55897. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  55898. /**
  55899. * Return the list of active sub meshes
  55900. * @param mesh The mesh to get the candidates sub meshes from
  55901. * @returns the list of active sub meshes
  55902. */
  55903. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  55904. private _tempRay;
  55905. /**
  55906. * Return the list of sub meshes intersecting with a given local ray
  55907. * @param mesh defines the mesh to find the submesh for
  55908. * @param localRay defines the ray in local space
  55909. * @returns the list of intersecting sub meshes
  55910. */
  55911. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  55912. /**
  55913. * Return the list of sub meshes colliding with a collider
  55914. * @param mesh defines the mesh to find the submesh for
  55915. * @param collider defines the collider to evaluate the collision against
  55916. * @returns the list of colliding sub meshes
  55917. */
  55918. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  55919. /**
  55920. * Rebuilds the elements related to this component in case of
  55921. * context lost for instance.
  55922. */
  55923. rebuild(): void;
  55924. /**
  55925. * Disposes the component and the associated ressources.
  55926. */
  55927. dispose(): void;
  55928. }
  55929. }
  55930. declare module "babylonjs/Culling/Octrees/index" {
  55931. export * from "babylonjs/Culling/Octrees/octree";
  55932. export * from "babylonjs/Culling/Octrees/octreeBlock";
  55933. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  55934. }
  55935. declare module "babylonjs/Culling/index" {
  55936. export * from "babylonjs/Culling/boundingBox";
  55937. export * from "babylonjs/Culling/boundingInfo";
  55938. export * from "babylonjs/Culling/boundingSphere";
  55939. export * from "babylonjs/Culling/Octrees/index";
  55940. export * from "babylonjs/Culling/ray";
  55941. }
  55942. declare module "babylonjs/Gizmos/gizmo" {
  55943. import { Nullable } from "babylonjs/types";
  55944. import { IDisposable } from "babylonjs/scene";
  55945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55946. import { Mesh } from "babylonjs/Meshes/mesh";
  55947. import { Node } from "babylonjs/node";
  55948. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55949. /**
  55950. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  55951. */
  55952. export class Gizmo implements IDisposable {
  55953. /** The utility layer the gizmo will be added to */
  55954. gizmoLayer: UtilityLayerRenderer;
  55955. /**
  55956. * The root mesh of the gizmo
  55957. */
  55958. _rootMesh: Mesh;
  55959. private _attachedMesh;
  55960. private _attachedNode;
  55961. /**
  55962. * Ratio for the scale of the gizmo (Default: 1)
  55963. */
  55964. protected _scaleRatio: number;
  55965. /**
  55966. * boolean updated by pointermove when a gizmo mesh is hovered
  55967. */
  55968. protected _isHovered: boolean;
  55969. /**
  55970. * Ratio for the scale of the gizmo (Default: 1)
  55971. */
  55972. set scaleRatio(value: number);
  55973. get scaleRatio(): number;
  55974. /**
  55975. * True when the mouse pointer is hovered a gizmo mesh
  55976. */
  55977. get isHovered(): boolean;
  55978. /**
  55979. * If a custom mesh has been set (Default: false)
  55980. */
  55981. protected _customMeshSet: boolean;
  55982. /**
  55983. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  55984. * * When set, interactions will be enabled
  55985. */
  55986. get attachedMesh(): Nullable<AbstractMesh>;
  55987. set attachedMesh(value: Nullable<AbstractMesh>);
  55988. /**
  55989. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  55990. * * When set, interactions will be enabled
  55991. */
  55992. get attachedNode(): Nullable<Node>;
  55993. set attachedNode(value: Nullable<Node>);
  55994. /**
  55995. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55996. * @param mesh The mesh to replace the default mesh of the gizmo
  55997. */
  55998. setCustomMesh(mesh: Mesh): void;
  55999. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  56000. /**
  56001. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  56002. */
  56003. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56004. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56005. /**
  56006. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  56007. */
  56008. updateGizmoPositionToMatchAttachedMesh: boolean;
  56009. /**
  56010. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  56011. */
  56012. updateScale: boolean;
  56013. protected _interactionsEnabled: boolean;
  56014. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56015. private _beforeRenderObserver;
  56016. private _tempQuaternion;
  56017. private _tempVector;
  56018. private _tempVector2;
  56019. private _tempMatrix1;
  56020. private _tempMatrix2;
  56021. private _rightHandtoLeftHandMatrix;
  56022. /**
  56023. * Creates a gizmo
  56024. * @param gizmoLayer The utility layer the gizmo will be added to
  56025. */
  56026. constructor(
  56027. /** The utility layer the gizmo will be added to */
  56028. gizmoLayer?: UtilityLayerRenderer);
  56029. /**
  56030. * Updates the gizmo to match the attached mesh's position/rotation
  56031. */
  56032. protected _update(): void;
  56033. /**
  56034. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  56035. * @param value Node, TransformNode or mesh
  56036. */
  56037. protected _matrixChanged(): void;
  56038. /**
  56039. * Disposes of the gizmo
  56040. */
  56041. dispose(): void;
  56042. }
  56043. }
  56044. declare module "babylonjs/Gizmos/planeDragGizmo" {
  56045. import { Observable } from "babylonjs/Misc/observable";
  56046. import { Nullable } from "babylonjs/types";
  56047. import { Vector3 } from "babylonjs/Maths/math.vector";
  56048. import { Color3 } from "babylonjs/Maths/math.color";
  56049. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56050. import { Node } from "babylonjs/node";
  56051. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56052. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56053. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56054. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56055. import { Scene } from "babylonjs/scene";
  56056. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56057. /**
  56058. * Single plane drag gizmo
  56059. */
  56060. export class PlaneDragGizmo extends Gizmo {
  56061. /**
  56062. * Drag behavior responsible for the gizmos dragging interactions
  56063. */
  56064. dragBehavior: PointerDragBehavior;
  56065. private _pointerObserver;
  56066. /**
  56067. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56068. */
  56069. snapDistance: number;
  56070. /**
  56071. * Event that fires each time the gizmo snaps to a new location.
  56072. * * snapDistance is the the change in distance
  56073. */
  56074. onSnapObservable: Observable<{
  56075. snapDistance: number;
  56076. }>;
  56077. private _plane;
  56078. private _coloredMaterial;
  56079. private _hoverMaterial;
  56080. private _isEnabled;
  56081. private _parent;
  56082. /** @hidden */
  56083. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  56084. /** @hidden */
  56085. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  56086. /**
  56087. * Creates a PlaneDragGizmo
  56088. * @param gizmoLayer The utility layer the gizmo will be added to
  56089. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  56090. * @param color The color of the gizmo
  56091. */
  56092. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  56093. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56094. /**
  56095. * If the gizmo is enabled
  56096. */
  56097. set isEnabled(value: boolean);
  56098. get isEnabled(): boolean;
  56099. /**
  56100. * Disposes of the gizmo
  56101. */
  56102. dispose(): void;
  56103. }
  56104. }
  56105. declare module "babylonjs/Gizmos/positionGizmo" {
  56106. import { Observable } from "babylonjs/Misc/observable";
  56107. import { Nullable } from "babylonjs/types";
  56108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56109. import { Node } from "babylonjs/node";
  56110. import { Mesh } from "babylonjs/Meshes/mesh";
  56111. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56112. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  56113. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  56114. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56115. /**
  56116. * Gizmo that enables dragging a mesh along 3 axis
  56117. */
  56118. export class PositionGizmo extends Gizmo {
  56119. /**
  56120. * Internal gizmo used for interactions on the x axis
  56121. */
  56122. xGizmo: AxisDragGizmo;
  56123. /**
  56124. * Internal gizmo used for interactions on the y axis
  56125. */
  56126. yGizmo: AxisDragGizmo;
  56127. /**
  56128. * Internal gizmo used for interactions on the z axis
  56129. */
  56130. zGizmo: AxisDragGizmo;
  56131. /**
  56132. * Internal gizmo used for interactions on the yz plane
  56133. */
  56134. xPlaneGizmo: PlaneDragGizmo;
  56135. /**
  56136. * Internal gizmo used for interactions on the xz plane
  56137. */
  56138. yPlaneGizmo: PlaneDragGizmo;
  56139. /**
  56140. * Internal gizmo used for interactions on the xy plane
  56141. */
  56142. zPlaneGizmo: PlaneDragGizmo;
  56143. /**
  56144. * private variables
  56145. */
  56146. private _meshAttached;
  56147. private _nodeAttached;
  56148. private _snapDistance;
  56149. /** Fires an event when any of it's sub gizmos are dragged */
  56150. onDragStartObservable: Observable<unknown>;
  56151. /** Fires an event when any of it's sub gizmos are released from dragging */
  56152. onDragEndObservable: Observable<unknown>;
  56153. /**
  56154. * If set to true, planar drag is enabled
  56155. */
  56156. private _planarGizmoEnabled;
  56157. get attachedMesh(): Nullable<AbstractMesh>;
  56158. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56159. get attachedNode(): Nullable<Node>;
  56160. set attachedNode(node: Nullable<Node>);
  56161. /**
  56162. * True when the mouse pointer is hovering a gizmo mesh
  56163. */
  56164. get isHovered(): boolean;
  56165. /**
  56166. * Creates a PositionGizmo
  56167. * @param gizmoLayer The utility layer the gizmo will be added to
  56168. @param thickness display gizmo axis thickness
  56169. */
  56170. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56171. /**
  56172. * If the planar drag gizmo is enabled
  56173. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  56174. */
  56175. set planarGizmoEnabled(value: boolean);
  56176. get planarGizmoEnabled(): boolean;
  56177. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56178. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56179. /**
  56180. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56181. */
  56182. set snapDistance(value: number);
  56183. get snapDistance(): number;
  56184. /**
  56185. * Ratio for the scale of the gizmo (Default: 1)
  56186. */
  56187. set scaleRatio(value: number);
  56188. get scaleRatio(): number;
  56189. /**
  56190. * Disposes of the gizmo
  56191. */
  56192. dispose(): void;
  56193. /**
  56194. * CustomMeshes are not supported by this gizmo
  56195. * @param mesh The mesh to replace the default mesh of the gizmo
  56196. */
  56197. setCustomMesh(mesh: Mesh): void;
  56198. }
  56199. }
  56200. declare module "babylonjs/Gizmos/axisDragGizmo" {
  56201. import { Observable } from "babylonjs/Misc/observable";
  56202. import { Nullable } from "babylonjs/types";
  56203. import { Vector3 } from "babylonjs/Maths/math.vector";
  56204. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56205. import { Node } from "babylonjs/node";
  56206. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56207. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56208. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56209. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56210. import { Scene } from "babylonjs/scene";
  56211. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56212. import { Color3 } from "babylonjs/Maths/math.color";
  56213. /**
  56214. * Single axis drag gizmo
  56215. */
  56216. export class AxisDragGizmo extends Gizmo {
  56217. /**
  56218. * Drag behavior responsible for the gizmos dragging interactions
  56219. */
  56220. dragBehavior: PointerDragBehavior;
  56221. private _pointerObserver;
  56222. /**
  56223. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56224. */
  56225. snapDistance: number;
  56226. /**
  56227. * Event that fires each time the gizmo snaps to a new location.
  56228. * * snapDistance is the the change in distance
  56229. */
  56230. onSnapObservable: Observable<{
  56231. snapDistance: number;
  56232. }>;
  56233. private _isEnabled;
  56234. private _parent;
  56235. private _arrow;
  56236. private _coloredMaterial;
  56237. private _hoverMaterial;
  56238. /** @hidden */
  56239. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  56240. /** @hidden */
  56241. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  56242. /**
  56243. * Creates an AxisDragGizmo
  56244. * @param gizmoLayer The utility layer the gizmo will be added to
  56245. * @param dragAxis The axis which the gizmo will be able to drag on
  56246. * @param color The color of the gizmo
  56247. * @param thickness display gizmo axis thickness
  56248. */
  56249. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  56250. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56251. /**
  56252. * If the gizmo is enabled
  56253. */
  56254. set isEnabled(value: boolean);
  56255. get isEnabled(): boolean;
  56256. /**
  56257. * Disposes of the gizmo
  56258. */
  56259. dispose(): void;
  56260. }
  56261. }
  56262. declare module "babylonjs/Debug/axesViewer" {
  56263. import { Vector3 } from "babylonjs/Maths/math.vector";
  56264. import { Nullable } from "babylonjs/types";
  56265. import { Scene } from "babylonjs/scene";
  56266. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56267. /**
  56268. * The Axes viewer will show 3 axes in a specific point in space
  56269. */
  56270. export class AxesViewer {
  56271. private _xAxis;
  56272. private _yAxis;
  56273. private _zAxis;
  56274. private _scaleLinesFactor;
  56275. private _instanced;
  56276. /**
  56277. * Gets the hosting scene
  56278. */
  56279. scene: Nullable<Scene>;
  56280. /**
  56281. * Gets or sets a number used to scale line length
  56282. */
  56283. scaleLines: number;
  56284. /** Gets the node hierarchy used to render x-axis */
  56285. get xAxis(): TransformNode;
  56286. /** Gets the node hierarchy used to render y-axis */
  56287. get yAxis(): TransformNode;
  56288. /** Gets the node hierarchy used to render z-axis */
  56289. get zAxis(): TransformNode;
  56290. /**
  56291. * Creates a new AxesViewer
  56292. * @param scene defines the hosting scene
  56293. * @param scaleLines defines a number used to scale line length (1 by default)
  56294. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  56295. * @param xAxis defines the node hierarchy used to render the x-axis
  56296. * @param yAxis defines the node hierarchy used to render the y-axis
  56297. * @param zAxis defines the node hierarchy used to render the z-axis
  56298. */
  56299. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  56300. /**
  56301. * Force the viewer to update
  56302. * @param position defines the position of the viewer
  56303. * @param xaxis defines the x axis of the viewer
  56304. * @param yaxis defines the y axis of the viewer
  56305. * @param zaxis defines the z axis of the viewer
  56306. */
  56307. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  56308. /**
  56309. * Creates an instance of this axes viewer.
  56310. * @returns a new axes viewer with instanced meshes
  56311. */
  56312. createInstance(): AxesViewer;
  56313. /** Releases resources */
  56314. dispose(): void;
  56315. private static _SetRenderingGroupId;
  56316. }
  56317. }
  56318. declare module "babylonjs/Debug/boneAxesViewer" {
  56319. import { Nullable } from "babylonjs/types";
  56320. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  56321. import { Vector3 } from "babylonjs/Maths/math.vector";
  56322. import { Mesh } from "babylonjs/Meshes/mesh";
  56323. import { Bone } from "babylonjs/Bones/bone";
  56324. import { Scene } from "babylonjs/scene";
  56325. /**
  56326. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  56327. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  56328. */
  56329. export class BoneAxesViewer extends AxesViewer {
  56330. /**
  56331. * Gets or sets the target mesh where to display the axes viewer
  56332. */
  56333. mesh: Nullable<Mesh>;
  56334. /**
  56335. * Gets or sets the target bone where to display the axes viewer
  56336. */
  56337. bone: Nullable<Bone>;
  56338. /** Gets current position */
  56339. pos: Vector3;
  56340. /** Gets direction of X axis */
  56341. xaxis: Vector3;
  56342. /** Gets direction of Y axis */
  56343. yaxis: Vector3;
  56344. /** Gets direction of Z axis */
  56345. zaxis: Vector3;
  56346. /**
  56347. * Creates a new BoneAxesViewer
  56348. * @param scene defines the hosting scene
  56349. * @param bone defines the target bone
  56350. * @param mesh defines the target mesh
  56351. * @param scaleLines defines a scaling factor for line length (1 by default)
  56352. */
  56353. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  56354. /**
  56355. * Force the viewer to update
  56356. */
  56357. update(): void;
  56358. /** Releases resources */
  56359. dispose(): void;
  56360. }
  56361. }
  56362. declare module "babylonjs/Debug/debugLayer" {
  56363. import { Scene } from "babylonjs/scene";
  56364. /**
  56365. * Interface used to define scene explorer extensibility option
  56366. */
  56367. export interface IExplorerExtensibilityOption {
  56368. /**
  56369. * Define the option label
  56370. */
  56371. label: string;
  56372. /**
  56373. * Defines the action to execute on click
  56374. */
  56375. action: (entity: any) => void;
  56376. }
  56377. /**
  56378. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  56379. */
  56380. export interface IExplorerExtensibilityGroup {
  56381. /**
  56382. * Defines a predicate to test if a given type mut be extended
  56383. */
  56384. predicate: (entity: any) => boolean;
  56385. /**
  56386. * Gets the list of options added to a type
  56387. */
  56388. entries: IExplorerExtensibilityOption[];
  56389. }
  56390. /**
  56391. * Interface used to define the options to use to create the Inspector
  56392. */
  56393. export interface IInspectorOptions {
  56394. /**
  56395. * Display in overlay mode (default: false)
  56396. */
  56397. overlay?: boolean;
  56398. /**
  56399. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  56400. */
  56401. globalRoot?: HTMLElement;
  56402. /**
  56403. * Display the Scene explorer
  56404. */
  56405. showExplorer?: boolean;
  56406. /**
  56407. * Display the property inspector
  56408. */
  56409. showInspector?: boolean;
  56410. /**
  56411. * Display in embed mode (both panes on the right)
  56412. */
  56413. embedMode?: boolean;
  56414. /**
  56415. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  56416. */
  56417. handleResize?: boolean;
  56418. /**
  56419. * Allow the panes to popup (default: true)
  56420. */
  56421. enablePopup?: boolean;
  56422. /**
  56423. * Allow the panes to be closed by users (default: true)
  56424. */
  56425. enableClose?: boolean;
  56426. /**
  56427. * Optional list of extensibility entries
  56428. */
  56429. explorerExtensibility?: IExplorerExtensibilityGroup[];
  56430. /**
  56431. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  56432. */
  56433. inspectorURL?: string;
  56434. /**
  56435. * Optional initial tab (default to DebugLayerTab.Properties)
  56436. */
  56437. initialTab?: DebugLayerTab;
  56438. }
  56439. module "babylonjs/scene" {
  56440. interface Scene {
  56441. /**
  56442. * @hidden
  56443. * Backing field
  56444. */
  56445. _debugLayer: DebugLayer;
  56446. /**
  56447. * Gets the debug layer (aka Inspector) associated with the scene
  56448. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56449. */
  56450. debugLayer: DebugLayer;
  56451. }
  56452. }
  56453. /**
  56454. * Enum of inspector action tab
  56455. */
  56456. export enum DebugLayerTab {
  56457. /**
  56458. * Properties tag (default)
  56459. */
  56460. Properties = 0,
  56461. /**
  56462. * Debug tab
  56463. */
  56464. Debug = 1,
  56465. /**
  56466. * Statistics tab
  56467. */
  56468. Statistics = 2,
  56469. /**
  56470. * Tools tab
  56471. */
  56472. Tools = 3,
  56473. /**
  56474. * Settings tab
  56475. */
  56476. Settings = 4
  56477. }
  56478. /**
  56479. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56480. * what is happening in your scene
  56481. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56482. */
  56483. export class DebugLayer {
  56484. /**
  56485. * Define the url to get the inspector script from.
  56486. * By default it uses the babylonjs CDN.
  56487. * @ignoreNaming
  56488. */
  56489. static InspectorURL: string;
  56490. private _scene;
  56491. private BJSINSPECTOR;
  56492. private _onPropertyChangedObservable?;
  56493. /**
  56494. * Observable triggered when a property is changed through the inspector.
  56495. */
  56496. get onPropertyChangedObservable(): any;
  56497. /**
  56498. * Instantiates a new debug layer.
  56499. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56500. * what is happening in your scene
  56501. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56502. * @param scene Defines the scene to inspect
  56503. */
  56504. constructor(scene: Scene);
  56505. /** Creates the inspector window. */
  56506. private _createInspector;
  56507. /**
  56508. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  56509. * @param entity defines the entity to select
  56510. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  56511. */
  56512. select(entity: any, lineContainerTitles?: string | string[]): void;
  56513. /** Get the inspector from bundle or global */
  56514. private _getGlobalInspector;
  56515. /**
  56516. * Get if the inspector is visible or not.
  56517. * @returns true if visible otherwise, false
  56518. */
  56519. isVisible(): boolean;
  56520. /**
  56521. * Hide the inspector and close its window.
  56522. */
  56523. hide(): void;
  56524. /**
  56525. * Update the scene in the inspector
  56526. */
  56527. setAsActiveScene(): void;
  56528. /**
  56529. * Launch the debugLayer.
  56530. * @param config Define the configuration of the inspector
  56531. * @return a promise fulfilled when the debug layer is visible
  56532. */
  56533. show(config?: IInspectorOptions): Promise<DebugLayer>;
  56534. }
  56535. }
  56536. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56537. import { Nullable } from "babylonjs/types";
  56538. import { Scene } from "babylonjs/scene";
  56539. import { Vector4 } from "babylonjs/Maths/math.vector";
  56540. import { Color4 } from "babylonjs/Maths/math.color";
  56541. import { Mesh } from "babylonjs/Meshes/mesh";
  56542. /**
  56543. * Class containing static functions to help procedurally build meshes
  56544. */
  56545. export class BoxBuilder {
  56546. /**
  56547. * Creates a box mesh
  56548. * * The parameter `size` sets the size (float) of each box side (default 1)
  56549. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56550. * * 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)
  56551. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56555. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56556. * @param name defines the name of the mesh
  56557. * @param options defines the options used to create the mesh
  56558. * @param scene defines the hosting scene
  56559. * @returns the box mesh
  56560. */
  56561. static CreateBox(name: string, options: {
  56562. size?: number;
  56563. width?: number;
  56564. height?: number;
  56565. depth?: number;
  56566. faceUV?: Vector4[];
  56567. faceColors?: Color4[];
  56568. sideOrientation?: number;
  56569. frontUVs?: Vector4;
  56570. backUVs?: Vector4;
  56571. wrap?: boolean;
  56572. topBaseAt?: number;
  56573. bottomBaseAt?: number;
  56574. updatable?: boolean;
  56575. }, scene?: Nullable<Scene>): Mesh;
  56576. }
  56577. }
  56578. declare module "babylonjs/Debug/physicsViewer" {
  56579. import { Nullable } from "babylonjs/types";
  56580. import { Scene } from "babylonjs/scene";
  56581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56582. import { Mesh } from "babylonjs/Meshes/mesh";
  56583. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56584. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56585. /**
  56586. * Used to show the physics impostor around the specific mesh
  56587. */
  56588. export class PhysicsViewer {
  56589. /** @hidden */
  56590. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  56591. /** @hidden */
  56592. protected _meshes: Array<Nullable<AbstractMesh>>;
  56593. /** @hidden */
  56594. protected _scene: Nullable<Scene>;
  56595. /** @hidden */
  56596. protected _numMeshes: number;
  56597. /** @hidden */
  56598. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  56599. private _renderFunction;
  56600. private _utilityLayer;
  56601. private _debugBoxMesh;
  56602. private _debugSphereMesh;
  56603. private _debugCylinderMesh;
  56604. private _debugMaterial;
  56605. private _debugMeshMeshes;
  56606. /**
  56607. * Creates a new PhysicsViewer
  56608. * @param scene defines the hosting scene
  56609. */
  56610. constructor(scene: Scene);
  56611. /** @hidden */
  56612. protected _updateDebugMeshes(): void;
  56613. /**
  56614. * Renders a specified physic impostor
  56615. * @param impostor defines the impostor to render
  56616. * @param targetMesh defines the mesh represented by the impostor
  56617. * @returns the new debug mesh used to render the impostor
  56618. */
  56619. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  56620. /**
  56621. * Hides a specified physic impostor
  56622. * @param impostor defines the impostor to hide
  56623. */
  56624. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  56625. private _getDebugMaterial;
  56626. private _getDebugBoxMesh;
  56627. private _getDebugSphereMesh;
  56628. private _getDebugCylinderMesh;
  56629. private _getDebugMeshMesh;
  56630. private _getDebugMesh;
  56631. /** Releases all resources */
  56632. dispose(): void;
  56633. }
  56634. }
  56635. declare module "babylonjs/Debug/rayHelper" {
  56636. import { Nullable } from "babylonjs/types";
  56637. import { Ray } from "babylonjs/Culling/ray";
  56638. import { Vector3 } from "babylonjs/Maths/math.vector";
  56639. import { Color3 } from "babylonjs/Maths/math.color";
  56640. import { Scene } from "babylonjs/scene";
  56641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56642. import "babylonjs/Meshes/Builders/linesBuilder";
  56643. /**
  56644. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56645. * in order to better appreciate the issue one might have.
  56646. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56647. */
  56648. export class RayHelper {
  56649. /**
  56650. * Defines the ray we are currently tryin to visualize.
  56651. */
  56652. ray: Nullable<Ray>;
  56653. private _renderPoints;
  56654. private _renderLine;
  56655. private _renderFunction;
  56656. private _scene;
  56657. private _onAfterRenderObserver;
  56658. private _onAfterStepObserver;
  56659. private _attachedToMesh;
  56660. private _meshSpaceDirection;
  56661. private _meshSpaceOrigin;
  56662. /**
  56663. * Helper function to create a colored helper in a scene in one line.
  56664. * @param ray Defines the ray we are currently tryin to visualize
  56665. * @param scene Defines the scene the ray is used in
  56666. * @param color Defines the color we want to see the ray in
  56667. * @returns The newly created ray helper.
  56668. */
  56669. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  56670. /**
  56671. * Instantiate a new ray helper.
  56672. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56673. * in order to better appreciate the issue one might have.
  56674. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56675. * @param ray Defines the ray we are currently tryin to visualize
  56676. */
  56677. constructor(ray: Ray);
  56678. /**
  56679. * Shows the ray we are willing to debug.
  56680. * @param scene Defines the scene the ray needs to be rendered in
  56681. * @param color Defines the color the ray needs to be rendered in
  56682. */
  56683. show(scene: Scene, color?: Color3): void;
  56684. /**
  56685. * Hides the ray we are debugging.
  56686. */
  56687. hide(): void;
  56688. private _render;
  56689. /**
  56690. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  56691. * @param mesh Defines the mesh we want the helper attached to
  56692. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  56693. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  56694. * @param length Defines the length of the ray
  56695. */
  56696. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  56697. /**
  56698. * Detach the ray helper from the mesh it has previously been attached to.
  56699. */
  56700. detachFromMesh(): void;
  56701. private _updateToMesh;
  56702. /**
  56703. * Dispose the helper and release its associated resources.
  56704. */
  56705. dispose(): void;
  56706. }
  56707. }
  56708. declare module "babylonjs/Debug/ISkeletonViewer" {
  56709. import { Skeleton } from "babylonjs/Bones/skeleton";
  56710. import { Color3 } from "babylonjs/Maths/math.color";
  56711. /**
  56712. * Defines the options associated with the creation of a SkeletonViewer.
  56713. */
  56714. export interface ISkeletonViewerOptions {
  56715. /** Should the system pause animations before building the Viewer? */
  56716. pauseAnimations: boolean;
  56717. /** Should the system return the skeleton to rest before building? */
  56718. returnToRest: boolean;
  56719. /** public Display Mode of the Viewer */
  56720. displayMode: number;
  56721. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56722. displayOptions: ISkeletonViewerDisplayOptions;
  56723. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56724. computeBonesUsingShaders: boolean;
  56725. /** Flag ignore non weighted bones */
  56726. useAllBones: boolean;
  56727. }
  56728. /**
  56729. * Defines how to display the various bone meshes for the viewer.
  56730. */
  56731. export interface ISkeletonViewerDisplayOptions {
  56732. /** How far down to start tapering the bone spurs */
  56733. midStep?: number;
  56734. /** How big is the midStep? */
  56735. midStepFactor?: number;
  56736. /** Base for the Sphere Size */
  56737. sphereBaseSize?: number;
  56738. /** The ratio of the sphere to the longest bone in units */
  56739. sphereScaleUnit?: number;
  56740. /** Ratio for the Sphere Size */
  56741. sphereFactor?: number;
  56742. /** Whether a spur should attach its far end to the child bone position */
  56743. spurFollowsChild?: boolean;
  56744. /** Whether to show local axes or not */
  56745. showLocalAxes?: boolean;
  56746. /** Length of each local axis */
  56747. localAxesSize?: number;
  56748. }
  56749. /**
  56750. * Defines the constructor options for the BoneWeight Shader.
  56751. */
  56752. export interface IBoneWeightShaderOptions {
  56753. /** Skeleton to Map */
  56754. skeleton: Skeleton;
  56755. /** Colors for Uninfluenced bones */
  56756. colorBase?: Color3;
  56757. /** Colors for 0.0-0.25 Weight bones */
  56758. colorZero?: Color3;
  56759. /** Color for 0.25-0.5 Weight Influence */
  56760. colorQuarter?: Color3;
  56761. /** Color for 0.5-0.75 Weight Influence */
  56762. colorHalf?: Color3;
  56763. /** Color for 0.75-1 Weight Influence */
  56764. colorFull?: Color3;
  56765. /** Color for Zero Weight Influence */
  56766. targetBoneIndex?: number;
  56767. }
  56768. /**
  56769. * Simple structure of the gradient steps for the Color Map.
  56770. */
  56771. export interface ISkeletonMapShaderColorMapKnot {
  56772. /** Color of the Knot */
  56773. color: Color3;
  56774. /** Location of the Knot */
  56775. location: number;
  56776. }
  56777. /**
  56778. * Defines the constructor options for the SkeletonMap Shader.
  56779. */
  56780. export interface ISkeletonMapShaderOptions {
  56781. /** Skeleton to Map */
  56782. skeleton: Skeleton;
  56783. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  56784. colorMap?: ISkeletonMapShaderColorMapKnot[];
  56785. }
  56786. }
  56787. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56788. import { Nullable } from "babylonjs/types";
  56789. import { Scene } from "babylonjs/scene";
  56790. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56791. import { Color4 } from "babylonjs/Maths/math.color";
  56792. import { Mesh } from "babylonjs/Meshes/mesh";
  56793. /**
  56794. * Class containing static functions to help procedurally build meshes
  56795. */
  56796. export class RibbonBuilder {
  56797. /**
  56798. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56799. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56800. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56801. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56802. * * 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
  56803. * * 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
  56804. * * 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
  56805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56807. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56808. * * 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
  56809. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56810. * * 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
  56811. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56813. * @param name defines the name of the mesh
  56814. * @param options defines the options used to create the mesh
  56815. * @param scene defines the hosting scene
  56816. * @returns the ribbon mesh
  56817. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56818. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56819. */
  56820. static CreateRibbon(name: string, options: {
  56821. pathArray: Vector3[][];
  56822. closeArray?: boolean;
  56823. closePath?: boolean;
  56824. offset?: number;
  56825. updatable?: boolean;
  56826. sideOrientation?: number;
  56827. frontUVs?: Vector4;
  56828. backUVs?: Vector4;
  56829. instance?: Mesh;
  56830. invertUV?: boolean;
  56831. uvs?: Vector2[];
  56832. colors?: Color4[];
  56833. }, scene?: Nullable<Scene>): Mesh;
  56834. }
  56835. }
  56836. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56837. import { Nullable } from "babylonjs/types";
  56838. import { Scene } from "babylonjs/scene";
  56839. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56840. import { Mesh } from "babylonjs/Meshes/mesh";
  56841. /**
  56842. * Class containing static functions to help procedurally build meshes
  56843. */
  56844. export class ShapeBuilder {
  56845. /**
  56846. * 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.
  56847. * * 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.
  56848. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56849. * * 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.
  56850. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56851. * * 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
  56852. * * 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
  56853. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56856. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56858. * @param name defines the name of the mesh
  56859. * @param options defines the options used to create the mesh
  56860. * @param scene defines the hosting scene
  56861. * @returns the extruded shape mesh
  56862. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56864. */
  56865. static ExtrudeShape(name: string, options: {
  56866. shape: Vector3[];
  56867. path: Vector3[];
  56868. scale?: number;
  56869. rotation?: number;
  56870. cap?: number;
  56871. updatable?: boolean;
  56872. sideOrientation?: number;
  56873. frontUVs?: Vector4;
  56874. backUVs?: Vector4;
  56875. instance?: Mesh;
  56876. invertUV?: boolean;
  56877. }, scene?: Nullable<Scene>): Mesh;
  56878. /**
  56879. * Creates an custom extruded shape mesh.
  56880. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56881. * * 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.
  56882. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56883. * * 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
  56884. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56885. * * 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
  56886. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56887. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56888. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56889. * * 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
  56890. * * 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
  56891. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56894. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56896. * @param name defines the name of the mesh
  56897. * @param options defines the options used to create the mesh
  56898. * @param scene defines the hosting scene
  56899. * @returns the custom extruded shape mesh
  56900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56901. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56903. */
  56904. static ExtrudeShapeCustom(name: string, options: {
  56905. shape: Vector3[];
  56906. path: Vector3[];
  56907. scaleFunction?: any;
  56908. rotationFunction?: any;
  56909. ribbonCloseArray?: boolean;
  56910. ribbonClosePath?: boolean;
  56911. cap?: number;
  56912. updatable?: boolean;
  56913. sideOrientation?: number;
  56914. frontUVs?: Vector4;
  56915. backUVs?: Vector4;
  56916. instance?: Mesh;
  56917. invertUV?: boolean;
  56918. }, scene?: Nullable<Scene>): Mesh;
  56919. private static _ExtrudeShapeGeneric;
  56920. }
  56921. }
  56922. declare module "babylonjs/Debug/skeletonViewer" {
  56923. import { Color3 } from "babylonjs/Maths/math.color";
  56924. import { Scene } from "babylonjs/scene";
  56925. import { Nullable } from "babylonjs/types";
  56926. import { Skeleton } from "babylonjs/Bones/skeleton";
  56927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56928. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56929. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56930. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  56931. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  56932. /**
  56933. * Class used to render a debug view of a given skeleton
  56934. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  56935. */
  56936. export class SkeletonViewer {
  56937. /** defines the skeleton to render */
  56938. skeleton: Skeleton;
  56939. /** defines the mesh attached to the skeleton */
  56940. mesh: AbstractMesh;
  56941. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56942. autoUpdateBonesMatrices: boolean;
  56943. /** defines the rendering group id to use with the viewer */
  56944. renderingGroupId: number;
  56945. /** is the options for the viewer */
  56946. options: Partial<ISkeletonViewerOptions>;
  56947. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  56948. static readonly DISPLAY_LINES: number;
  56949. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  56950. static readonly DISPLAY_SPHERES: number;
  56951. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  56952. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  56953. /** public static method to create a BoneWeight Shader
  56954. * @param options The constructor options
  56955. * @param scene The scene that the shader is scoped to
  56956. * @returns The created ShaderMaterial
  56957. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  56958. */
  56959. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  56960. /** public static method to create a BoneWeight Shader
  56961. * @param options The constructor options
  56962. * @param scene The scene that the shader is scoped to
  56963. * @returns The created ShaderMaterial
  56964. */
  56965. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  56966. /** private static method to create a BoneWeight Shader
  56967. * @param size The size of the buffer to create (usually the bone count)
  56968. * @param colorMap The gradient data to generate
  56969. * @param scene The scene that the shader is scoped to
  56970. * @returns an Array of floats from the color gradient values
  56971. */
  56972. private static _CreateBoneMapColorBuffer;
  56973. /** If SkeletonViewer scene scope. */
  56974. private _scene;
  56975. /** Gets or sets the color used to render the skeleton */
  56976. color: Color3;
  56977. /** Array of the points of the skeleton fo the line view. */
  56978. private _debugLines;
  56979. /** The SkeletonViewers Mesh. */
  56980. private _debugMesh;
  56981. /** The local axes Meshes. */
  56982. private _localAxes;
  56983. /** If SkeletonViewer is enabled. */
  56984. private _isEnabled;
  56985. /** If SkeletonViewer is ready. */
  56986. private _ready;
  56987. /** SkeletonViewer render observable. */
  56988. private _obs;
  56989. /** The Utility Layer to render the gizmos in. */
  56990. private _utilityLayer;
  56991. private _boneIndices;
  56992. /** Gets the Scene. */
  56993. get scene(): Scene;
  56994. /** Gets the utilityLayer. */
  56995. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  56996. /** Checks Ready Status. */
  56997. get isReady(): Boolean;
  56998. /** Sets Ready Status. */
  56999. set ready(value: boolean);
  57000. /** Gets the debugMesh */
  57001. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  57002. /** Sets the debugMesh */
  57003. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  57004. /** Gets the displayMode */
  57005. get displayMode(): number;
  57006. /** Sets the displayMode */
  57007. set displayMode(value: number);
  57008. /**
  57009. * Creates a new SkeletonViewer
  57010. * @param skeleton defines the skeleton to render
  57011. * @param mesh defines the mesh attached to the skeleton
  57012. * @param scene defines the hosting scene
  57013. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  57014. * @param renderingGroupId defines the rendering group id to use with the viewer
  57015. * @param options All of the extra constructor options for the SkeletonViewer
  57016. */
  57017. constructor(
  57018. /** defines the skeleton to render */
  57019. skeleton: Skeleton,
  57020. /** defines the mesh attached to the skeleton */
  57021. mesh: AbstractMesh,
  57022. /** The Scene scope*/
  57023. scene: Scene,
  57024. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  57025. autoUpdateBonesMatrices?: boolean,
  57026. /** defines the rendering group id to use with the viewer */
  57027. renderingGroupId?: number,
  57028. /** is the options for the viewer */
  57029. options?: Partial<ISkeletonViewerOptions>);
  57030. /** The Dynamic bindings for the update functions */
  57031. private _bindObs;
  57032. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  57033. update(): void;
  57034. /** Gets or sets a boolean indicating if the viewer is enabled */
  57035. set isEnabled(value: boolean);
  57036. get isEnabled(): boolean;
  57037. private _getBonePosition;
  57038. private _getLinesForBonesWithLength;
  57039. private _getLinesForBonesNoLength;
  57040. /** function to revert the mesh and scene back to the initial state. */
  57041. private _revert;
  57042. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  57043. private _getAbsoluteBindPoseToRef;
  57044. /** function to build and bind sphere joint points and spur bone representations. */
  57045. private _buildSpheresAndSpurs;
  57046. private _buildLocalAxes;
  57047. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  57048. private _displayLinesUpdate;
  57049. /** Changes the displayMode of the skeleton viewer
  57050. * @param mode The displayMode numerical value
  57051. */
  57052. changeDisplayMode(mode: number): void;
  57053. /** Sets a display option of the skeleton viewer
  57054. *
  57055. * | Option | Type | Default | Description |
  57056. * | ---------------- | ------- | ------- | ----------- |
  57057. * | 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`. |
  57058. * | 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`. |
  57059. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  57060. * | 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`. |
  57061. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  57062. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  57063. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  57064. *
  57065. * @param option String of the option name
  57066. * @param value The numerical option value
  57067. */
  57068. changeDisplayOptions(option: string, value: number): void;
  57069. /** Release associated resources */
  57070. dispose(): void;
  57071. }
  57072. }
  57073. declare module "babylonjs/Debug/index" {
  57074. export * from "babylonjs/Debug/axesViewer";
  57075. export * from "babylonjs/Debug/boneAxesViewer";
  57076. export * from "babylonjs/Debug/debugLayer";
  57077. export * from "babylonjs/Debug/physicsViewer";
  57078. export * from "babylonjs/Debug/rayHelper";
  57079. export * from "babylonjs/Debug/skeletonViewer";
  57080. export * from "babylonjs/Debug/ISkeletonViewer";
  57081. }
  57082. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  57083. /**
  57084. * Enum for Device Types
  57085. */
  57086. export enum DeviceType {
  57087. /** Generic */
  57088. Generic = 0,
  57089. /** Keyboard */
  57090. Keyboard = 1,
  57091. /** Mouse */
  57092. Mouse = 2,
  57093. /** Touch Pointers */
  57094. Touch = 3,
  57095. /** PS4 Dual Shock */
  57096. DualShock = 4,
  57097. /** Xbox */
  57098. Xbox = 5,
  57099. /** Switch Controller */
  57100. Switch = 6
  57101. }
  57102. /**
  57103. * Enum for All Pointers (Touch/Mouse)
  57104. */
  57105. export enum PointerInput {
  57106. /** Horizontal Axis */
  57107. Horizontal = 0,
  57108. /** Vertical Axis */
  57109. Vertical = 1,
  57110. /** Left Click or Touch */
  57111. LeftClick = 2,
  57112. /** Middle Click */
  57113. MiddleClick = 3,
  57114. /** Right Click */
  57115. RightClick = 4,
  57116. /** Browser Back */
  57117. BrowserBack = 5,
  57118. /** Browser Forward */
  57119. BrowserForward = 6
  57120. }
  57121. /**
  57122. * Enum for Dual Shock Gamepad
  57123. */
  57124. export enum DualShockInput {
  57125. /** Cross */
  57126. Cross = 0,
  57127. /** Circle */
  57128. Circle = 1,
  57129. /** Square */
  57130. Square = 2,
  57131. /** Triangle */
  57132. Triangle = 3,
  57133. /** L1 */
  57134. L1 = 4,
  57135. /** R1 */
  57136. R1 = 5,
  57137. /** L2 */
  57138. L2 = 6,
  57139. /** R2 */
  57140. R2 = 7,
  57141. /** Share */
  57142. Share = 8,
  57143. /** Options */
  57144. Options = 9,
  57145. /** L3 */
  57146. L3 = 10,
  57147. /** R3 */
  57148. R3 = 11,
  57149. /** DPadUp */
  57150. DPadUp = 12,
  57151. /** DPadDown */
  57152. DPadDown = 13,
  57153. /** DPadLeft */
  57154. DPadLeft = 14,
  57155. /** DRight */
  57156. DPadRight = 15,
  57157. /** Home */
  57158. Home = 16,
  57159. /** TouchPad */
  57160. TouchPad = 17,
  57161. /** LStickXAxis */
  57162. LStickXAxis = 18,
  57163. /** LStickYAxis */
  57164. LStickYAxis = 19,
  57165. /** RStickXAxis */
  57166. RStickXAxis = 20,
  57167. /** RStickYAxis */
  57168. RStickYAxis = 21
  57169. }
  57170. /**
  57171. * Enum for Xbox Gamepad
  57172. */
  57173. export enum XboxInput {
  57174. /** A */
  57175. A = 0,
  57176. /** B */
  57177. B = 1,
  57178. /** X */
  57179. X = 2,
  57180. /** Y */
  57181. Y = 3,
  57182. /** LB */
  57183. LB = 4,
  57184. /** RB */
  57185. RB = 5,
  57186. /** LT */
  57187. LT = 6,
  57188. /** RT */
  57189. RT = 7,
  57190. /** Back */
  57191. Back = 8,
  57192. /** Start */
  57193. Start = 9,
  57194. /** LS */
  57195. LS = 10,
  57196. /** RS */
  57197. RS = 11,
  57198. /** DPadUp */
  57199. DPadUp = 12,
  57200. /** DPadDown */
  57201. DPadDown = 13,
  57202. /** DPadLeft */
  57203. DPadLeft = 14,
  57204. /** DRight */
  57205. DPadRight = 15,
  57206. /** Home */
  57207. Home = 16,
  57208. /** LStickXAxis */
  57209. LStickXAxis = 17,
  57210. /** LStickYAxis */
  57211. LStickYAxis = 18,
  57212. /** RStickXAxis */
  57213. RStickXAxis = 19,
  57214. /** RStickYAxis */
  57215. RStickYAxis = 20
  57216. }
  57217. /**
  57218. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  57219. */
  57220. export enum SwitchInput {
  57221. /** B */
  57222. B = 0,
  57223. /** A */
  57224. A = 1,
  57225. /** Y */
  57226. Y = 2,
  57227. /** X */
  57228. X = 3,
  57229. /** L */
  57230. L = 4,
  57231. /** R */
  57232. R = 5,
  57233. /** ZL */
  57234. ZL = 6,
  57235. /** ZR */
  57236. ZR = 7,
  57237. /** Minus */
  57238. Minus = 8,
  57239. /** Plus */
  57240. Plus = 9,
  57241. /** LS */
  57242. LS = 10,
  57243. /** RS */
  57244. RS = 11,
  57245. /** DPadUp */
  57246. DPadUp = 12,
  57247. /** DPadDown */
  57248. DPadDown = 13,
  57249. /** DPadLeft */
  57250. DPadLeft = 14,
  57251. /** DRight */
  57252. DPadRight = 15,
  57253. /** Home */
  57254. Home = 16,
  57255. /** Capture */
  57256. Capture = 17,
  57257. /** LStickXAxis */
  57258. LStickXAxis = 18,
  57259. /** LStickYAxis */
  57260. LStickYAxis = 19,
  57261. /** RStickXAxis */
  57262. RStickXAxis = 20,
  57263. /** RStickYAxis */
  57264. RStickYAxis = 21
  57265. }
  57266. }
  57267. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  57268. import { Engine } from "babylonjs/Engines/engine";
  57269. import { IDisposable } from "babylonjs/scene";
  57270. import { Nullable } from "babylonjs/types";
  57271. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57272. /**
  57273. * This class will take all inputs from Keyboard, Pointer, and
  57274. * any Gamepads and provide a polling system that all devices
  57275. * will use. This class assumes that there will only be one
  57276. * pointer device and one keyboard.
  57277. */
  57278. export class DeviceInputSystem implements IDisposable {
  57279. /**
  57280. * Returns onDeviceConnected callback property
  57281. * @returns Callback with function to execute when a device is connected
  57282. */
  57283. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  57284. /**
  57285. * Sets callback function when a device is connected and executes against all connected devices
  57286. * @param callback Function to execute when a device is connected
  57287. */
  57288. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  57289. /**
  57290. * Callback to be triggered when a device is disconnected
  57291. */
  57292. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  57293. /**
  57294. * Callback to be triggered when event driven input is updated
  57295. */
  57296. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  57297. private _inputs;
  57298. private _gamepads;
  57299. private _keyboardActive;
  57300. private _pointerActive;
  57301. private _elementToAttachTo;
  57302. private _keyboardDownEvent;
  57303. private _keyboardUpEvent;
  57304. private _pointerMoveEvent;
  57305. private _pointerDownEvent;
  57306. private _pointerUpEvent;
  57307. private _gamepadConnectedEvent;
  57308. private _gamepadDisconnectedEvent;
  57309. private _onDeviceConnected;
  57310. private static _MAX_KEYCODES;
  57311. private static _MAX_POINTER_INPUTS;
  57312. private constructor();
  57313. /**
  57314. * Creates a new DeviceInputSystem instance
  57315. * @param engine Engine to pull input element from
  57316. * @returns The new instance
  57317. */
  57318. static Create(engine: Engine): DeviceInputSystem;
  57319. /**
  57320. * Checks for current device input value, given an id and input index
  57321. * @param deviceName Id of connected device
  57322. * @param inputIndex Index of device input
  57323. * @returns Current value of input
  57324. */
  57325. /**
  57326. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  57327. * @param deviceType Enum specifiying device type
  57328. * @param deviceSlot "Slot" or index that device is referenced in
  57329. * @param inputIndex Id of input to be checked
  57330. * @returns Current value of input
  57331. */
  57332. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  57333. /**
  57334. * Dispose of all the eventlisteners
  57335. */
  57336. dispose(): void;
  57337. /**
  57338. * Checks for existing connections to devices and register them, if necessary
  57339. * Currently handles gamepads and mouse
  57340. */
  57341. private _checkForConnectedDevices;
  57342. /**
  57343. * Add a gamepad to the DeviceInputSystem
  57344. * @param gamepad A single DOM Gamepad object
  57345. */
  57346. private _addGamePad;
  57347. /**
  57348. * Add pointer device to DeviceInputSystem
  57349. * @param deviceType Type of Pointer to add
  57350. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  57351. * @param currentX Current X at point of adding
  57352. * @param currentY Current Y at point of adding
  57353. */
  57354. private _addPointerDevice;
  57355. /**
  57356. * Add device and inputs to device array
  57357. * @param deviceType Enum specifiying device type
  57358. * @param deviceSlot "Slot" or index that device is referenced in
  57359. * @param numberOfInputs Number of input entries to create for given device
  57360. */
  57361. private _registerDevice;
  57362. /**
  57363. * Given a specific device name, remove that device from the device map
  57364. * @param deviceType Enum specifiying device type
  57365. * @param deviceSlot "Slot" or index that device is referenced in
  57366. */
  57367. private _unregisterDevice;
  57368. /**
  57369. * Handle all actions that come from keyboard interaction
  57370. */
  57371. private _handleKeyActions;
  57372. /**
  57373. * Handle all actions that come from pointer interaction
  57374. */
  57375. private _handlePointerActions;
  57376. /**
  57377. * Handle all actions that come from gamepad interaction
  57378. */
  57379. private _handleGamepadActions;
  57380. /**
  57381. * Update all non-event based devices with each frame
  57382. * @param deviceType Enum specifiying device type
  57383. * @param deviceSlot "Slot" or index that device is referenced in
  57384. * @param inputIndex Id of input to be checked
  57385. */
  57386. private _updateDevice;
  57387. /**
  57388. * Gets DeviceType from the device name
  57389. * @param deviceName Name of Device from DeviceInputSystem
  57390. * @returns DeviceType enum value
  57391. */
  57392. private _getGamepadDeviceType;
  57393. }
  57394. }
  57395. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  57396. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57397. /**
  57398. * Type to handle enforcement of inputs
  57399. */
  57400. 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;
  57401. }
  57402. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  57403. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  57404. import { Engine } from "babylonjs/Engines/engine";
  57405. import { IDisposable } from "babylonjs/scene";
  57406. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57407. import { Nullable } from "babylonjs/types";
  57408. import { Observable } from "babylonjs/Misc/observable";
  57409. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57410. /**
  57411. * Class that handles all input for a specific device
  57412. */
  57413. export class DeviceSource<T extends DeviceType> {
  57414. /** Type of device */
  57415. readonly deviceType: DeviceType;
  57416. /** "Slot" or index that device is referenced in */
  57417. readonly deviceSlot: number;
  57418. /**
  57419. * Observable to handle device input changes per device
  57420. */
  57421. readonly onInputChangedObservable: Observable<{
  57422. inputIndex: DeviceInput<T>;
  57423. previousState: Nullable<number>;
  57424. currentState: Nullable<number>;
  57425. }>;
  57426. private readonly _deviceInputSystem;
  57427. /**
  57428. * Default Constructor
  57429. * @param deviceInputSystem Reference to DeviceInputSystem
  57430. * @param deviceType Type of device
  57431. * @param deviceSlot "Slot" or index that device is referenced in
  57432. */
  57433. constructor(deviceInputSystem: DeviceInputSystem,
  57434. /** Type of device */
  57435. deviceType: DeviceType,
  57436. /** "Slot" or index that device is referenced in */
  57437. deviceSlot?: number);
  57438. /**
  57439. * Get input for specific input
  57440. * @param inputIndex index of specific input on device
  57441. * @returns Input value from DeviceInputSystem
  57442. */
  57443. getInput(inputIndex: DeviceInput<T>): number;
  57444. }
  57445. /**
  57446. * Class to keep track of devices
  57447. */
  57448. export class DeviceSourceManager implements IDisposable {
  57449. /**
  57450. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  57451. */
  57452. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  57453. /**
  57454. * Observable to be triggered when after a device is disconnected
  57455. */
  57456. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  57457. private readonly _devices;
  57458. private readonly _firstDevice;
  57459. private readonly _deviceInputSystem;
  57460. /**
  57461. * Default Constructor
  57462. * @param engine engine to pull input element from
  57463. */
  57464. constructor(engine: Engine);
  57465. /**
  57466. * Gets a DeviceSource, given a type and slot
  57467. * @param deviceType Enum specifying device type
  57468. * @param deviceSlot "Slot" or index that device is referenced in
  57469. * @returns DeviceSource object
  57470. */
  57471. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  57472. /**
  57473. * Gets an array of DeviceSource objects for a given device type
  57474. * @param deviceType Enum specifying device type
  57475. * @returns Array of DeviceSource objects
  57476. */
  57477. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  57478. /**
  57479. * Returns a read-only list of all available devices
  57480. * @returns Read-only array with active devices
  57481. */
  57482. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  57483. /**
  57484. * Dispose of DeviceInputSystem and other parts
  57485. */
  57486. dispose(): void;
  57487. /**
  57488. * Function to add device name to device list
  57489. * @param deviceType Enum specifying device type
  57490. * @param deviceSlot "Slot" or index that device is referenced in
  57491. */
  57492. private _addDevice;
  57493. /**
  57494. * Function to remove device name to device list
  57495. * @param deviceType Enum specifying device type
  57496. * @param deviceSlot "Slot" or index that device is referenced in
  57497. */
  57498. private _removeDevice;
  57499. /**
  57500. * Updates array storing first connected device of each type
  57501. * @param type Type of Device
  57502. */
  57503. private _updateFirstDevices;
  57504. }
  57505. }
  57506. declare module "babylonjs/DeviceInput/index" {
  57507. export * from "babylonjs/DeviceInput/deviceInputSystem";
  57508. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57509. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57510. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57511. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57512. }
  57513. declare module "babylonjs/Engines/nullEngine" {
  57514. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  57515. import { Engine } from "babylonjs/Engines/engine";
  57516. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57517. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57518. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57519. import { Effect } from "babylonjs/Materials/effect";
  57520. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57521. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57522. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  57523. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57524. /**
  57525. * Options to create the null engine
  57526. */
  57527. export class NullEngineOptions {
  57528. /**
  57529. * Render width (Default: 512)
  57530. */
  57531. renderWidth: number;
  57532. /**
  57533. * Render height (Default: 256)
  57534. */
  57535. renderHeight: number;
  57536. /**
  57537. * Texture size (Default: 512)
  57538. */
  57539. textureSize: number;
  57540. /**
  57541. * If delta time between frames should be constant
  57542. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57543. */
  57544. deterministicLockstep: boolean;
  57545. /**
  57546. * Maximum about of steps between frames (Default: 4)
  57547. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57548. */
  57549. lockstepMaxSteps: number;
  57550. /**
  57551. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  57552. */
  57553. useHighPrecisionMatrix?: boolean;
  57554. }
  57555. /**
  57556. * The null engine class provides support for headless version of babylon.js.
  57557. * This can be used in server side scenario or for testing purposes
  57558. */
  57559. export class NullEngine extends Engine {
  57560. private _options;
  57561. /**
  57562. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  57563. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57564. * @returns true if engine is in deterministic lock step mode
  57565. */
  57566. isDeterministicLockStep(): boolean;
  57567. /**
  57568. * Gets the max steps when engine is running in deterministic lock step
  57569. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57570. * @returns the max steps
  57571. */
  57572. getLockstepMaxSteps(): number;
  57573. /**
  57574. * Gets the current hardware scaling level.
  57575. * By default the hardware scaling level is computed from the window device ratio.
  57576. * 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.
  57577. * @returns a number indicating the current hardware scaling level
  57578. */
  57579. getHardwareScalingLevel(): number;
  57580. constructor(options?: NullEngineOptions);
  57581. /**
  57582. * Creates a vertex buffer
  57583. * @param vertices the data for the vertex buffer
  57584. * @returns the new WebGL static buffer
  57585. */
  57586. createVertexBuffer(vertices: FloatArray): DataBuffer;
  57587. /**
  57588. * Creates a new index buffer
  57589. * @param indices defines the content of the index buffer
  57590. * @param updatable defines if the index buffer must be updatable
  57591. * @returns a new webGL buffer
  57592. */
  57593. createIndexBuffer(indices: IndicesArray): DataBuffer;
  57594. /**
  57595. * Clear the current render buffer or the current render target (if any is set up)
  57596. * @param color defines the color to use
  57597. * @param backBuffer defines if the back buffer must be cleared
  57598. * @param depth defines if the depth buffer must be cleared
  57599. * @param stencil defines if the stencil buffer must be cleared
  57600. */
  57601. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57602. /**
  57603. * Gets the current render width
  57604. * @param useScreen defines if screen size must be used (or the current render target if any)
  57605. * @returns a number defining the current render width
  57606. */
  57607. getRenderWidth(useScreen?: boolean): number;
  57608. /**
  57609. * Gets the current render height
  57610. * @param useScreen defines if screen size must be used (or the current render target if any)
  57611. * @returns a number defining the current render height
  57612. */
  57613. getRenderHeight(useScreen?: boolean): number;
  57614. /**
  57615. * Set the WebGL's viewport
  57616. * @param viewport defines the viewport element to be used
  57617. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  57618. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  57619. */
  57620. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  57621. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  57622. /**
  57623. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  57624. * @param pipelineContext defines the pipeline context to use
  57625. * @param uniformsNames defines the list of uniform names
  57626. * @returns an array of webGL uniform locations
  57627. */
  57628. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  57629. /**
  57630. * Gets the lsit of active attributes for a given webGL program
  57631. * @param pipelineContext defines the pipeline context to use
  57632. * @param attributesNames defines the list of attribute names to get
  57633. * @returns an array of indices indicating the offset of each attribute
  57634. */
  57635. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57636. /**
  57637. * Binds an effect to the webGL context
  57638. * @param effect defines the effect to bind
  57639. */
  57640. bindSamplers(effect: Effect): void;
  57641. /**
  57642. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  57643. * @param effect defines the effect to activate
  57644. */
  57645. enableEffect(effect: Effect): void;
  57646. /**
  57647. * Set various states to the webGL context
  57648. * @param culling defines backface culling state
  57649. * @param zOffset defines the value to apply to zOffset (0 by default)
  57650. * @param force defines if states must be applied even if cache is up to date
  57651. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  57652. */
  57653. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57654. /**
  57655. * Set the value of an uniform to an array of int32
  57656. * @param uniform defines the webGL uniform location where to store the value
  57657. * @param array defines the array of int32 to store
  57658. * @returns true if value was set
  57659. */
  57660. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57661. /**
  57662. * Set the value of an uniform to an array of int32 (stored as vec2)
  57663. * @param uniform defines the webGL uniform location where to store the value
  57664. * @param array defines the array of int32 to store
  57665. * @returns true if value was set
  57666. */
  57667. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57668. /**
  57669. * Set the value of an uniform to an array of int32 (stored as vec3)
  57670. * @param uniform defines the webGL uniform location where to store the value
  57671. * @param array defines the array of int32 to store
  57672. * @returns true if value was set
  57673. */
  57674. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57675. /**
  57676. * Set the value of an uniform to an array of int32 (stored as vec4)
  57677. * @param uniform defines the webGL uniform location where to store the value
  57678. * @param array defines the array of int32 to store
  57679. * @returns true if value was set
  57680. */
  57681. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57682. /**
  57683. * Set the value of an uniform to an array of float32
  57684. * @param uniform defines the webGL uniform location where to store the value
  57685. * @param array defines the array of float32 to store
  57686. * @returns true if value was set
  57687. */
  57688. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57689. /**
  57690. * Set the value of an uniform to an array of float32 (stored as vec2)
  57691. * @param uniform defines the webGL uniform location where to store the value
  57692. * @param array defines the array of float32 to store
  57693. * @returns true if value was set
  57694. */
  57695. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57696. /**
  57697. * Set the value of an uniform to an array of float32 (stored as vec3)
  57698. * @param uniform defines the webGL uniform location where to store the value
  57699. * @param array defines the array of float32 to store
  57700. * @returns true if value was set
  57701. */
  57702. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57703. /**
  57704. * Set the value of an uniform to an array of float32 (stored as vec4)
  57705. * @param uniform defines the webGL uniform location where to store the value
  57706. * @param array defines the array of float32 to store
  57707. * @returns true if value was set
  57708. */
  57709. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57710. /**
  57711. * Set the value of an uniform to an array of number
  57712. * @param uniform defines the webGL uniform location where to store the value
  57713. * @param array defines the array of number to store
  57714. * @returns true if value was set
  57715. */
  57716. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57717. /**
  57718. * Set the value of an uniform to an array of number (stored as vec2)
  57719. * @param uniform defines the webGL uniform location where to store the value
  57720. * @param array defines the array of number to store
  57721. * @returns true if value was set
  57722. */
  57723. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57724. /**
  57725. * Set the value of an uniform to an array of number (stored as vec3)
  57726. * @param uniform defines the webGL uniform location where to store the value
  57727. * @param array defines the array of number to store
  57728. * @returns true if value was set
  57729. */
  57730. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57731. /**
  57732. * Set the value of an uniform to an array of number (stored as vec4)
  57733. * @param uniform defines the webGL uniform location where to store the value
  57734. * @param array defines the array of number to store
  57735. * @returns true if value was set
  57736. */
  57737. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57738. /**
  57739. * Set the value of an uniform to an array of float32 (stored as matrices)
  57740. * @param uniform defines the webGL uniform location where to store the value
  57741. * @param matrices defines the array of float32 to store
  57742. * @returns true if value was set
  57743. */
  57744. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57745. /**
  57746. * Set the value of an uniform to a matrix (3x3)
  57747. * @param uniform defines the webGL uniform location where to store the value
  57748. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  57749. * @returns true if value was set
  57750. */
  57751. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57752. /**
  57753. * Set the value of an uniform to a matrix (2x2)
  57754. * @param uniform defines the webGL uniform location where to store the value
  57755. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  57756. * @returns true if value was set
  57757. */
  57758. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57759. /**
  57760. * Set the value of an uniform to a number (float)
  57761. * @param uniform defines the webGL uniform location where to store the value
  57762. * @param value defines the float number to store
  57763. * @returns true if value was set
  57764. */
  57765. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57766. /**
  57767. * Set the value of an uniform to a vec2
  57768. * @param uniform defines the webGL uniform location where to store the value
  57769. * @param x defines the 1st component of the value
  57770. * @param y defines the 2nd component of the value
  57771. * @returns true if value was set
  57772. */
  57773. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57774. /**
  57775. * Set the value of an uniform to a vec3
  57776. * @param uniform defines the webGL uniform location where to store the value
  57777. * @param x defines the 1st component of the value
  57778. * @param y defines the 2nd component of the value
  57779. * @param z defines the 3rd component of the value
  57780. * @returns true if value was set
  57781. */
  57782. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57783. /**
  57784. * Set the value of an uniform to a boolean
  57785. * @param uniform defines the webGL uniform location where to store the value
  57786. * @param bool defines the boolean to store
  57787. * @returns true if value was set
  57788. */
  57789. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  57790. /**
  57791. * Set the value of an uniform to a vec4
  57792. * @param uniform defines the webGL uniform location where to store the value
  57793. * @param x defines the 1st component of the value
  57794. * @param y defines the 2nd component of the value
  57795. * @param z defines the 3rd component of the value
  57796. * @param w defines the 4th component of the value
  57797. * @returns true if value was set
  57798. */
  57799. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57800. /**
  57801. * Sets the current alpha mode
  57802. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  57803. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57804. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57805. */
  57806. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57807. /**
  57808. * Bind webGl buffers directly to the webGL context
  57809. * @param vertexBuffers defines the vertex buffer to bind
  57810. * @param indexBuffer defines the index buffer to bind
  57811. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  57812. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  57813. * @param effect defines the effect associated with the vertex buffer
  57814. */
  57815. bindBuffers(vertexBuffers: {
  57816. [key: string]: VertexBuffer;
  57817. }, indexBuffer: DataBuffer, effect: Effect): void;
  57818. /**
  57819. * Force the entire cache to be cleared
  57820. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  57821. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  57822. */
  57823. wipeCaches(bruteForce?: boolean): void;
  57824. /**
  57825. * Send a draw order
  57826. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  57827. * @param indexStart defines the starting index
  57828. * @param indexCount defines the number of index to draw
  57829. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57830. */
  57831. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  57832. /**
  57833. * Draw a list of indexed primitives
  57834. * @param fillMode defines the primitive to use
  57835. * @param indexStart defines the starting index
  57836. * @param indexCount defines the number of index to draw
  57837. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57838. */
  57839. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57840. /**
  57841. * Draw a list of unindexed primitives
  57842. * @param fillMode defines the primitive to use
  57843. * @param verticesStart defines the index of first vertex to draw
  57844. * @param verticesCount defines the count of vertices to draw
  57845. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57846. */
  57847. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57848. /** @hidden */
  57849. _createTexture(): WebGLTexture;
  57850. /** @hidden */
  57851. _releaseTexture(texture: InternalTexture): void;
  57852. /**
  57853. * Usually called from Texture.ts.
  57854. * Passed information to create a WebGLTexture
  57855. * @param urlArg defines a value which contains one of the following:
  57856. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57857. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57858. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57859. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57860. * @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)
  57861. * @param scene needed for loading to the correct scene
  57862. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57863. * @param onLoad optional callback to be called upon successful completion
  57864. * @param onError optional callback to be called upon failure
  57865. * @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
  57866. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57867. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57868. * @param forcedExtension defines the extension to use to pick the right loader
  57869. * @param mimeType defines an optional mime type
  57870. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57871. */
  57872. 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;
  57873. /**
  57874. * Creates a new render target texture
  57875. * @param size defines the size of the texture
  57876. * @param options defines the options used to create the texture
  57877. * @returns a new render target texture stored in an InternalTexture
  57878. */
  57879. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  57880. /**
  57881. * Update the sampling mode of a given texture
  57882. * @param samplingMode defines the required sampling mode
  57883. * @param texture defines the texture to update
  57884. */
  57885. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57886. /**
  57887. * Binds the frame buffer to the specified texture.
  57888. * @param texture The texture to render to or null for the default canvas
  57889. * @param faceIndex The face of the texture to render to in case of cube texture
  57890. * @param requiredWidth The width of the target to render to
  57891. * @param requiredHeight The height of the target to render to
  57892. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  57893. * @param lodLevel defines le lod level to bind to the frame buffer
  57894. */
  57895. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57896. /**
  57897. * Unbind the current render target texture from the webGL context
  57898. * @param texture defines the render target texture to unbind
  57899. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  57900. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  57901. */
  57902. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57903. /**
  57904. * Creates a dynamic vertex buffer
  57905. * @param vertices the data for the dynamic vertex buffer
  57906. * @returns the new WebGL dynamic buffer
  57907. */
  57908. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  57909. /**
  57910. * Update the content of a dynamic texture
  57911. * @param texture defines the texture to update
  57912. * @param canvas defines the canvas containing the source
  57913. * @param invertY defines if data must be stored with Y axis inverted
  57914. * @param premulAlpha defines if alpha is stored as premultiplied
  57915. * @param format defines the format of the data
  57916. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57917. */
  57918. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57919. /**
  57920. * Gets a boolean indicating if all created effects are ready
  57921. * @returns true if all effects are ready
  57922. */
  57923. areAllEffectsReady(): boolean;
  57924. /**
  57925. * @hidden
  57926. * Get the current error code of the webGL context
  57927. * @returns the error code
  57928. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  57929. */
  57930. getError(): number;
  57931. /** @hidden */
  57932. _getUnpackAlignement(): number;
  57933. /** @hidden */
  57934. _unpackFlipY(value: boolean): void;
  57935. /**
  57936. * Update a dynamic index buffer
  57937. * @param indexBuffer defines the target index buffer
  57938. * @param indices defines the data to update
  57939. * @param offset defines the offset in the target index buffer where update should start
  57940. */
  57941. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  57942. /**
  57943. * Updates a dynamic vertex buffer.
  57944. * @param vertexBuffer the vertex buffer to update
  57945. * @param vertices the data used to update the vertex buffer
  57946. * @param byteOffset the byte offset of the data (optional)
  57947. * @param byteLength the byte length of the data (optional)
  57948. */
  57949. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  57950. /** @hidden */
  57951. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  57952. /** @hidden */
  57953. _bindTexture(channel: number, texture: InternalTexture): void;
  57954. protected _deleteBuffer(buffer: WebGLBuffer): void;
  57955. /**
  57956. * 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
  57957. */
  57958. releaseEffects(): void;
  57959. displayLoadingUI(): void;
  57960. hideLoadingUI(): void;
  57961. /** @hidden */
  57962. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57963. /** @hidden */
  57964. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57965. /** @hidden */
  57966. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57967. /** @hidden */
  57968. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57969. }
  57970. }
  57971. declare module "babylonjs/Instrumentation/timeToken" {
  57972. import { Nullable } from "babylonjs/types";
  57973. /**
  57974. * @hidden
  57975. **/
  57976. export class _TimeToken {
  57977. _startTimeQuery: Nullable<WebGLQuery>;
  57978. _endTimeQuery: Nullable<WebGLQuery>;
  57979. _timeElapsedQuery: Nullable<WebGLQuery>;
  57980. _timeElapsedQueryEnded: boolean;
  57981. }
  57982. }
  57983. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  57984. import { Nullable, int } from "babylonjs/types";
  57985. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  57986. /** @hidden */
  57987. export class _OcclusionDataStorage {
  57988. /** @hidden */
  57989. occlusionInternalRetryCounter: number;
  57990. /** @hidden */
  57991. isOcclusionQueryInProgress: boolean;
  57992. /** @hidden */
  57993. isOccluded: boolean;
  57994. /** @hidden */
  57995. occlusionRetryCount: number;
  57996. /** @hidden */
  57997. occlusionType: number;
  57998. /** @hidden */
  57999. occlusionQueryAlgorithmType: number;
  58000. }
  58001. module "babylonjs/Engines/engine" {
  58002. interface Engine {
  58003. /**
  58004. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  58005. * @return the new query
  58006. */
  58007. createQuery(): WebGLQuery;
  58008. /**
  58009. * Delete and release a webGL query
  58010. * @param query defines the query to delete
  58011. * @return the current engine
  58012. */
  58013. deleteQuery(query: WebGLQuery): Engine;
  58014. /**
  58015. * Check if a given query has resolved and got its value
  58016. * @param query defines the query to check
  58017. * @returns true if the query got its value
  58018. */
  58019. isQueryResultAvailable(query: WebGLQuery): boolean;
  58020. /**
  58021. * Gets the value of a given query
  58022. * @param query defines the query to check
  58023. * @returns the value of the query
  58024. */
  58025. getQueryResult(query: WebGLQuery): number;
  58026. /**
  58027. * Initiates an occlusion query
  58028. * @param algorithmType defines the algorithm to use
  58029. * @param query defines the query to use
  58030. * @returns the current engine
  58031. * @see https://doc.babylonjs.com/features/occlusionquery
  58032. */
  58033. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  58034. /**
  58035. * Ends an occlusion query
  58036. * @see https://doc.babylonjs.com/features/occlusionquery
  58037. * @param algorithmType defines the algorithm to use
  58038. * @returns the current engine
  58039. */
  58040. endOcclusionQuery(algorithmType: number): Engine;
  58041. /**
  58042. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  58043. * Please note that only one query can be issued at a time
  58044. * @returns a time token used to track the time span
  58045. */
  58046. startTimeQuery(): Nullable<_TimeToken>;
  58047. /**
  58048. * Ends a time query
  58049. * @param token defines the token used to measure the time span
  58050. * @returns the time spent (in ns)
  58051. */
  58052. endTimeQuery(token: _TimeToken): int;
  58053. /** @hidden */
  58054. _currentNonTimestampToken: Nullable<_TimeToken>;
  58055. /** @hidden */
  58056. _createTimeQuery(): WebGLQuery;
  58057. /** @hidden */
  58058. _deleteTimeQuery(query: WebGLQuery): void;
  58059. /** @hidden */
  58060. _getGlAlgorithmType(algorithmType: number): number;
  58061. /** @hidden */
  58062. _getTimeQueryResult(query: WebGLQuery): any;
  58063. /** @hidden */
  58064. _getTimeQueryAvailability(query: WebGLQuery): any;
  58065. }
  58066. }
  58067. module "babylonjs/Meshes/abstractMesh" {
  58068. interface AbstractMesh {
  58069. /**
  58070. * Backing filed
  58071. * @hidden
  58072. */
  58073. __occlusionDataStorage: _OcclusionDataStorage;
  58074. /**
  58075. * Access property
  58076. * @hidden
  58077. */
  58078. _occlusionDataStorage: _OcclusionDataStorage;
  58079. /**
  58080. * 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.
  58081. * The default value is -1 which means don't break the query and wait till the result
  58082. * @see https://doc.babylonjs.com/features/occlusionquery
  58083. */
  58084. occlusionRetryCount: number;
  58085. /**
  58086. * 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:
  58087. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  58088. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  58089. * * 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.
  58090. * @see https://doc.babylonjs.com/features/occlusionquery
  58091. */
  58092. occlusionType: number;
  58093. /**
  58094. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  58095. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  58096. * * 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.
  58097. * @see https://doc.babylonjs.com/features/occlusionquery
  58098. */
  58099. occlusionQueryAlgorithmType: number;
  58100. /**
  58101. * 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
  58102. * @see https://doc.babylonjs.com/features/occlusionquery
  58103. */
  58104. isOccluded: boolean;
  58105. /**
  58106. * Flag to check the progress status of the query
  58107. * @see https://doc.babylonjs.com/features/occlusionquery
  58108. */
  58109. isOcclusionQueryInProgress: boolean;
  58110. }
  58111. }
  58112. }
  58113. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  58114. import { Nullable } from "babylonjs/types";
  58115. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58116. /** @hidden */
  58117. export var _forceTransformFeedbackToBundle: boolean;
  58118. module "babylonjs/Engines/engine" {
  58119. interface Engine {
  58120. /**
  58121. * Creates a webGL transform feedback object
  58122. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  58123. * @returns the webGL transform feedback object
  58124. */
  58125. createTransformFeedback(): WebGLTransformFeedback;
  58126. /**
  58127. * Delete a webGL transform feedback object
  58128. * @param value defines the webGL transform feedback object to delete
  58129. */
  58130. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  58131. /**
  58132. * Bind a webGL transform feedback object to the webgl context
  58133. * @param value defines the webGL transform feedback object to bind
  58134. */
  58135. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  58136. /**
  58137. * Begins a transform feedback operation
  58138. * @param usePoints defines if points or triangles must be used
  58139. */
  58140. beginTransformFeedback(usePoints: boolean): void;
  58141. /**
  58142. * Ends a transform feedback operation
  58143. */
  58144. endTransformFeedback(): void;
  58145. /**
  58146. * Specify the varyings to use with transform feedback
  58147. * @param program defines the associated webGL program
  58148. * @param value defines the list of strings representing the varying names
  58149. */
  58150. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  58151. /**
  58152. * Bind a webGL buffer for a transform feedback operation
  58153. * @param value defines the webGL buffer to bind
  58154. */
  58155. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  58156. }
  58157. }
  58158. }
  58159. declare module "babylonjs/Engines/Extensions/engine.views" {
  58160. import { Camera } from "babylonjs/Cameras/camera";
  58161. import { Nullable } from "babylonjs/types";
  58162. /**
  58163. * Class used to define an additional view for the engine
  58164. * @see https://doc.babylonjs.com/how_to/multi_canvases
  58165. */
  58166. export class EngineView {
  58167. /** Defines the canvas where to render the view */
  58168. target: HTMLCanvasElement;
  58169. /** Defines an optional camera used to render the view (will use active camera else) */
  58170. camera?: Camera;
  58171. }
  58172. module "babylonjs/Engines/engine" {
  58173. interface Engine {
  58174. /**
  58175. * Gets or sets the HTML element to use for attaching events
  58176. */
  58177. inputElement: Nullable<HTMLElement>;
  58178. /**
  58179. * Gets the current engine view
  58180. * @see https://doc.babylonjs.com/how_to/multi_canvases
  58181. */
  58182. activeView: Nullable<EngineView>;
  58183. /** Gets or sets the list of views */
  58184. views: EngineView[];
  58185. /**
  58186. * Register a new child canvas
  58187. * @param canvas defines the canvas to register
  58188. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  58189. * @returns the associated view
  58190. */
  58191. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  58192. /**
  58193. * Remove a registered child canvas
  58194. * @param canvas defines the canvas to remove
  58195. * @returns the current engine
  58196. */
  58197. unRegisterView(canvas: HTMLCanvasElement): Engine;
  58198. }
  58199. }
  58200. }
  58201. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  58202. import { Nullable } from "babylonjs/types";
  58203. module "babylonjs/Engines/engine" {
  58204. interface Engine {
  58205. /** @hidden */
  58206. _excludedCompressedTextures: string[];
  58207. /** @hidden */
  58208. _textureFormatInUse: string;
  58209. /**
  58210. * Gets the list of texture formats supported
  58211. */
  58212. readonly texturesSupported: Array<string>;
  58213. /**
  58214. * Gets the texture format in use
  58215. */
  58216. readonly textureFormatInUse: Nullable<string>;
  58217. /**
  58218. * Set the compressed texture extensions or file names to skip.
  58219. *
  58220. * @param skippedFiles defines the list of those texture files you want to skip
  58221. * Example: [".dds", ".env", "myfile.png"]
  58222. */
  58223. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  58224. /**
  58225. * Set the compressed texture format to use, based on the formats you have, and the formats
  58226. * supported by the hardware / browser.
  58227. *
  58228. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  58229. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  58230. * to API arguments needed to compressed textures. This puts the burden on the container
  58231. * generator to house the arcane code for determining these for current & future formats.
  58232. *
  58233. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58234. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58235. *
  58236. * Note: The result of this call is not taken into account when a texture is base64.
  58237. *
  58238. * @param formatsAvailable defines the list of those format families you have created
  58239. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  58240. *
  58241. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  58242. * @returns The extension selected.
  58243. */
  58244. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  58245. }
  58246. }
  58247. }
  58248. declare module "babylonjs/Engines/Extensions/index" {
  58249. export * from "babylonjs/Engines/Extensions/engine.alpha";
  58250. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  58251. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  58252. export * from "babylonjs/Engines/Extensions/engine.multiview";
  58253. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  58254. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58255. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  58256. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  58257. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  58258. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  58259. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  58260. export * from "babylonjs/Engines/Extensions/engine.webVR";
  58261. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  58262. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  58263. export * from "babylonjs/Engines/Extensions/engine.views";
  58264. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  58265. import "babylonjs/Engines/Extensions/engine.textureSelector";
  58266. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  58267. }
  58268. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  58269. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58270. /** @hidden */
  58271. export var rgbdEncodePixelShader: {
  58272. name: string;
  58273. shader: string;
  58274. };
  58275. }
  58276. declare module "babylonjs/Misc/environmentTextureTools" {
  58277. import { Nullable } from "babylonjs/types";
  58278. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58279. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58281. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  58282. import "babylonjs/Engines/Extensions/engine.readTexture";
  58283. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58284. import "babylonjs/Shaders/rgbdEncode.fragment";
  58285. import "babylonjs/Shaders/rgbdDecode.fragment";
  58286. /**
  58287. * Raw texture data and descriptor sufficient for WebGL texture upload
  58288. */
  58289. export interface EnvironmentTextureInfo {
  58290. /**
  58291. * Version of the environment map
  58292. */
  58293. version: number;
  58294. /**
  58295. * Width of image
  58296. */
  58297. width: number;
  58298. /**
  58299. * Irradiance information stored in the file.
  58300. */
  58301. irradiance: any;
  58302. /**
  58303. * Specular information stored in the file.
  58304. */
  58305. specular: any;
  58306. }
  58307. /**
  58308. * Defines One Image in the file. It requires only the position in the file
  58309. * as well as the length.
  58310. */
  58311. interface BufferImageData {
  58312. /**
  58313. * Length of the image data.
  58314. */
  58315. length: number;
  58316. /**
  58317. * Position of the data from the null terminator delimiting the end of the JSON.
  58318. */
  58319. position: number;
  58320. }
  58321. /**
  58322. * Defines the specular data enclosed in the file.
  58323. * This corresponds to the version 1 of the data.
  58324. */
  58325. export interface EnvironmentTextureSpecularInfoV1 {
  58326. /**
  58327. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  58328. */
  58329. specularDataPosition?: number;
  58330. /**
  58331. * This contains all the images data needed to reconstruct the cubemap.
  58332. */
  58333. mipmaps: Array<BufferImageData>;
  58334. /**
  58335. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  58336. */
  58337. lodGenerationScale: number;
  58338. }
  58339. /**
  58340. * Sets of helpers addressing the serialization and deserialization of environment texture
  58341. * stored in a BabylonJS env file.
  58342. * Those files are usually stored as .env files.
  58343. */
  58344. export class EnvironmentTextureTools {
  58345. /**
  58346. * Magic number identifying the env file.
  58347. */
  58348. private static _MagicBytes;
  58349. /**
  58350. * Gets the environment info from an env file.
  58351. * @param data The array buffer containing the .env bytes.
  58352. * @returns the environment file info (the json header) if successfully parsed.
  58353. */
  58354. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  58355. /**
  58356. * Creates an environment texture from a loaded cube texture.
  58357. * @param texture defines the cube texture to convert in env file
  58358. * @return a promise containing the environment data if succesfull.
  58359. */
  58360. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  58361. /**
  58362. * Creates a JSON representation of the spherical data.
  58363. * @param texture defines the texture containing the polynomials
  58364. * @return the JSON representation of the spherical info
  58365. */
  58366. private static _CreateEnvTextureIrradiance;
  58367. /**
  58368. * Creates the ArrayBufferViews used for initializing environment texture image data.
  58369. * @param data the image data
  58370. * @param info parameters that determine what views will be created for accessing the underlying buffer
  58371. * @return the views described by info providing access to the underlying buffer
  58372. */
  58373. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  58374. /**
  58375. * Uploads the texture info contained in the env file to the GPU.
  58376. * @param texture defines the internal texture to upload to
  58377. * @param data defines the data to load
  58378. * @param info defines the texture info retrieved through the GetEnvInfo method
  58379. * @returns a promise
  58380. */
  58381. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  58382. private static _OnImageReadyAsync;
  58383. /**
  58384. * Uploads the levels of image data to the GPU.
  58385. * @param texture defines the internal texture to upload to
  58386. * @param imageData defines the array buffer views of image data [mipmap][face]
  58387. * @returns a promise
  58388. */
  58389. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  58390. /**
  58391. * Uploads spherical polynomials information to the texture.
  58392. * @param texture defines the texture we are trying to upload the information to
  58393. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  58394. */
  58395. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  58396. /** @hidden */
  58397. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58398. }
  58399. }
  58400. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  58401. /**
  58402. * Class used to inline functions in shader code
  58403. */
  58404. export class ShaderCodeInliner {
  58405. private static readonly _RegexpFindFunctionNameAndType;
  58406. private _sourceCode;
  58407. private _functionDescr;
  58408. private _numMaxIterations;
  58409. /** Gets or sets the token used to mark the functions to inline */
  58410. inlineToken: string;
  58411. /** Gets or sets the debug mode */
  58412. debug: boolean;
  58413. /** Gets the code after the inlining process */
  58414. get code(): string;
  58415. /**
  58416. * Initializes the inliner
  58417. * @param sourceCode shader code source to inline
  58418. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  58419. */
  58420. constructor(sourceCode: string, numMaxIterations?: number);
  58421. /**
  58422. * Start the processing of the shader code
  58423. */
  58424. processCode(): void;
  58425. private _collectFunctions;
  58426. private _processInlining;
  58427. private _extractBetweenMarkers;
  58428. private _skipWhitespaces;
  58429. private _removeComments;
  58430. private _replaceFunctionCallsByCode;
  58431. private _findBackward;
  58432. private _escapeRegExp;
  58433. private _replaceNames;
  58434. }
  58435. }
  58436. declare module "babylonjs/Engines/nativeEngine" {
  58437. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  58438. import { Engine } from "babylonjs/Engines/engine";
  58439. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58440. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58441. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58442. import { Effect } from "babylonjs/Materials/effect";
  58443. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58444. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  58445. import { IColor4Like } from "babylonjs/Maths/math.like";
  58446. import { Scene } from "babylonjs/scene";
  58447. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58448. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58449. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58450. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  58451. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  58452. /**
  58453. * Container for accessors for natively-stored mesh data buffers.
  58454. */
  58455. class NativeDataBuffer extends DataBuffer {
  58456. /**
  58457. * Accessor value used to identify/retrieve a natively-stored index buffer.
  58458. */
  58459. nativeIndexBuffer?: any;
  58460. /**
  58461. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  58462. */
  58463. nativeVertexBuffer?: any;
  58464. }
  58465. /** @hidden */
  58466. class NativeTexture extends InternalTexture {
  58467. getInternalTexture(): InternalTexture;
  58468. getViewCount(): number;
  58469. }
  58470. /** @hidden */
  58471. export class NativeEngine extends Engine {
  58472. private readonly _native;
  58473. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  58474. private readonly INVALID_HANDLE;
  58475. private _boundBuffersVertexArray;
  58476. private _currentDepthTest;
  58477. getHardwareScalingLevel(): number;
  58478. constructor();
  58479. dispose(): void;
  58480. /**
  58481. * Can be used to override the current requestAnimationFrame requester.
  58482. * @hidden
  58483. */
  58484. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  58485. /**
  58486. * Override default engine behavior.
  58487. * @param color
  58488. * @param backBuffer
  58489. * @param depth
  58490. * @param stencil
  58491. */
  58492. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  58493. /**
  58494. * Gets host document
  58495. * @returns the host document object
  58496. */
  58497. getHostDocument(): Nullable<Document>;
  58498. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58499. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  58500. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  58501. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  58502. [key: string]: VertexBuffer;
  58503. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58504. bindBuffers(vertexBuffers: {
  58505. [key: string]: VertexBuffer;
  58506. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58507. recordVertexArrayObject(vertexBuffers: {
  58508. [key: string]: VertexBuffer;
  58509. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  58510. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58511. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58512. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58513. /**
  58514. * Draw a list of indexed primitives
  58515. * @param fillMode defines the primitive to use
  58516. * @param indexStart defines the starting index
  58517. * @param indexCount defines the number of index to draw
  58518. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58519. */
  58520. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58521. /**
  58522. * Draw a list of unindexed primitives
  58523. * @param fillMode defines the primitive to use
  58524. * @param verticesStart defines the index of first vertex to draw
  58525. * @param verticesCount defines the count of vertices to draw
  58526. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58527. */
  58528. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58529. createPipelineContext(): IPipelineContext;
  58530. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  58531. /** @hidden */
  58532. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  58533. /** @hidden */
  58534. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  58535. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58536. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58537. protected _setProgram(program: WebGLProgram): void;
  58538. _releaseEffect(effect: Effect): void;
  58539. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  58540. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  58541. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  58542. bindSamplers(effect: Effect): void;
  58543. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  58544. getRenderWidth(useScreen?: boolean): number;
  58545. getRenderHeight(useScreen?: boolean): number;
  58546. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  58547. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58548. /**
  58549. * Set the z offset to apply to current rendering
  58550. * @param value defines the offset to apply
  58551. */
  58552. setZOffset(value: number): void;
  58553. /**
  58554. * Gets the current value of the zOffset
  58555. * @returns the current zOffset state
  58556. */
  58557. getZOffset(): number;
  58558. /**
  58559. * Enable or disable depth buffering
  58560. * @param enable defines the state to set
  58561. */
  58562. setDepthBuffer(enable: boolean): void;
  58563. /**
  58564. * Gets a boolean indicating if depth writing is enabled
  58565. * @returns the current depth writing state
  58566. */
  58567. getDepthWrite(): boolean;
  58568. setDepthFunctionToGreater(): void;
  58569. setDepthFunctionToGreaterOrEqual(): void;
  58570. setDepthFunctionToLess(): void;
  58571. setDepthFunctionToLessOrEqual(): void;
  58572. /**
  58573. * Enable or disable depth writing
  58574. * @param enable defines the state to set
  58575. */
  58576. setDepthWrite(enable: boolean): void;
  58577. /**
  58578. * Enable or disable color writing
  58579. * @param enable defines the state to set
  58580. */
  58581. setColorWrite(enable: boolean): void;
  58582. /**
  58583. * Gets a boolean indicating if color writing is enabled
  58584. * @returns the current color writing state
  58585. */
  58586. getColorWrite(): boolean;
  58587. /**
  58588. * Sets alpha constants used by some alpha blending modes
  58589. * @param r defines the red component
  58590. * @param g defines the green component
  58591. * @param b defines the blue component
  58592. * @param a defines the alpha component
  58593. */
  58594. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  58595. /**
  58596. * Sets the current alpha mode
  58597. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  58598. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58599. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58600. */
  58601. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58602. /**
  58603. * Gets the current alpha mode
  58604. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58605. * @returns the current alpha mode
  58606. */
  58607. getAlphaMode(): number;
  58608. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  58609. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58610. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58611. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58612. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58613. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58614. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58615. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58616. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58617. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58618. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58619. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58620. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58621. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58622. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58623. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58624. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58625. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58626. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58627. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58628. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  58629. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  58630. wipeCaches(bruteForce?: boolean): void;
  58631. _createTexture(): WebGLTexture;
  58632. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  58633. /**
  58634. * Update the content of a dynamic texture
  58635. * @param texture defines the texture to update
  58636. * @param canvas defines the canvas containing the source
  58637. * @param invertY defines if data must be stored with Y axis inverted
  58638. * @param premulAlpha defines if alpha is stored as premultiplied
  58639. * @param format defines the format of the data
  58640. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58641. */
  58642. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58643. /**
  58644. * Usually called from Texture.ts.
  58645. * Passed information to create a WebGLTexture
  58646. * @param url defines a value which contains one of the following:
  58647. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58648. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58649. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58650. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58651. * @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)
  58652. * @param scene needed for loading to the correct scene
  58653. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58654. * @param onLoad optional callback to be called upon successful completion
  58655. * @param onError optional callback to be called upon failure
  58656. * @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
  58657. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58658. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58659. * @param forcedExtension defines the extension to use to pick the right loader
  58660. * @param mimeType defines an optional mime type
  58661. * @param loaderOptions options to be passed to the loader
  58662. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58663. */
  58664. 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;
  58665. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  58666. _releaseFramebufferObjects(texture: InternalTexture): void;
  58667. /**
  58668. * Creates a cube texture
  58669. * @param rootUrl defines the url where the files to load is located
  58670. * @param scene defines the current scene
  58671. * @param files defines the list of files to load (1 per face)
  58672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  58673. * @param onLoad defines an optional callback raised when the texture is loaded
  58674. * @param onError defines an optional callback raised if there is an issue to load the texture
  58675. * @param format defines the format of the data
  58676. * @param forcedExtension defines the extension to use to pick the right loader
  58677. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  58678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58680. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  58681. * @returns the cube texture as an InternalTexture
  58682. */
  58683. 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;
  58684. createRenderTargetTexture(size: number | {
  58685. width: number;
  58686. height: number;
  58687. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  58688. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58689. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58690. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58691. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  58692. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  58693. /**
  58694. * Updates a dynamic vertex buffer.
  58695. * @param vertexBuffer the vertex buffer to update
  58696. * @param data the data used to update the vertex buffer
  58697. * @param byteOffset the byte offset of the data (optional)
  58698. * @param byteLength the byte length of the data (optional)
  58699. */
  58700. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  58701. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  58702. private _updateAnisotropicLevel;
  58703. private _getAddressMode;
  58704. /** @hidden */
  58705. _bindTexture(channel: number, texture: InternalTexture): void;
  58706. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  58707. releaseEffects(): void;
  58708. /** @hidden */
  58709. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58710. /** @hidden */
  58711. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58712. /** @hidden */
  58713. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58714. /** @hidden */
  58715. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58716. private _getNativeSamplingMode;
  58717. private _getNativeTextureFormat;
  58718. private _getNativeAlphaMode;
  58719. private _getNativeAttribType;
  58720. }
  58721. }
  58722. declare module "babylonjs/Engines/index" {
  58723. export * from "babylonjs/Engines/constants";
  58724. export * from "babylonjs/Engines/engineCapabilities";
  58725. export * from "babylonjs/Engines/instancingAttributeInfo";
  58726. export * from "babylonjs/Engines/thinEngine";
  58727. export * from "babylonjs/Engines/engine";
  58728. export * from "babylonjs/Engines/engineStore";
  58729. export * from "babylonjs/Engines/nullEngine";
  58730. export * from "babylonjs/Engines/Extensions/index";
  58731. export * from "babylonjs/Engines/IPipelineContext";
  58732. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  58733. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  58734. export * from "babylonjs/Engines/nativeEngine";
  58735. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  58736. export * from "babylonjs/Engines/performanceConfigurator";
  58737. }
  58738. declare module "babylonjs/Events/clipboardEvents" {
  58739. /**
  58740. * Gather the list of clipboard event types as constants.
  58741. */
  58742. export class ClipboardEventTypes {
  58743. /**
  58744. * The clipboard event is fired when a copy command is active (pressed).
  58745. */
  58746. static readonly COPY: number;
  58747. /**
  58748. * The clipboard event is fired when a cut command is active (pressed).
  58749. */
  58750. static readonly CUT: number;
  58751. /**
  58752. * The clipboard event is fired when a paste command is active (pressed).
  58753. */
  58754. static readonly PASTE: number;
  58755. }
  58756. /**
  58757. * This class is used to store clipboard related info for the onClipboardObservable event.
  58758. */
  58759. export class ClipboardInfo {
  58760. /**
  58761. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58762. */
  58763. type: number;
  58764. /**
  58765. * Defines the related dom event
  58766. */
  58767. event: ClipboardEvent;
  58768. /**
  58769. *Creates an instance of ClipboardInfo.
  58770. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  58771. * @param event Defines the related dom event
  58772. */
  58773. constructor(
  58774. /**
  58775. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58776. */
  58777. type: number,
  58778. /**
  58779. * Defines the related dom event
  58780. */
  58781. event: ClipboardEvent);
  58782. /**
  58783. * Get the clipboard event's type from the keycode.
  58784. * @param keyCode Defines the keyCode for the current keyboard event.
  58785. * @return {number}
  58786. */
  58787. static GetTypeFromCharacter(keyCode: number): number;
  58788. }
  58789. }
  58790. declare module "babylonjs/Events/index" {
  58791. export * from "babylonjs/Events/keyboardEvents";
  58792. export * from "babylonjs/Events/pointerEvents";
  58793. export * from "babylonjs/Events/clipboardEvents";
  58794. }
  58795. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  58796. import { Scene } from "babylonjs/scene";
  58797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58798. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58799. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58800. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58801. /**
  58802. * Google Daydream controller
  58803. */
  58804. export class DaydreamController extends WebVRController {
  58805. /**
  58806. * Base Url for the controller model.
  58807. */
  58808. static MODEL_BASE_URL: string;
  58809. /**
  58810. * File name for the controller model.
  58811. */
  58812. static MODEL_FILENAME: string;
  58813. /**
  58814. * Gamepad Id prefix used to identify Daydream Controller.
  58815. */
  58816. static readonly GAMEPAD_ID_PREFIX: string;
  58817. /**
  58818. * Creates a new DaydreamController from a gamepad
  58819. * @param vrGamepad the gamepad that the controller should be created from
  58820. */
  58821. constructor(vrGamepad: any);
  58822. /**
  58823. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58824. * @param scene scene in which to add meshes
  58825. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58826. */
  58827. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58828. /**
  58829. * Called once for each button that changed state since the last frame
  58830. * @param buttonIdx Which button index changed
  58831. * @param state New state of the button
  58832. * @param changes Which properties on the state changed since last frame
  58833. */
  58834. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58835. }
  58836. }
  58837. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  58838. import { Scene } from "babylonjs/scene";
  58839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58840. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58841. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58842. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58843. /**
  58844. * Gear VR Controller
  58845. */
  58846. export class GearVRController extends WebVRController {
  58847. /**
  58848. * Base Url for the controller model.
  58849. */
  58850. static MODEL_BASE_URL: string;
  58851. /**
  58852. * File name for the controller model.
  58853. */
  58854. static MODEL_FILENAME: string;
  58855. /**
  58856. * Gamepad Id prefix used to identify this controller.
  58857. */
  58858. static readonly GAMEPAD_ID_PREFIX: string;
  58859. private readonly _buttonIndexToObservableNameMap;
  58860. /**
  58861. * Creates a new GearVRController from a gamepad
  58862. * @param vrGamepad the gamepad that the controller should be created from
  58863. */
  58864. constructor(vrGamepad: any);
  58865. /**
  58866. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58867. * @param scene scene in which to add meshes
  58868. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58869. */
  58870. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58871. /**
  58872. * Called once for each button that changed state since the last frame
  58873. * @param buttonIdx Which button index changed
  58874. * @param state New state of the button
  58875. * @param changes Which properties on the state changed since last frame
  58876. */
  58877. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58878. }
  58879. }
  58880. declare module "babylonjs/Gamepads/Controllers/genericController" {
  58881. import { Scene } from "babylonjs/scene";
  58882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58883. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58884. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58885. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58886. /**
  58887. * Generic Controller
  58888. */
  58889. export class GenericController extends WebVRController {
  58890. /**
  58891. * Base Url for the controller model.
  58892. */
  58893. static readonly MODEL_BASE_URL: string;
  58894. /**
  58895. * File name for the controller model.
  58896. */
  58897. static readonly MODEL_FILENAME: string;
  58898. /**
  58899. * Creates a new GenericController from a gamepad
  58900. * @param vrGamepad the gamepad that the controller should be created from
  58901. */
  58902. constructor(vrGamepad: any);
  58903. /**
  58904. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58905. * @param scene scene in which to add meshes
  58906. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58907. */
  58908. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58909. /**
  58910. * Called once for each button that changed state since the last frame
  58911. * @param buttonIdx Which button index changed
  58912. * @param state New state of the button
  58913. * @param changes Which properties on the state changed since last frame
  58914. */
  58915. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58916. }
  58917. }
  58918. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  58919. import { Observable } from "babylonjs/Misc/observable";
  58920. import { Scene } from "babylonjs/scene";
  58921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58922. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58923. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58924. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58925. /**
  58926. * Oculus Touch Controller
  58927. */
  58928. export class OculusTouchController extends WebVRController {
  58929. /**
  58930. * Base Url for the controller model.
  58931. */
  58932. static MODEL_BASE_URL: string;
  58933. /**
  58934. * File name for the left controller model.
  58935. */
  58936. static MODEL_LEFT_FILENAME: string;
  58937. /**
  58938. * File name for the right controller model.
  58939. */
  58940. static MODEL_RIGHT_FILENAME: string;
  58941. /**
  58942. * Base Url for the Quest controller model.
  58943. */
  58944. static QUEST_MODEL_BASE_URL: string;
  58945. /**
  58946. * @hidden
  58947. * If the controllers are running on a device that needs the updated Quest controller models
  58948. */
  58949. static _IsQuest: boolean;
  58950. /**
  58951. * Fired when the secondary trigger on this controller is modified
  58952. */
  58953. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  58954. /**
  58955. * Fired when the thumb rest on this controller is modified
  58956. */
  58957. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  58958. /**
  58959. * Creates a new OculusTouchController from a gamepad
  58960. * @param vrGamepad the gamepad that the controller should be created from
  58961. */
  58962. constructor(vrGamepad: any);
  58963. /**
  58964. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58965. * @param scene scene in which to add meshes
  58966. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58967. */
  58968. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58969. /**
  58970. * Fired when the A button on this controller is modified
  58971. */
  58972. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58973. /**
  58974. * Fired when the B button on this controller is modified
  58975. */
  58976. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58977. /**
  58978. * Fired when the X button on this controller is modified
  58979. */
  58980. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58981. /**
  58982. * Fired when the Y button on this controller is modified
  58983. */
  58984. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58985. /**
  58986. * Called once for each button that changed state since the last frame
  58987. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  58988. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  58989. * 2) secondary trigger (same)
  58990. * 3) A (right) X (left), touch, pressed = value
  58991. * 4) B / Y
  58992. * 5) thumb rest
  58993. * @param buttonIdx Which button index changed
  58994. * @param state New state of the button
  58995. * @param changes Which properties on the state changed since last frame
  58996. */
  58997. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58998. }
  58999. }
  59000. declare module "babylonjs/Gamepads/Controllers/viveController" {
  59001. import { Scene } from "babylonjs/scene";
  59002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59003. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59004. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59005. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59006. import { Observable } from "babylonjs/Misc/observable";
  59007. /**
  59008. * Vive Controller
  59009. */
  59010. export class ViveController extends WebVRController {
  59011. /**
  59012. * Base Url for the controller model.
  59013. */
  59014. static MODEL_BASE_URL: string;
  59015. /**
  59016. * File name for the controller model.
  59017. */
  59018. static MODEL_FILENAME: string;
  59019. /**
  59020. * Creates a new ViveController from a gamepad
  59021. * @param vrGamepad the gamepad that the controller should be created from
  59022. */
  59023. constructor(vrGamepad: any);
  59024. /**
  59025. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59026. * @param scene scene in which to add meshes
  59027. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59028. */
  59029. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59030. /**
  59031. * Fired when the left button on this controller is modified
  59032. */
  59033. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59034. /**
  59035. * Fired when the right button on this controller is modified
  59036. */
  59037. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59038. /**
  59039. * Fired when the menu button on this controller is modified
  59040. */
  59041. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59042. /**
  59043. * Called once for each button that changed state since the last frame
  59044. * Vive mapping:
  59045. * 0: touchpad
  59046. * 1: trigger
  59047. * 2: left AND right buttons
  59048. * 3: menu button
  59049. * @param buttonIdx Which button index changed
  59050. * @param state New state of the button
  59051. * @param changes Which properties on the state changed since last frame
  59052. */
  59053. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59054. }
  59055. }
  59056. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  59057. import { Observable } from "babylonjs/Misc/observable";
  59058. import { Scene } from "babylonjs/scene";
  59059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59060. import { Ray } from "babylonjs/Culling/ray";
  59061. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59062. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59063. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59064. /**
  59065. * Defines the WindowsMotionController object that the state of the windows motion controller
  59066. */
  59067. export class WindowsMotionController extends WebVRController {
  59068. /**
  59069. * The base url used to load the left and right controller models
  59070. */
  59071. static MODEL_BASE_URL: string;
  59072. /**
  59073. * The name of the left controller model file
  59074. */
  59075. static MODEL_LEFT_FILENAME: string;
  59076. /**
  59077. * The name of the right controller model file
  59078. */
  59079. static MODEL_RIGHT_FILENAME: string;
  59080. /**
  59081. * The controller name prefix for this controller type
  59082. */
  59083. static readonly GAMEPAD_ID_PREFIX: string;
  59084. /**
  59085. * The controller id pattern for this controller type
  59086. */
  59087. private static readonly GAMEPAD_ID_PATTERN;
  59088. private _loadedMeshInfo;
  59089. protected readonly _mapping: {
  59090. buttons: string[];
  59091. buttonMeshNames: {
  59092. trigger: string;
  59093. menu: string;
  59094. grip: string;
  59095. thumbstick: string;
  59096. trackpad: string;
  59097. };
  59098. buttonObservableNames: {
  59099. trigger: string;
  59100. menu: string;
  59101. grip: string;
  59102. thumbstick: string;
  59103. trackpad: string;
  59104. };
  59105. axisMeshNames: string[];
  59106. pointingPoseMeshName: string;
  59107. };
  59108. /**
  59109. * Fired when the trackpad on this controller is clicked
  59110. */
  59111. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  59112. /**
  59113. * Fired when the trackpad on this controller is modified
  59114. */
  59115. onTrackpadValuesChangedObservable: Observable<StickValues>;
  59116. /**
  59117. * The current x and y values of this controller's trackpad
  59118. */
  59119. trackpad: StickValues;
  59120. /**
  59121. * Creates a new WindowsMotionController from a gamepad
  59122. * @param vrGamepad the gamepad that the controller should be created from
  59123. */
  59124. constructor(vrGamepad: any);
  59125. /**
  59126. * Fired when the trigger on this controller is modified
  59127. */
  59128. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59129. /**
  59130. * Fired when the menu button on this controller is modified
  59131. */
  59132. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59133. /**
  59134. * Fired when the grip button on this controller is modified
  59135. */
  59136. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59137. /**
  59138. * Fired when the thumbstick button on this controller is modified
  59139. */
  59140. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59141. /**
  59142. * Fired when the touchpad button on this controller is modified
  59143. */
  59144. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59145. /**
  59146. * Fired when the touchpad values on this controller are modified
  59147. */
  59148. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  59149. protected _updateTrackpad(): void;
  59150. /**
  59151. * Called once per frame by the engine.
  59152. */
  59153. update(): void;
  59154. /**
  59155. * Called once for each button that changed state since the last frame
  59156. * @param buttonIdx Which button index changed
  59157. * @param state New state of the button
  59158. * @param changes Which properties on the state changed since last frame
  59159. */
  59160. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59161. /**
  59162. * Moves the buttons on the controller mesh based on their current state
  59163. * @param buttonName the name of the button to move
  59164. * @param buttonValue the value of the button which determines the buttons new position
  59165. */
  59166. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  59167. /**
  59168. * Moves the axis on the controller mesh based on its current state
  59169. * @param axis the index of the axis
  59170. * @param axisValue the value of the axis which determines the meshes new position
  59171. * @hidden
  59172. */
  59173. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  59174. /**
  59175. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59176. * @param scene scene in which to add meshes
  59177. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59178. */
  59179. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  59180. /**
  59181. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  59182. * can be transformed by button presses and axes values, based on this._mapping.
  59183. *
  59184. * @param scene scene in which the meshes exist
  59185. * @param meshes list of meshes that make up the controller model to process
  59186. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  59187. */
  59188. private processModel;
  59189. private createMeshInfo;
  59190. /**
  59191. * Gets the ray of the controller in the direction the controller is pointing
  59192. * @param length the length the resulting ray should be
  59193. * @returns a ray in the direction the controller is pointing
  59194. */
  59195. getForwardRay(length?: number): Ray;
  59196. /**
  59197. * Disposes of the controller
  59198. */
  59199. dispose(): void;
  59200. }
  59201. /**
  59202. * This class represents a new windows motion controller in XR.
  59203. */
  59204. export class XRWindowsMotionController extends WindowsMotionController {
  59205. /**
  59206. * Changing the original WIndowsMotionController mapping to fir the new mapping
  59207. */
  59208. protected readonly _mapping: {
  59209. buttons: string[];
  59210. buttonMeshNames: {
  59211. trigger: string;
  59212. menu: string;
  59213. grip: string;
  59214. thumbstick: string;
  59215. trackpad: string;
  59216. };
  59217. buttonObservableNames: {
  59218. trigger: string;
  59219. menu: string;
  59220. grip: string;
  59221. thumbstick: string;
  59222. trackpad: string;
  59223. };
  59224. axisMeshNames: string[];
  59225. pointingPoseMeshName: string;
  59226. };
  59227. /**
  59228. * Construct a new XR-Based windows motion controller
  59229. *
  59230. * @param gamepadInfo the gamepad object from the browser
  59231. */
  59232. constructor(gamepadInfo: any);
  59233. /**
  59234. * holds the thumbstick values (X,Y)
  59235. */
  59236. thumbstickValues: StickValues;
  59237. /**
  59238. * Fired when the thumbstick on this controller is clicked
  59239. */
  59240. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  59241. /**
  59242. * Fired when the thumbstick on this controller is modified
  59243. */
  59244. onThumbstickValuesChangedObservable: Observable<StickValues>;
  59245. /**
  59246. * Fired when the touchpad button on this controller is modified
  59247. */
  59248. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  59249. /**
  59250. * Fired when the touchpad values on this controller are modified
  59251. */
  59252. onTrackpadValuesChangedObservable: Observable<StickValues>;
  59253. /**
  59254. * Fired when the thumbstick button on this controller is modified
  59255. * here to prevent breaking changes
  59256. */
  59257. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59258. /**
  59259. * updating the thumbstick(!) and not the trackpad.
  59260. * This is named this way due to the difference between WebVR and XR and to avoid
  59261. * changing the parent class.
  59262. */
  59263. protected _updateTrackpad(): void;
  59264. /**
  59265. * Disposes the class with joy
  59266. */
  59267. dispose(): void;
  59268. }
  59269. }
  59270. declare module "babylonjs/Gamepads/Controllers/index" {
  59271. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  59272. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  59273. export * from "babylonjs/Gamepads/Controllers/genericController";
  59274. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  59275. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59276. export * from "babylonjs/Gamepads/Controllers/viveController";
  59277. export * from "babylonjs/Gamepads/Controllers/webVRController";
  59278. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  59279. }
  59280. declare module "babylonjs/Gamepads/index" {
  59281. export * from "babylonjs/Gamepads/Controllers/index";
  59282. export * from "babylonjs/Gamepads/gamepad";
  59283. export * from "babylonjs/Gamepads/gamepadManager";
  59284. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  59285. export * from "babylonjs/Gamepads/xboxGamepad";
  59286. export * from "babylonjs/Gamepads/dualShockGamepad";
  59287. }
  59288. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  59289. import { Scene } from "babylonjs/scene";
  59290. import { Vector4 } from "babylonjs/Maths/math.vector";
  59291. import { Color4 } from "babylonjs/Maths/math.color";
  59292. import { Mesh } from "babylonjs/Meshes/mesh";
  59293. import { Nullable } from "babylonjs/types";
  59294. /**
  59295. * Class containing static functions to help procedurally build meshes
  59296. */
  59297. export class PolyhedronBuilder {
  59298. /**
  59299. * Creates a polyhedron mesh
  59300. * * 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
  59301. * * The parameter `size` (positive float, default 1) sets the polygon size
  59302. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59303. * * 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`
  59304. * * 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
  59305. * * 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)`)
  59306. * * 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
  59307. * * 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
  59308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59311. * @param name defines the name of the mesh
  59312. * @param options defines the options used to create the mesh
  59313. * @param scene defines the hosting scene
  59314. * @returns the polyhedron mesh
  59315. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59316. */
  59317. static CreatePolyhedron(name: string, options: {
  59318. type?: number;
  59319. size?: number;
  59320. sizeX?: number;
  59321. sizeY?: number;
  59322. sizeZ?: number;
  59323. custom?: any;
  59324. faceUV?: Vector4[];
  59325. faceColors?: Color4[];
  59326. flat?: boolean;
  59327. updatable?: boolean;
  59328. sideOrientation?: number;
  59329. frontUVs?: Vector4;
  59330. backUVs?: Vector4;
  59331. }, scene?: Nullable<Scene>): Mesh;
  59332. }
  59333. }
  59334. declare module "babylonjs/Gizmos/scaleGizmo" {
  59335. import { Observable } from "babylonjs/Misc/observable";
  59336. import { Nullable } from "babylonjs/types";
  59337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59338. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59339. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  59340. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59341. import { Node } from "babylonjs/node";
  59342. /**
  59343. * Gizmo that enables scaling a mesh along 3 axis
  59344. */
  59345. export class ScaleGizmo extends Gizmo {
  59346. /**
  59347. * Internal gizmo used for interactions on the x axis
  59348. */
  59349. xGizmo: AxisScaleGizmo;
  59350. /**
  59351. * Internal gizmo used for interactions on the y axis
  59352. */
  59353. yGizmo: AxisScaleGizmo;
  59354. /**
  59355. * Internal gizmo used for interactions on the z axis
  59356. */
  59357. zGizmo: AxisScaleGizmo;
  59358. /**
  59359. * Internal gizmo used to scale all axis equally
  59360. */
  59361. uniformScaleGizmo: AxisScaleGizmo;
  59362. private _meshAttached;
  59363. private _nodeAttached;
  59364. private _snapDistance;
  59365. private _uniformScalingMesh;
  59366. private _octahedron;
  59367. private _sensitivity;
  59368. /** Fires an event when any of it's sub gizmos are dragged */
  59369. onDragStartObservable: Observable<unknown>;
  59370. /** Fires an event when any of it's sub gizmos are released from dragging */
  59371. onDragEndObservable: Observable<unknown>;
  59372. get attachedMesh(): Nullable<AbstractMesh>;
  59373. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59374. get attachedNode(): Nullable<Node>;
  59375. set attachedNode(node: Nullable<Node>);
  59376. /**
  59377. * True when the mouse pointer is hovering a gizmo mesh
  59378. */
  59379. get isHovered(): boolean;
  59380. /**
  59381. * Creates a ScaleGizmo
  59382. * @param gizmoLayer The utility layer the gizmo will be added to
  59383. * @param thickness display gizmo axis thickness
  59384. */
  59385. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  59386. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59387. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59388. /**
  59389. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59390. */
  59391. set snapDistance(value: number);
  59392. get snapDistance(): number;
  59393. /**
  59394. * Ratio for the scale of the gizmo (Default: 1)
  59395. */
  59396. set scaleRatio(value: number);
  59397. get scaleRatio(): number;
  59398. /**
  59399. * Sensitivity factor for dragging (Default: 1)
  59400. */
  59401. set sensitivity(value: number);
  59402. get sensitivity(): number;
  59403. /**
  59404. * Disposes of the gizmo
  59405. */
  59406. dispose(): void;
  59407. }
  59408. }
  59409. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  59410. import { Observable } from "babylonjs/Misc/observable";
  59411. import { Nullable } from "babylonjs/types";
  59412. import { Vector3 } from "babylonjs/Maths/math.vector";
  59413. import { Node } from "babylonjs/node";
  59414. import { Mesh } from "babylonjs/Meshes/mesh";
  59415. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59416. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59417. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59418. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59419. import { Color3 } from "babylonjs/Maths/math.color";
  59420. /**
  59421. * Single axis scale gizmo
  59422. */
  59423. export class AxisScaleGizmo extends Gizmo {
  59424. /**
  59425. * Drag behavior responsible for the gizmos dragging interactions
  59426. */
  59427. dragBehavior: PointerDragBehavior;
  59428. private _pointerObserver;
  59429. /**
  59430. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59431. */
  59432. snapDistance: number;
  59433. /**
  59434. * Event that fires each time the gizmo snaps to a new location.
  59435. * * snapDistance is the the change in distance
  59436. */
  59437. onSnapObservable: Observable<{
  59438. snapDistance: number;
  59439. }>;
  59440. /**
  59441. * If the scaling operation should be done on all axis (default: false)
  59442. */
  59443. uniformScaling: boolean;
  59444. /**
  59445. * Custom sensitivity value for the drag strength
  59446. */
  59447. sensitivity: number;
  59448. private _isEnabled;
  59449. private _parent;
  59450. private _arrow;
  59451. private _coloredMaterial;
  59452. private _hoverMaterial;
  59453. /**
  59454. * Creates an AxisScaleGizmo
  59455. * @param gizmoLayer The utility layer the gizmo will be added to
  59456. * @param dragAxis The axis which the gizmo will be able to scale on
  59457. * @param color The color of the gizmo
  59458. * @param thickness display gizmo axis thickness
  59459. */
  59460. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59461. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59462. /**
  59463. * If the gizmo is enabled
  59464. */
  59465. set isEnabled(value: boolean);
  59466. get isEnabled(): boolean;
  59467. /**
  59468. * Disposes of the gizmo
  59469. */
  59470. dispose(): void;
  59471. /**
  59472. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59473. * @param mesh The mesh to replace the default mesh of the gizmo
  59474. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59475. */
  59476. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59477. }
  59478. }
  59479. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  59480. import { Observable } from "babylonjs/Misc/observable";
  59481. import { Nullable } from "babylonjs/types";
  59482. import { Vector3 } from "babylonjs/Maths/math.vector";
  59483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59484. import { Mesh } from "babylonjs/Meshes/mesh";
  59485. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59486. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59487. import { Color3 } from "babylonjs/Maths/math.color";
  59488. import "babylonjs/Meshes/Builders/boxBuilder";
  59489. /**
  59490. * Bounding box gizmo
  59491. */
  59492. export class BoundingBoxGizmo extends Gizmo {
  59493. private _lineBoundingBox;
  59494. private _rotateSpheresParent;
  59495. private _scaleBoxesParent;
  59496. private _boundingDimensions;
  59497. private _renderObserver;
  59498. private _pointerObserver;
  59499. private _scaleDragSpeed;
  59500. private _tmpQuaternion;
  59501. private _tmpVector;
  59502. private _tmpRotationMatrix;
  59503. /**
  59504. * 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)
  59505. */
  59506. ignoreChildren: boolean;
  59507. /**
  59508. * 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)
  59509. */
  59510. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59511. /**
  59512. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59513. */
  59514. rotationSphereSize: number;
  59515. /**
  59516. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59517. */
  59518. scaleBoxSize: number;
  59519. /**
  59520. * 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)
  59521. */
  59522. fixedDragMeshScreenSize: boolean;
  59523. /**
  59524. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59525. */
  59526. fixedDragMeshScreenSizeDistanceFactor: number;
  59527. /**
  59528. * Fired when a rotation sphere or scale box is dragged
  59529. */
  59530. onDragStartObservable: Observable<{}>;
  59531. /**
  59532. * Fired when a scale box is dragged
  59533. */
  59534. onScaleBoxDragObservable: Observable<{}>;
  59535. /**
  59536. * Fired when a scale box drag is ended
  59537. */
  59538. onScaleBoxDragEndObservable: Observable<{}>;
  59539. /**
  59540. * Fired when a rotation sphere is dragged
  59541. */
  59542. onRotationSphereDragObservable: Observable<{}>;
  59543. /**
  59544. * Fired when a rotation sphere drag is ended
  59545. */
  59546. onRotationSphereDragEndObservable: Observable<{}>;
  59547. /**
  59548. * 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)
  59549. */
  59550. scalePivot: Nullable<Vector3>;
  59551. /**
  59552. * Mesh used as a pivot to rotate the attached node
  59553. */
  59554. private _anchorMesh;
  59555. private _existingMeshScale;
  59556. private _dragMesh;
  59557. private pointerDragBehavior;
  59558. private coloredMaterial;
  59559. private hoverColoredMaterial;
  59560. /**
  59561. * Sets the color of the bounding box gizmo
  59562. * @param color the color to set
  59563. */
  59564. setColor(color: Color3): void;
  59565. /**
  59566. * Creates an BoundingBoxGizmo
  59567. * @param gizmoLayer The utility layer the gizmo will be added to
  59568. * @param color The color of the gizmo
  59569. */
  59570. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59571. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59572. private _selectNode;
  59573. /**
  59574. * Updates the bounding box information for the Gizmo
  59575. */
  59576. updateBoundingBox(): void;
  59577. private _updateRotationSpheres;
  59578. private _updateScaleBoxes;
  59579. /**
  59580. * Enables rotation on the specified axis and disables rotation on the others
  59581. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59582. */
  59583. setEnabledRotationAxis(axis: string): void;
  59584. /**
  59585. * Enables/disables scaling
  59586. * @param enable if scaling should be enabled
  59587. * @param homogeneousScaling defines if scaling should only be homogeneous
  59588. */
  59589. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59590. private _updateDummy;
  59591. /**
  59592. * Enables a pointer drag behavior on the bounding box of the gizmo
  59593. */
  59594. enableDragBehavior(): void;
  59595. /**
  59596. * Disposes of the gizmo
  59597. */
  59598. dispose(): void;
  59599. /**
  59600. * 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)
  59601. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59602. * @returns the bounding box mesh with the passed in mesh as a child
  59603. */
  59604. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59605. /**
  59606. * CustomMeshes are not supported by this gizmo
  59607. * @param mesh The mesh to replace the default mesh of the gizmo
  59608. */
  59609. setCustomMesh(mesh: Mesh): void;
  59610. }
  59611. }
  59612. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59613. import { Observable } from "babylonjs/Misc/observable";
  59614. import { Nullable } from "babylonjs/types";
  59615. import { Vector3 } from "babylonjs/Maths/math.vector";
  59616. import { Color3 } from "babylonjs/Maths/math.color";
  59617. import { Node } from "babylonjs/node";
  59618. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59619. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59620. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59621. import "babylonjs/Meshes/Builders/linesBuilder";
  59622. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59623. /**
  59624. * Single plane rotation gizmo
  59625. */
  59626. export class PlaneRotationGizmo extends Gizmo {
  59627. /**
  59628. * Drag behavior responsible for the gizmos dragging interactions
  59629. */
  59630. dragBehavior: PointerDragBehavior;
  59631. private _pointerObserver;
  59632. /**
  59633. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59634. */
  59635. snapDistance: number;
  59636. /**
  59637. * Event that fires each time the gizmo snaps to a new location.
  59638. * * snapDistance is the the change in distance
  59639. */
  59640. onSnapObservable: Observable<{
  59641. snapDistance: number;
  59642. }>;
  59643. private _isEnabled;
  59644. private _parent;
  59645. /**
  59646. * Creates a PlaneRotationGizmo
  59647. * @param gizmoLayer The utility layer the gizmo will be added to
  59648. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59649. * @param color The color of the gizmo
  59650. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59651. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59652. * @param thickness display gizmo axis thickness
  59653. */
  59654. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59655. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59656. /**
  59657. * If the gizmo is enabled
  59658. */
  59659. set isEnabled(value: boolean);
  59660. get isEnabled(): boolean;
  59661. /**
  59662. * Disposes of the gizmo
  59663. */
  59664. dispose(): void;
  59665. }
  59666. }
  59667. declare module "babylonjs/Gizmos/rotationGizmo" {
  59668. import { Observable } from "babylonjs/Misc/observable";
  59669. import { Nullable } from "babylonjs/types";
  59670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59671. import { Mesh } from "babylonjs/Meshes/mesh";
  59672. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59673. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59674. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59675. import { Node } from "babylonjs/node";
  59676. /**
  59677. * Gizmo that enables rotating a mesh along 3 axis
  59678. */
  59679. export class RotationGizmo extends Gizmo {
  59680. /**
  59681. * Internal gizmo used for interactions on the x axis
  59682. */
  59683. xGizmo: PlaneRotationGizmo;
  59684. /**
  59685. * Internal gizmo used for interactions on the y axis
  59686. */
  59687. yGizmo: PlaneRotationGizmo;
  59688. /**
  59689. * Internal gizmo used for interactions on the z axis
  59690. */
  59691. zGizmo: PlaneRotationGizmo;
  59692. /** Fires an event when any of it's sub gizmos are dragged */
  59693. onDragStartObservable: Observable<unknown>;
  59694. /** Fires an event when any of it's sub gizmos are released from dragging */
  59695. onDragEndObservable: Observable<unknown>;
  59696. private _meshAttached;
  59697. private _nodeAttached;
  59698. get attachedMesh(): Nullable<AbstractMesh>;
  59699. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59700. get attachedNode(): Nullable<Node>;
  59701. set attachedNode(node: Nullable<Node>);
  59702. protected _checkBillboardTransform(): void;
  59703. /**
  59704. * True when the mouse pointer is hovering a gizmo mesh
  59705. */
  59706. get isHovered(): boolean;
  59707. /**
  59708. * Creates a RotationGizmo
  59709. * @param gizmoLayer The utility layer the gizmo will be added to
  59710. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59711. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59712. * @param thickness display gizmo axis thickness
  59713. */
  59714. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  59715. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59716. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59717. /**
  59718. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59719. */
  59720. set snapDistance(value: number);
  59721. get snapDistance(): number;
  59722. /**
  59723. * Ratio for the scale of the gizmo (Default: 1)
  59724. */
  59725. set scaleRatio(value: number);
  59726. get scaleRatio(): number;
  59727. /**
  59728. * Disposes of the gizmo
  59729. */
  59730. dispose(): void;
  59731. /**
  59732. * CustomMeshes are not supported by this gizmo
  59733. * @param mesh The mesh to replace the default mesh of the gizmo
  59734. */
  59735. setCustomMesh(mesh: Mesh): void;
  59736. }
  59737. }
  59738. declare module "babylonjs/Gizmos/gizmoManager" {
  59739. import { Observable } from "babylonjs/Misc/observable";
  59740. import { Nullable } from "babylonjs/types";
  59741. import { Scene, IDisposable } from "babylonjs/scene";
  59742. import { Node } from "babylonjs/node";
  59743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59744. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59745. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59746. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59747. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59748. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59749. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59750. /**
  59751. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59752. */
  59753. export class GizmoManager implements IDisposable {
  59754. private scene;
  59755. /**
  59756. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59757. */
  59758. gizmos: {
  59759. positionGizmo: Nullable<PositionGizmo>;
  59760. rotationGizmo: Nullable<RotationGizmo>;
  59761. scaleGizmo: Nullable<ScaleGizmo>;
  59762. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59763. };
  59764. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59765. clearGizmoOnEmptyPointerEvent: boolean;
  59766. /** Fires an event when the manager is attached to a mesh */
  59767. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59768. /** Fires an event when the manager is attached to a node */
  59769. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59770. private _gizmosEnabled;
  59771. private _pointerObserver;
  59772. private _attachedMesh;
  59773. private _attachedNode;
  59774. private _boundingBoxColor;
  59775. private _defaultUtilityLayer;
  59776. private _defaultKeepDepthUtilityLayer;
  59777. private _thickness;
  59778. /**
  59779. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59780. */
  59781. boundingBoxDragBehavior: SixDofDragBehavior;
  59782. /**
  59783. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59784. */
  59785. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59786. /**
  59787. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59788. */
  59789. attachableNodes: Nullable<Array<Node>>;
  59790. /**
  59791. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59792. */
  59793. usePointerToAttachGizmos: boolean;
  59794. /**
  59795. * Utility layer that the bounding box gizmo belongs to
  59796. */
  59797. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59798. /**
  59799. * Utility layer that all gizmos besides bounding box belong to
  59800. */
  59801. get utilityLayer(): UtilityLayerRenderer;
  59802. /**
  59803. * True when the mouse pointer is hovering a gizmo mesh
  59804. */
  59805. get isHovered(): boolean;
  59806. /**
  59807. * Instatiates a gizmo manager
  59808. * @param scene the scene to overlay the gizmos on top of
  59809. * @param thickness display gizmo axis thickness
  59810. */
  59811. constructor(scene: Scene, thickness?: number);
  59812. /**
  59813. * Attaches a set of gizmos to the specified mesh
  59814. * @param mesh The mesh the gizmo's should be attached to
  59815. */
  59816. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59817. /**
  59818. * Attaches a set of gizmos to the specified node
  59819. * @param node The node the gizmo's should be attached to
  59820. */
  59821. attachToNode(node: Nullable<Node>): void;
  59822. /**
  59823. * If the position gizmo is enabled
  59824. */
  59825. set positionGizmoEnabled(value: boolean);
  59826. get positionGizmoEnabled(): boolean;
  59827. /**
  59828. * If the rotation gizmo is enabled
  59829. */
  59830. set rotationGizmoEnabled(value: boolean);
  59831. get rotationGizmoEnabled(): boolean;
  59832. /**
  59833. * If the scale gizmo is enabled
  59834. */
  59835. set scaleGizmoEnabled(value: boolean);
  59836. get scaleGizmoEnabled(): boolean;
  59837. /**
  59838. * If the boundingBox gizmo is enabled
  59839. */
  59840. set boundingBoxGizmoEnabled(value: boolean);
  59841. get boundingBoxGizmoEnabled(): boolean;
  59842. /**
  59843. * Disposes of the gizmo manager
  59844. */
  59845. dispose(): void;
  59846. }
  59847. }
  59848. declare module "babylonjs/Lights/directionalLight" {
  59849. import { Camera } from "babylonjs/Cameras/camera";
  59850. import { Scene } from "babylonjs/scene";
  59851. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59853. import { Light } from "babylonjs/Lights/light";
  59854. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59855. import { Effect } from "babylonjs/Materials/effect";
  59856. /**
  59857. * A directional light is defined by a direction (what a surprise!).
  59858. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59859. * 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.
  59860. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59861. */
  59862. export class DirectionalLight extends ShadowLight {
  59863. private _shadowFrustumSize;
  59864. /**
  59865. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59866. */
  59867. get shadowFrustumSize(): number;
  59868. /**
  59869. * Specifies a fix frustum size for the shadow generation.
  59870. */
  59871. set shadowFrustumSize(value: number);
  59872. private _shadowOrthoScale;
  59873. /**
  59874. * Gets the shadow projection scale against the optimal computed one.
  59875. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59876. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59877. */
  59878. get shadowOrthoScale(): number;
  59879. /**
  59880. * Sets the shadow projection scale against the optimal computed one.
  59881. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59882. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59883. */
  59884. set shadowOrthoScale(value: number);
  59885. /**
  59886. * Automatically compute the projection matrix to best fit (including all the casters)
  59887. * on each frame.
  59888. */
  59889. autoUpdateExtends: boolean;
  59890. /**
  59891. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59892. * on each frame. autoUpdateExtends must be set to true for this to work
  59893. */
  59894. autoCalcShadowZBounds: boolean;
  59895. private _orthoLeft;
  59896. private _orthoRight;
  59897. private _orthoTop;
  59898. private _orthoBottom;
  59899. /**
  59900. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59901. * The directional light is emitted from everywhere in the given direction.
  59902. * It can cast shadows.
  59903. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59904. * @param name The friendly name of the light
  59905. * @param direction The direction of the light
  59906. * @param scene The scene the light belongs to
  59907. */
  59908. constructor(name: string, direction: Vector3, scene: Scene);
  59909. /**
  59910. * Returns the string "DirectionalLight".
  59911. * @return The class name
  59912. */
  59913. getClassName(): string;
  59914. /**
  59915. * Returns the integer 1.
  59916. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59917. */
  59918. getTypeID(): number;
  59919. /**
  59920. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59921. * Returns the DirectionalLight Shadow projection matrix.
  59922. */
  59923. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59924. /**
  59925. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59926. * Returns the DirectionalLight Shadow projection matrix.
  59927. */
  59928. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59929. /**
  59930. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59931. * Returns the DirectionalLight Shadow projection matrix.
  59932. */
  59933. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59934. protected _buildUniformLayout(): void;
  59935. /**
  59936. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59937. * @param effect The effect to update
  59938. * @param lightIndex The index of the light in the effect to update
  59939. * @returns The directional light
  59940. */
  59941. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59942. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59943. /**
  59944. * Gets the minZ used for shadow according to both the scene and the light.
  59945. *
  59946. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59947. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59948. * @param activeCamera The camera we are returning the min for
  59949. * @returns the depth min z
  59950. */
  59951. getDepthMinZ(activeCamera: Camera): number;
  59952. /**
  59953. * Gets the maxZ used for shadow according to both the scene and the light.
  59954. *
  59955. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59956. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59957. * @param activeCamera The camera we are returning the max for
  59958. * @returns the depth max z
  59959. */
  59960. getDepthMaxZ(activeCamera: Camera): number;
  59961. /**
  59962. * Prepares the list of defines specific to the light type.
  59963. * @param defines the list of defines
  59964. * @param lightIndex defines the index of the light for the effect
  59965. */
  59966. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59967. }
  59968. }
  59969. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  59970. import { Mesh } from "babylonjs/Meshes/mesh";
  59971. /**
  59972. * Class containing static functions to help procedurally build meshes
  59973. */
  59974. export class HemisphereBuilder {
  59975. /**
  59976. * Creates a hemisphere mesh
  59977. * @param name defines the name of the mesh
  59978. * @param options defines the options used to create the mesh
  59979. * @param scene defines the hosting scene
  59980. * @returns the hemisphere mesh
  59981. */
  59982. static CreateHemisphere(name: string, options: {
  59983. segments?: number;
  59984. diameter?: number;
  59985. sideOrientation?: number;
  59986. }, scene: any): Mesh;
  59987. }
  59988. }
  59989. declare module "babylonjs/Lights/spotLight" {
  59990. import { Nullable } from "babylonjs/types";
  59991. import { Scene } from "babylonjs/scene";
  59992. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59994. import { Effect } from "babylonjs/Materials/effect";
  59995. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59996. import { Light } from "babylonjs/Lights/light";
  59997. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59998. /**
  59999. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60000. * These values define a cone of light starting from the position, emitting toward the direction.
  60001. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60002. * and the exponent defines the speed of the decay of the light with distance (reach).
  60003. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60004. */
  60005. export class SpotLight extends ShadowLight {
  60006. private _angle;
  60007. private _innerAngle;
  60008. private _cosHalfAngle;
  60009. private _lightAngleScale;
  60010. private _lightAngleOffset;
  60011. /**
  60012. * Gets the cone angle of the spot light in Radians.
  60013. */
  60014. get angle(): number;
  60015. /**
  60016. * Sets the cone angle of the spot light in Radians.
  60017. */
  60018. set angle(value: number);
  60019. /**
  60020. * Only used in gltf falloff mode, this defines the angle where
  60021. * the directional falloff will start before cutting at angle which could be seen
  60022. * as outer angle.
  60023. */
  60024. get innerAngle(): number;
  60025. /**
  60026. * Only used in gltf falloff mode, this defines the angle where
  60027. * the directional falloff will start before cutting at angle which could be seen
  60028. * as outer angle.
  60029. */
  60030. set innerAngle(value: number);
  60031. private _shadowAngleScale;
  60032. /**
  60033. * Allows scaling the angle of the light for shadow generation only.
  60034. */
  60035. get shadowAngleScale(): number;
  60036. /**
  60037. * Allows scaling the angle of the light for shadow generation only.
  60038. */
  60039. set shadowAngleScale(value: number);
  60040. /**
  60041. * The light decay speed with the distance from the emission spot.
  60042. */
  60043. exponent: number;
  60044. private _projectionTextureMatrix;
  60045. /**
  60046. * Allows reading the projecton texture
  60047. */
  60048. get projectionTextureMatrix(): Matrix;
  60049. protected _projectionTextureLightNear: number;
  60050. /**
  60051. * Gets the near clip of the Spotlight for texture projection.
  60052. */
  60053. get projectionTextureLightNear(): number;
  60054. /**
  60055. * Sets the near clip of the Spotlight for texture projection.
  60056. */
  60057. set projectionTextureLightNear(value: number);
  60058. protected _projectionTextureLightFar: number;
  60059. /**
  60060. * Gets the far clip of the Spotlight for texture projection.
  60061. */
  60062. get projectionTextureLightFar(): number;
  60063. /**
  60064. * Sets the far clip of the Spotlight for texture projection.
  60065. */
  60066. set projectionTextureLightFar(value: number);
  60067. protected _projectionTextureUpDirection: Vector3;
  60068. /**
  60069. * Gets the Up vector of the Spotlight for texture projection.
  60070. */
  60071. get projectionTextureUpDirection(): Vector3;
  60072. /**
  60073. * Sets the Up vector of the Spotlight for texture projection.
  60074. */
  60075. set projectionTextureUpDirection(value: Vector3);
  60076. private _projectionTexture;
  60077. /**
  60078. * Gets the projection texture of the light.
  60079. */
  60080. get projectionTexture(): Nullable<BaseTexture>;
  60081. /**
  60082. * Sets the projection texture of the light.
  60083. */
  60084. set projectionTexture(value: Nullable<BaseTexture>);
  60085. private static _IsProceduralTexture;
  60086. private static _IsTexture;
  60087. private _projectionTextureViewLightDirty;
  60088. private _projectionTextureProjectionLightDirty;
  60089. private _projectionTextureDirty;
  60090. private _projectionTextureViewTargetVector;
  60091. private _projectionTextureViewLightMatrix;
  60092. private _projectionTextureProjectionLightMatrix;
  60093. private _projectionTextureScalingMatrix;
  60094. /**
  60095. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60096. * It can cast shadows.
  60097. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60098. * @param name The light friendly name
  60099. * @param position The position of the spot light in the scene
  60100. * @param direction The direction of the light in the scene
  60101. * @param angle The cone angle of the light in Radians
  60102. * @param exponent The light decay speed with the distance from the emission spot
  60103. * @param scene The scene the lights belongs to
  60104. */
  60105. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60106. /**
  60107. * Returns the string "SpotLight".
  60108. * @returns the class name
  60109. */
  60110. getClassName(): string;
  60111. /**
  60112. * Returns the integer 2.
  60113. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60114. */
  60115. getTypeID(): number;
  60116. /**
  60117. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60118. */
  60119. protected _setDirection(value: Vector3): void;
  60120. /**
  60121. * Overrides the position setter to recompute the projection texture view light Matrix.
  60122. */
  60123. protected _setPosition(value: Vector3): void;
  60124. /**
  60125. * 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.
  60126. * Returns the SpotLight.
  60127. */
  60128. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60129. protected _computeProjectionTextureViewLightMatrix(): void;
  60130. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60131. /**
  60132. * Main function for light texture projection matrix computing.
  60133. */
  60134. protected _computeProjectionTextureMatrix(): void;
  60135. protected _buildUniformLayout(): void;
  60136. private _computeAngleValues;
  60137. /**
  60138. * Sets the passed Effect "effect" with the Light textures.
  60139. * @param effect The effect to update
  60140. * @param lightIndex The index of the light in the effect to update
  60141. * @returns The light
  60142. */
  60143. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60144. /**
  60145. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60146. * @param effect The effect to update
  60147. * @param lightIndex The index of the light in the effect to update
  60148. * @returns The spot light
  60149. */
  60150. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60151. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60152. /**
  60153. * Disposes the light and the associated resources.
  60154. */
  60155. dispose(): void;
  60156. /**
  60157. * Prepares the list of defines specific to the light type.
  60158. * @param defines the list of defines
  60159. * @param lightIndex defines the index of the light for the effect
  60160. */
  60161. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60162. }
  60163. }
  60164. declare module "babylonjs/Gizmos/lightGizmo" {
  60165. import { Nullable } from "babylonjs/types";
  60166. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60167. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60168. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60169. import { Light } from "babylonjs/Lights/light";
  60170. import { Observable } from "babylonjs/Misc/observable";
  60171. /**
  60172. * Gizmo that enables viewing a light
  60173. */
  60174. export class LightGizmo extends Gizmo {
  60175. private _lightMesh;
  60176. private _material;
  60177. private _cachedPosition;
  60178. private _cachedForward;
  60179. private _attachedMeshParent;
  60180. private _pointerObserver;
  60181. /**
  60182. * Event that fires each time the gizmo is clicked
  60183. */
  60184. onClickedObservable: Observable<Light>;
  60185. /**
  60186. * Creates a LightGizmo
  60187. * @param gizmoLayer The utility layer the gizmo will be added to
  60188. */
  60189. constructor(gizmoLayer?: UtilityLayerRenderer);
  60190. private _light;
  60191. /**
  60192. * The light that the gizmo is attached to
  60193. */
  60194. set light(light: Nullable<Light>);
  60195. get light(): Nullable<Light>;
  60196. /**
  60197. * Gets the material used to render the light gizmo
  60198. */
  60199. get material(): StandardMaterial;
  60200. /**
  60201. * @hidden
  60202. * Updates the gizmo to match the attached mesh's position/rotation
  60203. */
  60204. protected _update(): void;
  60205. private static _Scale;
  60206. /**
  60207. * Creates the lines for a light mesh
  60208. */
  60209. private static _CreateLightLines;
  60210. /**
  60211. * Disposes of the light gizmo
  60212. */
  60213. dispose(): void;
  60214. private static _CreateHemisphericLightMesh;
  60215. private static _CreatePointLightMesh;
  60216. private static _CreateSpotLightMesh;
  60217. private static _CreateDirectionalLightMesh;
  60218. }
  60219. }
  60220. declare module "babylonjs/Gizmos/cameraGizmo" {
  60221. import { Nullable } from "babylonjs/types";
  60222. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60223. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60224. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60225. import { Camera } from "babylonjs/Cameras/camera";
  60226. import { Observable } from "babylonjs/Misc/observable";
  60227. /**
  60228. * Gizmo that enables viewing a camera
  60229. */
  60230. export class CameraGizmo extends Gizmo {
  60231. private _cameraMesh;
  60232. private _cameraLinesMesh;
  60233. private _material;
  60234. private _pointerObserver;
  60235. /**
  60236. * Event that fires each time the gizmo is clicked
  60237. */
  60238. onClickedObservable: Observable<Camera>;
  60239. /**
  60240. * Creates a CameraGizmo
  60241. * @param gizmoLayer The utility layer the gizmo will be added to
  60242. */
  60243. constructor(gizmoLayer?: UtilityLayerRenderer);
  60244. private _camera;
  60245. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60246. get displayFrustum(): boolean;
  60247. set displayFrustum(value: boolean);
  60248. /**
  60249. * The camera that the gizmo is attached to
  60250. */
  60251. set camera(camera: Nullable<Camera>);
  60252. get camera(): Nullable<Camera>;
  60253. /**
  60254. * Gets the material used to render the camera gizmo
  60255. */
  60256. get material(): StandardMaterial;
  60257. /**
  60258. * @hidden
  60259. * Updates the gizmo to match the attached mesh's position/rotation
  60260. */
  60261. protected _update(): void;
  60262. private static _Scale;
  60263. private _invProjection;
  60264. /**
  60265. * Disposes of the camera gizmo
  60266. */
  60267. dispose(): void;
  60268. private static _CreateCameraMesh;
  60269. private static _CreateCameraFrustum;
  60270. }
  60271. }
  60272. declare module "babylonjs/Gizmos/index" {
  60273. export * from "babylonjs/Gizmos/axisDragGizmo";
  60274. export * from "babylonjs/Gizmos/axisScaleGizmo";
  60275. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  60276. export * from "babylonjs/Gizmos/gizmo";
  60277. export * from "babylonjs/Gizmos/gizmoManager";
  60278. export * from "babylonjs/Gizmos/planeRotationGizmo";
  60279. export * from "babylonjs/Gizmos/positionGizmo";
  60280. export * from "babylonjs/Gizmos/rotationGizmo";
  60281. export * from "babylonjs/Gizmos/scaleGizmo";
  60282. export * from "babylonjs/Gizmos/lightGizmo";
  60283. export * from "babylonjs/Gizmos/cameraGizmo";
  60284. export * from "babylonjs/Gizmos/planeDragGizmo";
  60285. }
  60286. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  60287. /** @hidden */
  60288. export var backgroundFragmentDeclaration: {
  60289. name: string;
  60290. shader: string;
  60291. };
  60292. }
  60293. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  60294. /** @hidden */
  60295. export var backgroundUboDeclaration: {
  60296. name: string;
  60297. shader: string;
  60298. };
  60299. }
  60300. declare module "babylonjs/Shaders/background.fragment" {
  60301. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  60302. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60303. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60304. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60305. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60306. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60307. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60308. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60309. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60310. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60311. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  60312. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60313. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60314. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60315. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  60316. /** @hidden */
  60317. export var backgroundPixelShader: {
  60318. name: string;
  60319. shader: string;
  60320. };
  60321. }
  60322. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  60323. /** @hidden */
  60324. export var backgroundVertexDeclaration: {
  60325. name: string;
  60326. shader: string;
  60327. };
  60328. }
  60329. declare module "babylonjs/Shaders/background.vertex" {
  60330. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  60331. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60333. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60334. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60335. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  60336. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  60337. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60338. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60339. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60340. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60341. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60342. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  60343. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60344. /** @hidden */
  60345. export var backgroundVertexShader: {
  60346. name: string;
  60347. shader: string;
  60348. };
  60349. }
  60350. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  60351. import { Nullable, int, float } from "babylonjs/types";
  60352. import { Scene } from "babylonjs/scene";
  60353. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60354. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60356. import { Mesh } from "babylonjs/Meshes/mesh";
  60357. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60358. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  60359. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  60360. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60361. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  60362. import { Color3 } from "babylonjs/Maths/math.color";
  60363. import "babylonjs/Shaders/background.fragment";
  60364. import "babylonjs/Shaders/background.vertex";
  60365. /**
  60366. * Background material used to create an efficient environement around your scene.
  60367. */
  60368. export class BackgroundMaterial extends PushMaterial {
  60369. /**
  60370. * Standard reflectance value at parallel view angle.
  60371. */
  60372. static StandardReflectance0: number;
  60373. /**
  60374. * Standard reflectance value at grazing angle.
  60375. */
  60376. static StandardReflectance90: number;
  60377. protected _primaryColor: Color3;
  60378. /**
  60379. * Key light Color (multiply against the environement texture)
  60380. */
  60381. primaryColor: Color3;
  60382. protected __perceptualColor: Nullable<Color3>;
  60383. /**
  60384. * Experimental Internal Use Only.
  60385. *
  60386. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60387. * This acts as a helper to set the primary color to a more "human friendly" value.
  60388. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60389. * output color as close as possible from the chosen value.
  60390. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60391. * part of lighting setup.)
  60392. */
  60393. get _perceptualColor(): Nullable<Color3>;
  60394. set _perceptualColor(value: Nullable<Color3>);
  60395. protected _primaryColorShadowLevel: float;
  60396. /**
  60397. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60398. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60399. */
  60400. get primaryColorShadowLevel(): float;
  60401. set primaryColorShadowLevel(value: float);
  60402. protected _primaryColorHighlightLevel: float;
  60403. /**
  60404. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60405. * The primary color is used at the level chosen to define what the white area would look.
  60406. */
  60407. get primaryColorHighlightLevel(): float;
  60408. set primaryColorHighlightLevel(value: float);
  60409. protected _reflectionTexture: Nullable<BaseTexture>;
  60410. /**
  60411. * Reflection Texture used in the material.
  60412. * Should be author in a specific way for the best result (refer to the documentation).
  60413. */
  60414. reflectionTexture: Nullable<BaseTexture>;
  60415. protected _reflectionBlur: float;
  60416. /**
  60417. * Reflection Texture level of blur.
  60418. *
  60419. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60420. * texture twice.
  60421. */
  60422. reflectionBlur: float;
  60423. protected _diffuseTexture: Nullable<BaseTexture>;
  60424. /**
  60425. * Diffuse Texture used in the material.
  60426. * Should be author in a specific way for the best result (refer to the documentation).
  60427. */
  60428. diffuseTexture: Nullable<BaseTexture>;
  60429. protected _shadowLights: Nullable<IShadowLight[]>;
  60430. /**
  60431. * Specify the list of lights casting shadow on the material.
  60432. * All scene shadow lights will be included if null.
  60433. */
  60434. shadowLights: Nullable<IShadowLight[]>;
  60435. protected _shadowLevel: float;
  60436. /**
  60437. * Helps adjusting the shadow to a softer level if required.
  60438. * 0 means black shadows and 1 means no shadows.
  60439. */
  60440. shadowLevel: float;
  60441. protected _sceneCenter: Vector3;
  60442. /**
  60443. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60444. * It is usually zero but might be interesting to modify according to your setup.
  60445. */
  60446. sceneCenter: Vector3;
  60447. protected _opacityFresnel: boolean;
  60448. /**
  60449. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60450. * This helps ensuring a nice transition when the camera goes under the ground.
  60451. */
  60452. opacityFresnel: boolean;
  60453. protected _reflectionFresnel: boolean;
  60454. /**
  60455. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60456. * This helps adding a mirror texture on the ground.
  60457. */
  60458. reflectionFresnel: boolean;
  60459. protected _reflectionFalloffDistance: number;
  60460. /**
  60461. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60462. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60463. */
  60464. reflectionFalloffDistance: number;
  60465. protected _reflectionAmount: number;
  60466. /**
  60467. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60468. */
  60469. reflectionAmount: number;
  60470. protected _reflectionReflectance0: number;
  60471. /**
  60472. * This specifies the weight of the reflection at grazing angle.
  60473. */
  60474. reflectionReflectance0: number;
  60475. protected _reflectionReflectance90: number;
  60476. /**
  60477. * This specifies the weight of the reflection at a perpendicular point of view.
  60478. */
  60479. reflectionReflectance90: number;
  60480. /**
  60481. * Sets the reflection reflectance fresnel values according to the default standard
  60482. * empirically know to work well :-)
  60483. */
  60484. set reflectionStandardFresnelWeight(value: number);
  60485. protected _useRGBColor: boolean;
  60486. /**
  60487. * Helps to directly use the maps channels instead of their level.
  60488. */
  60489. useRGBColor: boolean;
  60490. protected _enableNoise: boolean;
  60491. /**
  60492. * This helps reducing the banding effect that could occur on the background.
  60493. */
  60494. enableNoise: boolean;
  60495. /**
  60496. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60497. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60498. * Recommended to be keep at 1.0 except for special cases.
  60499. */
  60500. get fovMultiplier(): number;
  60501. set fovMultiplier(value: number);
  60502. private _fovMultiplier;
  60503. /**
  60504. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60505. */
  60506. useEquirectangularFOV: boolean;
  60507. private _maxSimultaneousLights;
  60508. /**
  60509. * Number of Simultaneous lights allowed on the material.
  60510. */
  60511. maxSimultaneousLights: int;
  60512. private _shadowOnly;
  60513. /**
  60514. * Make the material only render shadows
  60515. */
  60516. shadowOnly: boolean;
  60517. /**
  60518. * Default configuration related to image processing available in the Background Material.
  60519. */
  60520. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60521. /**
  60522. * Keep track of the image processing observer to allow dispose and replace.
  60523. */
  60524. private _imageProcessingObserver;
  60525. /**
  60526. * Attaches a new image processing configuration to the PBR Material.
  60527. * @param configuration (if null the scene configuration will be use)
  60528. */
  60529. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60530. /**
  60531. * Gets the image processing configuration used either in this material.
  60532. */
  60533. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60534. /**
  60535. * Sets the Default image processing configuration used either in the this material.
  60536. *
  60537. * If sets to null, the scene one is in use.
  60538. */
  60539. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60540. /**
  60541. * Gets wether the color curves effect is enabled.
  60542. */
  60543. get cameraColorCurvesEnabled(): boolean;
  60544. /**
  60545. * Sets wether the color curves effect is enabled.
  60546. */
  60547. set cameraColorCurvesEnabled(value: boolean);
  60548. /**
  60549. * Gets wether the color grading effect is enabled.
  60550. */
  60551. get cameraColorGradingEnabled(): boolean;
  60552. /**
  60553. * Gets wether the color grading effect is enabled.
  60554. */
  60555. set cameraColorGradingEnabled(value: boolean);
  60556. /**
  60557. * Gets wether tonemapping is enabled or not.
  60558. */
  60559. get cameraToneMappingEnabled(): boolean;
  60560. /**
  60561. * Sets wether tonemapping is enabled or not
  60562. */
  60563. set cameraToneMappingEnabled(value: boolean);
  60564. /**
  60565. * The camera exposure used on this material.
  60566. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60567. * This corresponds to a photographic exposure.
  60568. */
  60569. get cameraExposure(): float;
  60570. /**
  60571. * The camera exposure used on this material.
  60572. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60573. * This corresponds to a photographic exposure.
  60574. */
  60575. set cameraExposure(value: float);
  60576. /**
  60577. * Gets The camera contrast used on this material.
  60578. */
  60579. get cameraContrast(): float;
  60580. /**
  60581. * Sets The camera contrast used on this material.
  60582. */
  60583. set cameraContrast(value: float);
  60584. /**
  60585. * Gets the Color Grading 2D Lookup Texture.
  60586. */
  60587. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60588. /**
  60589. * Sets the Color Grading 2D Lookup Texture.
  60590. */
  60591. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60592. /**
  60593. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60594. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60595. * 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;
  60596. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60597. */
  60598. get cameraColorCurves(): Nullable<ColorCurves>;
  60599. /**
  60600. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60601. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60602. * 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;
  60603. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60604. */
  60605. set cameraColorCurves(value: Nullable<ColorCurves>);
  60606. /**
  60607. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60608. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60609. */
  60610. switchToBGR: boolean;
  60611. private _renderTargets;
  60612. private _reflectionControls;
  60613. private _white;
  60614. private _primaryShadowColor;
  60615. private _primaryHighlightColor;
  60616. /**
  60617. * Instantiates a Background Material in the given scene
  60618. * @param name The friendly name of the material
  60619. * @param scene The scene to add the material to
  60620. */
  60621. constructor(name: string, scene: Scene);
  60622. /**
  60623. * Gets a boolean indicating that current material needs to register RTT
  60624. */
  60625. get hasRenderTargetTextures(): boolean;
  60626. /**
  60627. * The entire material has been created in order to prevent overdraw.
  60628. * @returns false
  60629. */
  60630. needAlphaTesting(): boolean;
  60631. /**
  60632. * The entire material has been created in order to prevent overdraw.
  60633. * @returns true if blending is enable
  60634. */
  60635. needAlphaBlending(): boolean;
  60636. /**
  60637. * Checks wether the material is ready to be rendered for a given mesh.
  60638. * @param mesh The mesh to render
  60639. * @param subMesh The submesh to check against
  60640. * @param useInstances Specify wether or not the material is used with instances
  60641. * @returns true if all the dependencies are ready (Textures, Effects...)
  60642. */
  60643. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60644. /**
  60645. * Compute the primary color according to the chosen perceptual color.
  60646. */
  60647. private _computePrimaryColorFromPerceptualColor;
  60648. /**
  60649. * Compute the highlights and shadow colors according to their chosen levels.
  60650. */
  60651. private _computePrimaryColors;
  60652. /**
  60653. * Build the uniform buffer used in the material.
  60654. */
  60655. buildUniformLayout(): void;
  60656. /**
  60657. * Unbind the material.
  60658. */
  60659. unbind(): void;
  60660. /**
  60661. * Bind only the world matrix to the material.
  60662. * @param world The world matrix to bind.
  60663. */
  60664. bindOnlyWorldMatrix(world: Matrix): void;
  60665. /**
  60666. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  60667. * @param world The world matrix to bind.
  60668. * @param subMesh The submesh to bind for.
  60669. */
  60670. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60671. /**
  60672. * Checks to see if a texture is used in the material.
  60673. * @param texture - Base texture to use.
  60674. * @returns - Boolean specifying if a texture is used in the material.
  60675. */
  60676. hasTexture(texture: BaseTexture): boolean;
  60677. /**
  60678. * Dispose the material.
  60679. * @param forceDisposeEffect Force disposal of the associated effect.
  60680. * @param forceDisposeTextures Force disposal of the associated textures.
  60681. */
  60682. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  60683. /**
  60684. * Clones the material.
  60685. * @param name The cloned name.
  60686. * @returns The cloned material.
  60687. */
  60688. clone(name: string): BackgroundMaterial;
  60689. /**
  60690. * Serializes the current material to its JSON representation.
  60691. * @returns The JSON representation.
  60692. */
  60693. serialize(): any;
  60694. /**
  60695. * Gets the class name of the material
  60696. * @returns "BackgroundMaterial"
  60697. */
  60698. getClassName(): string;
  60699. /**
  60700. * Parse a JSON input to create back a background material.
  60701. * @param source The JSON data to parse
  60702. * @param scene The scene to create the parsed material in
  60703. * @param rootUrl The root url of the assets the material depends upon
  60704. * @returns the instantiated BackgroundMaterial.
  60705. */
  60706. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  60707. }
  60708. }
  60709. declare module "babylonjs/Helpers/environmentHelper" {
  60710. import { Observable } from "babylonjs/Misc/observable";
  60711. import { Nullable } from "babylonjs/types";
  60712. import { Scene } from "babylonjs/scene";
  60713. import { Vector3 } from "babylonjs/Maths/math.vector";
  60714. import { Color3 } from "babylonjs/Maths/math.color";
  60715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60716. import { Mesh } from "babylonjs/Meshes/mesh";
  60717. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60718. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  60719. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60720. import "babylonjs/Meshes/Builders/planeBuilder";
  60721. import "babylonjs/Meshes/Builders/boxBuilder";
  60722. /**
  60723. * Represents the different options available during the creation of
  60724. * a Environment helper.
  60725. *
  60726. * This can control the default ground, skybox and image processing setup of your scene.
  60727. */
  60728. export interface IEnvironmentHelperOptions {
  60729. /**
  60730. * Specifies whether or not to create a ground.
  60731. * True by default.
  60732. */
  60733. createGround: boolean;
  60734. /**
  60735. * Specifies the ground size.
  60736. * 15 by default.
  60737. */
  60738. groundSize: number;
  60739. /**
  60740. * The texture used on the ground for the main color.
  60741. * Comes from the BabylonJS CDN by default.
  60742. *
  60743. * Remarks: Can be either a texture or a url.
  60744. */
  60745. groundTexture: string | BaseTexture;
  60746. /**
  60747. * The color mixed in the ground texture by default.
  60748. * BabylonJS clearColor by default.
  60749. */
  60750. groundColor: Color3;
  60751. /**
  60752. * Specifies the ground opacity.
  60753. * 1 by default.
  60754. */
  60755. groundOpacity: number;
  60756. /**
  60757. * Enables the ground to receive shadows.
  60758. * True by default.
  60759. */
  60760. enableGroundShadow: boolean;
  60761. /**
  60762. * Helps preventing the shadow to be fully black on the ground.
  60763. * 0.5 by default.
  60764. */
  60765. groundShadowLevel: number;
  60766. /**
  60767. * Creates a mirror texture attach to the ground.
  60768. * false by default.
  60769. */
  60770. enableGroundMirror: boolean;
  60771. /**
  60772. * Specifies the ground mirror size ratio.
  60773. * 0.3 by default as the default kernel is 64.
  60774. */
  60775. groundMirrorSizeRatio: number;
  60776. /**
  60777. * Specifies the ground mirror blur kernel size.
  60778. * 64 by default.
  60779. */
  60780. groundMirrorBlurKernel: number;
  60781. /**
  60782. * Specifies the ground mirror visibility amount.
  60783. * 1 by default
  60784. */
  60785. groundMirrorAmount: number;
  60786. /**
  60787. * Specifies the ground mirror reflectance weight.
  60788. * This uses the standard weight of the background material to setup the fresnel effect
  60789. * of the mirror.
  60790. * 1 by default.
  60791. */
  60792. groundMirrorFresnelWeight: number;
  60793. /**
  60794. * Specifies the ground mirror Falloff distance.
  60795. * This can helps reducing the size of the reflection.
  60796. * 0 by Default.
  60797. */
  60798. groundMirrorFallOffDistance: number;
  60799. /**
  60800. * Specifies the ground mirror texture type.
  60801. * Unsigned Int by Default.
  60802. */
  60803. groundMirrorTextureType: number;
  60804. /**
  60805. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  60806. * the shown objects.
  60807. */
  60808. groundYBias: number;
  60809. /**
  60810. * Specifies whether or not to create a skybox.
  60811. * True by default.
  60812. */
  60813. createSkybox: boolean;
  60814. /**
  60815. * Specifies the skybox size.
  60816. * 20 by default.
  60817. */
  60818. skyboxSize: number;
  60819. /**
  60820. * The texture used on the skybox for the main color.
  60821. * Comes from the BabylonJS CDN by default.
  60822. *
  60823. * Remarks: Can be either a texture or a url.
  60824. */
  60825. skyboxTexture: string | BaseTexture;
  60826. /**
  60827. * The color mixed in the skybox texture by default.
  60828. * BabylonJS clearColor by default.
  60829. */
  60830. skyboxColor: Color3;
  60831. /**
  60832. * The background rotation around the Y axis of the scene.
  60833. * This helps aligning the key lights of your scene with the background.
  60834. * 0 by default.
  60835. */
  60836. backgroundYRotation: number;
  60837. /**
  60838. * Compute automatically the size of the elements to best fit with the scene.
  60839. */
  60840. sizeAuto: boolean;
  60841. /**
  60842. * Default position of the rootMesh if autoSize is not true.
  60843. */
  60844. rootPosition: Vector3;
  60845. /**
  60846. * Sets up the image processing in the scene.
  60847. * true by default.
  60848. */
  60849. setupImageProcessing: boolean;
  60850. /**
  60851. * The texture used as your environment texture in the scene.
  60852. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  60853. *
  60854. * Remarks: Can be either a texture or a url.
  60855. */
  60856. environmentTexture: string | BaseTexture;
  60857. /**
  60858. * The value of the exposure to apply to the scene.
  60859. * 0.6 by default if setupImageProcessing is true.
  60860. */
  60861. cameraExposure: number;
  60862. /**
  60863. * The value of the contrast to apply to the scene.
  60864. * 1.6 by default if setupImageProcessing is true.
  60865. */
  60866. cameraContrast: number;
  60867. /**
  60868. * Specifies whether or not tonemapping should be enabled in the scene.
  60869. * true by default if setupImageProcessing is true.
  60870. */
  60871. toneMappingEnabled: boolean;
  60872. }
  60873. /**
  60874. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  60875. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  60876. * It also helps with the default setup of your imageProcessing configuration.
  60877. */
  60878. export class EnvironmentHelper {
  60879. /**
  60880. * Default ground texture URL.
  60881. */
  60882. private static _groundTextureCDNUrl;
  60883. /**
  60884. * Default skybox texture URL.
  60885. */
  60886. private static _skyboxTextureCDNUrl;
  60887. /**
  60888. * Default environment texture URL.
  60889. */
  60890. private static _environmentTextureCDNUrl;
  60891. /**
  60892. * Creates the default options for the helper.
  60893. */
  60894. private static _getDefaultOptions;
  60895. private _rootMesh;
  60896. /**
  60897. * Gets the root mesh created by the helper.
  60898. */
  60899. get rootMesh(): Mesh;
  60900. private _skybox;
  60901. /**
  60902. * Gets the skybox created by the helper.
  60903. */
  60904. get skybox(): Nullable<Mesh>;
  60905. private _skyboxTexture;
  60906. /**
  60907. * Gets the skybox texture created by the helper.
  60908. */
  60909. get skyboxTexture(): Nullable<BaseTexture>;
  60910. private _skyboxMaterial;
  60911. /**
  60912. * Gets the skybox material created by the helper.
  60913. */
  60914. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  60915. private _ground;
  60916. /**
  60917. * Gets the ground mesh created by the helper.
  60918. */
  60919. get ground(): Nullable<Mesh>;
  60920. private _groundTexture;
  60921. /**
  60922. * Gets the ground texture created by the helper.
  60923. */
  60924. get groundTexture(): Nullable<BaseTexture>;
  60925. private _groundMirror;
  60926. /**
  60927. * Gets the ground mirror created by the helper.
  60928. */
  60929. get groundMirror(): Nullable<MirrorTexture>;
  60930. /**
  60931. * Gets the ground mirror render list to helps pushing the meshes
  60932. * you wish in the ground reflection.
  60933. */
  60934. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  60935. private _groundMaterial;
  60936. /**
  60937. * Gets the ground material created by the helper.
  60938. */
  60939. get groundMaterial(): Nullable<BackgroundMaterial>;
  60940. /**
  60941. * Stores the creation options.
  60942. */
  60943. private readonly _scene;
  60944. private _options;
  60945. /**
  60946. * This observable will be notified with any error during the creation of the environment,
  60947. * mainly texture creation errors.
  60948. */
  60949. onErrorObservable: Observable<{
  60950. message?: string;
  60951. exception?: any;
  60952. }>;
  60953. /**
  60954. * constructor
  60955. * @param options Defines the options we want to customize the helper
  60956. * @param scene The scene to add the material to
  60957. */
  60958. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  60959. /**
  60960. * Updates the background according to the new options
  60961. * @param options
  60962. */
  60963. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  60964. /**
  60965. * Sets the primary color of all the available elements.
  60966. * @param color the main color to affect to the ground and the background
  60967. */
  60968. setMainColor(color: Color3): void;
  60969. /**
  60970. * Setup the image processing according to the specified options.
  60971. */
  60972. private _setupImageProcessing;
  60973. /**
  60974. * Setup the environment texture according to the specified options.
  60975. */
  60976. private _setupEnvironmentTexture;
  60977. /**
  60978. * Setup the background according to the specified options.
  60979. */
  60980. private _setupBackground;
  60981. /**
  60982. * Get the scene sizes according to the setup.
  60983. */
  60984. private _getSceneSize;
  60985. /**
  60986. * Setup the ground according to the specified options.
  60987. */
  60988. private _setupGround;
  60989. /**
  60990. * Setup the ground material according to the specified options.
  60991. */
  60992. private _setupGroundMaterial;
  60993. /**
  60994. * Setup the ground diffuse texture according to the specified options.
  60995. */
  60996. private _setupGroundDiffuseTexture;
  60997. /**
  60998. * Setup the ground mirror texture according to the specified options.
  60999. */
  61000. private _setupGroundMirrorTexture;
  61001. /**
  61002. * Setup the ground to receive the mirror texture.
  61003. */
  61004. private _setupMirrorInGroundMaterial;
  61005. /**
  61006. * Setup the skybox according to the specified options.
  61007. */
  61008. private _setupSkybox;
  61009. /**
  61010. * Setup the skybox material according to the specified options.
  61011. */
  61012. private _setupSkyboxMaterial;
  61013. /**
  61014. * Setup the skybox reflection texture according to the specified options.
  61015. */
  61016. private _setupSkyboxReflectionTexture;
  61017. private _errorHandler;
  61018. /**
  61019. * Dispose all the elements created by the Helper.
  61020. */
  61021. dispose(): void;
  61022. }
  61023. }
  61024. declare module "babylonjs/Helpers/textureDome" {
  61025. import { Scene } from "babylonjs/scene";
  61026. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61027. import { Mesh } from "babylonjs/Meshes/mesh";
  61028. import { Texture } from "babylonjs/Materials/Textures/texture";
  61029. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61030. import "babylonjs/Meshes/Builders/sphereBuilder";
  61031. import { Nullable } from "babylonjs/types";
  61032. import { Observable } from "babylonjs/Misc/observable";
  61033. /**
  61034. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61035. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61036. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61037. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61038. */
  61039. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61040. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61041. /**
  61042. * Define the source as a Monoscopic panoramic 360/180.
  61043. */
  61044. static readonly MODE_MONOSCOPIC: number;
  61045. /**
  61046. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61047. */
  61048. static readonly MODE_TOPBOTTOM: number;
  61049. /**
  61050. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61051. */
  61052. static readonly MODE_SIDEBYSIDE: number;
  61053. private _halfDome;
  61054. private _crossEye;
  61055. protected _useDirectMapping: boolean;
  61056. /**
  61057. * The texture being displayed on the sphere
  61058. */
  61059. protected _texture: T;
  61060. /**
  61061. * Gets the texture being displayed on the sphere
  61062. */
  61063. get texture(): T;
  61064. /**
  61065. * Sets the texture being displayed on the sphere
  61066. */
  61067. set texture(newTexture: T);
  61068. /**
  61069. * The skybox material
  61070. */
  61071. protected _material: BackgroundMaterial;
  61072. /**
  61073. * The surface used for the dome
  61074. */
  61075. protected _mesh: Mesh;
  61076. /**
  61077. * Gets the mesh used for the dome.
  61078. */
  61079. get mesh(): Mesh;
  61080. /**
  61081. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61082. */
  61083. private _halfDomeMask;
  61084. /**
  61085. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61086. * Also see the options.resolution property.
  61087. */
  61088. get fovMultiplier(): number;
  61089. set fovMultiplier(value: number);
  61090. protected _textureMode: number;
  61091. /**
  61092. * Gets or set the current texture mode for the texture. It can be:
  61093. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61094. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61095. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61096. */
  61097. get textureMode(): number;
  61098. /**
  61099. * Sets the current texture mode for the texture. It can be:
  61100. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61101. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61102. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61103. */
  61104. set textureMode(value: number);
  61105. /**
  61106. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61107. */
  61108. get halfDome(): boolean;
  61109. /**
  61110. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61111. */
  61112. set halfDome(enabled: boolean);
  61113. /**
  61114. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61115. */
  61116. set crossEye(enabled: boolean);
  61117. /**
  61118. * Is it a cross-eye texture?
  61119. */
  61120. get crossEye(): boolean;
  61121. /**
  61122. * The background material of this dome.
  61123. */
  61124. get material(): BackgroundMaterial;
  61125. /**
  61126. * Oberserver used in Stereoscopic VR Mode.
  61127. */
  61128. private _onBeforeCameraRenderObserver;
  61129. /**
  61130. * Observable raised when an error occured while loading the 360 image
  61131. */
  61132. onLoadErrorObservable: Observable<string>;
  61133. /**
  61134. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61135. * @param name Element's name, child elements will append suffixes for their own names.
  61136. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61137. * @param options An object containing optional or exposed sub element properties
  61138. */
  61139. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61140. resolution?: number;
  61141. clickToPlay?: boolean;
  61142. autoPlay?: boolean;
  61143. loop?: boolean;
  61144. size?: number;
  61145. poster?: string;
  61146. faceForward?: boolean;
  61147. useDirectMapping?: boolean;
  61148. halfDomeMode?: boolean;
  61149. crossEyeMode?: boolean;
  61150. generateMipMaps?: boolean;
  61151. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61152. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61153. protected _changeTextureMode(value: number): void;
  61154. /**
  61155. * Releases resources associated with this node.
  61156. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61157. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61158. */
  61159. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61160. }
  61161. }
  61162. declare module "babylonjs/Helpers/photoDome" {
  61163. import { Scene } from "babylonjs/scene";
  61164. import { Texture } from "babylonjs/Materials/Textures/texture";
  61165. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61166. /**
  61167. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61168. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61169. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61170. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61171. */
  61172. export class PhotoDome extends TextureDome<Texture> {
  61173. /**
  61174. * Define the image as a Monoscopic panoramic 360 image.
  61175. */
  61176. static readonly MODE_MONOSCOPIC: number;
  61177. /**
  61178. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61179. */
  61180. static readonly MODE_TOPBOTTOM: number;
  61181. /**
  61182. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61183. */
  61184. static readonly MODE_SIDEBYSIDE: number;
  61185. /**
  61186. * Gets or sets the texture being displayed on the sphere
  61187. */
  61188. get photoTexture(): Texture;
  61189. /**
  61190. * sets the texture being displayed on the sphere
  61191. */
  61192. set photoTexture(value: Texture);
  61193. /**
  61194. * Gets the current video mode for the video. It can be:
  61195. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61196. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61197. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61198. */
  61199. get imageMode(): number;
  61200. /**
  61201. * Sets the current video mode for the video. It can be:
  61202. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61203. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61204. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61205. */
  61206. set imageMode(value: number);
  61207. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61208. }
  61209. }
  61210. declare module "babylonjs/Misc/dds" {
  61211. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  61212. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61213. import { Nullable } from "babylonjs/types";
  61214. import { Scene } from "babylonjs/scene";
  61215. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  61216. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61217. /**
  61218. * Direct draw surface info
  61219. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61220. */
  61221. export interface DDSInfo {
  61222. /**
  61223. * Width of the texture
  61224. */
  61225. width: number;
  61226. /**
  61227. * Width of the texture
  61228. */
  61229. height: number;
  61230. /**
  61231. * Number of Mipmaps for the texture
  61232. * @see https://en.wikipedia.org/wiki/Mipmap
  61233. */
  61234. mipmapCount: number;
  61235. /**
  61236. * If the textures format is a known fourCC format
  61237. * @see https://www.fourcc.org/
  61238. */
  61239. isFourCC: boolean;
  61240. /**
  61241. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61242. */
  61243. isRGB: boolean;
  61244. /**
  61245. * If the texture is a lumincance format
  61246. */
  61247. isLuminance: boolean;
  61248. /**
  61249. * If this is a cube texture
  61250. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61251. */
  61252. isCube: boolean;
  61253. /**
  61254. * If the texture is a compressed format eg. FOURCC_DXT1
  61255. */
  61256. isCompressed: boolean;
  61257. /**
  61258. * The dxgiFormat of the texture
  61259. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61260. */
  61261. dxgiFormat: number;
  61262. /**
  61263. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61264. */
  61265. textureType: number;
  61266. /**
  61267. * Sphericle polynomial created for the dds texture
  61268. */
  61269. sphericalPolynomial?: SphericalPolynomial;
  61270. }
  61271. /**
  61272. * Class used to provide DDS decompression tools
  61273. */
  61274. export class DDSTools {
  61275. /**
  61276. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61277. */
  61278. static StoreLODInAlphaChannel: boolean;
  61279. /**
  61280. * Gets DDS information from an array buffer
  61281. * @param data defines the array buffer view to read data from
  61282. * @returns the DDS information
  61283. */
  61284. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61285. private static _FloatView;
  61286. private static _Int32View;
  61287. private static _ToHalfFloat;
  61288. private static _FromHalfFloat;
  61289. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61290. private static _GetHalfFloatRGBAArrayBuffer;
  61291. private static _GetFloatRGBAArrayBuffer;
  61292. private static _GetFloatAsUIntRGBAArrayBuffer;
  61293. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61294. private static _GetRGBAArrayBuffer;
  61295. private static _ExtractLongWordOrder;
  61296. private static _GetRGBArrayBuffer;
  61297. private static _GetLuminanceArrayBuffer;
  61298. /**
  61299. * Uploads DDS Levels to a Babylon Texture
  61300. * @hidden
  61301. */
  61302. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61303. }
  61304. module "babylonjs/Engines/thinEngine" {
  61305. interface ThinEngine {
  61306. /**
  61307. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61308. * @param rootUrl defines the url where the file to load is located
  61309. * @param scene defines the current scene
  61310. * @param lodScale defines scale to apply to the mip map selection
  61311. * @param lodOffset defines offset to apply to the mip map selection
  61312. * @param onLoad defines an optional callback raised when the texture is loaded
  61313. * @param onError defines an optional callback raised if there is an issue to load the texture
  61314. * @param format defines the format of the data
  61315. * @param forcedExtension defines the extension to use to pick the right loader
  61316. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61317. * @returns the cube texture as an InternalTexture
  61318. */
  61319. 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;
  61320. }
  61321. }
  61322. }
  61323. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  61324. import { Nullable } from "babylonjs/types";
  61325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61326. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61327. /**
  61328. * Implementation of the DDS Texture Loader.
  61329. * @hidden
  61330. */
  61331. export class _DDSTextureLoader implements IInternalTextureLoader {
  61332. /**
  61333. * Defines wether the loader supports cascade loading the different faces.
  61334. */
  61335. readonly supportCascades: boolean;
  61336. /**
  61337. * This returns if the loader support the current file information.
  61338. * @param extension defines the file extension of the file being loaded
  61339. * @returns true if the loader can load the specified file
  61340. */
  61341. canLoad(extension: string): boolean;
  61342. /**
  61343. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61344. * @param data contains the texture data
  61345. * @param texture defines the BabylonJS internal texture
  61346. * @param createPolynomials will be true if polynomials have been requested
  61347. * @param onLoad defines the callback to trigger once the texture is ready
  61348. * @param onError defines the callback to trigger in case of error
  61349. */
  61350. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61351. /**
  61352. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61353. * @param data contains the texture data
  61354. * @param texture defines the BabylonJS internal texture
  61355. * @param callback defines the method to call once ready to upload
  61356. */
  61357. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61358. }
  61359. }
  61360. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  61361. import { Nullable } from "babylonjs/types";
  61362. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61363. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61364. /**
  61365. * Implementation of the ENV Texture Loader.
  61366. * @hidden
  61367. */
  61368. export class _ENVTextureLoader implements IInternalTextureLoader {
  61369. /**
  61370. * Defines wether the loader supports cascade loading the different faces.
  61371. */
  61372. readonly supportCascades: boolean;
  61373. /**
  61374. * This returns if the loader support the current file information.
  61375. * @param extension defines the file extension of the file being loaded
  61376. * @returns true if the loader can load the specified file
  61377. */
  61378. canLoad(extension: string): boolean;
  61379. /**
  61380. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61381. * @param data contains the texture data
  61382. * @param texture defines the BabylonJS internal texture
  61383. * @param createPolynomials will be true if polynomials have been requested
  61384. * @param onLoad defines the callback to trigger once the texture is ready
  61385. * @param onError defines the callback to trigger in case of error
  61386. */
  61387. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61388. /**
  61389. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61390. * @param data contains the texture data
  61391. * @param texture defines the BabylonJS internal texture
  61392. * @param callback defines the method to call once ready to upload
  61393. */
  61394. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61395. }
  61396. }
  61397. declare module "babylonjs/Misc/khronosTextureContainer" {
  61398. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61399. /**
  61400. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61401. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61402. */
  61403. export class KhronosTextureContainer {
  61404. /** contents of the KTX container file */
  61405. data: ArrayBufferView;
  61406. private static HEADER_LEN;
  61407. private static COMPRESSED_2D;
  61408. private static COMPRESSED_3D;
  61409. private static TEX_2D;
  61410. private static TEX_3D;
  61411. /**
  61412. * Gets the openGL type
  61413. */
  61414. glType: number;
  61415. /**
  61416. * Gets the openGL type size
  61417. */
  61418. glTypeSize: number;
  61419. /**
  61420. * Gets the openGL format
  61421. */
  61422. glFormat: number;
  61423. /**
  61424. * Gets the openGL internal format
  61425. */
  61426. glInternalFormat: number;
  61427. /**
  61428. * Gets the base internal format
  61429. */
  61430. glBaseInternalFormat: number;
  61431. /**
  61432. * Gets image width in pixel
  61433. */
  61434. pixelWidth: number;
  61435. /**
  61436. * Gets image height in pixel
  61437. */
  61438. pixelHeight: number;
  61439. /**
  61440. * Gets image depth in pixels
  61441. */
  61442. pixelDepth: number;
  61443. /**
  61444. * Gets the number of array elements
  61445. */
  61446. numberOfArrayElements: number;
  61447. /**
  61448. * Gets the number of faces
  61449. */
  61450. numberOfFaces: number;
  61451. /**
  61452. * Gets the number of mipmap levels
  61453. */
  61454. numberOfMipmapLevels: number;
  61455. /**
  61456. * Gets the bytes of key value data
  61457. */
  61458. bytesOfKeyValueData: number;
  61459. /**
  61460. * Gets the load type
  61461. */
  61462. loadType: number;
  61463. /**
  61464. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61465. */
  61466. isInvalid: boolean;
  61467. /**
  61468. * Creates a new KhronosTextureContainer
  61469. * @param data contents of the KTX container file
  61470. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61471. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61472. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61473. */
  61474. constructor(
  61475. /** contents of the KTX container file */
  61476. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61477. /**
  61478. * Uploads KTX content to a Babylon Texture.
  61479. * It is assumed that the texture has already been created & is currently bound
  61480. * @hidden
  61481. */
  61482. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61483. private _upload2DCompressedLevels;
  61484. /**
  61485. * Checks if the given data starts with a KTX file identifier.
  61486. * @param data the data to check
  61487. * @returns true if the data is a KTX file or false otherwise
  61488. */
  61489. static IsValid(data: ArrayBufferView): boolean;
  61490. }
  61491. }
  61492. declare module "babylonjs/Misc/workerPool" {
  61493. import { IDisposable } from "babylonjs/scene";
  61494. /**
  61495. * Helper class to push actions to a pool of workers.
  61496. */
  61497. export class WorkerPool implements IDisposable {
  61498. private _workerInfos;
  61499. private _pendingActions;
  61500. /**
  61501. * Constructor
  61502. * @param workers Array of workers to use for actions
  61503. */
  61504. constructor(workers: Array<Worker>);
  61505. /**
  61506. * Terminates all workers and clears any pending actions.
  61507. */
  61508. dispose(): void;
  61509. /**
  61510. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61511. * pended until a worker has completed its action.
  61512. * @param action The action to perform. Call onComplete when the action is complete.
  61513. */
  61514. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61515. private _execute;
  61516. }
  61517. }
  61518. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61520. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61521. /**
  61522. * Class for loading KTX2 files
  61523. */
  61524. export class KhronosTextureContainer2 {
  61525. private static _WorkerPoolPromise?;
  61526. private static _Initialized;
  61527. private static _Ktx2Decoder;
  61528. /**
  61529. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61530. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61531. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61532. * Urls you can change:
  61533. * URLConfig.jsDecoderModule
  61534. * URLConfig.wasmUASTCToASTC
  61535. * URLConfig.wasmUASTCToBC7
  61536. * URLConfig.wasmUASTCToRGBA_UNORM
  61537. * URLConfig.wasmUASTCToRGBA_SRGB
  61538. * URLConfig.jsMSCTranscoder
  61539. * URLConfig.wasmMSCTranscoder
  61540. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61541. */
  61542. static URLConfig: {
  61543. jsDecoderModule: string;
  61544. wasmUASTCToASTC: null;
  61545. wasmUASTCToBC7: null;
  61546. wasmUASTCToRGBA_UNORM: null;
  61547. wasmUASTCToRGBA_SRGB: null;
  61548. jsMSCTranscoder: null;
  61549. wasmMSCTranscoder: null;
  61550. };
  61551. /**
  61552. * Default number of workers used to handle data decoding
  61553. */
  61554. static DefaultNumWorkers: number;
  61555. private static GetDefaultNumWorkers;
  61556. private _engine;
  61557. private static _CreateWorkerPool;
  61558. /**
  61559. * Constructor
  61560. * @param engine The engine to use
  61561. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61562. */
  61563. constructor(engine: ThinEngine, numWorkers?: number);
  61564. /** @hidden */
  61565. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  61566. /**
  61567. * Stop all async operations and release resources.
  61568. */
  61569. dispose(): void;
  61570. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  61571. /**
  61572. * Checks if the given data starts with a KTX2 file identifier.
  61573. * @param data the data to check
  61574. * @returns true if the data is a KTX2 file or false otherwise
  61575. */
  61576. static IsValid(data: ArrayBufferView): boolean;
  61577. }
  61578. }
  61579. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61580. import { Nullable } from "babylonjs/types";
  61581. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61582. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61583. /**
  61584. * Implementation of the KTX Texture Loader.
  61585. * @hidden
  61586. */
  61587. export class _KTXTextureLoader implements IInternalTextureLoader {
  61588. /**
  61589. * Defines wether the loader supports cascade loading the different faces.
  61590. */
  61591. readonly supportCascades: boolean;
  61592. /**
  61593. * This returns if the loader support the current file information.
  61594. * @param extension defines the file extension of the file being loaded
  61595. * @param mimeType defines the optional mime type of the file being loaded
  61596. * @returns true if the loader can load the specified file
  61597. */
  61598. canLoad(extension: string, mimeType?: string): boolean;
  61599. /**
  61600. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61601. * @param data contains the texture data
  61602. * @param texture defines the BabylonJS internal texture
  61603. * @param createPolynomials will be true if polynomials have been requested
  61604. * @param onLoad defines the callback to trigger once the texture is ready
  61605. * @param onError defines the callback to trigger in case of error
  61606. */
  61607. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61608. /**
  61609. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61610. * @param data contains the texture data
  61611. * @param texture defines the BabylonJS internal texture
  61612. * @param callback defines the method to call once ready to upload
  61613. */
  61614. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  61615. }
  61616. }
  61617. declare module "babylonjs/Helpers/sceneHelpers" {
  61618. import { Nullable } from "babylonjs/types";
  61619. import { Mesh } from "babylonjs/Meshes/mesh";
  61620. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61621. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61622. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61623. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61624. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61625. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61626. import "babylonjs/Meshes/Builders/boxBuilder";
  61627. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61628. /** @hidden */
  61629. export var _forceSceneHelpersToBundle: boolean;
  61630. module "babylonjs/scene" {
  61631. interface Scene {
  61632. /**
  61633. * Creates a default light for the scene.
  61634. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61635. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61636. */
  61637. createDefaultLight(replace?: boolean): void;
  61638. /**
  61639. * Creates a default camera for the scene.
  61640. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61641. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61642. * @param replace has default false, when true replaces the active camera in the scene
  61643. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61644. */
  61645. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61646. /**
  61647. * Creates a default camera and a default light.
  61648. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  61649. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61650. * @param replace has the default false, when true replaces the active camera/light in the scene
  61651. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  61652. */
  61653. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61654. /**
  61655. * Creates a new sky box
  61656. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  61657. * @param environmentTexture defines the texture to use as environment texture
  61658. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  61659. * @param scale defines the overall scale of the skybox
  61660. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  61661. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  61662. * @returns a new mesh holding the sky box
  61663. */
  61664. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  61665. /**
  61666. * Creates a new environment
  61667. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  61668. * @param options defines the options you can use to configure the environment
  61669. * @returns the new EnvironmentHelper
  61670. */
  61671. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  61672. /**
  61673. * Creates a new VREXperienceHelper
  61674. * @see https://doc.babylonjs.com/how_to/webvr_helper
  61675. * @param webVROptions defines the options used to create the new VREXperienceHelper
  61676. * @returns a new VREXperienceHelper
  61677. */
  61678. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  61679. /**
  61680. * Creates a new WebXRDefaultExperience
  61681. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  61682. * @param options experience options
  61683. * @returns a promise for a new WebXRDefaultExperience
  61684. */
  61685. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  61686. }
  61687. }
  61688. }
  61689. declare module "babylonjs/Helpers/videoDome" {
  61690. import { Scene } from "babylonjs/scene";
  61691. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  61692. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61693. /**
  61694. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  61695. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  61696. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  61697. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61698. */
  61699. export class VideoDome extends TextureDome<VideoTexture> {
  61700. /**
  61701. * Define the video source as a Monoscopic panoramic 360 video.
  61702. */
  61703. static readonly MODE_MONOSCOPIC: number;
  61704. /**
  61705. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  61706. */
  61707. static readonly MODE_TOPBOTTOM: number;
  61708. /**
  61709. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  61710. */
  61711. static readonly MODE_SIDEBYSIDE: number;
  61712. /**
  61713. * Get the video texture associated with this video dome
  61714. */
  61715. get videoTexture(): VideoTexture;
  61716. /**
  61717. * Get the video mode of this dome
  61718. */
  61719. get videoMode(): number;
  61720. /**
  61721. * Set the video mode of this dome.
  61722. * @see textureMode
  61723. */
  61724. set videoMode(value: number);
  61725. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  61726. }
  61727. }
  61728. declare module "babylonjs/Helpers/index" {
  61729. export * from "babylonjs/Helpers/environmentHelper";
  61730. export * from "babylonjs/Helpers/photoDome";
  61731. export * from "babylonjs/Helpers/sceneHelpers";
  61732. export * from "babylonjs/Helpers/videoDome";
  61733. }
  61734. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  61735. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61736. import { IDisposable } from "babylonjs/scene";
  61737. import { Engine } from "babylonjs/Engines/engine";
  61738. /**
  61739. * This class can be used to get instrumentation data from a Babylon engine
  61740. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61741. */
  61742. export class EngineInstrumentation implements IDisposable {
  61743. /**
  61744. * Define the instrumented engine.
  61745. */
  61746. engine: Engine;
  61747. private _captureGPUFrameTime;
  61748. private _gpuFrameTimeToken;
  61749. private _gpuFrameTime;
  61750. private _captureShaderCompilationTime;
  61751. private _shaderCompilationTime;
  61752. private _onBeginFrameObserver;
  61753. private _onEndFrameObserver;
  61754. private _onBeforeShaderCompilationObserver;
  61755. private _onAfterShaderCompilationObserver;
  61756. /**
  61757. * Gets the perf counter used for GPU frame time
  61758. */
  61759. get gpuFrameTimeCounter(): PerfCounter;
  61760. /**
  61761. * Gets the GPU frame time capture status
  61762. */
  61763. get captureGPUFrameTime(): boolean;
  61764. /**
  61765. * Enable or disable the GPU frame time capture
  61766. */
  61767. set captureGPUFrameTime(value: boolean);
  61768. /**
  61769. * Gets the perf counter used for shader compilation time
  61770. */
  61771. get shaderCompilationTimeCounter(): PerfCounter;
  61772. /**
  61773. * Gets the shader compilation time capture status
  61774. */
  61775. get captureShaderCompilationTime(): boolean;
  61776. /**
  61777. * Enable or disable the shader compilation time capture
  61778. */
  61779. set captureShaderCompilationTime(value: boolean);
  61780. /**
  61781. * Instantiates a new engine instrumentation.
  61782. * This class can be used to get instrumentation data from a Babylon engine
  61783. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61784. * @param engine Defines the engine to instrument
  61785. */
  61786. constructor(
  61787. /**
  61788. * Define the instrumented engine.
  61789. */
  61790. engine: Engine);
  61791. /**
  61792. * Dispose and release associated resources.
  61793. */
  61794. dispose(): void;
  61795. }
  61796. }
  61797. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  61798. import { Scene, IDisposable } from "babylonjs/scene";
  61799. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61800. /**
  61801. * This class can be used to get instrumentation data from a Babylon engine
  61802. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61803. */
  61804. export class SceneInstrumentation implements IDisposable {
  61805. /**
  61806. * Defines the scene to instrument
  61807. */
  61808. scene: Scene;
  61809. private _captureActiveMeshesEvaluationTime;
  61810. private _activeMeshesEvaluationTime;
  61811. private _captureRenderTargetsRenderTime;
  61812. private _renderTargetsRenderTime;
  61813. private _captureFrameTime;
  61814. private _frameTime;
  61815. private _captureRenderTime;
  61816. private _renderTime;
  61817. private _captureInterFrameTime;
  61818. private _interFrameTime;
  61819. private _captureParticlesRenderTime;
  61820. private _particlesRenderTime;
  61821. private _captureSpritesRenderTime;
  61822. private _spritesRenderTime;
  61823. private _capturePhysicsTime;
  61824. private _physicsTime;
  61825. private _captureAnimationsTime;
  61826. private _animationsTime;
  61827. private _captureCameraRenderTime;
  61828. private _cameraRenderTime;
  61829. private _onBeforeActiveMeshesEvaluationObserver;
  61830. private _onAfterActiveMeshesEvaluationObserver;
  61831. private _onBeforeRenderTargetsRenderObserver;
  61832. private _onAfterRenderTargetsRenderObserver;
  61833. private _onAfterRenderObserver;
  61834. private _onBeforeDrawPhaseObserver;
  61835. private _onAfterDrawPhaseObserver;
  61836. private _onBeforeAnimationsObserver;
  61837. private _onBeforeParticlesRenderingObserver;
  61838. private _onAfterParticlesRenderingObserver;
  61839. private _onBeforeSpritesRenderingObserver;
  61840. private _onAfterSpritesRenderingObserver;
  61841. private _onBeforePhysicsObserver;
  61842. private _onAfterPhysicsObserver;
  61843. private _onAfterAnimationsObserver;
  61844. private _onBeforeCameraRenderObserver;
  61845. private _onAfterCameraRenderObserver;
  61846. /**
  61847. * Gets the perf counter used for active meshes evaluation time
  61848. */
  61849. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61850. /**
  61851. * Gets the active meshes evaluation time capture status
  61852. */
  61853. get captureActiveMeshesEvaluationTime(): boolean;
  61854. /**
  61855. * Enable or disable the active meshes evaluation time capture
  61856. */
  61857. set captureActiveMeshesEvaluationTime(value: boolean);
  61858. /**
  61859. * Gets the perf counter used for render targets render time
  61860. */
  61861. get renderTargetsRenderTimeCounter(): PerfCounter;
  61862. /**
  61863. * Gets the render targets render time capture status
  61864. */
  61865. get captureRenderTargetsRenderTime(): boolean;
  61866. /**
  61867. * Enable or disable the render targets render time capture
  61868. */
  61869. set captureRenderTargetsRenderTime(value: boolean);
  61870. /**
  61871. * Gets the perf counter used for particles render time
  61872. */
  61873. get particlesRenderTimeCounter(): PerfCounter;
  61874. /**
  61875. * Gets the particles render time capture status
  61876. */
  61877. get captureParticlesRenderTime(): boolean;
  61878. /**
  61879. * Enable or disable the particles render time capture
  61880. */
  61881. set captureParticlesRenderTime(value: boolean);
  61882. /**
  61883. * Gets the perf counter used for sprites render time
  61884. */
  61885. get spritesRenderTimeCounter(): PerfCounter;
  61886. /**
  61887. * Gets the sprites render time capture status
  61888. */
  61889. get captureSpritesRenderTime(): boolean;
  61890. /**
  61891. * Enable or disable the sprites render time capture
  61892. */
  61893. set captureSpritesRenderTime(value: boolean);
  61894. /**
  61895. * Gets the perf counter used for physics time
  61896. */
  61897. get physicsTimeCounter(): PerfCounter;
  61898. /**
  61899. * Gets the physics time capture status
  61900. */
  61901. get capturePhysicsTime(): boolean;
  61902. /**
  61903. * Enable or disable the physics time capture
  61904. */
  61905. set capturePhysicsTime(value: boolean);
  61906. /**
  61907. * Gets the perf counter used for animations time
  61908. */
  61909. get animationsTimeCounter(): PerfCounter;
  61910. /**
  61911. * Gets the animations time capture status
  61912. */
  61913. get captureAnimationsTime(): boolean;
  61914. /**
  61915. * Enable or disable the animations time capture
  61916. */
  61917. set captureAnimationsTime(value: boolean);
  61918. /**
  61919. * Gets the perf counter used for frame time capture
  61920. */
  61921. get frameTimeCounter(): PerfCounter;
  61922. /**
  61923. * Gets the frame time capture status
  61924. */
  61925. get captureFrameTime(): boolean;
  61926. /**
  61927. * Enable or disable the frame time capture
  61928. */
  61929. set captureFrameTime(value: boolean);
  61930. /**
  61931. * Gets the perf counter used for inter-frames time capture
  61932. */
  61933. get interFrameTimeCounter(): PerfCounter;
  61934. /**
  61935. * Gets the inter-frames time capture status
  61936. */
  61937. get captureInterFrameTime(): boolean;
  61938. /**
  61939. * Enable or disable the inter-frames time capture
  61940. */
  61941. set captureInterFrameTime(value: boolean);
  61942. /**
  61943. * Gets the perf counter used for render time capture
  61944. */
  61945. get renderTimeCounter(): PerfCounter;
  61946. /**
  61947. * Gets the render time capture status
  61948. */
  61949. get captureRenderTime(): boolean;
  61950. /**
  61951. * Enable or disable the render time capture
  61952. */
  61953. set captureRenderTime(value: boolean);
  61954. /**
  61955. * Gets the perf counter used for camera render time capture
  61956. */
  61957. get cameraRenderTimeCounter(): PerfCounter;
  61958. /**
  61959. * Gets the camera render time capture status
  61960. */
  61961. get captureCameraRenderTime(): boolean;
  61962. /**
  61963. * Enable or disable the camera render time capture
  61964. */
  61965. set captureCameraRenderTime(value: boolean);
  61966. /**
  61967. * Gets the perf counter used for draw calls
  61968. */
  61969. get drawCallsCounter(): PerfCounter;
  61970. /**
  61971. * Instantiates a new scene instrumentation.
  61972. * This class can be used to get instrumentation data from a Babylon engine
  61973. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61974. * @param scene Defines the scene to instrument
  61975. */
  61976. constructor(
  61977. /**
  61978. * Defines the scene to instrument
  61979. */
  61980. scene: Scene);
  61981. /**
  61982. * Dispose and release associated resources.
  61983. */
  61984. dispose(): void;
  61985. }
  61986. }
  61987. declare module "babylonjs/Instrumentation/index" {
  61988. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61989. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61990. export * from "babylonjs/Instrumentation/timeToken";
  61991. }
  61992. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61993. /** @hidden */
  61994. export var glowMapGenerationPixelShader: {
  61995. name: string;
  61996. shader: string;
  61997. };
  61998. }
  61999. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  62000. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62001. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62002. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62003. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62004. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62005. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62006. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62007. /** @hidden */
  62008. export var glowMapGenerationVertexShader: {
  62009. name: string;
  62010. shader: string;
  62011. };
  62012. }
  62013. declare module "babylonjs/Layers/effectLayer" {
  62014. import { Observable } from "babylonjs/Misc/observable";
  62015. import { Nullable } from "babylonjs/types";
  62016. import { Camera } from "babylonjs/Cameras/camera";
  62017. import { Scene } from "babylonjs/scene";
  62018. import { ISize } from "babylonjs/Maths/math.size";
  62019. import { Color4 } from "babylonjs/Maths/math.color";
  62020. import { Engine } from "babylonjs/Engines/engine";
  62021. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62023. import { Mesh } from "babylonjs/Meshes/mesh";
  62024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62025. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62026. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62027. import { Effect } from "babylonjs/Materials/effect";
  62028. import { Material } from "babylonjs/Materials/material";
  62029. import "babylonjs/Shaders/glowMapGeneration.fragment";
  62030. import "babylonjs/Shaders/glowMapGeneration.vertex";
  62031. /**
  62032. * Effect layer options. This helps customizing the behaviour
  62033. * of the effect layer.
  62034. */
  62035. export interface IEffectLayerOptions {
  62036. /**
  62037. * Multiplication factor apply to the canvas size to compute the render target size
  62038. * used to generated the objects (the smaller the faster).
  62039. */
  62040. mainTextureRatio: number;
  62041. /**
  62042. * Enforces a fixed size texture to ensure effect stability across devices.
  62043. */
  62044. mainTextureFixedSize?: number;
  62045. /**
  62046. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62047. */
  62048. alphaBlendingMode: number;
  62049. /**
  62050. * The camera attached to the layer.
  62051. */
  62052. camera: Nullable<Camera>;
  62053. /**
  62054. * The rendering group to draw the layer in.
  62055. */
  62056. renderingGroupId: number;
  62057. }
  62058. /**
  62059. * The effect layer Helps adding post process effect blended with the main pass.
  62060. *
  62061. * This can be for instance use to generate glow or higlight effects on the scene.
  62062. *
  62063. * The effect layer class can not be used directly and is intented to inherited from to be
  62064. * customized per effects.
  62065. */
  62066. export abstract class EffectLayer {
  62067. private _vertexBuffers;
  62068. private _indexBuffer;
  62069. private _cachedDefines;
  62070. private _effectLayerMapGenerationEffect;
  62071. private _effectLayerOptions;
  62072. private _mergeEffect;
  62073. protected _scene: Scene;
  62074. protected _engine: Engine;
  62075. protected _maxSize: number;
  62076. protected _mainTextureDesiredSize: ISize;
  62077. protected _mainTexture: RenderTargetTexture;
  62078. protected _shouldRender: boolean;
  62079. protected _postProcesses: PostProcess[];
  62080. protected _textures: BaseTexture[];
  62081. protected _emissiveTextureAndColor: {
  62082. texture: Nullable<BaseTexture>;
  62083. color: Color4;
  62084. };
  62085. /**
  62086. * The name of the layer
  62087. */
  62088. name: string;
  62089. /**
  62090. * The clear color of the texture used to generate the glow map.
  62091. */
  62092. neutralColor: Color4;
  62093. /**
  62094. * Specifies whether the highlight layer is enabled or not.
  62095. */
  62096. isEnabled: boolean;
  62097. /**
  62098. * Gets the camera attached to the layer.
  62099. */
  62100. get camera(): Nullable<Camera>;
  62101. /**
  62102. * Gets the rendering group id the layer should render in.
  62103. */
  62104. get renderingGroupId(): number;
  62105. set renderingGroupId(renderingGroupId: number);
  62106. /**
  62107. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62108. */
  62109. disableBoundingBoxesFromEffectLayer: boolean;
  62110. /**
  62111. * An event triggered when the effect layer has been disposed.
  62112. */
  62113. onDisposeObservable: Observable<EffectLayer>;
  62114. /**
  62115. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62116. */
  62117. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62118. /**
  62119. * An event triggered when the generated texture is being merged in the scene.
  62120. */
  62121. onBeforeComposeObservable: Observable<EffectLayer>;
  62122. /**
  62123. * An event triggered when the mesh is rendered into the effect render target.
  62124. */
  62125. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62126. /**
  62127. * An event triggered after the mesh has been rendered into the effect render target.
  62128. */
  62129. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62130. /**
  62131. * An event triggered when the generated texture has been merged in the scene.
  62132. */
  62133. onAfterComposeObservable: Observable<EffectLayer>;
  62134. /**
  62135. * An event triggered when the efffect layer changes its size.
  62136. */
  62137. onSizeChangedObservable: Observable<EffectLayer>;
  62138. /** @hidden */
  62139. static _SceneComponentInitialization: (scene: Scene) => void;
  62140. /**
  62141. * Instantiates a new effect Layer and references it in the scene.
  62142. * @param name The name of the layer
  62143. * @param scene The scene to use the layer in
  62144. */
  62145. constructor(
  62146. /** The Friendly of the effect in the scene */
  62147. name: string, scene: Scene);
  62148. /**
  62149. * Get the effect name of the layer.
  62150. * @return The effect name
  62151. */
  62152. abstract getEffectName(): string;
  62153. /**
  62154. * Checks for the readiness of the element composing the layer.
  62155. * @param subMesh the mesh to check for
  62156. * @param useInstances specify whether or not to use instances to render the mesh
  62157. * @return true if ready otherwise, false
  62158. */
  62159. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62160. /**
  62161. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62162. * @returns true if the effect requires stencil during the main canvas render pass.
  62163. */
  62164. abstract needStencil(): boolean;
  62165. /**
  62166. * Create the merge effect. This is the shader use to blit the information back
  62167. * to the main canvas at the end of the scene rendering.
  62168. * @returns The effect containing the shader used to merge the effect on the main canvas
  62169. */
  62170. protected abstract _createMergeEffect(): Effect;
  62171. /**
  62172. * Creates the render target textures and post processes used in the effect layer.
  62173. */
  62174. protected abstract _createTextureAndPostProcesses(): void;
  62175. /**
  62176. * Implementation specific of rendering the generating effect on the main canvas.
  62177. * @param effect The effect used to render through
  62178. */
  62179. protected abstract _internalRender(effect: Effect): void;
  62180. /**
  62181. * Sets the required values for both the emissive texture and and the main color.
  62182. */
  62183. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62184. /**
  62185. * Free any resources and references associated to a mesh.
  62186. * Internal use
  62187. * @param mesh The mesh to free.
  62188. */
  62189. abstract _disposeMesh(mesh: Mesh): void;
  62190. /**
  62191. * Serializes this layer (Glow or Highlight for example)
  62192. * @returns a serialized layer object
  62193. */
  62194. abstract serialize?(): any;
  62195. /**
  62196. * Initializes the effect layer with the required options.
  62197. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62198. */
  62199. protected _init(options: Partial<IEffectLayerOptions>): void;
  62200. /**
  62201. * Generates the index buffer of the full screen quad blending to the main canvas.
  62202. */
  62203. private _generateIndexBuffer;
  62204. /**
  62205. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62206. */
  62207. private _generateVertexBuffer;
  62208. /**
  62209. * Sets the main texture desired size which is the closest power of two
  62210. * of the engine canvas size.
  62211. */
  62212. private _setMainTextureSize;
  62213. /**
  62214. * Creates the main texture for the effect layer.
  62215. */
  62216. protected _createMainTexture(): void;
  62217. /**
  62218. * Adds specific effects defines.
  62219. * @param defines The defines to add specifics to.
  62220. */
  62221. protected _addCustomEffectDefines(defines: string[]): void;
  62222. /**
  62223. * Checks for the readiness of the element composing the layer.
  62224. * @param subMesh the mesh to check for
  62225. * @param useInstances specify whether or not to use instances to render the mesh
  62226. * @param emissiveTexture the associated emissive texture used to generate the glow
  62227. * @return true if ready otherwise, false
  62228. */
  62229. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62230. /**
  62231. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62232. */
  62233. render(): void;
  62234. /**
  62235. * Determine if a given mesh will be used in the current effect.
  62236. * @param mesh mesh to test
  62237. * @returns true if the mesh will be used
  62238. */
  62239. hasMesh(mesh: AbstractMesh): boolean;
  62240. /**
  62241. * Returns true if the layer contains information to display, otherwise false.
  62242. * @returns true if the glow layer should be rendered
  62243. */
  62244. shouldRender(): boolean;
  62245. /**
  62246. * Returns true if the mesh should render, otherwise false.
  62247. * @param mesh The mesh to render
  62248. * @returns true if it should render otherwise false
  62249. */
  62250. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62251. /**
  62252. * Returns true if the mesh can be rendered, otherwise false.
  62253. * @param mesh The mesh to render
  62254. * @param material The material used on the mesh
  62255. * @returns true if it can be rendered otherwise false
  62256. */
  62257. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62258. /**
  62259. * Returns true if the mesh should render, otherwise false.
  62260. * @param mesh The mesh to render
  62261. * @returns true if it should render otherwise false
  62262. */
  62263. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62264. /**
  62265. * Renders the submesh passed in parameter to the generation map.
  62266. */
  62267. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62268. /**
  62269. * Defines whether the current material of the mesh should be use to render the effect.
  62270. * @param mesh defines the current mesh to render
  62271. */
  62272. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62273. /**
  62274. * Rebuild the required buffers.
  62275. * @hidden Internal use only.
  62276. */
  62277. _rebuild(): void;
  62278. /**
  62279. * Dispose only the render target textures and post process.
  62280. */
  62281. private _disposeTextureAndPostProcesses;
  62282. /**
  62283. * Dispose the highlight layer and free resources.
  62284. */
  62285. dispose(): void;
  62286. /**
  62287. * Gets the class name of the effect layer
  62288. * @returns the string with the class name of the effect layer
  62289. */
  62290. getClassName(): string;
  62291. /**
  62292. * Creates an effect layer from parsed effect layer data
  62293. * @param parsedEffectLayer defines effect layer data
  62294. * @param scene defines the current scene
  62295. * @param rootUrl defines the root URL containing the effect layer information
  62296. * @returns a parsed effect Layer
  62297. */
  62298. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62299. }
  62300. }
  62301. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  62302. import { Scene } from "babylonjs/scene";
  62303. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62304. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62305. import { AbstractScene } from "babylonjs/abstractScene";
  62306. module "babylonjs/abstractScene" {
  62307. interface AbstractScene {
  62308. /**
  62309. * The list of effect layers (highlights/glow) added to the scene
  62310. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62311. * @see https://doc.babylonjs.com/how_to/glow_layer
  62312. */
  62313. effectLayers: Array<EffectLayer>;
  62314. /**
  62315. * Removes the given effect layer from this scene.
  62316. * @param toRemove defines the effect layer to remove
  62317. * @returns the index of the removed effect layer
  62318. */
  62319. removeEffectLayer(toRemove: EffectLayer): number;
  62320. /**
  62321. * Adds the given effect layer to this scene
  62322. * @param newEffectLayer defines the effect layer to add
  62323. */
  62324. addEffectLayer(newEffectLayer: EffectLayer): void;
  62325. }
  62326. }
  62327. /**
  62328. * Defines the layer scene component responsible to manage any effect layers
  62329. * in a given scene.
  62330. */
  62331. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62332. /**
  62333. * The component name helpfull to identify the component in the list of scene components.
  62334. */
  62335. readonly name: string;
  62336. /**
  62337. * The scene the component belongs to.
  62338. */
  62339. scene: Scene;
  62340. private _engine;
  62341. private _renderEffects;
  62342. private _needStencil;
  62343. private _previousStencilState;
  62344. /**
  62345. * Creates a new instance of the component for the given scene
  62346. * @param scene Defines the scene to register the component in
  62347. */
  62348. constructor(scene: Scene);
  62349. /**
  62350. * Registers the component in a given scene
  62351. */
  62352. register(): void;
  62353. /**
  62354. * Rebuilds the elements related to this component in case of
  62355. * context lost for instance.
  62356. */
  62357. rebuild(): void;
  62358. /**
  62359. * Serializes the component data to the specified json object
  62360. * @param serializationObject The object to serialize to
  62361. */
  62362. serialize(serializationObject: any): void;
  62363. /**
  62364. * Adds all the elements from the container to the scene
  62365. * @param container the container holding the elements
  62366. */
  62367. addFromContainer(container: AbstractScene): void;
  62368. /**
  62369. * Removes all the elements in the container from the scene
  62370. * @param container contains the elements to remove
  62371. * @param dispose if the removed element should be disposed (default: false)
  62372. */
  62373. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62374. /**
  62375. * Disposes the component and the associated ressources.
  62376. */
  62377. dispose(): void;
  62378. private _isReadyForMesh;
  62379. private _renderMainTexture;
  62380. private _setStencil;
  62381. private _setStencilBack;
  62382. private _draw;
  62383. private _drawCamera;
  62384. private _drawRenderingGroup;
  62385. }
  62386. }
  62387. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62388. /** @hidden */
  62389. export var glowMapMergePixelShader: {
  62390. name: string;
  62391. shader: string;
  62392. };
  62393. }
  62394. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62395. /** @hidden */
  62396. export var glowMapMergeVertexShader: {
  62397. name: string;
  62398. shader: string;
  62399. };
  62400. }
  62401. declare module "babylonjs/Layers/glowLayer" {
  62402. import { Nullable } from "babylonjs/types";
  62403. import { Camera } from "babylonjs/Cameras/camera";
  62404. import { Scene } from "babylonjs/scene";
  62405. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62407. import { Mesh } from "babylonjs/Meshes/mesh";
  62408. import { Texture } from "babylonjs/Materials/Textures/texture";
  62409. import { Effect } from "babylonjs/Materials/effect";
  62410. import { Material } from "babylonjs/Materials/material";
  62411. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62412. import { Color4 } from "babylonjs/Maths/math.color";
  62413. import "babylonjs/Shaders/glowMapMerge.fragment";
  62414. import "babylonjs/Shaders/glowMapMerge.vertex";
  62415. import "babylonjs/Layers/effectLayerSceneComponent";
  62416. module "babylonjs/abstractScene" {
  62417. interface AbstractScene {
  62418. /**
  62419. * Return a the first highlight layer of the scene with a given name.
  62420. * @param name The name of the highlight layer to look for.
  62421. * @return The highlight layer if found otherwise null.
  62422. */
  62423. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62424. }
  62425. }
  62426. /**
  62427. * Glow layer options. This helps customizing the behaviour
  62428. * of the glow layer.
  62429. */
  62430. export interface IGlowLayerOptions {
  62431. /**
  62432. * Multiplication factor apply to the canvas size to compute the render target size
  62433. * used to generated the glowing objects (the smaller the faster).
  62434. */
  62435. mainTextureRatio: number;
  62436. /**
  62437. * Enforces a fixed size texture to ensure resize independant blur.
  62438. */
  62439. mainTextureFixedSize?: number;
  62440. /**
  62441. * How big is the kernel of the blur texture.
  62442. */
  62443. blurKernelSize: number;
  62444. /**
  62445. * The camera attached to the layer.
  62446. */
  62447. camera: Nullable<Camera>;
  62448. /**
  62449. * Enable MSAA by chosing the number of samples.
  62450. */
  62451. mainTextureSamples?: number;
  62452. /**
  62453. * The rendering group to draw the layer in.
  62454. */
  62455. renderingGroupId: number;
  62456. }
  62457. /**
  62458. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62459. *
  62460. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62461. *
  62462. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62463. */
  62464. export class GlowLayer extends EffectLayer {
  62465. /**
  62466. * Effect Name of the layer.
  62467. */
  62468. static readonly EffectName: string;
  62469. /**
  62470. * The default blur kernel size used for the glow.
  62471. */
  62472. static DefaultBlurKernelSize: number;
  62473. /**
  62474. * The default texture size ratio used for the glow.
  62475. */
  62476. static DefaultTextureRatio: number;
  62477. /**
  62478. * Sets the kernel size of the blur.
  62479. */
  62480. set blurKernelSize(value: number);
  62481. /**
  62482. * Gets the kernel size of the blur.
  62483. */
  62484. get blurKernelSize(): number;
  62485. /**
  62486. * Sets the glow intensity.
  62487. */
  62488. set intensity(value: number);
  62489. /**
  62490. * Gets the glow intensity.
  62491. */
  62492. get intensity(): number;
  62493. private _options;
  62494. private _intensity;
  62495. private _horizontalBlurPostprocess1;
  62496. private _verticalBlurPostprocess1;
  62497. private _horizontalBlurPostprocess2;
  62498. private _verticalBlurPostprocess2;
  62499. private _blurTexture1;
  62500. private _blurTexture2;
  62501. private _postProcesses1;
  62502. private _postProcesses2;
  62503. private _includedOnlyMeshes;
  62504. private _excludedMeshes;
  62505. private _meshesUsingTheirOwnMaterials;
  62506. /**
  62507. * Callback used to let the user override the color selection on a per mesh basis
  62508. */
  62509. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62510. /**
  62511. * Callback used to let the user override the texture selection on a per mesh basis
  62512. */
  62513. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62514. /**
  62515. * Instantiates a new glow Layer and references it to the scene.
  62516. * @param name The name of the layer
  62517. * @param scene The scene to use the layer in
  62518. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62519. */
  62520. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62521. /**
  62522. * Get the effect name of the layer.
  62523. * @return The effect name
  62524. */
  62525. getEffectName(): string;
  62526. /**
  62527. * Create the merge effect. This is the shader use to blit the information back
  62528. * to the main canvas at the end of the scene rendering.
  62529. */
  62530. protected _createMergeEffect(): Effect;
  62531. /**
  62532. * Creates the render target textures and post processes used in the glow layer.
  62533. */
  62534. protected _createTextureAndPostProcesses(): void;
  62535. /**
  62536. * Checks for the readiness of the element composing the layer.
  62537. * @param subMesh the mesh to check for
  62538. * @param useInstances specify wether or not to use instances to render the mesh
  62539. * @param emissiveTexture the associated emissive texture used to generate the glow
  62540. * @return true if ready otherwise, false
  62541. */
  62542. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62543. /**
  62544. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62545. */
  62546. needStencil(): boolean;
  62547. /**
  62548. * Returns true if the mesh can be rendered, otherwise false.
  62549. * @param mesh The mesh to render
  62550. * @param material The material used on the mesh
  62551. * @returns true if it can be rendered otherwise false
  62552. */
  62553. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62554. /**
  62555. * Implementation specific of rendering the generating effect on the main canvas.
  62556. * @param effect The effect used to render through
  62557. */
  62558. protected _internalRender(effect: Effect): void;
  62559. /**
  62560. * Sets the required values for both the emissive texture and and the main color.
  62561. */
  62562. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62563. /**
  62564. * Returns true if the mesh should render, otherwise false.
  62565. * @param mesh The mesh to render
  62566. * @returns true if it should render otherwise false
  62567. */
  62568. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62569. /**
  62570. * Adds specific effects defines.
  62571. * @param defines The defines to add specifics to.
  62572. */
  62573. protected _addCustomEffectDefines(defines: string[]): void;
  62574. /**
  62575. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62576. * @param mesh The mesh to exclude from the glow layer
  62577. */
  62578. addExcludedMesh(mesh: Mesh): void;
  62579. /**
  62580. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62581. * @param mesh The mesh to remove
  62582. */
  62583. removeExcludedMesh(mesh: Mesh): void;
  62584. /**
  62585. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62586. * @param mesh The mesh to include in the glow layer
  62587. */
  62588. addIncludedOnlyMesh(mesh: Mesh): void;
  62589. /**
  62590. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62591. * @param mesh The mesh to remove
  62592. */
  62593. removeIncludedOnlyMesh(mesh: Mesh): void;
  62594. /**
  62595. * Determine if a given mesh will be used in the glow layer
  62596. * @param mesh The mesh to test
  62597. * @returns true if the mesh will be highlighted by the current glow layer
  62598. */
  62599. hasMesh(mesh: AbstractMesh): boolean;
  62600. /**
  62601. * Defines whether the current material of the mesh should be use to render the effect.
  62602. * @param mesh defines the current mesh to render
  62603. */
  62604. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62605. /**
  62606. * Add a mesh to be rendered through its own material and not with emissive only.
  62607. * @param mesh The mesh for which we need to use its material
  62608. */
  62609. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62610. /**
  62611. * Remove a mesh from being rendered through its own material and not with emissive only.
  62612. * @param mesh The mesh for which we need to not use its material
  62613. */
  62614. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62615. /**
  62616. * Free any resources and references associated to a mesh.
  62617. * Internal use
  62618. * @param mesh The mesh to free.
  62619. * @hidden
  62620. */
  62621. _disposeMesh(mesh: Mesh): void;
  62622. /**
  62623. * Gets the class name of the effect layer
  62624. * @returns the string with the class name of the effect layer
  62625. */
  62626. getClassName(): string;
  62627. /**
  62628. * Serializes this glow layer
  62629. * @returns a serialized glow layer object
  62630. */
  62631. serialize(): any;
  62632. /**
  62633. * Creates a Glow Layer from parsed glow layer data
  62634. * @param parsedGlowLayer defines glow layer data
  62635. * @param scene defines the current scene
  62636. * @param rootUrl defines the root URL containing the glow layer information
  62637. * @returns a parsed Glow Layer
  62638. */
  62639. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62640. }
  62641. }
  62642. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62643. /** @hidden */
  62644. export var glowBlurPostProcessPixelShader: {
  62645. name: string;
  62646. shader: string;
  62647. };
  62648. }
  62649. declare module "babylonjs/Layers/highlightLayer" {
  62650. import { Observable } from "babylonjs/Misc/observable";
  62651. import { Nullable } from "babylonjs/types";
  62652. import { Camera } from "babylonjs/Cameras/camera";
  62653. import { Scene } from "babylonjs/scene";
  62654. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62656. import { Mesh } from "babylonjs/Meshes/mesh";
  62657. import { Effect } from "babylonjs/Materials/effect";
  62658. import { Material } from "babylonjs/Materials/material";
  62659. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62660. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62661. import "babylonjs/Shaders/glowMapMerge.fragment";
  62662. import "babylonjs/Shaders/glowMapMerge.vertex";
  62663. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  62664. module "babylonjs/abstractScene" {
  62665. interface AbstractScene {
  62666. /**
  62667. * Return a the first highlight layer of the scene with a given name.
  62668. * @param name The name of the highlight layer to look for.
  62669. * @return The highlight layer if found otherwise null.
  62670. */
  62671. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  62672. }
  62673. }
  62674. /**
  62675. * Highlight layer options. This helps customizing the behaviour
  62676. * of the highlight layer.
  62677. */
  62678. export interface IHighlightLayerOptions {
  62679. /**
  62680. * Multiplication factor apply to the canvas size to compute the render target size
  62681. * used to generated the glowing objects (the smaller the faster).
  62682. */
  62683. mainTextureRatio: number;
  62684. /**
  62685. * Enforces a fixed size texture to ensure resize independant blur.
  62686. */
  62687. mainTextureFixedSize?: number;
  62688. /**
  62689. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  62690. * of the picture to blur (the smaller the faster).
  62691. */
  62692. blurTextureSizeRatio: number;
  62693. /**
  62694. * How big in texel of the blur texture is the vertical blur.
  62695. */
  62696. blurVerticalSize: number;
  62697. /**
  62698. * How big in texel of the blur texture is the horizontal blur.
  62699. */
  62700. blurHorizontalSize: number;
  62701. /**
  62702. * Alpha blending mode used to apply the blur. Default is combine.
  62703. */
  62704. alphaBlendingMode: number;
  62705. /**
  62706. * The camera attached to the layer.
  62707. */
  62708. camera: Nullable<Camera>;
  62709. /**
  62710. * Should we display highlight as a solid stroke?
  62711. */
  62712. isStroke?: boolean;
  62713. /**
  62714. * The rendering group to draw the layer in.
  62715. */
  62716. renderingGroupId: number;
  62717. }
  62718. /**
  62719. * The highlight layer Helps adding a glow effect around a mesh.
  62720. *
  62721. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  62722. * glowy meshes to your scene.
  62723. *
  62724. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  62725. */
  62726. export class HighlightLayer extends EffectLayer {
  62727. name: string;
  62728. /**
  62729. * Effect Name of the highlight layer.
  62730. */
  62731. static readonly EffectName: string;
  62732. /**
  62733. * The neutral color used during the preparation of the glow effect.
  62734. * This is black by default as the blend operation is a blend operation.
  62735. */
  62736. static NeutralColor: Color4;
  62737. /**
  62738. * Stencil value used for glowing meshes.
  62739. */
  62740. static GlowingMeshStencilReference: number;
  62741. /**
  62742. * Stencil value used for the other meshes in the scene.
  62743. */
  62744. static NormalMeshStencilReference: number;
  62745. /**
  62746. * Specifies whether or not the inner glow is ACTIVE in the layer.
  62747. */
  62748. innerGlow: boolean;
  62749. /**
  62750. * Specifies whether or not the outer glow is ACTIVE in the layer.
  62751. */
  62752. outerGlow: boolean;
  62753. /**
  62754. * Specifies the horizontal size of the blur.
  62755. */
  62756. set blurHorizontalSize(value: number);
  62757. /**
  62758. * Specifies the vertical size of the blur.
  62759. */
  62760. set blurVerticalSize(value: number);
  62761. /**
  62762. * Gets the horizontal size of the blur.
  62763. */
  62764. get blurHorizontalSize(): number;
  62765. /**
  62766. * Gets the vertical size of the blur.
  62767. */
  62768. get blurVerticalSize(): number;
  62769. /**
  62770. * An event triggered when the highlight layer is being blurred.
  62771. */
  62772. onBeforeBlurObservable: Observable<HighlightLayer>;
  62773. /**
  62774. * An event triggered when the highlight layer has been blurred.
  62775. */
  62776. onAfterBlurObservable: Observable<HighlightLayer>;
  62777. private _instanceGlowingMeshStencilReference;
  62778. private _options;
  62779. private _downSamplePostprocess;
  62780. private _horizontalBlurPostprocess;
  62781. private _verticalBlurPostprocess;
  62782. private _blurTexture;
  62783. private _meshes;
  62784. private _excludedMeshes;
  62785. /**
  62786. * Instantiates a new highlight Layer and references it to the scene..
  62787. * @param name The name of the layer
  62788. * @param scene The scene to use the layer in
  62789. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  62790. */
  62791. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  62792. /**
  62793. * Get the effect name of the layer.
  62794. * @return The effect name
  62795. */
  62796. getEffectName(): string;
  62797. /**
  62798. * Create the merge effect. This is the shader use to blit the information back
  62799. * to the main canvas at the end of the scene rendering.
  62800. */
  62801. protected _createMergeEffect(): Effect;
  62802. /**
  62803. * Creates the render target textures and post processes used in the highlight layer.
  62804. */
  62805. protected _createTextureAndPostProcesses(): void;
  62806. /**
  62807. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  62808. */
  62809. needStencil(): boolean;
  62810. /**
  62811. * Checks for the readiness of the element composing the layer.
  62812. * @param subMesh the mesh to check for
  62813. * @param useInstances specify wether or not to use instances to render the mesh
  62814. * @param emissiveTexture the associated emissive texture used to generate the glow
  62815. * @return true if ready otherwise, false
  62816. */
  62817. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62818. /**
  62819. * Implementation specific of rendering the generating effect on the main canvas.
  62820. * @param effect The effect used to render through
  62821. */
  62822. protected _internalRender(effect: Effect): void;
  62823. /**
  62824. * Returns true if the layer contains information to display, otherwise false.
  62825. */
  62826. shouldRender(): boolean;
  62827. /**
  62828. * Returns true if the mesh should render, otherwise false.
  62829. * @param mesh The mesh to render
  62830. * @returns true if it should render otherwise false
  62831. */
  62832. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62833. /**
  62834. * Returns true if the mesh can be rendered, otherwise false.
  62835. * @param mesh The mesh to render
  62836. * @param material The material used on the mesh
  62837. * @returns true if it can be rendered otherwise false
  62838. */
  62839. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62840. /**
  62841. * Adds specific effects defines.
  62842. * @param defines The defines to add specifics to.
  62843. */
  62844. protected _addCustomEffectDefines(defines: string[]): void;
  62845. /**
  62846. * Sets the required values for both the emissive texture and and the main color.
  62847. */
  62848. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62849. /**
  62850. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62851. * @param mesh The mesh to exclude from the highlight layer
  62852. */
  62853. addExcludedMesh(mesh: Mesh): void;
  62854. /**
  62855. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62856. * @param mesh The mesh to highlight
  62857. */
  62858. removeExcludedMesh(mesh: Mesh): void;
  62859. /**
  62860. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62861. * @param mesh mesh to test
  62862. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62863. */
  62864. hasMesh(mesh: AbstractMesh): boolean;
  62865. /**
  62866. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62867. * @param mesh The mesh to highlight
  62868. * @param color The color of the highlight
  62869. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62870. */
  62871. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62872. /**
  62873. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62874. * @param mesh The mesh to highlight
  62875. */
  62876. removeMesh(mesh: Mesh): void;
  62877. /**
  62878. * Remove all the meshes currently referenced in the highlight layer
  62879. */
  62880. removeAllMeshes(): void;
  62881. /**
  62882. * Force the stencil to the normal expected value for none glowing parts
  62883. */
  62884. private _defaultStencilReference;
  62885. /**
  62886. * Free any resources and references associated to a mesh.
  62887. * Internal use
  62888. * @param mesh The mesh to free.
  62889. * @hidden
  62890. */
  62891. _disposeMesh(mesh: Mesh): void;
  62892. /**
  62893. * Dispose the highlight layer and free resources.
  62894. */
  62895. dispose(): void;
  62896. /**
  62897. * Gets the class name of the effect layer
  62898. * @returns the string with the class name of the effect layer
  62899. */
  62900. getClassName(): string;
  62901. /**
  62902. * Serializes this Highlight layer
  62903. * @returns a serialized Highlight layer object
  62904. */
  62905. serialize(): any;
  62906. /**
  62907. * Creates a Highlight layer from parsed Highlight layer data
  62908. * @param parsedHightlightLayer defines the Highlight layer data
  62909. * @param scene defines the current scene
  62910. * @param rootUrl defines the root URL containing the Highlight layer information
  62911. * @returns a parsed Highlight layer
  62912. */
  62913. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62914. }
  62915. }
  62916. declare module "babylonjs/Layers/layerSceneComponent" {
  62917. import { Scene } from "babylonjs/scene";
  62918. import { ISceneComponent } from "babylonjs/sceneComponent";
  62919. import { Layer } from "babylonjs/Layers/layer";
  62920. import { AbstractScene } from "babylonjs/abstractScene";
  62921. module "babylonjs/abstractScene" {
  62922. interface AbstractScene {
  62923. /**
  62924. * The list of layers (background and foreground) of the scene
  62925. */
  62926. layers: Array<Layer>;
  62927. }
  62928. }
  62929. /**
  62930. * Defines the layer scene component responsible to manage any layers
  62931. * in a given scene.
  62932. */
  62933. export class LayerSceneComponent implements ISceneComponent {
  62934. /**
  62935. * The component name helpfull to identify the component in the list of scene components.
  62936. */
  62937. readonly name: string;
  62938. /**
  62939. * The scene the component belongs to.
  62940. */
  62941. scene: Scene;
  62942. private _engine;
  62943. /**
  62944. * Creates a new instance of the component for the given scene
  62945. * @param scene Defines the scene to register the component in
  62946. */
  62947. constructor(scene: Scene);
  62948. /**
  62949. * Registers the component in a given scene
  62950. */
  62951. register(): void;
  62952. /**
  62953. * Rebuilds the elements related to this component in case of
  62954. * context lost for instance.
  62955. */
  62956. rebuild(): void;
  62957. /**
  62958. * Disposes the component and the associated ressources.
  62959. */
  62960. dispose(): void;
  62961. private _draw;
  62962. private _drawCameraPredicate;
  62963. private _drawCameraBackground;
  62964. private _drawCameraForeground;
  62965. private _drawRenderTargetPredicate;
  62966. private _drawRenderTargetBackground;
  62967. private _drawRenderTargetForeground;
  62968. /**
  62969. * Adds all the elements from the container to the scene
  62970. * @param container the container holding the elements
  62971. */
  62972. addFromContainer(container: AbstractScene): void;
  62973. /**
  62974. * Removes all the elements in the container from the scene
  62975. * @param container contains the elements to remove
  62976. * @param dispose if the removed element should be disposed (default: false)
  62977. */
  62978. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62979. }
  62980. }
  62981. declare module "babylonjs/Shaders/layer.fragment" {
  62982. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62983. /** @hidden */
  62984. export var layerPixelShader: {
  62985. name: string;
  62986. shader: string;
  62987. };
  62988. }
  62989. declare module "babylonjs/Shaders/layer.vertex" {
  62990. /** @hidden */
  62991. export var layerVertexShader: {
  62992. name: string;
  62993. shader: string;
  62994. };
  62995. }
  62996. declare module "babylonjs/Layers/layer" {
  62997. import { Observable } from "babylonjs/Misc/observable";
  62998. import { Nullable } from "babylonjs/types";
  62999. import { Scene } from "babylonjs/scene";
  63000. import { Vector2 } from "babylonjs/Maths/math.vector";
  63001. import { Color4 } from "babylonjs/Maths/math.color";
  63002. import { Texture } from "babylonjs/Materials/Textures/texture";
  63003. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63004. import "babylonjs/Shaders/layer.fragment";
  63005. import "babylonjs/Shaders/layer.vertex";
  63006. /**
  63007. * This represents a full screen 2d layer.
  63008. * This can be useful to display a picture in the background of your scene for instance.
  63009. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63010. */
  63011. export class Layer {
  63012. /**
  63013. * Define the name of the layer.
  63014. */
  63015. name: string;
  63016. /**
  63017. * Define the texture the layer should display.
  63018. */
  63019. texture: Nullable<Texture>;
  63020. /**
  63021. * Is the layer in background or foreground.
  63022. */
  63023. isBackground: boolean;
  63024. /**
  63025. * Define the color of the layer (instead of texture).
  63026. */
  63027. color: Color4;
  63028. /**
  63029. * Define the scale of the layer in order to zoom in out of the texture.
  63030. */
  63031. scale: Vector2;
  63032. /**
  63033. * Define an offset for the layer in order to shift the texture.
  63034. */
  63035. offset: Vector2;
  63036. /**
  63037. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63038. */
  63039. alphaBlendingMode: number;
  63040. /**
  63041. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63042. * Alpha test will not mix with the background color in case of transparency.
  63043. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63044. */
  63045. alphaTest: boolean;
  63046. /**
  63047. * Define a mask to restrict the layer to only some of the scene cameras.
  63048. */
  63049. layerMask: number;
  63050. /**
  63051. * Define the list of render target the layer is visible into.
  63052. */
  63053. renderTargetTextures: RenderTargetTexture[];
  63054. /**
  63055. * Define if the layer is only used in renderTarget or if it also
  63056. * renders in the main frame buffer of the canvas.
  63057. */
  63058. renderOnlyInRenderTargetTextures: boolean;
  63059. private _scene;
  63060. private _vertexBuffers;
  63061. private _indexBuffer;
  63062. private _effect;
  63063. private _previousDefines;
  63064. /**
  63065. * An event triggered when the layer is disposed.
  63066. */
  63067. onDisposeObservable: Observable<Layer>;
  63068. private _onDisposeObserver;
  63069. /**
  63070. * Back compatibility with callback before the onDisposeObservable existed.
  63071. * The set callback will be triggered when the layer has been disposed.
  63072. */
  63073. set onDispose(callback: () => void);
  63074. /**
  63075. * An event triggered before rendering the scene
  63076. */
  63077. onBeforeRenderObservable: Observable<Layer>;
  63078. private _onBeforeRenderObserver;
  63079. /**
  63080. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63081. * The set callback will be triggered just before rendering the layer.
  63082. */
  63083. set onBeforeRender(callback: () => void);
  63084. /**
  63085. * An event triggered after rendering the scene
  63086. */
  63087. onAfterRenderObservable: Observable<Layer>;
  63088. private _onAfterRenderObserver;
  63089. /**
  63090. * Back compatibility with callback before the onAfterRenderObservable existed.
  63091. * The set callback will be triggered just after rendering the layer.
  63092. */
  63093. set onAfterRender(callback: () => void);
  63094. /**
  63095. * Instantiates a new layer.
  63096. * This represents a full screen 2d layer.
  63097. * This can be useful to display a picture in the background of your scene for instance.
  63098. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63099. * @param name Define the name of the layer in the scene
  63100. * @param imgUrl Define the url of the texture to display in the layer
  63101. * @param scene Define the scene the layer belongs to
  63102. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63103. * @param color Defines a color for the layer
  63104. */
  63105. constructor(
  63106. /**
  63107. * Define the name of the layer.
  63108. */
  63109. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63110. private _createIndexBuffer;
  63111. /** @hidden */
  63112. _rebuild(): void;
  63113. /**
  63114. * Renders the layer in the scene.
  63115. */
  63116. render(): void;
  63117. /**
  63118. * Disposes and releases the associated ressources.
  63119. */
  63120. dispose(): void;
  63121. }
  63122. }
  63123. declare module "babylonjs/Layers/index" {
  63124. export * from "babylonjs/Layers/effectLayer";
  63125. export * from "babylonjs/Layers/effectLayerSceneComponent";
  63126. export * from "babylonjs/Layers/glowLayer";
  63127. export * from "babylonjs/Layers/highlightLayer";
  63128. export * from "babylonjs/Layers/layer";
  63129. export * from "babylonjs/Layers/layerSceneComponent";
  63130. }
  63131. declare module "babylonjs/Shaders/lensFlare.fragment" {
  63132. /** @hidden */
  63133. export var lensFlarePixelShader: {
  63134. name: string;
  63135. shader: string;
  63136. };
  63137. }
  63138. declare module "babylonjs/Shaders/lensFlare.vertex" {
  63139. /** @hidden */
  63140. export var lensFlareVertexShader: {
  63141. name: string;
  63142. shader: string;
  63143. };
  63144. }
  63145. declare module "babylonjs/LensFlares/lensFlareSystem" {
  63146. import { Scene } from "babylonjs/scene";
  63147. import { Vector3 } from "babylonjs/Maths/math.vector";
  63148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63149. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  63150. import "babylonjs/Shaders/lensFlare.fragment";
  63151. import "babylonjs/Shaders/lensFlare.vertex";
  63152. import { Viewport } from "babylonjs/Maths/math.viewport";
  63153. /**
  63154. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63155. * It is usually composed of several `lensFlare`.
  63156. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63157. */
  63158. export class LensFlareSystem {
  63159. /**
  63160. * Define the name of the lens flare system
  63161. */
  63162. name: string;
  63163. /**
  63164. * List of lens flares used in this system.
  63165. */
  63166. lensFlares: LensFlare[];
  63167. /**
  63168. * Define a limit from the border the lens flare can be visible.
  63169. */
  63170. borderLimit: number;
  63171. /**
  63172. * Define a viewport border we do not want to see the lens flare in.
  63173. */
  63174. viewportBorder: number;
  63175. /**
  63176. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63177. */
  63178. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63179. /**
  63180. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63181. */
  63182. layerMask: number;
  63183. /**
  63184. * Define the id of the lens flare system in the scene.
  63185. * (equal to name by default)
  63186. */
  63187. id: string;
  63188. private _scene;
  63189. private _emitter;
  63190. private _vertexBuffers;
  63191. private _indexBuffer;
  63192. private _effect;
  63193. private _positionX;
  63194. private _positionY;
  63195. private _isEnabled;
  63196. /** @hidden */
  63197. static _SceneComponentInitialization: (scene: Scene) => void;
  63198. /**
  63199. * Instantiates a lens flare system.
  63200. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63201. * It is usually composed of several `lensFlare`.
  63202. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63203. * @param name Define the name of the lens flare system in the scene
  63204. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63205. * @param scene Define the scene the lens flare system belongs to
  63206. */
  63207. constructor(
  63208. /**
  63209. * Define the name of the lens flare system
  63210. */
  63211. name: string, emitter: any, scene: Scene);
  63212. /**
  63213. * Define if the lens flare system is enabled.
  63214. */
  63215. get isEnabled(): boolean;
  63216. set isEnabled(value: boolean);
  63217. /**
  63218. * Get the scene the effects belongs to.
  63219. * @returns the scene holding the lens flare system
  63220. */
  63221. getScene(): Scene;
  63222. /**
  63223. * Get the emitter of the lens flare system.
  63224. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63225. * @returns the emitter of the lens flare system
  63226. */
  63227. getEmitter(): any;
  63228. /**
  63229. * Set the emitter of the lens flare system.
  63230. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63231. * @param newEmitter Define the new emitter of the system
  63232. */
  63233. setEmitter(newEmitter: any): void;
  63234. /**
  63235. * Get the lens flare system emitter position.
  63236. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63237. * @returns the position
  63238. */
  63239. getEmitterPosition(): Vector3;
  63240. /**
  63241. * @hidden
  63242. */
  63243. computeEffectivePosition(globalViewport: Viewport): boolean;
  63244. /** @hidden */
  63245. _isVisible(): boolean;
  63246. /**
  63247. * @hidden
  63248. */
  63249. render(): boolean;
  63250. /**
  63251. * Dispose and release the lens flare with its associated resources.
  63252. */
  63253. dispose(): void;
  63254. /**
  63255. * Parse a lens flare system from a JSON repressentation
  63256. * @param parsedLensFlareSystem Define the JSON to parse
  63257. * @param scene Define the scene the parsed system should be instantiated in
  63258. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63259. * @returns the parsed system
  63260. */
  63261. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63262. /**
  63263. * Serialize the current Lens Flare System into a JSON representation.
  63264. * @returns the serialized JSON
  63265. */
  63266. serialize(): any;
  63267. }
  63268. }
  63269. declare module "babylonjs/LensFlares/lensFlare" {
  63270. import { Nullable } from "babylonjs/types";
  63271. import { Color3 } from "babylonjs/Maths/math.color";
  63272. import { Texture } from "babylonjs/Materials/Textures/texture";
  63273. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63274. /**
  63275. * This represents one of the lens effect in a `lensFlareSystem`.
  63276. * It controls one of the indiviual texture used in the effect.
  63277. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63278. */
  63279. export class LensFlare {
  63280. /**
  63281. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63282. */
  63283. size: number;
  63284. /**
  63285. * 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.
  63286. */
  63287. position: number;
  63288. /**
  63289. * Define the lens color.
  63290. */
  63291. color: Color3;
  63292. /**
  63293. * Define the lens texture.
  63294. */
  63295. texture: Nullable<Texture>;
  63296. /**
  63297. * Define the alpha mode to render this particular lens.
  63298. */
  63299. alphaMode: number;
  63300. private _system;
  63301. /**
  63302. * Creates a new Lens Flare.
  63303. * This represents one of the lens effect in a `lensFlareSystem`.
  63304. * It controls one of the indiviual texture used in the effect.
  63305. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63306. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63307. * @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.
  63308. * @param color Define the lens color
  63309. * @param imgUrl Define the lens texture url
  63310. * @param system Define the `lensFlareSystem` this flare is part of
  63311. * @returns The newly created Lens Flare
  63312. */
  63313. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63314. /**
  63315. * Instantiates a new Lens Flare.
  63316. * This represents one of the lens effect in a `lensFlareSystem`.
  63317. * It controls one of the indiviual texture used in the effect.
  63318. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63319. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63320. * @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.
  63321. * @param color Define the lens color
  63322. * @param imgUrl Define the lens texture url
  63323. * @param system Define the `lensFlareSystem` this flare is part of
  63324. */
  63325. constructor(
  63326. /**
  63327. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63328. */
  63329. size: number,
  63330. /**
  63331. * 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.
  63332. */
  63333. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63334. /**
  63335. * Dispose and release the lens flare with its associated resources.
  63336. */
  63337. dispose(): void;
  63338. }
  63339. }
  63340. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  63341. import { Nullable } from "babylonjs/types";
  63342. import { Scene } from "babylonjs/scene";
  63343. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63344. import { AbstractScene } from "babylonjs/abstractScene";
  63345. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63346. module "babylonjs/abstractScene" {
  63347. interface AbstractScene {
  63348. /**
  63349. * The list of lens flare system added to the scene
  63350. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63351. */
  63352. lensFlareSystems: Array<LensFlareSystem>;
  63353. /**
  63354. * Removes the given lens flare system from this scene.
  63355. * @param toRemove The lens flare system to remove
  63356. * @returns The index of the removed lens flare system
  63357. */
  63358. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63359. /**
  63360. * Adds the given lens flare system to this scene
  63361. * @param newLensFlareSystem The lens flare system to add
  63362. */
  63363. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63364. /**
  63365. * Gets a lens flare system using its name
  63366. * @param name defines the name to look for
  63367. * @returns the lens flare system or null if not found
  63368. */
  63369. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63370. /**
  63371. * Gets a lens flare system using its id
  63372. * @param id defines the id to look for
  63373. * @returns the lens flare system or null if not found
  63374. */
  63375. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63376. }
  63377. }
  63378. /**
  63379. * Defines the lens flare scene component responsible to manage any lens flares
  63380. * in a given scene.
  63381. */
  63382. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63383. /**
  63384. * The component name helpfull to identify the component in the list of scene components.
  63385. */
  63386. readonly name: string;
  63387. /**
  63388. * The scene the component belongs to.
  63389. */
  63390. scene: Scene;
  63391. /**
  63392. * Creates a new instance of the component for the given scene
  63393. * @param scene Defines the scene to register the component in
  63394. */
  63395. constructor(scene: Scene);
  63396. /**
  63397. * Registers the component in a given scene
  63398. */
  63399. register(): void;
  63400. /**
  63401. * Rebuilds the elements related to this component in case of
  63402. * context lost for instance.
  63403. */
  63404. rebuild(): void;
  63405. /**
  63406. * Adds all the elements from the container to the scene
  63407. * @param container the container holding the elements
  63408. */
  63409. addFromContainer(container: AbstractScene): void;
  63410. /**
  63411. * Removes all the elements in the container from the scene
  63412. * @param container contains the elements to remove
  63413. * @param dispose if the removed element should be disposed (default: false)
  63414. */
  63415. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63416. /**
  63417. * Serializes the component data to the specified json object
  63418. * @param serializationObject The object to serialize to
  63419. */
  63420. serialize(serializationObject: any): void;
  63421. /**
  63422. * Disposes the component and the associated ressources.
  63423. */
  63424. dispose(): void;
  63425. private _draw;
  63426. }
  63427. }
  63428. declare module "babylonjs/LensFlares/index" {
  63429. export * from "babylonjs/LensFlares/lensFlare";
  63430. export * from "babylonjs/LensFlares/lensFlareSystem";
  63431. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63432. }
  63433. declare module "babylonjs/Shaders/depth.fragment" {
  63434. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63435. /** @hidden */
  63436. export var depthPixelShader: {
  63437. name: string;
  63438. shader: string;
  63439. };
  63440. }
  63441. declare module "babylonjs/Shaders/depth.vertex" {
  63442. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63443. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63444. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63445. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63446. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63447. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63448. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63449. /** @hidden */
  63450. export var depthVertexShader: {
  63451. name: string;
  63452. shader: string;
  63453. };
  63454. }
  63455. declare module "babylonjs/Rendering/depthRenderer" {
  63456. import { Nullable } from "babylonjs/types";
  63457. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63458. import { Scene } from "babylonjs/scene";
  63459. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63460. import { Camera } from "babylonjs/Cameras/camera";
  63461. import "babylonjs/Shaders/depth.fragment";
  63462. import "babylonjs/Shaders/depth.vertex";
  63463. /**
  63464. * This represents a depth renderer in Babylon.
  63465. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63466. */
  63467. export class DepthRenderer {
  63468. private _scene;
  63469. private _depthMap;
  63470. private _effect;
  63471. private readonly _storeNonLinearDepth;
  63472. private readonly _clearColor;
  63473. /** Get if the depth renderer is using packed depth or not */
  63474. readonly isPacked: boolean;
  63475. private _cachedDefines;
  63476. private _camera;
  63477. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63478. enabled: boolean;
  63479. /**
  63480. * Specifiess that the depth renderer will only be used within
  63481. * the camera it is created for.
  63482. * This can help forcing its rendering during the camera processing.
  63483. */
  63484. useOnlyInActiveCamera: boolean;
  63485. /** @hidden */
  63486. static _SceneComponentInitialization: (scene: Scene) => void;
  63487. /**
  63488. * Instantiates a depth renderer
  63489. * @param scene The scene the renderer belongs to
  63490. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63491. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63492. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63493. */
  63494. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63495. /**
  63496. * Creates the depth rendering effect and checks if the effect is ready.
  63497. * @param subMesh The submesh to be used to render the depth map of
  63498. * @param useInstances If multiple world instances should be used
  63499. * @returns if the depth renderer is ready to render the depth map
  63500. */
  63501. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63502. /**
  63503. * Gets the texture which the depth map will be written to.
  63504. * @returns The depth map texture
  63505. */
  63506. getDepthMap(): RenderTargetTexture;
  63507. /**
  63508. * Disposes of the depth renderer.
  63509. */
  63510. dispose(): void;
  63511. }
  63512. }
  63513. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63514. /** @hidden */
  63515. export var minmaxReduxPixelShader: {
  63516. name: string;
  63517. shader: string;
  63518. };
  63519. }
  63520. declare module "babylonjs/Misc/minMaxReducer" {
  63521. import { Nullable } from "babylonjs/types";
  63522. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63523. import { Camera } from "babylonjs/Cameras/camera";
  63524. import { Observer } from "babylonjs/Misc/observable";
  63525. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63526. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63527. import { Observable } from "babylonjs/Misc/observable";
  63528. import "babylonjs/Shaders/minmaxRedux.fragment";
  63529. /**
  63530. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63531. * and maximum values from all values of the texture.
  63532. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63533. * The source values are read from the red channel of the texture.
  63534. */
  63535. export class MinMaxReducer {
  63536. /**
  63537. * Observable triggered when the computation has been performed
  63538. */
  63539. onAfterReductionPerformed: Observable<{
  63540. min: number;
  63541. max: number;
  63542. }>;
  63543. protected _camera: Camera;
  63544. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63545. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63546. protected _postProcessManager: PostProcessManager;
  63547. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63548. protected _forceFullscreenViewport: boolean;
  63549. /**
  63550. * Creates a min/max reducer
  63551. * @param camera The camera to use for the post processes
  63552. */
  63553. constructor(camera: Camera);
  63554. /**
  63555. * Gets the texture used to read the values from.
  63556. */
  63557. get sourceTexture(): Nullable<RenderTargetTexture>;
  63558. /**
  63559. * Sets the source texture to read the values from.
  63560. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63561. * because in such textures '1' value must not be taken into account to compute the maximum
  63562. * as this value is used to clear the texture.
  63563. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63564. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63565. * @param depthRedux Indicates if the texture is a depth texture or not
  63566. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63567. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63568. */
  63569. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63570. /**
  63571. * Defines the refresh rate of the computation.
  63572. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63573. */
  63574. get refreshRate(): number;
  63575. set refreshRate(value: number);
  63576. protected _activated: boolean;
  63577. /**
  63578. * Gets the activation status of the reducer
  63579. */
  63580. get activated(): boolean;
  63581. /**
  63582. * Activates the reduction computation.
  63583. * When activated, the observers registered in onAfterReductionPerformed are
  63584. * called after the compuation is performed
  63585. */
  63586. activate(): void;
  63587. /**
  63588. * Deactivates the reduction computation.
  63589. */
  63590. deactivate(): void;
  63591. /**
  63592. * Disposes the min/max reducer
  63593. * @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.
  63594. */
  63595. dispose(disposeAll?: boolean): void;
  63596. }
  63597. }
  63598. declare module "babylonjs/Misc/depthReducer" {
  63599. import { Nullable } from "babylonjs/types";
  63600. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63601. import { Camera } from "babylonjs/Cameras/camera";
  63602. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63603. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63604. /**
  63605. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63606. */
  63607. export class DepthReducer extends MinMaxReducer {
  63608. private _depthRenderer;
  63609. private _depthRendererId;
  63610. /**
  63611. * Gets the depth renderer used for the computation.
  63612. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63613. */
  63614. get depthRenderer(): Nullable<DepthRenderer>;
  63615. /**
  63616. * Creates a depth reducer
  63617. * @param camera The camera used to render the depth texture
  63618. */
  63619. constructor(camera: Camera);
  63620. /**
  63621. * Sets the depth renderer to use to generate the depth map
  63622. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63623. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63624. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63625. */
  63626. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63627. /** @hidden */
  63628. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63629. /**
  63630. * Activates the reduction computation.
  63631. * When activated, the observers registered in onAfterReductionPerformed are
  63632. * called after the compuation is performed
  63633. */
  63634. activate(): void;
  63635. /**
  63636. * Deactivates the reduction computation.
  63637. */
  63638. deactivate(): void;
  63639. /**
  63640. * Disposes the depth reducer
  63641. * @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.
  63642. */
  63643. dispose(disposeAll?: boolean): void;
  63644. }
  63645. }
  63646. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  63647. import { Nullable } from "babylonjs/types";
  63648. import { Scene } from "babylonjs/scene";
  63649. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63650. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63652. import { Effect } from "babylonjs/Materials/effect";
  63653. import "babylonjs/Shaders/shadowMap.fragment";
  63654. import "babylonjs/Shaders/shadowMap.vertex";
  63655. import "babylonjs/Shaders/depthBoxBlur.fragment";
  63656. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  63657. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63658. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63659. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63660. /**
  63661. * A CSM implementation allowing casting shadows on large scenes.
  63662. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63663. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63664. */
  63665. export class CascadedShadowGenerator extends ShadowGenerator {
  63666. private static readonly frustumCornersNDCSpace;
  63667. /**
  63668. * Name of the CSM class
  63669. */
  63670. static CLASSNAME: string;
  63671. /**
  63672. * Defines the default number of cascades used by the CSM.
  63673. */
  63674. static readonly DEFAULT_CASCADES_COUNT: number;
  63675. /**
  63676. * Defines the minimum number of cascades used by the CSM.
  63677. */
  63678. static readonly MIN_CASCADES_COUNT: number;
  63679. /**
  63680. * Defines the maximum number of cascades used by the CSM.
  63681. */
  63682. static readonly MAX_CASCADES_COUNT: number;
  63683. protected _validateFilter(filter: number): number;
  63684. /**
  63685. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63686. */
  63687. penumbraDarkness: number;
  63688. private _numCascades;
  63689. /**
  63690. * Gets or set the number of cascades used by the CSM.
  63691. */
  63692. get numCascades(): number;
  63693. set numCascades(value: number);
  63694. /**
  63695. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63696. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63697. */
  63698. stabilizeCascades: boolean;
  63699. private _freezeShadowCastersBoundingInfo;
  63700. private _freezeShadowCastersBoundingInfoObservable;
  63701. /**
  63702. * Enables or disables the shadow casters bounding info computation.
  63703. * If your shadow casters don't move, you can disable this feature.
  63704. * If it is enabled, the bounding box computation is done every frame.
  63705. */
  63706. get freezeShadowCastersBoundingInfo(): boolean;
  63707. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63708. private _scbiMin;
  63709. private _scbiMax;
  63710. protected _computeShadowCastersBoundingInfo(): void;
  63711. protected _shadowCastersBoundingInfo: BoundingInfo;
  63712. /**
  63713. * Gets or sets the shadow casters bounding info.
  63714. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63715. * so that the system won't overwrite the bounds you provide
  63716. */
  63717. get shadowCastersBoundingInfo(): BoundingInfo;
  63718. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63719. protected _breaksAreDirty: boolean;
  63720. protected _minDistance: number;
  63721. protected _maxDistance: number;
  63722. /**
  63723. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63724. *
  63725. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63726. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63727. * @param min minimal distance for the breaks (default to 0.)
  63728. * @param max maximal distance for the breaks (default to 1.)
  63729. */
  63730. setMinMaxDistance(min: number, max: number): void;
  63731. /** Gets the minimal distance used in the cascade break computation */
  63732. get minDistance(): number;
  63733. /** Gets the maximal distance used in the cascade break computation */
  63734. get maxDistance(): number;
  63735. /**
  63736. * Gets the class name of that object
  63737. * @returns "CascadedShadowGenerator"
  63738. */
  63739. getClassName(): string;
  63740. private _cascadeMinExtents;
  63741. private _cascadeMaxExtents;
  63742. /**
  63743. * Gets a cascade minimum extents
  63744. * @param cascadeIndex index of the cascade
  63745. * @returns the minimum cascade extents
  63746. */
  63747. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63748. /**
  63749. * Gets a cascade maximum extents
  63750. * @param cascadeIndex index of the cascade
  63751. * @returns the maximum cascade extents
  63752. */
  63753. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  63754. private _cascades;
  63755. private _currentLayer;
  63756. private _viewSpaceFrustumsZ;
  63757. private _viewMatrices;
  63758. private _projectionMatrices;
  63759. private _transformMatrices;
  63760. private _transformMatricesAsArray;
  63761. private _frustumLengths;
  63762. private _lightSizeUVCorrection;
  63763. private _depthCorrection;
  63764. private _frustumCornersWorldSpace;
  63765. private _frustumCenter;
  63766. private _shadowCameraPos;
  63767. private _shadowMaxZ;
  63768. /**
  63769. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  63770. * It defaults to camera.maxZ
  63771. */
  63772. get shadowMaxZ(): number;
  63773. /**
  63774. * Sets the shadow max z distance.
  63775. */
  63776. set shadowMaxZ(value: number);
  63777. protected _debug: boolean;
  63778. /**
  63779. * Gets or sets the debug flag.
  63780. * When enabled, the cascades are materialized by different colors on the screen.
  63781. */
  63782. get debug(): boolean;
  63783. set debug(dbg: boolean);
  63784. private _depthClamp;
  63785. /**
  63786. * Gets or sets the depth clamping value.
  63787. *
  63788. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  63789. * to account for the shadow casters far away.
  63790. *
  63791. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  63792. */
  63793. get depthClamp(): boolean;
  63794. set depthClamp(value: boolean);
  63795. private _cascadeBlendPercentage;
  63796. /**
  63797. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  63798. * It defaults to 0.1 (10% blending).
  63799. */
  63800. get cascadeBlendPercentage(): number;
  63801. set cascadeBlendPercentage(value: number);
  63802. private _lambda;
  63803. /**
  63804. * Gets or set the lambda parameter.
  63805. * This parameter is used to split the camera frustum and create the cascades.
  63806. * 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.
  63807. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  63808. */
  63809. get lambda(): number;
  63810. set lambda(value: number);
  63811. /**
  63812. * Gets the view matrix corresponding to a given cascade
  63813. * @param cascadeNum cascade to retrieve the view matrix from
  63814. * @returns the cascade view matrix
  63815. */
  63816. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63817. /**
  63818. * Gets the projection matrix corresponding to a given cascade
  63819. * @param cascadeNum cascade to retrieve the projection matrix from
  63820. * @returns the cascade projection matrix
  63821. */
  63822. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63823. /**
  63824. * Gets the transformation matrix corresponding to a given cascade
  63825. * @param cascadeNum cascade to retrieve the transformation matrix from
  63826. * @returns the cascade transformation matrix
  63827. */
  63828. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63829. private _depthRenderer;
  63830. /**
  63831. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63832. *
  63833. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63834. *
  63835. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63836. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63837. * @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
  63838. */
  63839. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63840. private _depthReducer;
  63841. private _autoCalcDepthBounds;
  63842. /**
  63843. * Gets or sets the autoCalcDepthBounds property.
  63844. *
  63845. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63846. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63847. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63848. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63849. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63850. */
  63851. get autoCalcDepthBounds(): boolean;
  63852. set autoCalcDepthBounds(value: boolean);
  63853. /**
  63854. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63855. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63856. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63857. * for setting the refresh rate on the renderer yourself!
  63858. */
  63859. get autoCalcDepthBoundsRefreshRate(): number;
  63860. set autoCalcDepthBoundsRefreshRate(value: number);
  63861. /**
  63862. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63863. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63864. * you change the camera near/far planes!
  63865. */
  63866. splitFrustum(): void;
  63867. private _splitFrustum;
  63868. private _computeMatrices;
  63869. private _computeFrustumInWorldSpace;
  63870. private _computeCascadeFrustum;
  63871. /**
  63872. * Support test.
  63873. */
  63874. static get IsSupported(): boolean;
  63875. /** @hidden */
  63876. static _SceneComponentInitialization: (scene: Scene) => void;
  63877. /**
  63878. * Creates a Cascaded Shadow Generator object.
  63879. * A ShadowGenerator is the required tool to use the shadows.
  63880. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63881. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63882. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63883. * @param light The directional light object generating the shadows.
  63884. * @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.
  63885. */
  63886. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63887. protected _initializeGenerator(): void;
  63888. protected _createTargetRenderTexture(): void;
  63889. protected _initializeShadowMap(): void;
  63890. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63891. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63892. /**
  63893. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63894. * @param defines Defines of the material we want to update
  63895. * @param lightIndex Index of the light in the enabled light list of the material
  63896. */
  63897. prepareDefines(defines: any, lightIndex: number): void;
  63898. /**
  63899. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63900. * defined in the generator but impacting the effect).
  63901. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63902. * @param effect The effect we are binfing the information for
  63903. */
  63904. bindShadowLight(lightIndex: string, effect: Effect): void;
  63905. /**
  63906. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63907. * (eq to view projection * shadow projection matrices)
  63908. * @returns The transform matrix used to create the shadow map
  63909. */
  63910. getTransformMatrix(): Matrix;
  63911. /**
  63912. * Disposes the ShadowGenerator.
  63913. * Returns nothing.
  63914. */
  63915. dispose(): void;
  63916. /**
  63917. * Serializes the shadow generator setup to a json object.
  63918. * @returns The serialized JSON object
  63919. */
  63920. serialize(): any;
  63921. /**
  63922. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63923. * @param parsedShadowGenerator The JSON object to parse
  63924. * @param scene The scene to create the shadow map for
  63925. * @returns The parsed shadow generator
  63926. */
  63927. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63928. }
  63929. }
  63930. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63931. import { Scene } from "babylonjs/scene";
  63932. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63933. import { AbstractScene } from "babylonjs/abstractScene";
  63934. /**
  63935. * Defines the shadow generator component responsible to manage any shadow generators
  63936. * in a given scene.
  63937. */
  63938. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63939. /**
  63940. * The component name helpfull to identify the component in the list of scene components.
  63941. */
  63942. readonly name: string;
  63943. /**
  63944. * The scene the component belongs to.
  63945. */
  63946. scene: Scene;
  63947. /**
  63948. * Creates a new instance of the component for the given scene
  63949. * @param scene Defines the scene to register the component in
  63950. */
  63951. constructor(scene: Scene);
  63952. /**
  63953. * Registers the component in a given scene
  63954. */
  63955. register(): void;
  63956. /**
  63957. * Rebuilds the elements related to this component in case of
  63958. * context lost for instance.
  63959. */
  63960. rebuild(): void;
  63961. /**
  63962. * Serializes the component data to the specified json object
  63963. * @param serializationObject The object to serialize to
  63964. */
  63965. serialize(serializationObject: any): void;
  63966. /**
  63967. * Adds all the elements from the container to the scene
  63968. * @param container the container holding the elements
  63969. */
  63970. addFromContainer(container: AbstractScene): void;
  63971. /**
  63972. * Removes all the elements in the container from the scene
  63973. * @param container contains the elements to remove
  63974. * @param dispose if the removed element should be disposed (default: false)
  63975. */
  63976. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63977. /**
  63978. * Rebuilds the elements related to this component in case of
  63979. * context lost for instance.
  63980. */
  63981. dispose(): void;
  63982. private _gatherRenderTargets;
  63983. }
  63984. }
  63985. declare module "babylonjs/Lights/Shadows/index" {
  63986. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63987. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63988. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63989. }
  63990. declare module "babylonjs/Lights/pointLight" {
  63991. import { Scene } from "babylonjs/scene";
  63992. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63994. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63995. import { Effect } from "babylonjs/Materials/effect";
  63996. /**
  63997. * A point light is a light defined by an unique point in world space.
  63998. * The light is emitted in every direction from this point.
  63999. * A good example of a point light is a standard light bulb.
  64000. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64001. */
  64002. export class PointLight extends ShadowLight {
  64003. private _shadowAngle;
  64004. /**
  64005. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64006. * This specifies what angle the shadow will use to be created.
  64007. *
  64008. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64009. */
  64010. get shadowAngle(): number;
  64011. /**
  64012. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64013. * This specifies what angle the shadow will use to be created.
  64014. *
  64015. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64016. */
  64017. set shadowAngle(value: number);
  64018. /**
  64019. * Gets the direction if it has been set.
  64020. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64021. */
  64022. get direction(): Vector3;
  64023. /**
  64024. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64025. */
  64026. set direction(value: Vector3);
  64027. /**
  64028. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64029. * A PointLight emits the light in every direction.
  64030. * It can cast shadows.
  64031. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64032. * ```javascript
  64033. * var pointLight = new PointLight("pl", camera.position, scene);
  64034. * ```
  64035. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64036. * @param name The light friendly name
  64037. * @param position The position of the point light in the scene
  64038. * @param scene The scene the lights belongs to
  64039. */
  64040. constructor(name: string, position: Vector3, scene: Scene);
  64041. /**
  64042. * Returns the string "PointLight"
  64043. * @returns the class name
  64044. */
  64045. getClassName(): string;
  64046. /**
  64047. * Returns the integer 0.
  64048. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64049. */
  64050. getTypeID(): number;
  64051. /**
  64052. * Specifies wether or not the shadowmap should be a cube texture.
  64053. * @returns true if the shadowmap needs to be a cube texture.
  64054. */
  64055. needCube(): boolean;
  64056. /**
  64057. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64058. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64059. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64060. */
  64061. getShadowDirection(faceIndex?: number): Vector3;
  64062. /**
  64063. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64064. * - fov = PI / 2
  64065. * - aspect ratio : 1.0
  64066. * - z-near and far equal to the active camera minZ and maxZ.
  64067. * Returns the PointLight.
  64068. */
  64069. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64070. protected _buildUniformLayout(): void;
  64071. /**
  64072. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64073. * @param effect The effect to update
  64074. * @param lightIndex The index of the light in the effect to update
  64075. * @returns The point light
  64076. */
  64077. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64078. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64079. /**
  64080. * Prepares the list of defines specific to the light type.
  64081. * @param defines the list of defines
  64082. * @param lightIndex defines the index of the light for the effect
  64083. */
  64084. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64085. }
  64086. }
  64087. declare module "babylonjs/Lights/index" {
  64088. export * from "babylonjs/Lights/light";
  64089. export * from "babylonjs/Lights/shadowLight";
  64090. export * from "babylonjs/Lights/Shadows/index";
  64091. export * from "babylonjs/Lights/directionalLight";
  64092. export * from "babylonjs/Lights/hemisphericLight";
  64093. export * from "babylonjs/Lights/pointLight";
  64094. export * from "babylonjs/Lights/spotLight";
  64095. }
  64096. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  64097. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64098. /**
  64099. * Header information of HDR texture files.
  64100. */
  64101. export interface HDRInfo {
  64102. /**
  64103. * The height of the texture in pixels.
  64104. */
  64105. height: number;
  64106. /**
  64107. * The width of the texture in pixels.
  64108. */
  64109. width: number;
  64110. /**
  64111. * The index of the beginning of the data in the binary file.
  64112. */
  64113. dataPosition: number;
  64114. }
  64115. /**
  64116. * This groups tools to convert HDR texture to native colors array.
  64117. */
  64118. export class HDRTools {
  64119. private static Ldexp;
  64120. private static Rgbe2float;
  64121. private static readStringLine;
  64122. /**
  64123. * Reads header information from an RGBE texture stored in a native array.
  64124. * More information on this format are available here:
  64125. * https://en.wikipedia.org/wiki/RGBE_image_format
  64126. *
  64127. * @param uint8array The binary file stored in native array.
  64128. * @return The header information.
  64129. */
  64130. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64131. /**
  64132. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64133. * This RGBE texture needs to store the information as a panorama.
  64134. *
  64135. * More information on this format are available here:
  64136. * https://en.wikipedia.org/wiki/RGBE_image_format
  64137. *
  64138. * @param buffer The binary file stored in an array buffer.
  64139. * @param size The expected size of the extracted cubemap.
  64140. * @return The Cube Map information.
  64141. */
  64142. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64143. /**
  64144. * Returns the pixels data extracted from an RGBE texture.
  64145. * This pixels will be stored left to right up to down in the R G B order in one array.
  64146. *
  64147. * More information on this format are available here:
  64148. * https://en.wikipedia.org/wiki/RGBE_image_format
  64149. *
  64150. * @param uint8array The binary file stored in an array buffer.
  64151. * @param hdrInfo The header information of the file.
  64152. * @return The pixels data in RGB right to left up to down order.
  64153. */
  64154. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64155. private static RGBE_ReadPixels_RLE;
  64156. private static RGBE_ReadPixels_NOT_RLE;
  64157. }
  64158. }
  64159. declare module "babylonjs/Materials/effectRenderer" {
  64160. import { Nullable } from "babylonjs/types";
  64161. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64163. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64164. import { Viewport } from "babylonjs/Maths/math.viewport";
  64165. import { Observable } from "babylonjs/Misc/observable";
  64166. import { Effect } from "babylonjs/Materials/effect";
  64167. import "babylonjs/Shaders/postprocess.vertex";
  64168. /**
  64169. * Effect Render Options
  64170. */
  64171. export interface IEffectRendererOptions {
  64172. /**
  64173. * Defines the vertices positions.
  64174. */
  64175. positions?: number[];
  64176. /**
  64177. * Defines the indices.
  64178. */
  64179. indices?: number[];
  64180. }
  64181. /**
  64182. * Helper class to render one or more effects.
  64183. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64184. */
  64185. export class EffectRenderer {
  64186. private engine;
  64187. private static _DefaultOptions;
  64188. private _vertexBuffers;
  64189. private _indexBuffer;
  64190. private _fullscreenViewport;
  64191. /**
  64192. * Creates an effect renderer
  64193. * @param engine the engine to use for rendering
  64194. * @param options defines the options of the effect renderer
  64195. */
  64196. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64197. /**
  64198. * Sets the current viewport in normalized coordinates 0-1
  64199. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64200. */
  64201. setViewport(viewport?: Viewport): void;
  64202. /**
  64203. * Binds the embedded attributes buffer to the effect.
  64204. * @param effect Defines the effect to bind the attributes for
  64205. */
  64206. bindBuffers(effect: Effect): void;
  64207. /**
  64208. * Sets the current effect wrapper to use during draw.
  64209. * The effect needs to be ready before calling this api.
  64210. * This also sets the default full screen position attribute.
  64211. * @param effectWrapper Defines the effect to draw with
  64212. */
  64213. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64214. /**
  64215. * Restores engine states
  64216. */
  64217. restoreStates(): void;
  64218. /**
  64219. * Draws a full screen quad.
  64220. */
  64221. draw(): void;
  64222. private isRenderTargetTexture;
  64223. /**
  64224. * renders one or more effects to a specified texture
  64225. * @param effectWrapper the effect to renderer
  64226. * @param outputTexture texture to draw to, if null it will render to the screen.
  64227. */
  64228. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64229. /**
  64230. * Disposes of the effect renderer
  64231. */
  64232. dispose(): void;
  64233. }
  64234. /**
  64235. * Options to create an EffectWrapper
  64236. */
  64237. interface EffectWrapperCreationOptions {
  64238. /**
  64239. * Engine to use to create the effect
  64240. */
  64241. engine: ThinEngine;
  64242. /**
  64243. * Fragment shader for the effect
  64244. */
  64245. fragmentShader: string;
  64246. /**
  64247. * Use the shader store instead of direct source code
  64248. */
  64249. useShaderStore?: boolean;
  64250. /**
  64251. * Vertex shader for the effect
  64252. */
  64253. vertexShader?: string;
  64254. /**
  64255. * Attributes to use in the shader
  64256. */
  64257. attributeNames?: Array<string>;
  64258. /**
  64259. * Uniforms to use in the shader
  64260. */
  64261. uniformNames?: Array<string>;
  64262. /**
  64263. * Texture sampler names to use in the shader
  64264. */
  64265. samplerNames?: Array<string>;
  64266. /**
  64267. * Defines to use in the shader
  64268. */
  64269. defines?: Array<string>;
  64270. /**
  64271. * Callback when effect is compiled
  64272. */
  64273. onCompiled?: Nullable<(effect: Effect) => void>;
  64274. /**
  64275. * The friendly name of the effect displayed in Spector.
  64276. */
  64277. name?: string;
  64278. }
  64279. /**
  64280. * Wraps an effect to be used for rendering
  64281. */
  64282. export class EffectWrapper {
  64283. /**
  64284. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64285. */
  64286. onApplyObservable: Observable<{}>;
  64287. /**
  64288. * The underlying effect
  64289. */
  64290. effect: Effect;
  64291. /**
  64292. * Creates an effect to be renderer
  64293. * @param creationOptions options to create the effect
  64294. */
  64295. constructor(creationOptions: EffectWrapperCreationOptions);
  64296. /**
  64297. * Disposes of the effect wrapper
  64298. */
  64299. dispose(): void;
  64300. }
  64301. }
  64302. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  64303. /** @hidden */
  64304. export var hdrFilteringVertexShader: {
  64305. name: string;
  64306. shader: string;
  64307. };
  64308. }
  64309. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  64310. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64311. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  64312. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  64313. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  64314. /** @hidden */
  64315. export var hdrFilteringPixelShader: {
  64316. name: string;
  64317. shader: string;
  64318. };
  64319. }
  64320. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  64321. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64322. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64323. import { Nullable } from "babylonjs/types";
  64324. import "babylonjs/Shaders/hdrFiltering.vertex";
  64325. import "babylonjs/Shaders/hdrFiltering.fragment";
  64326. /**
  64327. * Options for texture filtering
  64328. */
  64329. interface IHDRFilteringOptions {
  64330. /**
  64331. * Scales pixel intensity for the input HDR map.
  64332. */
  64333. hdrScale?: number;
  64334. /**
  64335. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64336. */
  64337. quality?: number;
  64338. }
  64339. /**
  64340. * Filters HDR maps to get correct renderings of PBR reflections
  64341. */
  64342. export class HDRFiltering {
  64343. private _engine;
  64344. private _effectRenderer;
  64345. private _effectWrapper;
  64346. private _lodGenerationOffset;
  64347. private _lodGenerationScale;
  64348. /**
  64349. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64350. * you care about baking speed.
  64351. */
  64352. quality: number;
  64353. /**
  64354. * Scales pixel intensity for the input HDR map.
  64355. */
  64356. hdrScale: number;
  64357. /**
  64358. * Instantiates HDR filter for reflection maps
  64359. *
  64360. * @param engine Thin engine
  64361. * @param options Options
  64362. */
  64363. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64364. private _createRenderTarget;
  64365. private _prefilterInternal;
  64366. private _createEffect;
  64367. /**
  64368. * Get a value indicating if the filter is ready to be used
  64369. * @param texture Texture to filter
  64370. * @returns true if the filter is ready
  64371. */
  64372. isReady(texture: BaseTexture): boolean;
  64373. /**
  64374. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64375. * Prefiltering will be invoked at the end of next rendering pass.
  64376. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64377. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64378. * @param texture Texture to filter
  64379. * @param onFinished Callback when filtering is done
  64380. * @return Promise called when prefiltering is done
  64381. */
  64382. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64383. }
  64384. }
  64385. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64386. import { Nullable } from "babylonjs/types";
  64387. import { Scene } from "babylonjs/scene";
  64388. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64390. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64391. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64392. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64393. /**
  64394. * This represents a texture coming from an HDR input.
  64395. *
  64396. * The only supported format is currently panorama picture stored in RGBE format.
  64397. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64398. */
  64399. export class HDRCubeTexture extends BaseTexture {
  64400. private static _facesMapping;
  64401. private _generateHarmonics;
  64402. private _noMipmap;
  64403. private _prefilterOnLoad;
  64404. private _textureMatrix;
  64405. private _size;
  64406. private _onLoad;
  64407. private _onError;
  64408. /**
  64409. * The texture URL.
  64410. */
  64411. url: string;
  64412. protected _isBlocking: boolean;
  64413. /**
  64414. * Sets wether or not the texture is blocking during loading.
  64415. */
  64416. set isBlocking(value: boolean);
  64417. /**
  64418. * Gets wether or not the texture is blocking during loading.
  64419. */
  64420. get isBlocking(): boolean;
  64421. protected _rotationY: number;
  64422. /**
  64423. * Sets texture matrix rotation angle around Y axis in radians.
  64424. */
  64425. set rotationY(value: number);
  64426. /**
  64427. * Gets texture matrix rotation angle around Y axis radians.
  64428. */
  64429. get rotationY(): number;
  64430. /**
  64431. * Gets or sets the center of the bounding box associated with the cube texture
  64432. * It must define where the camera used to render the texture was set
  64433. */
  64434. boundingBoxPosition: Vector3;
  64435. private _boundingBoxSize;
  64436. /**
  64437. * Gets or sets the size of the bounding box associated with the cube texture
  64438. * When defined, the cubemap will switch to local mode
  64439. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64440. * @example https://www.babylonjs-playground.com/#RNASML
  64441. */
  64442. set boundingBoxSize(value: Vector3);
  64443. get boundingBoxSize(): Vector3;
  64444. /**
  64445. * Instantiates an HDRTexture from the following parameters.
  64446. *
  64447. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64448. * @param sceneOrEngine The scene or engine the texture will be used in
  64449. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64450. * @param noMipmap Forces to not generate the mipmap if true
  64451. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64452. * @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)
  64453. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64454. */
  64455. 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>);
  64456. /**
  64457. * Get the current class name of the texture useful for serialization or dynamic coding.
  64458. * @returns "HDRCubeTexture"
  64459. */
  64460. getClassName(): string;
  64461. /**
  64462. * Occurs when the file is raw .hdr file.
  64463. */
  64464. private loadTexture;
  64465. clone(): HDRCubeTexture;
  64466. delayLoad(): void;
  64467. /**
  64468. * Get the texture reflection matrix used to rotate/transform the reflection.
  64469. * @returns the reflection matrix
  64470. */
  64471. getReflectionTextureMatrix(): Matrix;
  64472. /**
  64473. * Set the texture reflection matrix used to rotate/transform the reflection.
  64474. * @param value Define the reflection matrix to set
  64475. */
  64476. setReflectionTextureMatrix(value: Matrix): void;
  64477. /**
  64478. * Parses a JSON representation of an HDR Texture in order to create the texture
  64479. * @param parsedTexture Define the JSON representation
  64480. * @param scene Define the scene the texture should be created in
  64481. * @param rootUrl Define the root url in case we need to load relative dependencies
  64482. * @returns the newly created texture after parsing
  64483. */
  64484. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64485. serialize(): any;
  64486. }
  64487. }
  64488. declare module "babylonjs/Physics/physicsEngine" {
  64489. import { Nullable } from "babylonjs/types";
  64490. import { Vector3 } from "babylonjs/Maths/math.vector";
  64491. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64492. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64493. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64494. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64495. /**
  64496. * Class used to control physics engine
  64497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64498. */
  64499. export class PhysicsEngine implements IPhysicsEngine {
  64500. private _physicsPlugin;
  64501. /**
  64502. * Global value used to control the smallest number supported by the simulation
  64503. */
  64504. static Epsilon: number;
  64505. private _impostors;
  64506. private _joints;
  64507. private _subTimeStep;
  64508. /**
  64509. * Gets the gravity vector used by the simulation
  64510. */
  64511. gravity: Vector3;
  64512. /**
  64513. * Factory used to create the default physics plugin.
  64514. * @returns The default physics plugin
  64515. */
  64516. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64517. /**
  64518. * Creates a new Physics Engine
  64519. * @param gravity defines the gravity vector used by the simulation
  64520. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64521. */
  64522. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64523. /**
  64524. * Sets the gravity vector used by the simulation
  64525. * @param gravity defines the gravity vector to use
  64526. */
  64527. setGravity(gravity: Vector3): void;
  64528. /**
  64529. * Set the time step of the physics engine.
  64530. * Default is 1/60.
  64531. * To slow it down, enter 1/600 for example.
  64532. * To speed it up, 1/30
  64533. * @param newTimeStep defines the new timestep to apply to this world.
  64534. */
  64535. setTimeStep(newTimeStep?: number): void;
  64536. /**
  64537. * Get the time step of the physics engine.
  64538. * @returns the current time step
  64539. */
  64540. getTimeStep(): number;
  64541. /**
  64542. * Set the sub time step of the physics engine.
  64543. * Default is 0 meaning there is no sub steps
  64544. * To increase physics resolution precision, set a small value (like 1 ms)
  64545. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64546. */
  64547. setSubTimeStep(subTimeStep?: number): void;
  64548. /**
  64549. * Get the sub time step of the physics engine.
  64550. * @returns the current sub time step
  64551. */
  64552. getSubTimeStep(): number;
  64553. /**
  64554. * Release all resources
  64555. */
  64556. dispose(): void;
  64557. /**
  64558. * Gets the name of the current physics plugin
  64559. * @returns the name of the plugin
  64560. */
  64561. getPhysicsPluginName(): string;
  64562. /**
  64563. * Adding a new impostor for the impostor tracking.
  64564. * This will be done by the impostor itself.
  64565. * @param impostor the impostor to add
  64566. */
  64567. addImpostor(impostor: PhysicsImpostor): void;
  64568. /**
  64569. * Remove an impostor from the engine.
  64570. * This impostor and its mesh will not longer be updated by the physics engine.
  64571. * @param impostor the impostor to remove
  64572. */
  64573. removeImpostor(impostor: PhysicsImpostor): void;
  64574. /**
  64575. * Add a joint to the physics engine
  64576. * @param mainImpostor defines the main impostor to which the joint is added.
  64577. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64578. * @param joint defines the joint that will connect both impostors.
  64579. */
  64580. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64581. /**
  64582. * Removes a joint from the simulation
  64583. * @param mainImpostor defines the impostor used with the joint
  64584. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64585. * @param joint defines the joint to remove
  64586. */
  64587. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64588. /**
  64589. * Called by the scene. No need to call it.
  64590. * @param delta defines the timespam between frames
  64591. */
  64592. _step(delta: number): void;
  64593. /**
  64594. * Gets the current plugin used to run the simulation
  64595. * @returns current plugin
  64596. */
  64597. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64598. /**
  64599. * Gets the list of physic impostors
  64600. * @returns an array of PhysicsImpostor
  64601. */
  64602. getImpostors(): Array<PhysicsImpostor>;
  64603. /**
  64604. * Gets the impostor for a physics enabled object
  64605. * @param object defines the object impersonated by the impostor
  64606. * @returns the PhysicsImpostor or null if not found
  64607. */
  64608. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64609. /**
  64610. * Gets the impostor for a physics body object
  64611. * @param body defines physics body used by the impostor
  64612. * @returns the PhysicsImpostor or null if not found
  64613. */
  64614. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64615. /**
  64616. * Does a raycast in the physics world
  64617. * @param from when should the ray start?
  64618. * @param to when should the ray end?
  64619. * @returns PhysicsRaycastResult
  64620. */
  64621. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64622. }
  64623. }
  64624. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64625. import { Nullable } from "babylonjs/types";
  64626. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64628. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64629. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64630. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64631. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64632. /** @hidden */
  64633. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64634. private _useDeltaForWorldStep;
  64635. world: any;
  64636. name: string;
  64637. private _physicsMaterials;
  64638. private _fixedTimeStep;
  64639. private _cannonRaycastResult;
  64640. private _raycastResult;
  64641. private _physicsBodysToRemoveAfterStep;
  64642. private _firstFrame;
  64643. BJSCANNON: any;
  64644. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64645. setGravity(gravity: Vector3): void;
  64646. setTimeStep(timeStep: number): void;
  64647. getTimeStep(): number;
  64648. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64649. private _removeMarkedPhysicsBodiesFromWorld;
  64650. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64651. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64652. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64653. private _processChildMeshes;
  64654. removePhysicsBody(impostor: PhysicsImpostor): void;
  64655. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64656. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64657. private _addMaterial;
  64658. private _checkWithEpsilon;
  64659. private _createShape;
  64660. private _createHeightmap;
  64661. private _minus90X;
  64662. private _plus90X;
  64663. private _tmpPosition;
  64664. private _tmpDeltaPosition;
  64665. private _tmpUnityRotation;
  64666. private _updatePhysicsBodyTransformation;
  64667. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64668. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64669. isSupported(): boolean;
  64670. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64671. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64672. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64673. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64674. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64675. getBodyMass(impostor: PhysicsImpostor): number;
  64676. getBodyFriction(impostor: PhysicsImpostor): number;
  64677. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64678. getBodyRestitution(impostor: PhysicsImpostor): number;
  64679. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64680. sleepBody(impostor: PhysicsImpostor): void;
  64681. wakeUpBody(impostor: PhysicsImpostor): void;
  64682. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64683. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64684. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64685. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64686. getRadius(impostor: PhysicsImpostor): number;
  64687. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64688. dispose(): void;
  64689. private _extendNamespace;
  64690. /**
  64691. * Does a raycast in the physics world
  64692. * @param from when should the ray start?
  64693. * @param to when should the ray end?
  64694. * @returns PhysicsRaycastResult
  64695. */
  64696. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64697. }
  64698. }
  64699. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  64700. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64701. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64702. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64704. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64705. import { Nullable } from "babylonjs/types";
  64706. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64707. /** @hidden */
  64708. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64709. private _useDeltaForWorldStep;
  64710. world: any;
  64711. name: string;
  64712. BJSOIMO: any;
  64713. private _raycastResult;
  64714. private _fixedTimeStep;
  64715. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64716. setGravity(gravity: Vector3): void;
  64717. setTimeStep(timeStep: number): void;
  64718. getTimeStep(): number;
  64719. private _tmpImpostorsArray;
  64720. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64721. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64722. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64723. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64724. private _tmpPositionVector;
  64725. removePhysicsBody(impostor: PhysicsImpostor): void;
  64726. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64727. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64728. isSupported(): boolean;
  64729. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64730. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64731. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64732. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64733. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64734. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64735. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64736. getBodyMass(impostor: PhysicsImpostor): number;
  64737. getBodyFriction(impostor: PhysicsImpostor): number;
  64738. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64739. getBodyRestitution(impostor: PhysicsImpostor): number;
  64740. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64741. sleepBody(impostor: PhysicsImpostor): void;
  64742. wakeUpBody(impostor: PhysicsImpostor): void;
  64743. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64744. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64745. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64746. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64747. getRadius(impostor: PhysicsImpostor): number;
  64748. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64749. dispose(): void;
  64750. /**
  64751. * Does a raycast in the physics world
  64752. * @param from when should the ray start?
  64753. * @param to when should the ray end?
  64754. * @returns PhysicsRaycastResult
  64755. */
  64756. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64757. }
  64758. }
  64759. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  64760. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  64761. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64762. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64763. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64764. import { Nullable } from "babylonjs/types";
  64765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64766. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64767. /**
  64768. * AmmoJS Physics plugin
  64769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64770. * @see https://github.com/kripken/ammo.js/
  64771. */
  64772. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64773. private _useDeltaForWorldStep;
  64774. /**
  64775. * Reference to the Ammo library
  64776. */
  64777. bjsAMMO: any;
  64778. /**
  64779. * Created ammoJS world which physics bodies are added to
  64780. */
  64781. world: any;
  64782. /**
  64783. * Name of the plugin
  64784. */
  64785. name: string;
  64786. private _timeStep;
  64787. private _fixedTimeStep;
  64788. private _maxSteps;
  64789. private _tmpQuaternion;
  64790. private _tmpAmmoTransform;
  64791. private _tmpAmmoQuaternion;
  64792. private _tmpAmmoConcreteContactResultCallback;
  64793. private _collisionConfiguration;
  64794. private _dispatcher;
  64795. private _overlappingPairCache;
  64796. private _solver;
  64797. private _softBodySolver;
  64798. private _tmpAmmoVectorA;
  64799. private _tmpAmmoVectorB;
  64800. private _tmpAmmoVectorC;
  64801. private _tmpAmmoVectorD;
  64802. private _tmpContactCallbackResult;
  64803. private _tmpAmmoVectorRCA;
  64804. private _tmpAmmoVectorRCB;
  64805. private _raycastResult;
  64806. private _tmpContactPoint;
  64807. private static readonly DISABLE_COLLISION_FLAG;
  64808. private static readonly KINEMATIC_FLAG;
  64809. private static readonly DISABLE_DEACTIVATION_FLAG;
  64810. /**
  64811. * Initializes the ammoJS plugin
  64812. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64813. * @param ammoInjection can be used to inject your own ammo reference
  64814. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64815. */
  64816. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64817. /**
  64818. * Sets the gravity of the physics world (m/(s^2))
  64819. * @param gravity Gravity to set
  64820. */
  64821. setGravity(gravity: Vector3): void;
  64822. /**
  64823. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64824. * @param timeStep timestep to use in seconds
  64825. */
  64826. setTimeStep(timeStep: number): void;
  64827. /**
  64828. * 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)
  64829. * @param fixedTimeStep fixedTimeStep to use in seconds
  64830. */
  64831. setFixedTimeStep(fixedTimeStep: number): void;
  64832. /**
  64833. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64834. * @param maxSteps the maximum number of steps by the physics engine per frame
  64835. */
  64836. setMaxSteps(maxSteps: number): void;
  64837. /**
  64838. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64839. * @returns the current timestep in seconds
  64840. */
  64841. getTimeStep(): number;
  64842. /**
  64843. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64844. */
  64845. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64846. private _isImpostorInContact;
  64847. private _isImpostorPairInContact;
  64848. private _stepSimulation;
  64849. /**
  64850. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64851. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64852. * After the step the babylon meshes are set to the position of the physics imposters
  64853. * @param delta amount of time to step forward
  64854. * @param impostors array of imposters to update before/after the step
  64855. */
  64856. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64857. /**
  64858. * Update babylon mesh to match physics world object
  64859. * @param impostor imposter to match
  64860. */
  64861. private _afterSoftStep;
  64862. /**
  64863. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64864. * @param impostor imposter to match
  64865. */
  64866. private _ropeStep;
  64867. /**
  64868. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64869. * @param impostor imposter to match
  64870. */
  64871. private _softbodyOrClothStep;
  64872. private _tmpMatrix;
  64873. /**
  64874. * Applies an impulse on the imposter
  64875. * @param impostor imposter to apply impulse to
  64876. * @param force amount of force to be applied to the imposter
  64877. * @param contactPoint the location to apply the impulse on the imposter
  64878. */
  64879. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64880. /**
  64881. * Applies a force on the imposter
  64882. * @param impostor imposter to apply force
  64883. * @param force amount of force to be applied to the imposter
  64884. * @param contactPoint the location to apply the force on the imposter
  64885. */
  64886. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64887. /**
  64888. * Creates a physics body using the plugin
  64889. * @param impostor the imposter to create the physics body on
  64890. */
  64891. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64892. /**
  64893. * Removes the physics body from the imposter and disposes of the body's memory
  64894. * @param impostor imposter to remove the physics body from
  64895. */
  64896. removePhysicsBody(impostor: PhysicsImpostor): void;
  64897. /**
  64898. * Generates a joint
  64899. * @param impostorJoint the imposter joint to create the joint with
  64900. */
  64901. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64902. /**
  64903. * Removes a joint
  64904. * @param impostorJoint the imposter joint to remove the joint from
  64905. */
  64906. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64907. private _addMeshVerts;
  64908. /**
  64909. * Initialise the soft body vertices to match its object's (mesh) vertices
  64910. * Softbody vertices (nodes) are in world space and to match this
  64911. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64912. * @param impostor to create the softbody for
  64913. */
  64914. private _softVertexData;
  64915. /**
  64916. * Create an impostor's soft body
  64917. * @param impostor to create the softbody for
  64918. */
  64919. private _createSoftbody;
  64920. /**
  64921. * Create cloth for an impostor
  64922. * @param impostor to create the softbody for
  64923. */
  64924. private _createCloth;
  64925. /**
  64926. * Create rope for an impostor
  64927. * @param impostor to create the softbody for
  64928. */
  64929. private _createRope;
  64930. /**
  64931. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64932. * @param impostor to create the custom physics shape for
  64933. */
  64934. private _createCustom;
  64935. private _addHullVerts;
  64936. private _createShape;
  64937. /**
  64938. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64939. * @param impostor imposter containing the physics body and babylon object
  64940. */
  64941. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64942. /**
  64943. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64944. * @param impostor imposter containing the physics body and babylon object
  64945. * @param newPosition new position
  64946. * @param newRotation new rotation
  64947. */
  64948. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64949. /**
  64950. * If this plugin is supported
  64951. * @returns true if its supported
  64952. */
  64953. isSupported(): boolean;
  64954. /**
  64955. * Sets the linear velocity of the physics body
  64956. * @param impostor imposter to set the velocity on
  64957. * @param velocity velocity to set
  64958. */
  64959. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64960. /**
  64961. * Sets the angular velocity of the physics body
  64962. * @param impostor imposter to set the velocity on
  64963. * @param velocity velocity to set
  64964. */
  64965. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64966. /**
  64967. * gets the linear velocity
  64968. * @param impostor imposter to get linear velocity from
  64969. * @returns linear velocity
  64970. */
  64971. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64972. /**
  64973. * gets the angular velocity
  64974. * @param impostor imposter to get angular velocity from
  64975. * @returns angular velocity
  64976. */
  64977. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64978. /**
  64979. * Sets the mass of physics body
  64980. * @param impostor imposter to set the mass on
  64981. * @param mass mass to set
  64982. */
  64983. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64984. /**
  64985. * Gets the mass of the physics body
  64986. * @param impostor imposter to get the mass from
  64987. * @returns mass
  64988. */
  64989. getBodyMass(impostor: PhysicsImpostor): number;
  64990. /**
  64991. * Gets friction of the impostor
  64992. * @param impostor impostor to get friction from
  64993. * @returns friction value
  64994. */
  64995. getBodyFriction(impostor: PhysicsImpostor): number;
  64996. /**
  64997. * Sets friction of the impostor
  64998. * @param impostor impostor to set friction on
  64999. * @param friction friction value
  65000. */
  65001. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65002. /**
  65003. * Gets restitution of the impostor
  65004. * @param impostor impostor to get restitution from
  65005. * @returns restitution value
  65006. */
  65007. getBodyRestitution(impostor: PhysicsImpostor): number;
  65008. /**
  65009. * Sets resitution of the impostor
  65010. * @param impostor impostor to set resitution on
  65011. * @param restitution resitution value
  65012. */
  65013. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65014. /**
  65015. * Gets pressure inside the impostor
  65016. * @param impostor impostor to get pressure from
  65017. * @returns pressure value
  65018. */
  65019. getBodyPressure(impostor: PhysicsImpostor): number;
  65020. /**
  65021. * Sets pressure inside a soft body impostor
  65022. * Cloth and rope must remain 0 pressure
  65023. * @param impostor impostor to set pressure on
  65024. * @param pressure pressure value
  65025. */
  65026. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65027. /**
  65028. * Gets stiffness of the impostor
  65029. * @param impostor impostor to get stiffness from
  65030. * @returns pressure value
  65031. */
  65032. getBodyStiffness(impostor: PhysicsImpostor): number;
  65033. /**
  65034. * Sets stiffness of the impostor
  65035. * @param impostor impostor to set stiffness on
  65036. * @param stiffness stiffness value from 0 to 1
  65037. */
  65038. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65039. /**
  65040. * Gets velocityIterations of the impostor
  65041. * @param impostor impostor to get velocity iterations from
  65042. * @returns velocityIterations value
  65043. */
  65044. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65045. /**
  65046. * Sets velocityIterations of the impostor
  65047. * @param impostor impostor to set velocity iterations on
  65048. * @param velocityIterations velocityIterations value
  65049. */
  65050. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65051. /**
  65052. * Gets positionIterations of the impostor
  65053. * @param impostor impostor to get position iterations from
  65054. * @returns positionIterations value
  65055. */
  65056. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65057. /**
  65058. * Sets positionIterations of the impostor
  65059. * @param impostor impostor to set position on
  65060. * @param positionIterations positionIterations value
  65061. */
  65062. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65063. /**
  65064. * Append an anchor to a cloth object
  65065. * @param impostor is the cloth impostor to add anchor to
  65066. * @param otherImpostor is the rigid impostor to anchor to
  65067. * @param width ratio across width from 0 to 1
  65068. * @param height ratio up height from 0 to 1
  65069. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65070. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65071. */
  65072. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65073. /**
  65074. * Append an hook to a rope object
  65075. * @param impostor is the rope impostor to add hook to
  65076. * @param otherImpostor is the rigid impostor to hook to
  65077. * @param length ratio along the rope from 0 to 1
  65078. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65079. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65080. */
  65081. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65082. /**
  65083. * Sleeps the physics body and stops it from being active
  65084. * @param impostor impostor to sleep
  65085. */
  65086. sleepBody(impostor: PhysicsImpostor): void;
  65087. /**
  65088. * Activates the physics body
  65089. * @param impostor impostor to activate
  65090. */
  65091. wakeUpBody(impostor: PhysicsImpostor): void;
  65092. /**
  65093. * Updates the distance parameters of the joint
  65094. * @param joint joint to update
  65095. * @param maxDistance maximum distance of the joint
  65096. * @param minDistance minimum distance of the joint
  65097. */
  65098. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65099. /**
  65100. * Sets a motor on the joint
  65101. * @param joint joint to set motor on
  65102. * @param speed speed of the motor
  65103. * @param maxForce maximum force of the motor
  65104. * @param motorIndex index of the motor
  65105. */
  65106. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65107. /**
  65108. * Sets the motors limit
  65109. * @param joint joint to set limit on
  65110. * @param upperLimit upper limit
  65111. * @param lowerLimit lower limit
  65112. */
  65113. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65114. /**
  65115. * Syncs the position and rotation of a mesh with the impostor
  65116. * @param mesh mesh to sync
  65117. * @param impostor impostor to update the mesh with
  65118. */
  65119. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65120. /**
  65121. * Gets the radius of the impostor
  65122. * @param impostor impostor to get radius from
  65123. * @returns the radius
  65124. */
  65125. getRadius(impostor: PhysicsImpostor): number;
  65126. /**
  65127. * Gets the box size of the impostor
  65128. * @param impostor impostor to get box size from
  65129. * @param result the resulting box size
  65130. */
  65131. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65132. /**
  65133. * Disposes of the impostor
  65134. */
  65135. dispose(): void;
  65136. /**
  65137. * Does a raycast in the physics world
  65138. * @param from when should the ray start?
  65139. * @param to when should the ray end?
  65140. * @returns PhysicsRaycastResult
  65141. */
  65142. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65143. }
  65144. }
  65145. declare module "babylonjs/Probes/reflectionProbe" {
  65146. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65147. import { Vector3 } from "babylonjs/Maths/math.vector";
  65148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65149. import { Nullable } from "babylonjs/types";
  65150. import { Scene } from "babylonjs/scene";
  65151. module "babylonjs/abstractScene" {
  65152. interface AbstractScene {
  65153. /**
  65154. * The list of reflection probes added to the scene
  65155. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65156. */
  65157. reflectionProbes: Array<ReflectionProbe>;
  65158. /**
  65159. * Removes the given reflection probe from this scene.
  65160. * @param toRemove The reflection probe to remove
  65161. * @returns The index of the removed reflection probe
  65162. */
  65163. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65164. /**
  65165. * Adds the given reflection probe to this scene.
  65166. * @param newReflectionProbe The reflection probe to add
  65167. */
  65168. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65169. }
  65170. }
  65171. /**
  65172. * Class used to generate realtime reflection / refraction cube textures
  65173. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65174. */
  65175. export class ReflectionProbe {
  65176. /** defines the name of the probe */
  65177. name: string;
  65178. private _scene;
  65179. private _renderTargetTexture;
  65180. private _projectionMatrix;
  65181. private _viewMatrix;
  65182. private _target;
  65183. private _add;
  65184. private _attachedMesh;
  65185. private _invertYAxis;
  65186. /** Gets or sets probe position (center of the cube map) */
  65187. position: Vector3;
  65188. /**
  65189. * Creates a new reflection probe
  65190. * @param name defines the name of the probe
  65191. * @param size defines the texture resolution (for each face)
  65192. * @param scene defines the hosting scene
  65193. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65194. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65195. */
  65196. constructor(
  65197. /** defines the name of the probe */
  65198. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65199. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65200. get samples(): number;
  65201. set samples(value: number);
  65202. /** Gets or sets the refresh rate to use (on every frame by default) */
  65203. get refreshRate(): number;
  65204. set refreshRate(value: number);
  65205. /**
  65206. * Gets the hosting scene
  65207. * @returns a Scene
  65208. */
  65209. getScene(): Scene;
  65210. /** Gets the internal CubeTexture used to render to */
  65211. get cubeTexture(): RenderTargetTexture;
  65212. /** Gets the list of meshes to render */
  65213. get renderList(): Nullable<AbstractMesh[]>;
  65214. /**
  65215. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65216. * @param mesh defines the mesh to attach to
  65217. */
  65218. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65219. /**
  65220. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65221. * @param renderingGroupId The rendering group id corresponding to its index
  65222. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65223. */
  65224. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65225. /**
  65226. * Clean all associated resources
  65227. */
  65228. dispose(): void;
  65229. /**
  65230. * Converts the reflection probe information to a readable string for debug purpose.
  65231. * @param fullDetails Supports for multiple levels of logging within scene loading
  65232. * @returns the human readable reflection probe info
  65233. */
  65234. toString(fullDetails?: boolean): string;
  65235. /**
  65236. * Get the class name of the relfection probe.
  65237. * @returns "ReflectionProbe"
  65238. */
  65239. getClassName(): string;
  65240. /**
  65241. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65242. * @returns The JSON representation of the texture
  65243. */
  65244. serialize(): any;
  65245. /**
  65246. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65247. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65248. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65249. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65250. * @returns The parsed reflection probe if successful
  65251. */
  65252. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65253. }
  65254. }
  65255. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  65256. /** @hidden */
  65257. export var _BabylonLoaderRegistered: boolean;
  65258. /**
  65259. * Helps setting up some configuration for the babylon file loader.
  65260. */
  65261. export class BabylonFileLoaderConfiguration {
  65262. /**
  65263. * The loader does not allow injecting custom physix engine into the plugins.
  65264. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65265. * So you could set this variable to your engine import to make it work.
  65266. */
  65267. static LoaderInjectedPhysicsEngine: any;
  65268. }
  65269. }
  65270. declare module "babylonjs/Loading/Plugins/index" {
  65271. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  65272. }
  65273. declare module "babylonjs/Loading/index" {
  65274. export * from "babylonjs/Loading/loadingScreen";
  65275. export * from "babylonjs/Loading/Plugins/index";
  65276. export * from "babylonjs/Loading/sceneLoader";
  65277. export * from "babylonjs/Loading/sceneLoaderFlags";
  65278. }
  65279. declare module "babylonjs/Materials/Background/index" {
  65280. export * from "babylonjs/Materials/Background/backgroundMaterial";
  65281. }
  65282. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  65283. import { Scene } from "babylonjs/scene";
  65284. import { Color3 } from "babylonjs/Maths/math.color";
  65285. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65286. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65287. /**
  65288. * The Physically based simple base material of BJS.
  65289. *
  65290. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65291. * It is used as the base class for both the specGloss and metalRough conventions.
  65292. */
  65293. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65294. /**
  65295. * Number of Simultaneous lights allowed on the material.
  65296. */
  65297. maxSimultaneousLights: number;
  65298. /**
  65299. * If sets to true, disables all the lights affecting the material.
  65300. */
  65301. disableLighting: boolean;
  65302. /**
  65303. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65304. */
  65305. environmentTexture: BaseTexture;
  65306. /**
  65307. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65308. */
  65309. invertNormalMapX: boolean;
  65310. /**
  65311. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65312. */
  65313. invertNormalMapY: boolean;
  65314. /**
  65315. * Normal map used in the model.
  65316. */
  65317. normalTexture: BaseTexture;
  65318. /**
  65319. * Emissivie color used to self-illuminate the model.
  65320. */
  65321. emissiveColor: Color3;
  65322. /**
  65323. * Emissivie texture used to self-illuminate the model.
  65324. */
  65325. emissiveTexture: BaseTexture;
  65326. /**
  65327. * Occlusion Channel Strenght.
  65328. */
  65329. occlusionStrength: number;
  65330. /**
  65331. * Occlusion Texture of the material (adding extra occlusion effects).
  65332. */
  65333. occlusionTexture: BaseTexture;
  65334. /**
  65335. * Defines the alpha limits in alpha test mode.
  65336. */
  65337. alphaCutOff: number;
  65338. /**
  65339. * Gets the current double sided mode.
  65340. */
  65341. get doubleSided(): boolean;
  65342. /**
  65343. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65344. */
  65345. set doubleSided(value: boolean);
  65346. /**
  65347. * Stores the pre-calculated light information of a mesh in a texture.
  65348. */
  65349. lightmapTexture: BaseTexture;
  65350. /**
  65351. * If true, the light map contains occlusion information instead of lighting info.
  65352. */
  65353. useLightmapAsShadowmap: boolean;
  65354. /**
  65355. * Instantiates a new PBRMaterial instance.
  65356. *
  65357. * @param name The material name
  65358. * @param scene The scene the material will be use in.
  65359. */
  65360. constructor(name: string, scene: Scene);
  65361. getClassName(): string;
  65362. }
  65363. }
  65364. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  65365. import { Scene } from "babylonjs/scene";
  65366. import { Color3 } from "babylonjs/Maths/math.color";
  65367. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65368. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65369. /**
  65370. * The PBR material of BJS following the metal roughness convention.
  65371. *
  65372. * This fits to the PBR convention in the GLTF definition:
  65373. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65374. */
  65375. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65376. /**
  65377. * The base color has two different interpretations depending on the value of metalness.
  65378. * When the material is a metal, the base color is the specific measured reflectance value
  65379. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65380. * of the material.
  65381. */
  65382. baseColor: Color3;
  65383. /**
  65384. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65385. * well as opacity information in the alpha channel.
  65386. */
  65387. baseTexture: BaseTexture;
  65388. /**
  65389. * Specifies the metallic scalar value of the material.
  65390. * Can also be used to scale the metalness values of the metallic texture.
  65391. */
  65392. metallic: number;
  65393. /**
  65394. * Specifies the roughness scalar value of the material.
  65395. * Can also be used to scale the roughness values of the metallic texture.
  65396. */
  65397. roughness: number;
  65398. /**
  65399. * Texture containing both the metallic value in the B channel and the
  65400. * roughness value in the G channel to keep better precision.
  65401. */
  65402. metallicRoughnessTexture: BaseTexture;
  65403. /**
  65404. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65405. *
  65406. * @param name The material name
  65407. * @param scene The scene the material will be use in.
  65408. */
  65409. constructor(name: string, scene: Scene);
  65410. /**
  65411. * Return the currrent class name of the material.
  65412. */
  65413. getClassName(): string;
  65414. /**
  65415. * Makes a duplicate of the current material.
  65416. * @param name - name to use for the new material.
  65417. */
  65418. clone(name: string): PBRMetallicRoughnessMaterial;
  65419. /**
  65420. * Serialize the material to a parsable JSON object.
  65421. */
  65422. serialize(): any;
  65423. /**
  65424. * Parses a JSON object correponding to the serialize function.
  65425. */
  65426. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65427. }
  65428. }
  65429. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65430. import { Scene } from "babylonjs/scene";
  65431. import { Color3 } from "babylonjs/Maths/math.color";
  65432. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65433. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65434. /**
  65435. * The PBR material of BJS following the specular glossiness convention.
  65436. *
  65437. * This fits to the PBR convention in the GLTF definition:
  65438. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65439. */
  65440. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65441. /**
  65442. * Specifies the diffuse color of the material.
  65443. */
  65444. diffuseColor: Color3;
  65445. /**
  65446. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65447. * channel.
  65448. */
  65449. diffuseTexture: BaseTexture;
  65450. /**
  65451. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65452. */
  65453. specularColor: Color3;
  65454. /**
  65455. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65456. */
  65457. glossiness: number;
  65458. /**
  65459. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65460. */
  65461. specularGlossinessTexture: BaseTexture;
  65462. /**
  65463. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65464. *
  65465. * @param name The material name
  65466. * @param scene The scene the material will be use in.
  65467. */
  65468. constructor(name: string, scene: Scene);
  65469. /**
  65470. * Return the currrent class name of the material.
  65471. */
  65472. getClassName(): string;
  65473. /**
  65474. * Makes a duplicate of the current material.
  65475. * @param name - name to use for the new material.
  65476. */
  65477. clone(name: string): PBRSpecularGlossinessMaterial;
  65478. /**
  65479. * Serialize the material to a parsable JSON object.
  65480. */
  65481. serialize(): any;
  65482. /**
  65483. * Parses a JSON object correponding to the serialize function.
  65484. */
  65485. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65486. }
  65487. }
  65488. declare module "babylonjs/Materials/PBR/index" {
  65489. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65490. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65491. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65492. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65493. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65494. }
  65495. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65496. import { Nullable } from "babylonjs/types";
  65497. import { Scene } from "babylonjs/scene";
  65498. import { Matrix } from "babylonjs/Maths/math.vector";
  65499. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65500. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65501. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65502. /**
  65503. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65504. * It can help converting any input color in a desired output one. This can then be used to create effects
  65505. * from sepia, black and white to sixties or futuristic rendering...
  65506. *
  65507. * The only supported format is currently 3dl.
  65508. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65509. */
  65510. export class ColorGradingTexture extends BaseTexture {
  65511. /**
  65512. * The texture URL.
  65513. */
  65514. url: string;
  65515. /**
  65516. * Empty line regex stored for GC.
  65517. */
  65518. private static _noneEmptyLineRegex;
  65519. private _textureMatrix;
  65520. private _onLoad;
  65521. /**
  65522. * Instantiates a ColorGradingTexture from the following parameters.
  65523. *
  65524. * @param url The location of the color gradind data (currently only supporting 3dl)
  65525. * @param sceneOrEngine The scene or engine the texture will be used in
  65526. * @param onLoad defines a callback triggered when the texture has been loaded
  65527. */
  65528. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65529. /**
  65530. * Fires the onload event from the constructor if requested.
  65531. */
  65532. private _triggerOnLoad;
  65533. /**
  65534. * Returns the texture matrix used in most of the material.
  65535. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65536. */
  65537. getTextureMatrix(): Matrix;
  65538. /**
  65539. * Occurs when the file being loaded is a .3dl LUT file.
  65540. */
  65541. private load3dlTexture;
  65542. /**
  65543. * Starts the loading process of the texture.
  65544. */
  65545. private loadTexture;
  65546. /**
  65547. * Clones the color gradind texture.
  65548. */
  65549. clone(): ColorGradingTexture;
  65550. /**
  65551. * Called during delayed load for textures.
  65552. */
  65553. delayLoad(): void;
  65554. /**
  65555. * Parses a color grading texture serialized by Babylon.
  65556. * @param parsedTexture The texture information being parsedTexture
  65557. * @param scene The scene to load the texture in
  65558. * @param rootUrl The root url of the data assets to load
  65559. * @return A color gradind texture
  65560. */
  65561. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65562. /**
  65563. * Serializes the LUT texture to json format.
  65564. */
  65565. serialize(): any;
  65566. }
  65567. }
  65568. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65569. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65570. import { Scene } from "babylonjs/scene";
  65571. import { Nullable } from "babylonjs/types";
  65572. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65573. /**
  65574. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65575. */
  65576. export class EquiRectangularCubeTexture extends BaseTexture {
  65577. /** The six faces of the cube. */
  65578. private static _FacesMapping;
  65579. private _noMipmap;
  65580. private _onLoad;
  65581. private _onError;
  65582. /** The size of the cubemap. */
  65583. private _size;
  65584. /** The buffer of the image. */
  65585. private _buffer;
  65586. /** The width of the input image. */
  65587. private _width;
  65588. /** The height of the input image. */
  65589. private _height;
  65590. /** The URL to the image. */
  65591. url: string;
  65592. /**
  65593. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65594. * @param url The location of the image
  65595. * @param scene The scene the texture will be used in
  65596. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65597. * @param noMipmap Forces to not generate the mipmap if true
  65598. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65599. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65600. * @param onLoad — defines a callback called when texture is loaded
  65601. * @param onError — defines a callback called if there is an error
  65602. */
  65603. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65604. /**
  65605. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65606. */
  65607. private loadImage;
  65608. /**
  65609. * Convert the image buffer into a cubemap and create a CubeTexture.
  65610. */
  65611. private loadTexture;
  65612. /**
  65613. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65614. * @param buffer The ArrayBuffer that should be converted.
  65615. * @returns The buffer as Float32Array.
  65616. */
  65617. private getFloat32ArrayFromArrayBuffer;
  65618. /**
  65619. * Get the current class name of the texture useful for serialization or dynamic coding.
  65620. * @returns "EquiRectangularCubeTexture"
  65621. */
  65622. getClassName(): string;
  65623. /**
  65624. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65625. * @returns A clone of the current EquiRectangularCubeTexture.
  65626. */
  65627. clone(): EquiRectangularCubeTexture;
  65628. }
  65629. }
  65630. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65631. import { Nullable } from "babylonjs/types";
  65632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65633. import { Matrix } from "babylonjs/Maths/math.vector";
  65634. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65635. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65636. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65637. import { Scene } from "babylonjs/scene";
  65638. /**
  65639. * Defines the options related to the creation of an HtmlElementTexture
  65640. */
  65641. export interface IHtmlElementTextureOptions {
  65642. /**
  65643. * Defines wether mip maps should be created or not.
  65644. */
  65645. generateMipMaps?: boolean;
  65646. /**
  65647. * Defines the sampling mode of the texture.
  65648. */
  65649. samplingMode?: number;
  65650. /**
  65651. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65652. */
  65653. engine: Nullable<ThinEngine>;
  65654. /**
  65655. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65656. */
  65657. scene: Nullable<Scene>;
  65658. }
  65659. /**
  65660. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65661. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65662. * is automatically managed.
  65663. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65664. * in your application.
  65665. *
  65666. * As the update is not automatic, you need to call them manually.
  65667. */
  65668. export class HtmlElementTexture extends BaseTexture {
  65669. /**
  65670. * The texture URL.
  65671. */
  65672. element: HTMLVideoElement | HTMLCanvasElement;
  65673. private static readonly DefaultOptions;
  65674. private _textureMatrix;
  65675. private _isVideo;
  65676. private _generateMipMaps;
  65677. private _samplingMode;
  65678. /**
  65679. * Instantiates a HtmlElementTexture from the following parameters.
  65680. *
  65681. * @param name Defines the name of the texture
  65682. * @param element Defines the video or canvas the texture is filled with
  65683. * @param options Defines the other none mandatory texture creation options
  65684. */
  65685. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65686. private _createInternalTexture;
  65687. /**
  65688. * Returns the texture matrix used in most of the material.
  65689. */
  65690. getTextureMatrix(): Matrix;
  65691. /**
  65692. * Updates the content of the texture.
  65693. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65694. */
  65695. update(invertY?: Nullable<boolean>): void;
  65696. }
  65697. }
  65698. declare module "babylonjs/Misc/tga" {
  65699. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65700. /**
  65701. * Based on jsTGALoader - Javascript loader for TGA file
  65702. * By Vincent Thibault
  65703. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65704. */
  65705. export class TGATools {
  65706. private static _TYPE_INDEXED;
  65707. private static _TYPE_RGB;
  65708. private static _TYPE_GREY;
  65709. private static _TYPE_RLE_INDEXED;
  65710. private static _TYPE_RLE_RGB;
  65711. private static _TYPE_RLE_GREY;
  65712. private static _ORIGIN_MASK;
  65713. private static _ORIGIN_SHIFT;
  65714. private static _ORIGIN_BL;
  65715. private static _ORIGIN_BR;
  65716. private static _ORIGIN_UL;
  65717. private static _ORIGIN_UR;
  65718. /**
  65719. * Gets the header of a TGA file
  65720. * @param data defines the TGA data
  65721. * @returns the header
  65722. */
  65723. static GetTGAHeader(data: Uint8Array): any;
  65724. /**
  65725. * Uploads TGA content to a Babylon Texture
  65726. * @hidden
  65727. */
  65728. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65729. /** @hidden */
  65730. 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;
  65731. /** @hidden */
  65732. 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;
  65733. /** @hidden */
  65734. 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;
  65735. /** @hidden */
  65736. 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;
  65737. /** @hidden */
  65738. 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;
  65739. /** @hidden */
  65740. 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;
  65741. }
  65742. }
  65743. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  65744. import { Nullable } from "babylonjs/types";
  65745. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65746. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65747. /**
  65748. * Implementation of the TGA Texture Loader.
  65749. * @hidden
  65750. */
  65751. export class _TGATextureLoader implements IInternalTextureLoader {
  65752. /**
  65753. * Defines wether the loader supports cascade loading the different faces.
  65754. */
  65755. readonly supportCascades: boolean;
  65756. /**
  65757. * This returns if the loader support the current file information.
  65758. * @param extension defines the file extension of the file being loaded
  65759. * @returns true if the loader can load the specified file
  65760. */
  65761. canLoad(extension: string): boolean;
  65762. /**
  65763. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65764. * @param data contains the texture data
  65765. * @param texture defines the BabylonJS internal texture
  65766. * @param createPolynomials will be true if polynomials have been requested
  65767. * @param onLoad defines the callback to trigger once the texture is ready
  65768. * @param onError defines the callback to trigger in case of error
  65769. */
  65770. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65771. /**
  65772. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65773. * @param data contains the texture data
  65774. * @param texture defines the BabylonJS internal texture
  65775. * @param callback defines the method to call once ready to upload
  65776. */
  65777. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65778. }
  65779. }
  65780. declare module "babylonjs/Misc/basis" {
  65781. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65782. /**
  65783. * Info about the .basis files
  65784. */
  65785. class BasisFileInfo {
  65786. /**
  65787. * If the file has alpha
  65788. */
  65789. hasAlpha: boolean;
  65790. /**
  65791. * Info about each image of the basis file
  65792. */
  65793. images: Array<{
  65794. levels: Array<{
  65795. width: number;
  65796. height: number;
  65797. transcodedPixels: ArrayBufferView;
  65798. }>;
  65799. }>;
  65800. }
  65801. /**
  65802. * Result of transcoding a basis file
  65803. */
  65804. class TranscodeResult {
  65805. /**
  65806. * Info about the .basis file
  65807. */
  65808. fileInfo: BasisFileInfo;
  65809. /**
  65810. * Format to use when loading the file
  65811. */
  65812. format: number;
  65813. }
  65814. /**
  65815. * Configuration options for the Basis transcoder
  65816. */
  65817. export class BasisTranscodeConfiguration {
  65818. /**
  65819. * Supported compression formats used to determine the supported output format of the transcoder
  65820. */
  65821. supportedCompressionFormats?: {
  65822. /**
  65823. * etc1 compression format
  65824. */
  65825. etc1?: boolean;
  65826. /**
  65827. * s3tc compression format
  65828. */
  65829. s3tc?: boolean;
  65830. /**
  65831. * pvrtc compression format
  65832. */
  65833. pvrtc?: boolean;
  65834. /**
  65835. * etc2 compression format
  65836. */
  65837. etc2?: boolean;
  65838. };
  65839. /**
  65840. * If mipmap levels should be loaded for transcoded images (Default: true)
  65841. */
  65842. loadMipmapLevels?: boolean;
  65843. /**
  65844. * Index of a single image to load (Default: all images)
  65845. */
  65846. loadSingleImage?: number;
  65847. }
  65848. /**
  65849. * Used to load .Basis files
  65850. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65851. */
  65852. export class BasisTools {
  65853. private static _IgnoreSupportedFormats;
  65854. /**
  65855. * URL to use when loading the basis transcoder
  65856. */
  65857. static JSModuleURL: string;
  65858. /**
  65859. * URL to use when loading the wasm module for the transcoder
  65860. */
  65861. static WasmModuleURL: string;
  65862. /**
  65863. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65864. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65865. * @returns internal format corresponding to the Basis format
  65866. */
  65867. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65868. private static _WorkerPromise;
  65869. private static _Worker;
  65870. private static _actionId;
  65871. private static _CreateWorkerAsync;
  65872. /**
  65873. * Transcodes a loaded image file to compressed pixel data
  65874. * @param data image data to transcode
  65875. * @param config configuration options for the transcoding
  65876. * @returns a promise resulting in the transcoded image
  65877. */
  65878. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65879. /**
  65880. * Loads a texture from the transcode result
  65881. * @param texture texture load to
  65882. * @param transcodeResult the result of transcoding the basis file to load from
  65883. */
  65884. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65885. }
  65886. }
  65887. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65888. import { Nullable } from "babylonjs/types";
  65889. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65890. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65891. /**
  65892. * Loader for .basis file format
  65893. */
  65894. export class _BasisTextureLoader implements IInternalTextureLoader {
  65895. /**
  65896. * Defines whether the loader supports cascade loading the different faces.
  65897. */
  65898. readonly supportCascades: boolean;
  65899. /**
  65900. * This returns if the loader support the current file information.
  65901. * @param extension defines the file extension of the file being loaded
  65902. * @returns true if the loader can load the specified file
  65903. */
  65904. canLoad(extension: string): boolean;
  65905. /**
  65906. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65907. * @param data contains the texture data
  65908. * @param texture defines the BabylonJS internal texture
  65909. * @param createPolynomials will be true if polynomials have been requested
  65910. * @param onLoad defines the callback to trigger once the texture is ready
  65911. * @param onError defines the callback to trigger in case of error
  65912. */
  65913. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65914. /**
  65915. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65916. * @param data contains the texture data
  65917. * @param texture defines the BabylonJS internal texture
  65918. * @param callback defines the method to call once ready to upload
  65919. */
  65920. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65921. }
  65922. }
  65923. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65924. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65925. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65926. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65927. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65928. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65929. }
  65930. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65931. import { Vector2 } from "babylonjs/Maths/math.vector";
  65932. /**
  65933. * Defines the basic options interface of a TexturePacker Frame
  65934. */
  65935. export interface ITexturePackerFrame {
  65936. /**
  65937. * The frame ID
  65938. */
  65939. id: number;
  65940. /**
  65941. * The frames Scale
  65942. */
  65943. scale: Vector2;
  65944. /**
  65945. * The Frames offset
  65946. */
  65947. offset: Vector2;
  65948. }
  65949. /**
  65950. * This is a support class for frame Data on texture packer sets.
  65951. */
  65952. export class TexturePackerFrame implements ITexturePackerFrame {
  65953. /**
  65954. * The frame ID
  65955. */
  65956. id: number;
  65957. /**
  65958. * The frames Scale
  65959. */
  65960. scale: Vector2;
  65961. /**
  65962. * The Frames offset
  65963. */
  65964. offset: Vector2;
  65965. /**
  65966. * Initializes a texture package frame.
  65967. * @param id The numerical frame identifier
  65968. * @param scale Scalar Vector2 for UV frame
  65969. * @param offset Vector2 for the frame position in UV units.
  65970. * @returns TexturePackerFrame
  65971. */
  65972. constructor(id: number, scale: Vector2, offset: Vector2);
  65973. }
  65974. }
  65975. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65977. import { Scene } from "babylonjs/scene";
  65978. import { Nullable } from "babylonjs/types";
  65979. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65980. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65981. /**
  65982. * Defines the basic options interface of a TexturePacker
  65983. */
  65984. export interface ITexturePackerOptions {
  65985. /**
  65986. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65987. */
  65988. map?: string[];
  65989. /**
  65990. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65991. */
  65992. uvsIn?: string;
  65993. /**
  65994. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65995. */
  65996. uvsOut?: string;
  65997. /**
  65998. * number representing the layout style. Defaults to LAYOUT_STRIP
  65999. */
  66000. layout?: number;
  66001. /**
  66002. * number of columns if using custom column count layout(2). This defaults to 4.
  66003. */
  66004. colnum?: number;
  66005. /**
  66006. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66007. */
  66008. updateInputMeshes?: boolean;
  66009. /**
  66010. * boolean flag to dispose all the source textures. Defaults to true.
  66011. */
  66012. disposeSources?: boolean;
  66013. /**
  66014. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66015. */
  66016. fillBlanks?: boolean;
  66017. /**
  66018. * string value representing the context fill style color. Defaults to 'black'.
  66019. */
  66020. customFillColor?: string;
  66021. /**
  66022. * Width and Height Value of each Frame in the TexturePacker Sets
  66023. */
  66024. frameSize?: number;
  66025. /**
  66026. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66027. */
  66028. paddingRatio?: number;
  66029. /**
  66030. * Number that declares the fill method for the padding gutter.
  66031. */
  66032. paddingMode?: number;
  66033. /**
  66034. * If in SUBUV_COLOR padding mode what color to use.
  66035. */
  66036. paddingColor?: Color3 | Color4;
  66037. }
  66038. /**
  66039. * Defines the basic interface of a TexturePacker JSON File
  66040. */
  66041. export interface ITexturePackerJSON {
  66042. /**
  66043. * The frame ID
  66044. */
  66045. name: string;
  66046. /**
  66047. * The base64 channel data
  66048. */
  66049. sets: any;
  66050. /**
  66051. * The options of the Packer
  66052. */
  66053. options: ITexturePackerOptions;
  66054. /**
  66055. * The frame data of the Packer
  66056. */
  66057. frames: Array<number>;
  66058. }
  66059. /**
  66060. * This is a support class that generates a series of packed texture sets.
  66061. * @see https://doc.babylonjs.com/babylon101/materials
  66062. */
  66063. export class TexturePacker {
  66064. /** Packer Layout Constant 0 */
  66065. static readonly LAYOUT_STRIP: number;
  66066. /** Packer Layout Constant 1 */
  66067. static readonly LAYOUT_POWER2: number;
  66068. /** Packer Layout Constant 2 */
  66069. static readonly LAYOUT_COLNUM: number;
  66070. /** Packer Layout Constant 0 */
  66071. static readonly SUBUV_WRAP: number;
  66072. /** Packer Layout Constant 1 */
  66073. static readonly SUBUV_EXTEND: number;
  66074. /** Packer Layout Constant 2 */
  66075. static readonly SUBUV_COLOR: number;
  66076. /** The Name of the Texture Package */
  66077. name: string;
  66078. /** The scene scope of the TexturePacker */
  66079. scene: Scene;
  66080. /** The Meshes to target */
  66081. meshes: AbstractMesh[];
  66082. /** Arguments passed with the Constructor */
  66083. options: ITexturePackerOptions;
  66084. /** The promise that is started upon initialization */
  66085. promise: Nullable<Promise<TexturePacker | string>>;
  66086. /** The Container object for the channel sets that are generated */
  66087. sets: object;
  66088. /** The Container array for the frames that are generated */
  66089. frames: TexturePackerFrame[];
  66090. /** The expected number of textures the system is parsing. */
  66091. private _expecting;
  66092. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66093. private _paddingValue;
  66094. /**
  66095. * Initializes a texture package series from an array of meshes or a single mesh.
  66096. * @param name The name of the package
  66097. * @param meshes The target meshes to compose the package from
  66098. * @param options The arguments that texture packer should follow while building.
  66099. * @param scene The scene which the textures are scoped to.
  66100. * @returns TexturePacker
  66101. */
  66102. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66103. /**
  66104. * Starts the package process
  66105. * @param resolve The promises resolution function
  66106. * @returns TexturePacker
  66107. */
  66108. private _createFrames;
  66109. /**
  66110. * Calculates the Size of the Channel Sets
  66111. * @returns Vector2
  66112. */
  66113. private _calculateSize;
  66114. /**
  66115. * Calculates the UV data for the frames.
  66116. * @param baseSize the base frameSize
  66117. * @param padding the base frame padding
  66118. * @param dtSize size of the Dynamic Texture for that channel
  66119. * @param dtUnits is 1/dtSize
  66120. * @param update flag to update the input meshes
  66121. */
  66122. private _calculateMeshUVFrames;
  66123. /**
  66124. * Calculates the frames Offset.
  66125. * @param index of the frame
  66126. * @returns Vector2
  66127. */
  66128. private _getFrameOffset;
  66129. /**
  66130. * Updates a Mesh to the frame data
  66131. * @param mesh that is the target
  66132. * @param frameID or the frame index
  66133. */
  66134. private _updateMeshUV;
  66135. /**
  66136. * Updates a Meshes materials to use the texture packer channels
  66137. * @param m is the mesh to target
  66138. * @param force all channels on the packer to be set.
  66139. */
  66140. private _updateTextureReferences;
  66141. /**
  66142. * Public method to set a Mesh to a frame
  66143. * @param m that is the target
  66144. * @param frameID or the frame index
  66145. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66146. */
  66147. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66148. /**
  66149. * Starts the async promise to compile the texture packer.
  66150. * @returns Promise<void>
  66151. */
  66152. processAsync(): Promise<void>;
  66153. /**
  66154. * Disposes all textures associated with this packer
  66155. */
  66156. dispose(): void;
  66157. /**
  66158. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66159. * @param imageType is the image type to use.
  66160. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66161. */
  66162. download(imageType?: string, quality?: number): void;
  66163. /**
  66164. * Public method to load a texturePacker JSON file.
  66165. * @param data of the JSON file in string format.
  66166. */
  66167. updateFromJSON(data: string): void;
  66168. }
  66169. }
  66170. declare module "babylonjs/Materials/Textures/Packer/index" {
  66171. export * from "babylonjs/Materials/Textures/Packer/packer";
  66172. export * from "babylonjs/Materials/Textures/Packer/frame";
  66173. }
  66174. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  66175. import { Scene } from "babylonjs/scene";
  66176. import { Texture } from "babylonjs/Materials/Textures/texture";
  66177. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66178. /**
  66179. * 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.
  66180. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66181. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66182. */
  66183. export class CustomProceduralTexture extends ProceduralTexture {
  66184. private _animate;
  66185. private _time;
  66186. private _config;
  66187. private _texturePath;
  66188. /**
  66189. * Instantiates a new Custom Procedural Texture.
  66190. * 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.
  66191. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66192. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66193. * @param name Define the name of the texture
  66194. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66195. * @param size Define the size of the texture to create
  66196. * @param scene Define the scene the texture belongs to
  66197. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66198. * @param generateMipMaps Define if the texture should creates mip maps or not
  66199. */
  66200. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66201. private _loadJson;
  66202. /**
  66203. * Is the texture ready to be used ? (rendered at least once)
  66204. * @returns true if ready, otherwise, false.
  66205. */
  66206. isReady(): boolean;
  66207. /**
  66208. * Render the texture to its associated render target.
  66209. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66210. */
  66211. render(useCameraPostProcess?: boolean): void;
  66212. /**
  66213. * Update the list of dependant textures samplers in the shader.
  66214. */
  66215. updateTextures(): void;
  66216. /**
  66217. * Update the uniform values of the procedural texture in the shader.
  66218. */
  66219. updateShaderUniforms(): void;
  66220. /**
  66221. * Define if the texture animates or not.
  66222. */
  66223. get animate(): boolean;
  66224. set animate(value: boolean);
  66225. }
  66226. }
  66227. declare module "babylonjs/Shaders/noise.fragment" {
  66228. /** @hidden */
  66229. export var noisePixelShader: {
  66230. name: string;
  66231. shader: string;
  66232. };
  66233. }
  66234. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  66235. import { Nullable } from "babylonjs/types";
  66236. import { Scene } from "babylonjs/scene";
  66237. import { Texture } from "babylonjs/Materials/Textures/texture";
  66238. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66239. import "babylonjs/Shaders/noise.fragment";
  66240. /**
  66241. * Class used to generate noise procedural textures
  66242. */
  66243. export class NoiseProceduralTexture extends ProceduralTexture {
  66244. /** Gets or sets the start time (default is 0) */
  66245. time: number;
  66246. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66247. brightness: number;
  66248. /** Defines the number of octaves to process */
  66249. octaves: number;
  66250. /** Defines the level of persistence (0.8 by default) */
  66251. persistence: number;
  66252. /** Gets or sets animation speed factor (default is 1) */
  66253. animationSpeedFactor: number;
  66254. /**
  66255. * Creates a new NoiseProceduralTexture
  66256. * @param name defines the name fo the texture
  66257. * @param size defines the size of the texture (default is 256)
  66258. * @param scene defines the hosting scene
  66259. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66260. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66261. */
  66262. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66263. private _updateShaderUniforms;
  66264. protected _getDefines(): string;
  66265. /** Generate the current state of the procedural texture */
  66266. render(useCameraPostProcess?: boolean): void;
  66267. /**
  66268. * Serializes this noise procedural texture
  66269. * @returns a serialized noise procedural texture object
  66270. */
  66271. serialize(): any;
  66272. /**
  66273. * Clone the texture.
  66274. * @returns the cloned texture
  66275. */
  66276. clone(): NoiseProceduralTexture;
  66277. /**
  66278. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66279. * @param parsedTexture defines parsed texture data
  66280. * @param scene defines the current scene
  66281. * @param rootUrl defines the root URL containing noise procedural texture information
  66282. * @returns a parsed NoiseProceduralTexture
  66283. */
  66284. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66285. }
  66286. }
  66287. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  66288. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  66289. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  66290. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66291. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  66292. }
  66293. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  66294. import { Nullable } from "babylonjs/types";
  66295. import { Scene } from "babylonjs/scene";
  66296. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  66297. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66298. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66299. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66300. /**
  66301. * Raw cube texture where the raw buffers are passed in
  66302. */
  66303. export class RawCubeTexture extends CubeTexture {
  66304. /**
  66305. * Creates a cube texture where the raw buffers are passed in.
  66306. * @param scene defines the scene the texture is attached to
  66307. * @param data defines the array of data to use to create each face
  66308. * @param size defines the size of the textures
  66309. * @param format defines the format of the data
  66310. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66311. * @param generateMipMaps defines if the engine should generate the mip levels
  66312. * @param invertY defines if data must be stored with Y axis inverted
  66313. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66314. * @param compression defines the compression used (null by default)
  66315. */
  66316. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66317. /**
  66318. * Updates the raw cube texture.
  66319. * @param data defines the data to store
  66320. * @param format defines the data format
  66321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66322. * @param invertY defines if data must be stored with Y axis inverted
  66323. * @param compression defines the compression used (null by default)
  66324. * @param level defines which level of the texture to update
  66325. */
  66326. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66327. /**
  66328. * Updates a raw cube texture with RGBD encoded data.
  66329. * @param data defines the array of data [mipmap][face] to use to create each face
  66330. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66331. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66332. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66333. * @returns a promsie that resolves when the operation is complete
  66334. */
  66335. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66336. /**
  66337. * Clones the raw cube texture.
  66338. * @return a new cube texture
  66339. */
  66340. clone(): CubeTexture;
  66341. /** @hidden */
  66342. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66343. }
  66344. }
  66345. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  66346. import { Scene } from "babylonjs/scene";
  66347. import { Texture } from "babylonjs/Materials/Textures/texture";
  66348. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66349. /**
  66350. * Class used to store 2D array textures containing user data
  66351. */
  66352. export class RawTexture2DArray extends Texture {
  66353. /** Gets or sets the texture format to use */
  66354. format: number;
  66355. /**
  66356. * Create a new RawTexture2DArray
  66357. * @param data defines the data of the texture
  66358. * @param width defines the width of the texture
  66359. * @param height defines the height of the texture
  66360. * @param depth defines the number of layers of the texture
  66361. * @param format defines the texture format to use
  66362. * @param scene defines the hosting scene
  66363. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66364. * @param invertY defines if texture must be stored with Y axis inverted
  66365. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66366. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66367. */
  66368. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66369. /** Gets or sets the texture format to use */
  66370. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66371. /**
  66372. * Update the texture with new data
  66373. * @param data defines the data to store in the texture
  66374. */
  66375. update(data: ArrayBufferView): void;
  66376. }
  66377. }
  66378. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66379. import { Scene } from "babylonjs/scene";
  66380. import { Texture } from "babylonjs/Materials/Textures/texture";
  66381. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66382. /**
  66383. * Class used to store 3D textures containing user data
  66384. */
  66385. export class RawTexture3D extends Texture {
  66386. /** Gets or sets the texture format to use */
  66387. format: number;
  66388. /**
  66389. * Create a new RawTexture3D
  66390. * @param data defines the data of the texture
  66391. * @param width defines the width of the texture
  66392. * @param height defines the height of the texture
  66393. * @param depth defines the depth of the texture
  66394. * @param format defines the texture format to use
  66395. * @param scene defines the hosting scene
  66396. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66397. * @param invertY defines if texture must be stored with Y axis inverted
  66398. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66399. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66400. */
  66401. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66402. /** Gets or sets the texture format to use */
  66403. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66404. /**
  66405. * Update the texture with new data
  66406. * @param data defines the data to store in the texture
  66407. */
  66408. update(data: ArrayBufferView): void;
  66409. }
  66410. }
  66411. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66412. import { Scene } from "babylonjs/scene";
  66413. import { Plane } from "babylonjs/Maths/math.plane";
  66414. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66415. /**
  66416. * Creates a refraction texture used by refraction channel of the standard material.
  66417. * It is like a mirror but to see through a material.
  66418. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66419. */
  66420. export class RefractionTexture extends RenderTargetTexture {
  66421. /**
  66422. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66423. * 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.
  66424. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66425. */
  66426. refractionPlane: Plane;
  66427. /**
  66428. * Define how deep under the surface we should see.
  66429. */
  66430. depth: number;
  66431. /**
  66432. * Creates a refraction texture used by refraction channel of the standard material.
  66433. * It is like a mirror but to see through a material.
  66434. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66435. * @param name Define the texture name
  66436. * @param size Define the size of the underlying texture
  66437. * @param scene Define the scene the refraction belongs to
  66438. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66439. */
  66440. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66441. /**
  66442. * Clone the refraction texture.
  66443. * @returns the cloned texture
  66444. */
  66445. clone(): RefractionTexture;
  66446. /**
  66447. * Serialize the texture to a JSON representation you could use in Parse later on
  66448. * @returns the serialized JSON representation
  66449. */
  66450. serialize(): any;
  66451. }
  66452. }
  66453. declare module "babylonjs/Materials/Textures/index" {
  66454. export * from "babylonjs/Materials/Textures/baseTexture";
  66455. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66456. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66457. export * from "babylonjs/Materials/Textures/cubeTexture";
  66458. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66459. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66460. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66461. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66462. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66463. export * from "babylonjs/Materials/Textures/internalTexture";
  66464. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66465. export * from "babylonjs/Materials/Textures/Loaders/index";
  66466. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66467. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66468. export * from "babylonjs/Materials/Textures/Packer/index";
  66469. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66470. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66471. export * from "babylonjs/Materials/Textures/rawTexture";
  66472. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66473. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66474. export * from "babylonjs/Materials/Textures/refractionTexture";
  66475. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66476. export * from "babylonjs/Materials/Textures/texture";
  66477. export * from "babylonjs/Materials/Textures/videoTexture";
  66478. }
  66479. declare module "babylonjs/Materials/Node/Enums/index" {
  66480. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66481. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66482. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66483. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66484. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66485. }
  66486. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66487. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66488. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66490. import { Mesh } from "babylonjs/Meshes/mesh";
  66491. import { Effect } from "babylonjs/Materials/effect";
  66492. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66493. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66494. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66495. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66496. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66497. /**
  66498. * Block used to add support for vertex skinning (bones)
  66499. */
  66500. export class BonesBlock extends NodeMaterialBlock {
  66501. /**
  66502. * Creates a new BonesBlock
  66503. * @param name defines the block name
  66504. */
  66505. constructor(name: string);
  66506. /**
  66507. * Initialize the block and prepare the context for build
  66508. * @param state defines the state that will be used for the build
  66509. */
  66510. initialize(state: NodeMaterialBuildState): void;
  66511. /**
  66512. * Gets the current class name
  66513. * @returns the class name
  66514. */
  66515. getClassName(): string;
  66516. /**
  66517. * Gets the matrix indices input component
  66518. */
  66519. get matricesIndices(): NodeMaterialConnectionPoint;
  66520. /**
  66521. * Gets the matrix weights input component
  66522. */
  66523. get matricesWeights(): NodeMaterialConnectionPoint;
  66524. /**
  66525. * Gets the extra matrix indices input component
  66526. */
  66527. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66528. /**
  66529. * Gets the extra matrix weights input component
  66530. */
  66531. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66532. /**
  66533. * Gets the world input component
  66534. */
  66535. get world(): NodeMaterialConnectionPoint;
  66536. /**
  66537. * Gets the output component
  66538. */
  66539. get output(): NodeMaterialConnectionPoint;
  66540. autoConfigure(material: NodeMaterial): void;
  66541. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66542. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66543. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66544. protected _buildBlock(state: NodeMaterialBuildState): this;
  66545. }
  66546. }
  66547. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66549. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66550. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66552. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66553. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66554. /**
  66555. * Block used to add support for instances
  66556. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66557. */
  66558. export class InstancesBlock extends NodeMaterialBlock {
  66559. /**
  66560. * Creates a new InstancesBlock
  66561. * @param name defines the block name
  66562. */
  66563. constructor(name: string);
  66564. /**
  66565. * Gets the current class name
  66566. * @returns the class name
  66567. */
  66568. getClassName(): string;
  66569. /**
  66570. * Gets the first world row input component
  66571. */
  66572. get world0(): NodeMaterialConnectionPoint;
  66573. /**
  66574. * Gets the second world row input component
  66575. */
  66576. get world1(): NodeMaterialConnectionPoint;
  66577. /**
  66578. * Gets the third world row input component
  66579. */
  66580. get world2(): NodeMaterialConnectionPoint;
  66581. /**
  66582. * Gets the forth world row input component
  66583. */
  66584. get world3(): NodeMaterialConnectionPoint;
  66585. /**
  66586. * Gets the world input component
  66587. */
  66588. get world(): NodeMaterialConnectionPoint;
  66589. /**
  66590. * Gets the output component
  66591. */
  66592. get output(): NodeMaterialConnectionPoint;
  66593. /**
  66594. * Gets the isntanceID component
  66595. */
  66596. get instanceID(): NodeMaterialConnectionPoint;
  66597. autoConfigure(material: NodeMaterial): void;
  66598. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66599. protected _buildBlock(state: NodeMaterialBuildState): this;
  66600. }
  66601. }
  66602. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66603. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66604. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66605. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66607. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66608. import { Effect } from "babylonjs/Materials/effect";
  66609. import { Mesh } from "babylonjs/Meshes/mesh";
  66610. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66611. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66612. /**
  66613. * Block used to add morph targets support to vertex shader
  66614. */
  66615. export class MorphTargetsBlock extends NodeMaterialBlock {
  66616. private _repeatableContentAnchor;
  66617. /**
  66618. * Create a new MorphTargetsBlock
  66619. * @param name defines the block name
  66620. */
  66621. constructor(name: string);
  66622. /**
  66623. * Gets the current class name
  66624. * @returns the class name
  66625. */
  66626. getClassName(): string;
  66627. /**
  66628. * Gets the position input component
  66629. */
  66630. get position(): NodeMaterialConnectionPoint;
  66631. /**
  66632. * Gets the normal input component
  66633. */
  66634. get normal(): NodeMaterialConnectionPoint;
  66635. /**
  66636. * Gets the tangent input component
  66637. */
  66638. get tangent(): NodeMaterialConnectionPoint;
  66639. /**
  66640. * Gets the tangent input component
  66641. */
  66642. get uv(): NodeMaterialConnectionPoint;
  66643. /**
  66644. * Gets the position output component
  66645. */
  66646. get positionOutput(): NodeMaterialConnectionPoint;
  66647. /**
  66648. * Gets the normal output component
  66649. */
  66650. get normalOutput(): NodeMaterialConnectionPoint;
  66651. /**
  66652. * Gets the tangent output component
  66653. */
  66654. get tangentOutput(): NodeMaterialConnectionPoint;
  66655. /**
  66656. * Gets the tangent output component
  66657. */
  66658. get uvOutput(): NodeMaterialConnectionPoint;
  66659. initialize(state: NodeMaterialBuildState): void;
  66660. autoConfigure(material: NodeMaterial): void;
  66661. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66662. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66663. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66664. protected _buildBlock(state: NodeMaterialBuildState): this;
  66665. }
  66666. }
  66667. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  66668. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66669. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66670. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66671. import { Nullable } from "babylonjs/types";
  66672. import { Scene } from "babylonjs/scene";
  66673. import { Effect } from "babylonjs/Materials/effect";
  66674. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66675. import { Mesh } from "babylonjs/Meshes/mesh";
  66676. import { Light } from "babylonjs/Lights/light";
  66677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66678. /**
  66679. * Block used to get data information from a light
  66680. */
  66681. export class LightInformationBlock extends NodeMaterialBlock {
  66682. private _lightDataUniformName;
  66683. private _lightColorUniformName;
  66684. private _lightTypeDefineName;
  66685. /**
  66686. * Gets or sets the light associated with this block
  66687. */
  66688. light: Nullable<Light>;
  66689. /**
  66690. * Creates a new LightInformationBlock
  66691. * @param name defines the block name
  66692. */
  66693. constructor(name: string);
  66694. /**
  66695. * Gets the current class name
  66696. * @returns the class name
  66697. */
  66698. getClassName(): string;
  66699. /**
  66700. * Gets the world position input component
  66701. */
  66702. get worldPosition(): NodeMaterialConnectionPoint;
  66703. /**
  66704. * Gets the direction output component
  66705. */
  66706. get direction(): NodeMaterialConnectionPoint;
  66707. /**
  66708. * Gets the direction output component
  66709. */
  66710. get color(): NodeMaterialConnectionPoint;
  66711. /**
  66712. * Gets the direction output component
  66713. */
  66714. get intensity(): NodeMaterialConnectionPoint;
  66715. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66716. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66717. protected _buildBlock(state: NodeMaterialBuildState): this;
  66718. serialize(): any;
  66719. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66720. }
  66721. }
  66722. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  66723. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  66724. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  66725. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  66726. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  66727. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  66728. }
  66729. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  66730. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66731. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66732. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66734. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66735. import { Effect } from "babylonjs/Materials/effect";
  66736. import { Mesh } from "babylonjs/Meshes/mesh";
  66737. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66738. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66739. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66740. /**
  66741. * Block used to add image processing support to fragment shader
  66742. */
  66743. export class ImageProcessingBlock extends NodeMaterialBlock {
  66744. /**
  66745. * Create a new ImageProcessingBlock
  66746. * @param name defines the block name
  66747. */
  66748. constructor(name: string);
  66749. /**
  66750. * Gets the current class name
  66751. * @returns the class name
  66752. */
  66753. getClassName(): string;
  66754. /**
  66755. * Gets the color input component
  66756. */
  66757. get color(): NodeMaterialConnectionPoint;
  66758. /**
  66759. * Gets the output component
  66760. */
  66761. get output(): NodeMaterialConnectionPoint;
  66762. /**
  66763. * Initialize the block and prepare the context for build
  66764. * @param state defines the state that will be used for the build
  66765. */
  66766. initialize(state: NodeMaterialBuildState): void;
  66767. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66768. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66769. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66770. protected _buildBlock(state: NodeMaterialBuildState): this;
  66771. }
  66772. }
  66773. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  66774. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66775. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66776. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66777. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66779. import { Effect } from "babylonjs/Materials/effect";
  66780. import { Mesh } from "babylonjs/Meshes/mesh";
  66781. import { Scene } from "babylonjs/scene";
  66782. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  66783. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  66784. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  66785. /**
  66786. * Block used to pertub normals based on a normal map
  66787. */
  66788. export class PerturbNormalBlock extends NodeMaterialBlock {
  66789. private _tangentSpaceParameterName;
  66790. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66791. invertX: boolean;
  66792. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66793. invertY: boolean;
  66794. /**
  66795. * Create a new PerturbNormalBlock
  66796. * @param name defines the block name
  66797. */
  66798. constructor(name: string);
  66799. /**
  66800. * Gets the current class name
  66801. * @returns the class name
  66802. */
  66803. getClassName(): string;
  66804. /**
  66805. * Gets the world position input component
  66806. */
  66807. get worldPosition(): NodeMaterialConnectionPoint;
  66808. /**
  66809. * Gets the world normal input component
  66810. */
  66811. get worldNormal(): NodeMaterialConnectionPoint;
  66812. /**
  66813. * Gets the world tangent input component
  66814. */
  66815. get worldTangent(): NodeMaterialConnectionPoint;
  66816. /**
  66817. * Gets the uv input component
  66818. */
  66819. get uv(): NodeMaterialConnectionPoint;
  66820. /**
  66821. * Gets the normal map color input component
  66822. */
  66823. get normalMapColor(): NodeMaterialConnectionPoint;
  66824. /**
  66825. * Gets the strength input component
  66826. */
  66827. get strength(): NodeMaterialConnectionPoint;
  66828. /**
  66829. * Gets the output component
  66830. */
  66831. get output(): NodeMaterialConnectionPoint;
  66832. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66834. autoConfigure(material: NodeMaterial): void;
  66835. protected _buildBlock(state: NodeMaterialBuildState): this;
  66836. protected _dumpPropertiesCode(): string;
  66837. serialize(): any;
  66838. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66839. }
  66840. }
  66841. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66842. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66843. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66844. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66845. /**
  66846. * Block used to discard a pixel if a value is smaller than a cutoff
  66847. */
  66848. export class DiscardBlock extends NodeMaterialBlock {
  66849. /**
  66850. * Create a new DiscardBlock
  66851. * @param name defines the block name
  66852. */
  66853. constructor(name: string);
  66854. /**
  66855. * Gets the current class name
  66856. * @returns the class name
  66857. */
  66858. getClassName(): string;
  66859. /**
  66860. * Gets the color input component
  66861. */
  66862. get value(): NodeMaterialConnectionPoint;
  66863. /**
  66864. * Gets the cutoff input component
  66865. */
  66866. get cutoff(): NodeMaterialConnectionPoint;
  66867. protected _buildBlock(state: NodeMaterialBuildState): this;
  66868. }
  66869. }
  66870. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66871. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66872. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66873. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66874. /**
  66875. * Block used to test if the fragment shader is front facing
  66876. */
  66877. export class FrontFacingBlock extends NodeMaterialBlock {
  66878. /**
  66879. * Creates a new FrontFacingBlock
  66880. * @param name defines the block name
  66881. */
  66882. constructor(name: string);
  66883. /**
  66884. * Gets the current class name
  66885. * @returns the class name
  66886. */
  66887. getClassName(): string;
  66888. /**
  66889. * Gets the output component
  66890. */
  66891. get output(): NodeMaterialConnectionPoint;
  66892. protected _buildBlock(state: NodeMaterialBuildState): this;
  66893. }
  66894. }
  66895. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66896. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66897. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66898. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66899. /**
  66900. * Block used to get the derivative value on x and y of a given input
  66901. */
  66902. export class DerivativeBlock extends NodeMaterialBlock {
  66903. /**
  66904. * Create a new DerivativeBlock
  66905. * @param name defines the block name
  66906. */
  66907. constructor(name: string);
  66908. /**
  66909. * Gets the current class name
  66910. * @returns the class name
  66911. */
  66912. getClassName(): string;
  66913. /**
  66914. * Gets the input component
  66915. */
  66916. get input(): NodeMaterialConnectionPoint;
  66917. /**
  66918. * Gets the derivative output on x
  66919. */
  66920. get dx(): NodeMaterialConnectionPoint;
  66921. /**
  66922. * Gets the derivative output on y
  66923. */
  66924. get dy(): NodeMaterialConnectionPoint;
  66925. protected _buildBlock(state: NodeMaterialBuildState): this;
  66926. }
  66927. }
  66928. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66929. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66930. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66931. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66932. /**
  66933. * Block used to make gl_FragCoord available
  66934. */
  66935. export class FragCoordBlock extends NodeMaterialBlock {
  66936. /**
  66937. * Creates a new FragCoordBlock
  66938. * @param name defines the block name
  66939. */
  66940. constructor(name: string);
  66941. /**
  66942. * Gets the current class name
  66943. * @returns the class name
  66944. */
  66945. getClassName(): string;
  66946. /**
  66947. * Gets the xy component
  66948. */
  66949. get xy(): NodeMaterialConnectionPoint;
  66950. /**
  66951. * Gets the xyz component
  66952. */
  66953. get xyz(): NodeMaterialConnectionPoint;
  66954. /**
  66955. * Gets the xyzw component
  66956. */
  66957. get xyzw(): NodeMaterialConnectionPoint;
  66958. /**
  66959. * Gets the x component
  66960. */
  66961. get x(): NodeMaterialConnectionPoint;
  66962. /**
  66963. * Gets the y component
  66964. */
  66965. get y(): NodeMaterialConnectionPoint;
  66966. /**
  66967. * Gets the z component
  66968. */
  66969. get z(): NodeMaterialConnectionPoint;
  66970. /**
  66971. * Gets the w component
  66972. */
  66973. get output(): NodeMaterialConnectionPoint;
  66974. protected writeOutputs(state: NodeMaterialBuildState): string;
  66975. protected _buildBlock(state: NodeMaterialBuildState): this;
  66976. }
  66977. }
  66978. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66982. import { Effect } from "babylonjs/Materials/effect";
  66983. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66984. import { Mesh } from "babylonjs/Meshes/mesh";
  66985. /**
  66986. * Block used to get the screen sizes
  66987. */
  66988. export class ScreenSizeBlock extends NodeMaterialBlock {
  66989. private _varName;
  66990. private _scene;
  66991. /**
  66992. * Creates a new ScreenSizeBlock
  66993. * @param name defines the block name
  66994. */
  66995. constructor(name: string);
  66996. /**
  66997. * Gets the current class name
  66998. * @returns the class name
  66999. */
  67000. getClassName(): string;
  67001. /**
  67002. * Gets the xy component
  67003. */
  67004. get xy(): NodeMaterialConnectionPoint;
  67005. /**
  67006. * Gets the x component
  67007. */
  67008. get x(): NodeMaterialConnectionPoint;
  67009. /**
  67010. * Gets the y component
  67011. */
  67012. get y(): NodeMaterialConnectionPoint;
  67013. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67014. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67015. protected _buildBlock(state: NodeMaterialBuildState): this;
  67016. }
  67017. }
  67018. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  67019. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  67020. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  67021. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  67022. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  67023. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  67024. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  67025. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  67026. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  67027. }
  67028. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  67029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67031. import { Mesh } from "babylonjs/Meshes/mesh";
  67032. import { Effect } from "babylonjs/Materials/effect";
  67033. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67035. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67036. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  67037. /**
  67038. * Block used to add support for scene fog
  67039. */
  67040. export class FogBlock extends NodeMaterialBlock {
  67041. private _fogDistanceName;
  67042. private _fogParameters;
  67043. /**
  67044. * Create a new FogBlock
  67045. * @param name defines the block name
  67046. */
  67047. constructor(name: string);
  67048. /**
  67049. * Gets the current class name
  67050. * @returns the class name
  67051. */
  67052. getClassName(): string;
  67053. /**
  67054. * Gets the world position input component
  67055. */
  67056. get worldPosition(): NodeMaterialConnectionPoint;
  67057. /**
  67058. * Gets the view input component
  67059. */
  67060. get view(): NodeMaterialConnectionPoint;
  67061. /**
  67062. * Gets the color input component
  67063. */
  67064. get input(): NodeMaterialConnectionPoint;
  67065. /**
  67066. * Gets the fog color input component
  67067. */
  67068. get fogColor(): NodeMaterialConnectionPoint;
  67069. /**
  67070. * Gets the output component
  67071. */
  67072. get output(): NodeMaterialConnectionPoint;
  67073. autoConfigure(material: NodeMaterial): void;
  67074. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67075. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67076. protected _buildBlock(state: NodeMaterialBuildState): this;
  67077. }
  67078. }
  67079. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  67080. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67081. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67082. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67084. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67085. import { Effect } from "babylonjs/Materials/effect";
  67086. import { Mesh } from "babylonjs/Meshes/mesh";
  67087. import { Light } from "babylonjs/Lights/light";
  67088. import { Nullable } from "babylonjs/types";
  67089. import { Scene } from "babylonjs/scene";
  67090. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  67091. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  67092. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  67093. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67094. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  67095. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  67096. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  67097. /**
  67098. * Block used to add light in the fragment shader
  67099. */
  67100. export class LightBlock extends NodeMaterialBlock {
  67101. private _lightId;
  67102. /**
  67103. * Gets or sets the light associated with this block
  67104. */
  67105. light: Nullable<Light>;
  67106. /**
  67107. * Create a new LightBlock
  67108. * @param name defines the block name
  67109. */
  67110. constructor(name: string);
  67111. /**
  67112. * Gets the current class name
  67113. * @returns the class name
  67114. */
  67115. getClassName(): string;
  67116. /**
  67117. * Gets the world position input component
  67118. */
  67119. get worldPosition(): NodeMaterialConnectionPoint;
  67120. /**
  67121. * Gets the world normal input component
  67122. */
  67123. get worldNormal(): NodeMaterialConnectionPoint;
  67124. /**
  67125. * Gets the camera (or eye) position component
  67126. */
  67127. get cameraPosition(): NodeMaterialConnectionPoint;
  67128. /**
  67129. * Gets the glossiness component
  67130. */
  67131. get glossiness(): NodeMaterialConnectionPoint;
  67132. /**
  67133. * Gets the glossinness power component
  67134. */
  67135. get glossPower(): NodeMaterialConnectionPoint;
  67136. /**
  67137. * Gets the diffuse color component
  67138. */
  67139. get diffuseColor(): NodeMaterialConnectionPoint;
  67140. /**
  67141. * Gets the specular color component
  67142. */
  67143. get specularColor(): NodeMaterialConnectionPoint;
  67144. /**
  67145. * Gets the view matrix component
  67146. */
  67147. get view(): NodeMaterialConnectionPoint;
  67148. /**
  67149. * Gets the diffuse output component
  67150. */
  67151. get diffuseOutput(): NodeMaterialConnectionPoint;
  67152. /**
  67153. * Gets the specular output component
  67154. */
  67155. get specularOutput(): NodeMaterialConnectionPoint;
  67156. /**
  67157. * Gets the shadow output component
  67158. */
  67159. get shadow(): NodeMaterialConnectionPoint;
  67160. autoConfigure(material: NodeMaterial): void;
  67161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67162. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67164. private _injectVertexCode;
  67165. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67166. serialize(): any;
  67167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67168. }
  67169. }
  67170. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  67171. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67172. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67173. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67174. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67175. /**
  67176. * Block used to read a reflection texture from a sampler
  67177. */
  67178. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67179. /**
  67180. * Create a new ReflectionTextureBlock
  67181. * @param name defines the block name
  67182. */
  67183. constructor(name: string);
  67184. /**
  67185. * Gets the current class name
  67186. * @returns the class name
  67187. */
  67188. getClassName(): string;
  67189. /**
  67190. * Gets the world position input component
  67191. */
  67192. get position(): NodeMaterialConnectionPoint;
  67193. /**
  67194. * Gets the world position input component
  67195. */
  67196. get worldPosition(): NodeMaterialConnectionPoint;
  67197. /**
  67198. * Gets the world normal input component
  67199. */
  67200. get worldNormal(): NodeMaterialConnectionPoint;
  67201. /**
  67202. * Gets the world input component
  67203. */
  67204. get world(): NodeMaterialConnectionPoint;
  67205. /**
  67206. * Gets the camera (or eye) position component
  67207. */
  67208. get cameraPosition(): NodeMaterialConnectionPoint;
  67209. /**
  67210. * Gets the view input component
  67211. */
  67212. get view(): NodeMaterialConnectionPoint;
  67213. /**
  67214. * Gets the rgb output component
  67215. */
  67216. get rgb(): NodeMaterialConnectionPoint;
  67217. /**
  67218. * Gets the rgba output component
  67219. */
  67220. get rgba(): NodeMaterialConnectionPoint;
  67221. /**
  67222. * Gets the r output component
  67223. */
  67224. get r(): NodeMaterialConnectionPoint;
  67225. /**
  67226. * Gets the g output component
  67227. */
  67228. get g(): NodeMaterialConnectionPoint;
  67229. /**
  67230. * Gets the b output component
  67231. */
  67232. get b(): NodeMaterialConnectionPoint;
  67233. /**
  67234. * Gets the a output component
  67235. */
  67236. get a(): NodeMaterialConnectionPoint;
  67237. autoConfigure(material: NodeMaterial): void;
  67238. protected _buildBlock(state: NodeMaterialBuildState): this;
  67239. }
  67240. }
  67241. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  67242. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  67243. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  67244. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  67245. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  67246. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  67247. }
  67248. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  67249. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  67250. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  67251. }
  67252. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  67253. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67254. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67255. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67256. /**
  67257. * Block used to add 2 vectors
  67258. */
  67259. export class AddBlock extends NodeMaterialBlock {
  67260. /**
  67261. * Creates a new AddBlock
  67262. * @param name defines the block name
  67263. */
  67264. constructor(name: string);
  67265. /**
  67266. * Gets the current class name
  67267. * @returns the class name
  67268. */
  67269. getClassName(): string;
  67270. /**
  67271. * Gets the left operand input component
  67272. */
  67273. get left(): NodeMaterialConnectionPoint;
  67274. /**
  67275. * Gets the right operand input component
  67276. */
  67277. get right(): NodeMaterialConnectionPoint;
  67278. /**
  67279. * Gets the output component
  67280. */
  67281. get output(): NodeMaterialConnectionPoint;
  67282. protected _buildBlock(state: NodeMaterialBuildState): this;
  67283. }
  67284. }
  67285. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  67286. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67287. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67288. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67289. /**
  67290. * Block used to scale a vector by a float
  67291. */
  67292. export class ScaleBlock extends NodeMaterialBlock {
  67293. /**
  67294. * Creates a new ScaleBlock
  67295. * @param name defines the block name
  67296. */
  67297. constructor(name: string);
  67298. /**
  67299. * Gets the current class name
  67300. * @returns the class name
  67301. */
  67302. getClassName(): string;
  67303. /**
  67304. * Gets the input component
  67305. */
  67306. get input(): NodeMaterialConnectionPoint;
  67307. /**
  67308. * Gets the factor input component
  67309. */
  67310. get factor(): NodeMaterialConnectionPoint;
  67311. /**
  67312. * Gets the output component
  67313. */
  67314. get output(): NodeMaterialConnectionPoint;
  67315. protected _buildBlock(state: NodeMaterialBuildState): this;
  67316. }
  67317. }
  67318. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  67319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67322. import { Scene } from "babylonjs/scene";
  67323. /**
  67324. * Block used to clamp a float
  67325. */
  67326. export class ClampBlock extends NodeMaterialBlock {
  67327. /** Gets or sets the minimum range */
  67328. minimum: number;
  67329. /** Gets or sets the maximum range */
  67330. maximum: number;
  67331. /**
  67332. * Creates a new ClampBlock
  67333. * @param name defines the block name
  67334. */
  67335. constructor(name: string);
  67336. /**
  67337. * Gets the current class name
  67338. * @returns the class name
  67339. */
  67340. getClassName(): string;
  67341. /**
  67342. * Gets the value input component
  67343. */
  67344. get value(): NodeMaterialConnectionPoint;
  67345. /**
  67346. * Gets the output component
  67347. */
  67348. get output(): NodeMaterialConnectionPoint;
  67349. protected _buildBlock(state: NodeMaterialBuildState): this;
  67350. protected _dumpPropertiesCode(): string;
  67351. serialize(): any;
  67352. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67353. }
  67354. }
  67355. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  67356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67359. /**
  67360. * Block used to apply a cross product between 2 vectors
  67361. */
  67362. export class CrossBlock extends NodeMaterialBlock {
  67363. /**
  67364. * Creates a new CrossBlock
  67365. * @param name defines the block name
  67366. */
  67367. constructor(name: string);
  67368. /**
  67369. * Gets the current class name
  67370. * @returns the class name
  67371. */
  67372. getClassName(): string;
  67373. /**
  67374. * Gets the left operand input component
  67375. */
  67376. get left(): NodeMaterialConnectionPoint;
  67377. /**
  67378. * Gets the right operand input component
  67379. */
  67380. get right(): NodeMaterialConnectionPoint;
  67381. /**
  67382. * Gets the output component
  67383. */
  67384. get output(): NodeMaterialConnectionPoint;
  67385. protected _buildBlock(state: NodeMaterialBuildState): this;
  67386. }
  67387. }
  67388. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  67389. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67390. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67391. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67392. /**
  67393. * Block used to apply a dot product between 2 vectors
  67394. */
  67395. export class DotBlock extends NodeMaterialBlock {
  67396. /**
  67397. * Creates a new DotBlock
  67398. * @param name defines the block name
  67399. */
  67400. constructor(name: string);
  67401. /**
  67402. * Gets the current class name
  67403. * @returns the class name
  67404. */
  67405. getClassName(): string;
  67406. /**
  67407. * Gets the left operand input component
  67408. */
  67409. get left(): NodeMaterialConnectionPoint;
  67410. /**
  67411. * Gets the right operand input component
  67412. */
  67413. get right(): NodeMaterialConnectionPoint;
  67414. /**
  67415. * Gets the output component
  67416. */
  67417. get output(): NodeMaterialConnectionPoint;
  67418. protected _buildBlock(state: NodeMaterialBuildState): this;
  67419. }
  67420. }
  67421. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67425. /**
  67426. * Block used to normalize a vector
  67427. */
  67428. export class NormalizeBlock extends NodeMaterialBlock {
  67429. /**
  67430. * Creates a new NormalizeBlock
  67431. * @param name defines the block name
  67432. */
  67433. constructor(name: string);
  67434. /**
  67435. * Gets the current class name
  67436. * @returns the class name
  67437. */
  67438. getClassName(): string;
  67439. /**
  67440. * Gets the input component
  67441. */
  67442. get input(): NodeMaterialConnectionPoint;
  67443. /**
  67444. * Gets the output component
  67445. */
  67446. get output(): NodeMaterialConnectionPoint;
  67447. protected _buildBlock(state: NodeMaterialBuildState): this;
  67448. }
  67449. }
  67450. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67454. /**
  67455. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67456. */
  67457. export class ColorMergerBlock extends NodeMaterialBlock {
  67458. /**
  67459. * Create a new ColorMergerBlock
  67460. * @param name defines the block name
  67461. */
  67462. constructor(name: string);
  67463. /**
  67464. * Gets the current class name
  67465. * @returns the class name
  67466. */
  67467. getClassName(): string;
  67468. /**
  67469. * Gets the rgb component (input)
  67470. */
  67471. get rgbIn(): NodeMaterialConnectionPoint;
  67472. /**
  67473. * Gets the r component (input)
  67474. */
  67475. get r(): NodeMaterialConnectionPoint;
  67476. /**
  67477. * Gets the g component (input)
  67478. */
  67479. get g(): NodeMaterialConnectionPoint;
  67480. /**
  67481. * Gets the b component (input)
  67482. */
  67483. get b(): NodeMaterialConnectionPoint;
  67484. /**
  67485. * Gets the a component (input)
  67486. */
  67487. get a(): NodeMaterialConnectionPoint;
  67488. /**
  67489. * Gets the rgba component (output)
  67490. */
  67491. get rgba(): NodeMaterialConnectionPoint;
  67492. /**
  67493. * Gets the rgb component (output)
  67494. */
  67495. get rgbOut(): NodeMaterialConnectionPoint;
  67496. /**
  67497. * Gets the rgb component (output)
  67498. * @deprecated Please use rgbOut instead.
  67499. */
  67500. get rgb(): NodeMaterialConnectionPoint;
  67501. protected _buildBlock(state: NodeMaterialBuildState): this;
  67502. }
  67503. }
  67504. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67508. /**
  67509. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67510. */
  67511. export class VectorSplitterBlock extends NodeMaterialBlock {
  67512. /**
  67513. * Create a new VectorSplitterBlock
  67514. * @param name defines the block name
  67515. */
  67516. constructor(name: string);
  67517. /**
  67518. * Gets the current class name
  67519. * @returns the class name
  67520. */
  67521. getClassName(): string;
  67522. /**
  67523. * Gets the xyzw component (input)
  67524. */
  67525. get xyzw(): NodeMaterialConnectionPoint;
  67526. /**
  67527. * Gets the xyz component (input)
  67528. */
  67529. get xyzIn(): NodeMaterialConnectionPoint;
  67530. /**
  67531. * Gets the xy component (input)
  67532. */
  67533. get xyIn(): NodeMaterialConnectionPoint;
  67534. /**
  67535. * Gets the xyz component (output)
  67536. */
  67537. get xyzOut(): NodeMaterialConnectionPoint;
  67538. /**
  67539. * Gets the xy component (output)
  67540. */
  67541. get xyOut(): NodeMaterialConnectionPoint;
  67542. /**
  67543. * Gets the x component (output)
  67544. */
  67545. get x(): NodeMaterialConnectionPoint;
  67546. /**
  67547. * Gets the y component (output)
  67548. */
  67549. get y(): NodeMaterialConnectionPoint;
  67550. /**
  67551. * Gets the z component (output)
  67552. */
  67553. get z(): NodeMaterialConnectionPoint;
  67554. /**
  67555. * Gets the w component (output)
  67556. */
  67557. get w(): NodeMaterialConnectionPoint;
  67558. protected _inputRename(name: string): string;
  67559. protected _outputRename(name: string): string;
  67560. protected _buildBlock(state: NodeMaterialBuildState): this;
  67561. }
  67562. }
  67563. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67564. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67565. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67566. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67567. /**
  67568. * Block used to lerp between 2 values
  67569. */
  67570. export class LerpBlock extends NodeMaterialBlock {
  67571. /**
  67572. * Creates a new LerpBlock
  67573. * @param name defines the block name
  67574. */
  67575. constructor(name: string);
  67576. /**
  67577. * Gets the current class name
  67578. * @returns the class name
  67579. */
  67580. getClassName(): string;
  67581. /**
  67582. * Gets the left operand input component
  67583. */
  67584. get left(): NodeMaterialConnectionPoint;
  67585. /**
  67586. * Gets the right operand input component
  67587. */
  67588. get right(): NodeMaterialConnectionPoint;
  67589. /**
  67590. * Gets the gradient operand input component
  67591. */
  67592. get gradient(): NodeMaterialConnectionPoint;
  67593. /**
  67594. * Gets the output component
  67595. */
  67596. get output(): NodeMaterialConnectionPoint;
  67597. protected _buildBlock(state: NodeMaterialBuildState): this;
  67598. }
  67599. }
  67600. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67601. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67602. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67603. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67604. /**
  67605. * Block used to divide 2 vectors
  67606. */
  67607. export class DivideBlock extends NodeMaterialBlock {
  67608. /**
  67609. * Creates a new DivideBlock
  67610. * @param name defines the block name
  67611. */
  67612. constructor(name: string);
  67613. /**
  67614. * Gets the current class name
  67615. * @returns the class name
  67616. */
  67617. getClassName(): string;
  67618. /**
  67619. * Gets the left operand input component
  67620. */
  67621. get left(): NodeMaterialConnectionPoint;
  67622. /**
  67623. * Gets the right operand input component
  67624. */
  67625. get right(): NodeMaterialConnectionPoint;
  67626. /**
  67627. * Gets the output component
  67628. */
  67629. get output(): NodeMaterialConnectionPoint;
  67630. protected _buildBlock(state: NodeMaterialBuildState): this;
  67631. }
  67632. }
  67633. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  67634. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67635. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67636. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67637. /**
  67638. * Block used to subtract 2 vectors
  67639. */
  67640. export class SubtractBlock extends NodeMaterialBlock {
  67641. /**
  67642. * Creates a new SubtractBlock
  67643. * @param name defines the block name
  67644. */
  67645. constructor(name: string);
  67646. /**
  67647. * Gets the current class name
  67648. * @returns the class name
  67649. */
  67650. getClassName(): string;
  67651. /**
  67652. * Gets the left operand input component
  67653. */
  67654. get left(): NodeMaterialConnectionPoint;
  67655. /**
  67656. * Gets the right operand input component
  67657. */
  67658. get right(): NodeMaterialConnectionPoint;
  67659. /**
  67660. * Gets the output component
  67661. */
  67662. get output(): NodeMaterialConnectionPoint;
  67663. protected _buildBlock(state: NodeMaterialBuildState): this;
  67664. }
  67665. }
  67666. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  67667. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67668. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67669. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67670. /**
  67671. * Block used to step a value
  67672. */
  67673. export class StepBlock extends NodeMaterialBlock {
  67674. /**
  67675. * Creates a new StepBlock
  67676. * @param name defines the block name
  67677. */
  67678. constructor(name: string);
  67679. /**
  67680. * Gets the current class name
  67681. * @returns the class name
  67682. */
  67683. getClassName(): string;
  67684. /**
  67685. * Gets the value operand input component
  67686. */
  67687. get value(): NodeMaterialConnectionPoint;
  67688. /**
  67689. * Gets the edge operand input component
  67690. */
  67691. get edge(): NodeMaterialConnectionPoint;
  67692. /**
  67693. * Gets the output component
  67694. */
  67695. get output(): NodeMaterialConnectionPoint;
  67696. protected _buildBlock(state: NodeMaterialBuildState): this;
  67697. }
  67698. }
  67699. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  67700. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67701. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67702. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67703. /**
  67704. * Block used to get the opposite (1 - x) of a value
  67705. */
  67706. export class OneMinusBlock extends NodeMaterialBlock {
  67707. /**
  67708. * Creates a new OneMinusBlock
  67709. * @param name defines the block name
  67710. */
  67711. constructor(name: string);
  67712. /**
  67713. * Gets the current class name
  67714. * @returns the class name
  67715. */
  67716. getClassName(): string;
  67717. /**
  67718. * Gets the input component
  67719. */
  67720. get input(): NodeMaterialConnectionPoint;
  67721. /**
  67722. * Gets the output component
  67723. */
  67724. get output(): NodeMaterialConnectionPoint;
  67725. protected _buildBlock(state: NodeMaterialBuildState): this;
  67726. }
  67727. }
  67728. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  67729. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67730. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67731. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67732. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67733. /**
  67734. * Block used to get the view direction
  67735. */
  67736. export class ViewDirectionBlock extends NodeMaterialBlock {
  67737. /**
  67738. * Creates a new ViewDirectionBlock
  67739. * @param name defines the block name
  67740. */
  67741. constructor(name: string);
  67742. /**
  67743. * Gets the current class name
  67744. * @returns the class name
  67745. */
  67746. getClassName(): string;
  67747. /**
  67748. * Gets the world position component
  67749. */
  67750. get worldPosition(): NodeMaterialConnectionPoint;
  67751. /**
  67752. * Gets the camera position component
  67753. */
  67754. get cameraPosition(): NodeMaterialConnectionPoint;
  67755. /**
  67756. * Gets the output component
  67757. */
  67758. get output(): NodeMaterialConnectionPoint;
  67759. autoConfigure(material: NodeMaterial): void;
  67760. protected _buildBlock(state: NodeMaterialBuildState): this;
  67761. }
  67762. }
  67763. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  67764. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67765. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67766. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67767. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67768. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  67769. /**
  67770. * Block used to compute fresnel value
  67771. */
  67772. export class FresnelBlock extends NodeMaterialBlock {
  67773. /**
  67774. * Create a new FresnelBlock
  67775. * @param name defines the block name
  67776. */
  67777. constructor(name: string);
  67778. /**
  67779. * Gets the current class name
  67780. * @returns the class name
  67781. */
  67782. getClassName(): string;
  67783. /**
  67784. * Gets the world normal input component
  67785. */
  67786. get worldNormal(): NodeMaterialConnectionPoint;
  67787. /**
  67788. * Gets the view direction input component
  67789. */
  67790. get viewDirection(): NodeMaterialConnectionPoint;
  67791. /**
  67792. * Gets the bias input component
  67793. */
  67794. get bias(): NodeMaterialConnectionPoint;
  67795. /**
  67796. * Gets the camera (or eye) position component
  67797. */
  67798. get power(): NodeMaterialConnectionPoint;
  67799. /**
  67800. * Gets the fresnel output component
  67801. */
  67802. get fresnel(): NodeMaterialConnectionPoint;
  67803. autoConfigure(material: NodeMaterial): void;
  67804. protected _buildBlock(state: NodeMaterialBuildState): this;
  67805. }
  67806. }
  67807. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  67808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67811. /**
  67812. * Block used to get the max of 2 values
  67813. */
  67814. export class MaxBlock extends NodeMaterialBlock {
  67815. /**
  67816. * Creates a new MaxBlock
  67817. * @param name defines the block name
  67818. */
  67819. constructor(name: string);
  67820. /**
  67821. * Gets the current class name
  67822. * @returns the class name
  67823. */
  67824. getClassName(): string;
  67825. /**
  67826. * Gets the left operand input component
  67827. */
  67828. get left(): NodeMaterialConnectionPoint;
  67829. /**
  67830. * Gets the right operand input component
  67831. */
  67832. get right(): NodeMaterialConnectionPoint;
  67833. /**
  67834. * Gets the output component
  67835. */
  67836. get output(): NodeMaterialConnectionPoint;
  67837. protected _buildBlock(state: NodeMaterialBuildState): this;
  67838. }
  67839. }
  67840. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67844. /**
  67845. * Block used to get the min of 2 values
  67846. */
  67847. export class MinBlock extends NodeMaterialBlock {
  67848. /**
  67849. * Creates a new MinBlock
  67850. * @param name defines the block name
  67851. */
  67852. constructor(name: string);
  67853. /**
  67854. * Gets the current class name
  67855. * @returns the class name
  67856. */
  67857. getClassName(): string;
  67858. /**
  67859. * Gets the left operand input component
  67860. */
  67861. get left(): NodeMaterialConnectionPoint;
  67862. /**
  67863. * Gets the right operand input component
  67864. */
  67865. get right(): NodeMaterialConnectionPoint;
  67866. /**
  67867. * Gets the output component
  67868. */
  67869. get output(): NodeMaterialConnectionPoint;
  67870. protected _buildBlock(state: NodeMaterialBuildState): this;
  67871. }
  67872. }
  67873. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67874. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67875. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67877. /**
  67878. * Block used to get the distance between 2 values
  67879. */
  67880. export class DistanceBlock extends NodeMaterialBlock {
  67881. /**
  67882. * Creates a new DistanceBlock
  67883. * @param name defines the block name
  67884. */
  67885. constructor(name: string);
  67886. /**
  67887. * Gets the current class name
  67888. * @returns the class name
  67889. */
  67890. getClassName(): string;
  67891. /**
  67892. * Gets the left operand input component
  67893. */
  67894. get left(): NodeMaterialConnectionPoint;
  67895. /**
  67896. * Gets the right operand input component
  67897. */
  67898. get right(): NodeMaterialConnectionPoint;
  67899. /**
  67900. * Gets the output component
  67901. */
  67902. get output(): NodeMaterialConnectionPoint;
  67903. protected _buildBlock(state: NodeMaterialBuildState): this;
  67904. }
  67905. }
  67906. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67908. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67909. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67910. /**
  67911. * Block used to get the length of a vector
  67912. */
  67913. export class LengthBlock extends NodeMaterialBlock {
  67914. /**
  67915. * Creates a new LengthBlock
  67916. * @param name defines the block name
  67917. */
  67918. constructor(name: string);
  67919. /**
  67920. * Gets the current class name
  67921. * @returns the class name
  67922. */
  67923. getClassName(): string;
  67924. /**
  67925. * Gets the value input component
  67926. */
  67927. get value(): NodeMaterialConnectionPoint;
  67928. /**
  67929. * Gets the output component
  67930. */
  67931. get output(): NodeMaterialConnectionPoint;
  67932. protected _buildBlock(state: NodeMaterialBuildState): this;
  67933. }
  67934. }
  67935. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67936. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67937. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67938. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67939. /**
  67940. * Block used to get negative version of a value (i.e. x * -1)
  67941. */
  67942. export class NegateBlock extends NodeMaterialBlock {
  67943. /**
  67944. * Creates a new NegateBlock
  67945. * @param name defines the block name
  67946. */
  67947. constructor(name: string);
  67948. /**
  67949. * Gets the current class name
  67950. * @returns the class name
  67951. */
  67952. getClassName(): string;
  67953. /**
  67954. * Gets the value input component
  67955. */
  67956. get value(): NodeMaterialConnectionPoint;
  67957. /**
  67958. * Gets the output component
  67959. */
  67960. get output(): NodeMaterialConnectionPoint;
  67961. protected _buildBlock(state: NodeMaterialBuildState): this;
  67962. }
  67963. }
  67964. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67968. /**
  67969. * Block used to get the value of the first parameter raised to the power of the second
  67970. */
  67971. export class PowBlock extends NodeMaterialBlock {
  67972. /**
  67973. * Creates a new PowBlock
  67974. * @param name defines the block name
  67975. */
  67976. constructor(name: string);
  67977. /**
  67978. * Gets the current class name
  67979. * @returns the class name
  67980. */
  67981. getClassName(): string;
  67982. /**
  67983. * Gets the value operand input component
  67984. */
  67985. get value(): NodeMaterialConnectionPoint;
  67986. /**
  67987. * Gets the power operand input component
  67988. */
  67989. get power(): NodeMaterialConnectionPoint;
  67990. /**
  67991. * Gets the output component
  67992. */
  67993. get output(): NodeMaterialConnectionPoint;
  67994. protected _buildBlock(state: NodeMaterialBuildState): this;
  67995. }
  67996. }
  67997. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68001. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68002. /**
  68003. * Block used to get a random number
  68004. */
  68005. export class RandomNumberBlock extends NodeMaterialBlock {
  68006. /**
  68007. * Creates a new RandomNumberBlock
  68008. * @param name defines the block name
  68009. */
  68010. constructor(name: string);
  68011. /**
  68012. * Gets the current class name
  68013. * @returns the class name
  68014. */
  68015. getClassName(): string;
  68016. /**
  68017. * Gets the seed input component
  68018. */
  68019. get seed(): NodeMaterialConnectionPoint;
  68020. /**
  68021. * Gets the output component
  68022. */
  68023. get output(): NodeMaterialConnectionPoint;
  68024. protected _buildBlock(state: NodeMaterialBuildState): this;
  68025. }
  68026. }
  68027. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  68028. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68029. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68030. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68031. /**
  68032. * Block used to compute arc tangent of 2 values
  68033. */
  68034. export class ArcTan2Block extends NodeMaterialBlock {
  68035. /**
  68036. * Creates a new ArcTan2Block
  68037. * @param name defines the block name
  68038. */
  68039. constructor(name: string);
  68040. /**
  68041. * Gets the current class name
  68042. * @returns the class name
  68043. */
  68044. getClassName(): string;
  68045. /**
  68046. * Gets the x operand input component
  68047. */
  68048. get x(): NodeMaterialConnectionPoint;
  68049. /**
  68050. * Gets the y operand input component
  68051. */
  68052. get y(): NodeMaterialConnectionPoint;
  68053. /**
  68054. * Gets the output component
  68055. */
  68056. get output(): NodeMaterialConnectionPoint;
  68057. protected _buildBlock(state: NodeMaterialBuildState): this;
  68058. }
  68059. }
  68060. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  68061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68064. /**
  68065. * Block used to smooth step a value
  68066. */
  68067. export class SmoothStepBlock extends NodeMaterialBlock {
  68068. /**
  68069. * Creates a new SmoothStepBlock
  68070. * @param name defines the block name
  68071. */
  68072. constructor(name: string);
  68073. /**
  68074. * Gets the current class name
  68075. * @returns the class name
  68076. */
  68077. getClassName(): string;
  68078. /**
  68079. * Gets the value operand input component
  68080. */
  68081. get value(): NodeMaterialConnectionPoint;
  68082. /**
  68083. * Gets the first edge operand input component
  68084. */
  68085. get edge0(): NodeMaterialConnectionPoint;
  68086. /**
  68087. * Gets the second edge operand input component
  68088. */
  68089. get edge1(): NodeMaterialConnectionPoint;
  68090. /**
  68091. * Gets the output component
  68092. */
  68093. get output(): NodeMaterialConnectionPoint;
  68094. protected _buildBlock(state: NodeMaterialBuildState): this;
  68095. }
  68096. }
  68097. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  68098. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68099. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68100. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68101. /**
  68102. * Block used to get the reciprocal (1 / x) of a value
  68103. */
  68104. export class ReciprocalBlock extends NodeMaterialBlock {
  68105. /**
  68106. * Creates a new ReciprocalBlock
  68107. * @param name defines the block name
  68108. */
  68109. constructor(name: string);
  68110. /**
  68111. * Gets the current class name
  68112. * @returns the class name
  68113. */
  68114. getClassName(): string;
  68115. /**
  68116. * Gets the input component
  68117. */
  68118. get input(): NodeMaterialConnectionPoint;
  68119. /**
  68120. * Gets the output component
  68121. */
  68122. get output(): NodeMaterialConnectionPoint;
  68123. protected _buildBlock(state: NodeMaterialBuildState): this;
  68124. }
  68125. }
  68126. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  68127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68130. /**
  68131. * Block used to replace a color by another one
  68132. */
  68133. export class ReplaceColorBlock extends NodeMaterialBlock {
  68134. /**
  68135. * Creates a new ReplaceColorBlock
  68136. * @param name defines the block name
  68137. */
  68138. constructor(name: string);
  68139. /**
  68140. * Gets the current class name
  68141. * @returns the class name
  68142. */
  68143. getClassName(): string;
  68144. /**
  68145. * Gets the value input component
  68146. */
  68147. get value(): NodeMaterialConnectionPoint;
  68148. /**
  68149. * Gets the reference input component
  68150. */
  68151. get reference(): NodeMaterialConnectionPoint;
  68152. /**
  68153. * Gets the distance input component
  68154. */
  68155. get distance(): NodeMaterialConnectionPoint;
  68156. /**
  68157. * Gets the replacement input component
  68158. */
  68159. get replacement(): NodeMaterialConnectionPoint;
  68160. /**
  68161. * Gets the output component
  68162. */
  68163. get output(): NodeMaterialConnectionPoint;
  68164. protected _buildBlock(state: NodeMaterialBuildState): this;
  68165. }
  68166. }
  68167. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  68168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68171. /**
  68172. * Block used to posterize a value
  68173. * @see https://en.wikipedia.org/wiki/Posterization
  68174. */
  68175. export class PosterizeBlock extends NodeMaterialBlock {
  68176. /**
  68177. * Creates a new PosterizeBlock
  68178. * @param name defines the block name
  68179. */
  68180. constructor(name: string);
  68181. /**
  68182. * Gets the current class name
  68183. * @returns the class name
  68184. */
  68185. getClassName(): string;
  68186. /**
  68187. * Gets the value input component
  68188. */
  68189. get value(): NodeMaterialConnectionPoint;
  68190. /**
  68191. * Gets the steps input component
  68192. */
  68193. get steps(): NodeMaterialConnectionPoint;
  68194. /**
  68195. * Gets the output component
  68196. */
  68197. get output(): NodeMaterialConnectionPoint;
  68198. protected _buildBlock(state: NodeMaterialBuildState): this;
  68199. }
  68200. }
  68201. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  68202. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68203. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68204. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68205. import { Scene } from "babylonjs/scene";
  68206. /**
  68207. * Operations supported by the Wave block
  68208. */
  68209. export enum WaveBlockKind {
  68210. /** SawTooth */
  68211. SawTooth = 0,
  68212. /** Square */
  68213. Square = 1,
  68214. /** Triangle */
  68215. Triangle = 2
  68216. }
  68217. /**
  68218. * Block used to apply wave operation to floats
  68219. */
  68220. export class WaveBlock extends NodeMaterialBlock {
  68221. /**
  68222. * Gets or sets the kibnd of wave to be applied by the block
  68223. */
  68224. kind: WaveBlockKind;
  68225. /**
  68226. * Creates a new WaveBlock
  68227. * @param name defines the block name
  68228. */
  68229. constructor(name: string);
  68230. /**
  68231. * Gets the current class name
  68232. * @returns the class name
  68233. */
  68234. getClassName(): string;
  68235. /**
  68236. * Gets the input component
  68237. */
  68238. get input(): NodeMaterialConnectionPoint;
  68239. /**
  68240. * Gets the output component
  68241. */
  68242. get output(): NodeMaterialConnectionPoint;
  68243. protected _buildBlock(state: NodeMaterialBuildState): this;
  68244. serialize(): any;
  68245. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68246. }
  68247. }
  68248. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  68249. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68250. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68251. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68252. import { Color3 } from "babylonjs/Maths/math.color";
  68253. import { Scene } from "babylonjs/scene";
  68254. import { Observable } from "babylonjs/Misc/observable";
  68255. /**
  68256. * Class used to store a color step for the GradientBlock
  68257. */
  68258. export class GradientBlockColorStep {
  68259. private _step;
  68260. /**
  68261. * Gets value indicating which step this color is associated with (between 0 and 1)
  68262. */
  68263. get step(): number;
  68264. /**
  68265. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68266. */
  68267. set step(val: number);
  68268. private _color;
  68269. /**
  68270. * Gets the color associated with this step
  68271. */
  68272. get color(): Color3;
  68273. /**
  68274. * Sets the color associated with this step
  68275. */
  68276. set color(val: Color3);
  68277. /**
  68278. * Creates a new GradientBlockColorStep
  68279. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68280. * @param color defines the color associated with this step
  68281. */
  68282. constructor(step: number, color: Color3);
  68283. }
  68284. /**
  68285. * Block used to return a color from a gradient based on an input value between 0 and 1
  68286. */
  68287. export class GradientBlock extends NodeMaterialBlock {
  68288. /**
  68289. * Gets or sets the list of color steps
  68290. */
  68291. colorSteps: GradientBlockColorStep[];
  68292. /** Gets an observable raised when the value is changed */
  68293. onValueChangedObservable: Observable<GradientBlock>;
  68294. /** calls observable when the value is changed*/
  68295. colorStepsUpdated(): void;
  68296. /**
  68297. * Creates a new GradientBlock
  68298. * @param name defines the block name
  68299. */
  68300. constructor(name: string);
  68301. /**
  68302. * Gets the current class name
  68303. * @returns the class name
  68304. */
  68305. getClassName(): string;
  68306. /**
  68307. * Gets the gradient input component
  68308. */
  68309. get gradient(): NodeMaterialConnectionPoint;
  68310. /**
  68311. * Gets the output component
  68312. */
  68313. get output(): NodeMaterialConnectionPoint;
  68314. private _writeColorConstant;
  68315. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68316. serialize(): any;
  68317. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68318. protected _dumpPropertiesCode(): string;
  68319. }
  68320. }
  68321. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  68322. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68323. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68324. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68325. /**
  68326. * Block used to normalize lerp between 2 values
  68327. */
  68328. export class NLerpBlock extends NodeMaterialBlock {
  68329. /**
  68330. * Creates a new NLerpBlock
  68331. * @param name defines the block name
  68332. */
  68333. constructor(name: string);
  68334. /**
  68335. * Gets the current class name
  68336. * @returns the class name
  68337. */
  68338. getClassName(): string;
  68339. /**
  68340. * Gets the left operand input component
  68341. */
  68342. get left(): NodeMaterialConnectionPoint;
  68343. /**
  68344. * Gets the right operand input component
  68345. */
  68346. get right(): NodeMaterialConnectionPoint;
  68347. /**
  68348. * Gets the gradient operand input component
  68349. */
  68350. get gradient(): NodeMaterialConnectionPoint;
  68351. /**
  68352. * Gets the output component
  68353. */
  68354. get output(): NodeMaterialConnectionPoint;
  68355. protected _buildBlock(state: NodeMaterialBuildState): this;
  68356. }
  68357. }
  68358. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  68359. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68360. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68361. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68362. import { Scene } from "babylonjs/scene";
  68363. /**
  68364. * block used to Generate a Worley Noise 3D Noise Pattern
  68365. */
  68366. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68367. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68368. manhattanDistance: boolean;
  68369. /**
  68370. * Creates a new WorleyNoise3DBlock
  68371. * @param name defines the block name
  68372. */
  68373. constructor(name: string);
  68374. /**
  68375. * Gets the current class name
  68376. * @returns the class name
  68377. */
  68378. getClassName(): string;
  68379. /**
  68380. * Gets the seed input component
  68381. */
  68382. get seed(): NodeMaterialConnectionPoint;
  68383. /**
  68384. * Gets the jitter input component
  68385. */
  68386. get jitter(): NodeMaterialConnectionPoint;
  68387. /**
  68388. * Gets the output component
  68389. */
  68390. get output(): NodeMaterialConnectionPoint;
  68391. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68392. /**
  68393. * Exposes the properties to the UI?
  68394. */
  68395. protected _dumpPropertiesCode(): string;
  68396. /**
  68397. * Exposes the properties to the Seralize?
  68398. */
  68399. serialize(): any;
  68400. /**
  68401. * Exposes the properties to the deseralize?
  68402. */
  68403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68404. }
  68405. }
  68406. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  68407. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68408. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68409. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68410. /**
  68411. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68412. */
  68413. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68414. /**
  68415. * Creates a new SimplexPerlin3DBlock
  68416. * @param name defines the block name
  68417. */
  68418. constructor(name: string);
  68419. /**
  68420. * Gets the current class name
  68421. * @returns the class name
  68422. */
  68423. getClassName(): string;
  68424. /**
  68425. * Gets the seed operand input component
  68426. */
  68427. get seed(): NodeMaterialConnectionPoint;
  68428. /**
  68429. * Gets the output component
  68430. */
  68431. get output(): NodeMaterialConnectionPoint;
  68432. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68433. }
  68434. }
  68435. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68439. /**
  68440. * Block used to blend normals
  68441. */
  68442. export class NormalBlendBlock extends NodeMaterialBlock {
  68443. /**
  68444. * Creates a new NormalBlendBlock
  68445. * @param name defines the block name
  68446. */
  68447. constructor(name: string);
  68448. /**
  68449. * Gets the current class name
  68450. * @returns the class name
  68451. */
  68452. getClassName(): string;
  68453. /**
  68454. * Gets the first input component
  68455. */
  68456. get normalMap0(): NodeMaterialConnectionPoint;
  68457. /**
  68458. * Gets the second input component
  68459. */
  68460. get normalMap1(): NodeMaterialConnectionPoint;
  68461. /**
  68462. * Gets the output component
  68463. */
  68464. get output(): NodeMaterialConnectionPoint;
  68465. protected _buildBlock(state: NodeMaterialBuildState): this;
  68466. }
  68467. }
  68468. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68472. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68473. /**
  68474. * Block used to rotate a 2d vector by a given angle
  68475. */
  68476. export class Rotate2dBlock extends NodeMaterialBlock {
  68477. /**
  68478. * Creates a new Rotate2dBlock
  68479. * @param name defines the block name
  68480. */
  68481. constructor(name: string);
  68482. /**
  68483. * Gets the current class name
  68484. * @returns the class name
  68485. */
  68486. getClassName(): string;
  68487. /**
  68488. * Gets the input vector
  68489. */
  68490. get input(): NodeMaterialConnectionPoint;
  68491. /**
  68492. * Gets the input angle
  68493. */
  68494. get angle(): NodeMaterialConnectionPoint;
  68495. /**
  68496. * Gets the output component
  68497. */
  68498. get output(): NodeMaterialConnectionPoint;
  68499. autoConfigure(material: NodeMaterial): void;
  68500. protected _buildBlock(state: NodeMaterialBuildState): this;
  68501. }
  68502. }
  68503. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68507. /**
  68508. * Block used to get the reflected vector from a direction and a normal
  68509. */
  68510. export class ReflectBlock extends NodeMaterialBlock {
  68511. /**
  68512. * Creates a new ReflectBlock
  68513. * @param name defines the block name
  68514. */
  68515. constructor(name: string);
  68516. /**
  68517. * Gets the current class name
  68518. * @returns the class name
  68519. */
  68520. getClassName(): string;
  68521. /**
  68522. * Gets the incident component
  68523. */
  68524. get incident(): NodeMaterialConnectionPoint;
  68525. /**
  68526. * Gets the normal component
  68527. */
  68528. get normal(): NodeMaterialConnectionPoint;
  68529. /**
  68530. * Gets the output component
  68531. */
  68532. get output(): NodeMaterialConnectionPoint;
  68533. protected _buildBlock(state: NodeMaterialBuildState): this;
  68534. }
  68535. }
  68536. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68539. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68540. /**
  68541. * Block used to get the refracted vector from a direction and a normal
  68542. */
  68543. export class RefractBlock extends NodeMaterialBlock {
  68544. /**
  68545. * Creates a new RefractBlock
  68546. * @param name defines the block name
  68547. */
  68548. constructor(name: string);
  68549. /**
  68550. * Gets the current class name
  68551. * @returns the class name
  68552. */
  68553. getClassName(): string;
  68554. /**
  68555. * Gets the incident component
  68556. */
  68557. get incident(): NodeMaterialConnectionPoint;
  68558. /**
  68559. * Gets the normal component
  68560. */
  68561. get normal(): NodeMaterialConnectionPoint;
  68562. /**
  68563. * Gets the index of refraction component
  68564. */
  68565. get ior(): NodeMaterialConnectionPoint;
  68566. /**
  68567. * Gets the output component
  68568. */
  68569. get output(): NodeMaterialConnectionPoint;
  68570. protected _buildBlock(state: NodeMaterialBuildState): this;
  68571. }
  68572. }
  68573. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68574. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68575. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68576. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68577. /**
  68578. * Block used to desaturate a color
  68579. */
  68580. export class DesaturateBlock extends NodeMaterialBlock {
  68581. /**
  68582. * Creates a new DesaturateBlock
  68583. * @param name defines the block name
  68584. */
  68585. constructor(name: string);
  68586. /**
  68587. * Gets the current class name
  68588. * @returns the class name
  68589. */
  68590. getClassName(): string;
  68591. /**
  68592. * Gets the color operand input component
  68593. */
  68594. get color(): NodeMaterialConnectionPoint;
  68595. /**
  68596. * Gets the level operand input component
  68597. */
  68598. get level(): NodeMaterialConnectionPoint;
  68599. /**
  68600. * Gets the output component
  68601. */
  68602. get output(): NodeMaterialConnectionPoint;
  68603. protected _buildBlock(state: NodeMaterialBuildState): this;
  68604. }
  68605. }
  68606. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  68607. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68608. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68609. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68610. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68611. import { Nullable } from "babylonjs/types";
  68612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68613. import { Scene } from "babylonjs/scene";
  68614. /**
  68615. * Block used to implement the ambient occlusion module of the PBR material
  68616. */
  68617. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  68618. /**
  68619. * Create a new AmbientOcclusionBlock
  68620. * @param name defines the block name
  68621. */
  68622. constructor(name: string);
  68623. /**
  68624. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  68625. */
  68626. useAmbientInGrayScale: boolean;
  68627. /**
  68628. * Initialize the block and prepare the context for build
  68629. * @param state defines the state that will be used for the build
  68630. */
  68631. initialize(state: NodeMaterialBuildState): void;
  68632. /**
  68633. * Gets the current class name
  68634. * @returns the class name
  68635. */
  68636. getClassName(): string;
  68637. /**
  68638. * Gets the texture input component
  68639. */
  68640. get texture(): NodeMaterialConnectionPoint;
  68641. /**
  68642. * Gets the texture intensity component
  68643. */
  68644. get intensity(): NodeMaterialConnectionPoint;
  68645. /**
  68646. * Gets the direct light intensity input component
  68647. */
  68648. get directLightIntensity(): NodeMaterialConnectionPoint;
  68649. /**
  68650. * Gets the ambient occlusion object output component
  68651. */
  68652. get ambientOcc(): NodeMaterialConnectionPoint;
  68653. /**
  68654. * Gets the main code of the block (fragment side)
  68655. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  68656. * @returns the shader code
  68657. */
  68658. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  68659. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68660. protected _buildBlock(state: NodeMaterialBuildState): this;
  68661. protected _dumpPropertiesCode(): string;
  68662. serialize(): any;
  68663. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68664. }
  68665. }
  68666. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68667. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68668. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68669. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68670. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68672. import { Nullable } from "babylonjs/types";
  68673. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68674. import { Mesh } from "babylonjs/Meshes/mesh";
  68675. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68676. import { Effect } from "babylonjs/Materials/effect";
  68677. import { Scene } from "babylonjs/scene";
  68678. /**
  68679. * Block used to implement the reflection module of the PBR material
  68680. */
  68681. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68682. /** @hidden */
  68683. _defineLODReflectionAlpha: string;
  68684. /** @hidden */
  68685. _defineLinearSpecularReflection: string;
  68686. private _vEnvironmentIrradianceName;
  68687. /** @hidden */
  68688. _vReflectionMicrosurfaceInfosName: string;
  68689. /** @hidden */
  68690. _vReflectionInfosName: string;
  68691. /** @hidden */
  68692. _vReflectionFilteringInfoName: string;
  68693. private _scene;
  68694. /**
  68695. * The three properties below are set by the main PBR block prior to calling methods of this class.
  68696. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68697. * It's less burden on the user side in the editor part.
  68698. */
  68699. /** @hidden */
  68700. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68701. /** @hidden */
  68702. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68703. /** @hidden */
  68704. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68705. /**
  68706. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68707. * diffuse part of the IBL.
  68708. */
  68709. useSphericalHarmonics: boolean;
  68710. /**
  68711. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68712. */
  68713. forceIrradianceInFragment: boolean;
  68714. /**
  68715. * Create a new ReflectionBlock
  68716. * @param name defines the block name
  68717. */
  68718. constructor(name: string);
  68719. /**
  68720. * Gets the current class name
  68721. * @returns the class name
  68722. */
  68723. getClassName(): string;
  68724. /**
  68725. * Gets the position input component
  68726. */
  68727. get position(): NodeMaterialConnectionPoint;
  68728. /**
  68729. * Gets the world position input component
  68730. */
  68731. get worldPosition(): NodeMaterialConnectionPoint;
  68732. /**
  68733. * Gets the world normal input component
  68734. */
  68735. get worldNormal(): NodeMaterialConnectionPoint;
  68736. /**
  68737. * Gets the world input component
  68738. */
  68739. get world(): NodeMaterialConnectionPoint;
  68740. /**
  68741. * Gets the camera (or eye) position component
  68742. */
  68743. get cameraPosition(): NodeMaterialConnectionPoint;
  68744. /**
  68745. * Gets the view input component
  68746. */
  68747. get view(): NodeMaterialConnectionPoint;
  68748. /**
  68749. * Gets the color input component
  68750. */
  68751. get color(): NodeMaterialConnectionPoint;
  68752. /**
  68753. * Gets the reflection object output component
  68754. */
  68755. get reflection(): NodeMaterialConnectionPoint;
  68756. /**
  68757. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68758. */
  68759. get hasTexture(): boolean;
  68760. /**
  68761. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68762. */
  68763. get reflectionColor(): string;
  68764. protected _getTexture(): Nullable<BaseTexture>;
  68765. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68766. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68767. /**
  68768. * Gets the code to inject in the vertex shader
  68769. * @param state current state of the node material building
  68770. * @returns the shader code
  68771. */
  68772. handleVertexSide(state: NodeMaterialBuildState): string;
  68773. /**
  68774. * Gets the main code of the block (fragment side)
  68775. * @param state current state of the node material building
  68776. * @param normalVarName name of the existing variable corresponding to the normal
  68777. * @returns the shader code
  68778. */
  68779. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68780. protected _buildBlock(state: NodeMaterialBuildState): this;
  68781. protected _dumpPropertiesCode(): string;
  68782. serialize(): any;
  68783. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68784. }
  68785. }
  68786. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  68787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68789. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68790. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68792. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68793. import { Scene } from "babylonjs/scene";
  68794. import { Nullable } from "babylonjs/types";
  68795. /**
  68796. * Block used to implement the sheen module of the PBR material
  68797. */
  68798. export class SheenBlock extends NodeMaterialBlock {
  68799. /**
  68800. * Create a new SheenBlock
  68801. * @param name defines the block name
  68802. */
  68803. constructor(name: string);
  68804. /**
  68805. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68806. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68807. * making it easier to setup and tweak the effect
  68808. */
  68809. albedoScaling: boolean;
  68810. /**
  68811. * Defines if the sheen is linked to the sheen color.
  68812. */
  68813. linkSheenWithAlbedo: boolean;
  68814. /**
  68815. * Initialize the block and prepare the context for build
  68816. * @param state defines the state that will be used for the build
  68817. */
  68818. initialize(state: NodeMaterialBuildState): void;
  68819. /**
  68820. * Gets the current class name
  68821. * @returns the class name
  68822. */
  68823. getClassName(): string;
  68824. /**
  68825. * Gets the intensity input component
  68826. */
  68827. get intensity(): NodeMaterialConnectionPoint;
  68828. /**
  68829. * Gets the color input component
  68830. */
  68831. get color(): NodeMaterialConnectionPoint;
  68832. /**
  68833. * Gets the roughness input component
  68834. */
  68835. get roughness(): NodeMaterialConnectionPoint;
  68836. /**
  68837. * Gets the sheen object output component
  68838. */
  68839. get sheen(): NodeMaterialConnectionPoint;
  68840. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68841. /**
  68842. * Gets the main code of the block (fragment side)
  68843. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68844. * @returns the shader code
  68845. */
  68846. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68847. protected _buildBlock(state: NodeMaterialBuildState): this;
  68848. protected _dumpPropertiesCode(): string;
  68849. serialize(): any;
  68850. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68851. }
  68852. }
  68853. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68854. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68855. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68856. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68858. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68859. import { Scene } from "babylonjs/scene";
  68860. import { Nullable } from "babylonjs/types";
  68861. import { Mesh } from "babylonjs/Meshes/mesh";
  68862. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68863. import { Effect } from "babylonjs/Materials/effect";
  68864. /**
  68865. * Block used to implement the reflectivity module of the PBR material
  68866. */
  68867. export class ReflectivityBlock extends NodeMaterialBlock {
  68868. private _metallicReflectanceColor;
  68869. private _metallicF0Factor;
  68870. /** @hidden */
  68871. _vMetallicReflectanceFactorsName: string;
  68872. /**
  68873. * The property below is set by the main PBR block prior to calling methods of this class.
  68874. */
  68875. /** @hidden */
  68876. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68877. /**
  68878. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68879. */
  68880. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68881. /**
  68882. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68883. */
  68884. useMetallnessFromMetallicTextureBlue: boolean;
  68885. /**
  68886. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68887. */
  68888. useRoughnessFromMetallicTextureAlpha: boolean;
  68889. /**
  68890. * Specifies if the metallic texture contains the roughness information in its green channel.
  68891. */
  68892. useRoughnessFromMetallicTextureGreen: boolean;
  68893. /**
  68894. * Create a new ReflectivityBlock
  68895. * @param name defines the block name
  68896. */
  68897. constructor(name: string);
  68898. /**
  68899. * Initialize the block and prepare the context for build
  68900. * @param state defines the state that will be used for the build
  68901. */
  68902. initialize(state: NodeMaterialBuildState): void;
  68903. /**
  68904. * Gets the current class name
  68905. * @returns the class name
  68906. */
  68907. getClassName(): string;
  68908. /**
  68909. * Gets the metallic input component
  68910. */
  68911. get metallic(): NodeMaterialConnectionPoint;
  68912. /**
  68913. * Gets the roughness input component
  68914. */
  68915. get roughness(): NodeMaterialConnectionPoint;
  68916. /**
  68917. * Gets the texture input component
  68918. */
  68919. get texture(): NodeMaterialConnectionPoint;
  68920. /**
  68921. * Gets the reflectivity object output component
  68922. */
  68923. get reflectivity(): NodeMaterialConnectionPoint;
  68924. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68925. /**
  68926. * Gets the main code of the block (fragment side)
  68927. * @param state current state of the node material building
  68928. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68929. * @returns the shader code
  68930. */
  68931. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68932. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68933. protected _buildBlock(state: NodeMaterialBuildState): this;
  68934. protected _dumpPropertiesCode(): string;
  68935. serialize(): any;
  68936. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68937. }
  68938. }
  68939. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68940. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68941. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68942. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68945. /**
  68946. * Block used to implement the anisotropy module of the PBR material
  68947. */
  68948. export class AnisotropyBlock extends NodeMaterialBlock {
  68949. /**
  68950. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68951. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68952. * It's less burden on the user side in the editor part.
  68953. */
  68954. /** @hidden */
  68955. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68956. /** @hidden */
  68957. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68958. /**
  68959. * Create a new AnisotropyBlock
  68960. * @param name defines the block name
  68961. */
  68962. constructor(name: string);
  68963. /**
  68964. * Initialize the block and prepare the context for build
  68965. * @param state defines the state that will be used for the build
  68966. */
  68967. initialize(state: NodeMaterialBuildState): void;
  68968. /**
  68969. * Gets the current class name
  68970. * @returns the class name
  68971. */
  68972. getClassName(): string;
  68973. /**
  68974. * Gets the intensity input component
  68975. */
  68976. get intensity(): NodeMaterialConnectionPoint;
  68977. /**
  68978. * Gets the direction input component
  68979. */
  68980. get direction(): NodeMaterialConnectionPoint;
  68981. /**
  68982. * Gets the texture input component
  68983. */
  68984. get texture(): NodeMaterialConnectionPoint;
  68985. /**
  68986. * Gets the uv input component
  68987. */
  68988. get uv(): NodeMaterialConnectionPoint;
  68989. /**
  68990. * Gets the worldTangent input component
  68991. */
  68992. get worldTangent(): NodeMaterialConnectionPoint;
  68993. /**
  68994. * Gets the anisotropy object output component
  68995. */
  68996. get anisotropy(): NodeMaterialConnectionPoint;
  68997. private _generateTBNSpace;
  68998. /**
  68999. * Gets the main code of the block (fragment side)
  69000. * @param state current state of the node material building
  69001. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69002. * @returns the shader code
  69003. */
  69004. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69005. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69006. protected _buildBlock(state: NodeMaterialBuildState): this;
  69007. }
  69008. }
  69009. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  69010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69011. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69012. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69013. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69015. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69016. import { Nullable } from "babylonjs/types";
  69017. import { Mesh } from "babylonjs/Meshes/mesh";
  69018. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69019. import { Effect } from "babylonjs/Materials/effect";
  69020. /**
  69021. * Block used to implement the clear coat module of the PBR material
  69022. */
  69023. export class ClearCoatBlock extends NodeMaterialBlock {
  69024. private _scene;
  69025. /**
  69026. * Create a new ClearCoatBlock
  69027. * @param name defines the block name
  69028. */
  69029. constructor(name: string);
  69030. /**
  69031. * Initialize the block and prepare the context for build
  69032. * @param state defines the state that will be used for the build
  69033. */
  69034. initialize(state: NodeMaterialBuildState): void;
  69035. /**
  69036. * Gets the current class name
  69037. * @returns the class name
  69038. */
  69039. getClassName(): string;
  69040. /**
  69041. * Gets the intensity input component
  69042. */
  69043. get intensity(): NodeMaterialConnectionPoint;
  69044. /**
  69045. * Gets the roughness input component
  69046. */
  69047. get roughness(): NodeMaterialConnectionPoint;
  69048. /**
  69049. * Gets the ior input component
  69050. */
  69051. get ior(): NodeMaterialConnectionPoint;
  69052. /**
  69053. * Gets the texture input component
  69054. */
  69055. get texture(): NodeMaterialConnectionPoint;
  69056. /**
  69057. * Gets the bump texture input component
  69058. */
  69059. get bumpTexture(): NodeMaterialConnectionPoint;
  69060. /**
  69061. * Gets the uv input component
  69062. */
  69063. get uv(): NodeMaterialConnectionPoint;
  69064. /**
  69065. * Gets the tint color input component
  69066. */
  69067. get tintColor(): NodeMaterialConnectionPoint;
  69068. /**
  69069. * Gets the tint "at distance" input component
  69070. */
  69071. get tintAtDistance(): NodeMaterialConnectionPoint;
  69072. /**
  69073. * Gets the tint thickness input component
  69074. */
  69075. get tintThickness(): NodeMaterialConnectionPoint;
  69076. /**
  69077. * Gets the world tangent input component
  69078. */
  69079. get worldTangent(): NodeMaterialConnectionPoint;
  69080. /**
  69081. * Gets the clear coat object output component
  69082. */
  69083. get clearcoat(): NodeMaterialConnectionPoint;
  69084. autoConfigure(material: NodeMaterial): void;
  69085. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69086. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69087. private _generateTBNSpace;
  69088. /**
  69089. * Gets the main code of the block (fragment side)
  69090. * @param state current state of the node material building
  69091. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69092. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69093. * @param worldPosVarName name of the variable holding the world position
  69094. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69095. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69096. * @param worldNormalVarName name of the variable holding the world normal
  69097. * @returns the shader code
  69098. */
  69099. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69100. protected _buildBlock(state: NodeMaterialBuildState): this;
  69101. }
  69102. }
  69103. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  69104. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69105. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69106. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69107. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69109. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69110. import { Nullable } from "babylonjs/types";
  69111. /**
  69112. * Block used to implement the sub surface module of the PBR material
  69113. */
  69114. export class SubSurfaceBlock extends NodeMaterialBlock {
  69115. /**
  69116. * Create a new SubSurfaceBlock
  69117. * @param name defines the block name
  69118. */
  69119. constructor(name: string);
  69120. /**
  69121. * Stores the intensity of the different subsurface effects in the thickness texture.
  69122. * * the green channel is the translucency intensity.
  69123. * * the blue channel is the scattering intensity.
  69124. * * the alpha channel is the refraction intensity.
  69125. */
  69126. useMaskFromThicknessTexture: boolean;
  69127. /**
  69128. * Initialize the block and prepare the context for build
  69129. * @param state defines the state that will be used for the build
  69130. */
  69131. initialize(state: NodeMaterialBuildState): void;
  69132. /**
  69133. * Gets the current class name
  69134. * @returns the class name
  69135. */
  69136. getClassName(): string;
  69137. /**
  69138. * Gets the min thickness input component
  69139. */
  69140. get minThickness(): NodeMaterialConnectionPoint;
  69141. /**
  69142. * Gets the max thickness input component
  69143. */
  69144. get maxThickness(): NodeMaterialConnectionPoint;
  69145. /**
  69146. * Gets the thickness texture component
  69147. */
  69148. get thicknessTexture(): NodeMaterialConnectionPoint;
  69149. /**
  69150. * Gets the tint color input component
  69151. */
  69152. get tintColor(): NodeMaterialConnectionPoint;
  69153. /**
  69154. * Gets the translucency intensity input component
  69155. */
  69156. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69157. /**
  69158. * Gets the translucency diffusion distance input component
  69159. */
  69160. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  69161. /**
  69162. * Gets the refraction object parameters
  69163. */
  69164. get refraction(): NodeMaterialConnectionPoint;
  69165. /**
  69166. * Gets the sub surface object output component
  69167. */
  69168. get subsurface(): NodeMaterialConnectionPoint;
  69169. autoConfigure(material: NodeMaterial): void;
  69170. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69171. /**
  69172. * Gets the main code of the block (fragment side)
  69173. * @param state current state of the node material building
  69174. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69175. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69176. * @param worldPosVarName name of the variable holding the world position
  69177. * @returns the shader code
  69178. */
  69179. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69180. protected _buildBlock(state: NodeMaterialBuildState): this;
  69181. }
  69182. }
  69183. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  69184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69187. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69188. import { Light } from "babylonjs/Lights/light";
  69189. import { Nullable } from "babylonjs/types";
  69190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69191. import { Effect } from "babylonjs/Materials/effect";
  69192. import { Mesh } from "babylonjs/Meshes/mesh";
  69193. import { Scene } from "babylonjs/scene";
  69194. /**
  69195. * Block used to implement the PBR metallic/roughness model
  69196. */
  69197. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69198. /**
  69199. * Gets or sets the light associated with this block
  69200. */
  69201. light: Nullable<Light>;
  69202. private _lightId;
  69203. private _scene;
  69204. private _environmentBRDFTexture;
  69205. private _environmentBrdfSamplerName;
  69206. private _vNormalWName;
  69207. private _invertNormalName;
  69208. /**
  69209. * Create a new ReflectionBlock
  69210. * @param name defines the block name
  69211. */
  69212. constructor(name: string);
  69213. /**
  69214. * Intensity of the direct lights e.g. the four lights available in your scene.
  69215. * This impacts both the direct diffuse and specular highlights.
  69216. */
  69217. directIntensity: number;
  69218. /**
  69219. * Intensity of the environment e.g. how much the environment will light the object
  69220. * either through harmonics for rough material or through the refelction for shiny ones.
  69221. */
  69222. environmentIntensity: number;
  69223. /**
  69224. * This is a special control allowing the reduction of the specular highlights coming from the
  69225. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69226. */
  69227. specularIntensity: number;
  69228. /**
  69229. * Defines the falloff type used in this material.
  69230. * It by default is Physical.
  69231. */
  69232. lightFalloff: number;
  69233. /**
  69234. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  69235. */
  69236. useAlphaFromAlbedoTexture: boolean;
  69237. /**
  69238. * Specifies that alpha test should be used
  69239. */
  69240. useAlphaTest: boolean;
  69241. /**
  69242. * Defines the alpha limits in alpha test mode.
  69243. */
  69244. alphaTestCutoff: number;
  69245. /**
  69246. * Specifies that alpha blending should be used
  69247. */
  69248. useAlphaBlending: boolean;
  69249. /**
  69250. * Defines if the alpha value should be determined via the rgb values.
  69251. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  69252. */
  69253. opacityRGB: boolean;
  69254. /**
  69255. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69256. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69257. */
  69258. useRadianceOverAlpha: boolean;
  69259. /**
  69260. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69261. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69262. */
  69263. useSpecularOverAlpha: boolean;
  69264. /**
  69265. * Enables specular anti aliasing in the PBR shader.
  69266. * It will both interacts on the Geometry for analytical and IBL lighting.
  69267. * It also prefilter the roughness map based on the bump values.
  69268. */
  69269. enableSpecularAntiAliasing: boolean;
  69270. /**
  69271. * Enables realtime filtering on the texture.
  69272. */
  69273. realTimeFiltering: boolean;
  69274. /**
  69275. * Quality switch for realtime filtering
  69276. */
  69277. realTimeFilteringQuality: number;
  69278. /**
  69279. * Defines if the material uses energy conservation.
  69280. */
  69281. useEnergyConservation: boolean;
  69282. /**
  69283. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69284. * too much the area relying on ambient texture to define their ambient occlusion.
  69285. */
  69286. useRadianceOcclusion: boolean;
  69287. /**
  69288. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69289. * makes the reflect vector face the model (under horizon).
  69290. */
  69291. useHorizonOcclusion: boolean;
  69292. /**
  69293. * If set to true, no lighting calculations will be applied.
  69294. */
  69295. unlit: boolean;
  69296. /**
  69297. * Force normal to face away from face.
  69298. */
  69299. forceNormalForward: boolean;
  69300. /**
  69301. * Defines the material debug mode.
  69302. * It helps seeing only some components of the material while troubleshooting.
  69303. */
  69304. debugMode: number;
  69305. /**
  69306. * Specify from where on screen the debug mode should start.
  69307. * The value goes from -1 (full screen) to 1 (not visible)
  69308. * It helps with side by side comparison against the final render
  69309. * This defaults to 0
  69310. */
  69311. debugLimit: number;
  69312. /**
  69313. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69314. * You can use the factor to better multiply the final value.
  69315. */
  69316. debugFactor: number;
  69317. /**
  69318. * Initialize the block and prepare the context for build
  69319. * @param state defines the state that will be used for the build
  69320. */
  69321. initialize(state: NodeMaterialBuildState): void;
  69322. /**
  69323. * Gets the current class name
  69324. * @returns the class name
  69325. */
  69326. getClassName(): string;
  69327. /**
  69328. * Gets the world position input component
  69329. */
  69330. get worldPosition(): NodeMaterialConnectionPoint;
  69331. /**
  69332. * Gets the world normal input component
  69333. */
  69334. get worldNormal(): NodeMaterialConnectionPoint;
  69335. /**
  69336. * Gets the perturbed normal input component
  69337. */
  69338. get perturbedNormal(): NodeMaterialConnectionPoint;
  69339. /**
  69340. * Gets the camera position input component
  69341. */
  69342. get cameraPosition(): NodeMaterialConnectionPoint;
  69343. /**
  69344. * Gets the base color input component
  69345. */
  69346. get baseColor(): NodeMaterialConnectionPoint;
  69347. /**
  69348. * Gets the opacity texture input component
  69349. */
  69350. get opacityTexture(): NodeMaterialConnectionPoint;
  69351. /**
  69352. * Gets the ambient color input component
  69353. */
  69354. get ambientColor(): NodeMaterialConnectionPoint;
  69355. /**
  69356. * Gets the reflectivity object parameters
  69357. */
  69358. get reflectivity(): NodeMaterialConnectionPoint;
  69359. /**
  69360. * Gets the ambient occlusion object parameters
  69361. */
  69362. get ambientOcc(): NodeMaterialConnectionPoint;
  69363. /**
  69364. * Gets the reflection object parameters
  69365. */
  69366. get reflection(): NodeMaterialConnectionPoint;
  69367. /**
  69368. * Gets the sheen object parameters
  69369. */
  69370. get sheen(): NodeMaterialConnectionPoint;
  69371. /**
  69372. * Gets the clear coat object parameters
  69373. */
  69374. get clearcoat(): NodeMaterialConnectionPoint;
  69375. /**
  69376. * Gets the sub surface object parameters
  69377. */
  69378. get subsurface(): NodeMaterialConnectionPoint;
  69379. /**
  69380. * Gets the anisotropy object parameters
  69381. */
  69382. get anisotropy(): NodeMaterialConnectionPoint;
  69383. /**
  69384. * Gets the view matrix parameter
  69385. */
  69386. get view(): NodeMaterialConnectionPoint;
  69387. /**
  69388. * Gets the ambient output component
  69389. */
  69390. get ambient(): NodeMaterialConnectionPoint;
  69391. /**
  69392. * Gets the diffuse output component
  69393. */
  69394. get diffuse(): NodeMaterialConnectionPoint;
  69395. /**
  69396. * Gets the specular output component
  69397. */
  69398. get specular(): NodeMaterialConnectionPoint;
  69399. /**
  69400. * Gets the sheen output component
  69401. */
  69402. get sheenDir(): NodeMaterialConnectionPoint;
  69403. /**
  69404. * Gets the clear coat output component
  69405. */
  69406. get clearcoatDir(): NodeMaterialConnectionPoint;
  69407. /**
  69408. * Gets the indirect diffuse output component
  69409. */
  69410. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69411. /**
  69412. * Gets the indirect specular output component
  69413. */
  69414. get specularIndirect(): NodeMaterialConnectionPoint;
  69415. /**
  69416. * Gets the indirect sheen output component
  69417. */
  69418. get sheenIndirect(): NodeMaterialConnectionPoint;
  69419. /**
  69420. * Gets the indirect clear coat output component
  69421. */
  69422. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69423. /**
  69424. * Gets the refraction output component
  69425. */
  69426. get refraction(): NodeMaterialConnectionPoint;
  69427. /**
  69428. * Gets the global lighting output component
  69429. */
  69430. get lighting(): NodeMaterialConnectionPoint;
  69431. /**
  69432. * Gets the shadow output component
  69433. */
  69434. get shadow(): NodeMaterialConnectionPoint;
  69435. /**
  69436. * Gets the alpha output component
  69437. */
  69438. get alpha(): NodeMaterialConnectionPoint;
  69439. autoConfigure(material: NodeMaterial): void;
  69440. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69441. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69442. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69443. private _injectVertexCode;
  69444. /**
  69445. * Gets the code corresponding to the albedo/opacity module
  69446. * @returns the shader code
  69447. */
  69448. getAlbedoOpacityCode(): string;
  69449. protected _buildBlock(state: NodeMaterialBuildState): this;
  69450. protected _dumpPropertiesCode(): string;
  69451. serialize(): any;
  69452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69453. }
  69454. }
  69455. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69456. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69457. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69458. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  69459. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  69460. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69461. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69462. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69463. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69464. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69465. }
  69466. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69467. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69468. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69469. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69470. }
  69471. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69472. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69473. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69474. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69475. /**
  69476. * Block used to compute value of one parameter modulo another
  69477. */
  69478. export class ModBlock extends NodeMaterialBlock {
  69479. /**
  69480. * Creates a new ModBlock
  69481. * @param name defines the block name
  69482. */
  69483. constructor(name: string);
  69484. /**
  69485. * Gets the current class name
  69486. * @returns the class name
  69487. */
  69488. getClassName(): string;
  69489. /**
  69490. * Gets the left operand input component
  69491. */
  69492. get left(): NodeMaterialConnectionPoint;
  69493. /**
  69494. * Gets the right operand input component
  69495. */
  69496. get right(): NodeMaterialConnectionPoint;
  69497. /**
  69498. * Gets the output component
  69499. */
  69500. get output(): NodeMaterialConnectionPoint;
  69501. protected _buildBlock(state: NodeMaterialBuildState): this;
  69502. }
  69503. }
  69504. declare module "babylonjs/Materials/Node/Blocks/index" {
  69505. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69506. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69507. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69508. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69509. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69510. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69511. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69512. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69513. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69514. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69515. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69516. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69517. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69518. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69519. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69520. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69521. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69522. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69523. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69524. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69525. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69526. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69527. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69528. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69529. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69530. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69531. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69532. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69533. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69534. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69535. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69536. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69537. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69538. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69539. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69540. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69541. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69542. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69543. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69544. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69545. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69546. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69547. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69548. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69549. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69550. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69551. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69552. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69553. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69554. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69555. }
  69556. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69557. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69558. }
  69559. declare module "babylonjs/Materials/Node/index" {
  69560. export * from "babylonjs/Materials/Node/Enums/index";
  69561. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69562. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69563. export * from "babylonjs/Materials/Node/nodeMaterial";
  69564. export * from "babylonjs/Materials/Node/Blocks/index";
  69565. export * from "babylonjs/Materials/Node/Optimizers/index";
  69566. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69567. }
  69568. declare module "babylonjs/Materials/index" {
  69569. export * from "babylonjs/Materials/Background/index";
  69570. export * from "babylonjs/Materials/colorCurves";
  69571. export * from "babylonjs/Materials/iEffectFallbacks";
  69572. export * from "babylonjs/Materials/effectFallbacks";
  69573. export * from "babylonjs/Materials/effect";
  69574. export * from "babylonjs/Materials/fresnelParameters";
  69575. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69576. export * from "babylonjs/Materials/material";
  69577. export * from "babylonjs/Materials/materialDefines";
  69578. export * from "babylonjs/Materials/thinMaterialHelper";
  69579. export * from "babylonjs/Materials/materialHelper";
  69580. export * from "babylonjs/Materials/multiMaterial";
  69581. export * from "babylonjs/Materials/PBR/index";
  69582. export * from "babylonjs/Materials/pushMaterial";
  69583. export * from "babylonjs/Materials/shaderMaterial";
  69584. export * from "babylonjs/Materials/standardMaterial";
  69585. export * from "babylonjs/Materials/Textures/index";
  69586. export * from "babylonjs/Materials/uniformBuffer";
  69587. export * from "babylonjs/Materials/materialFlags";
  69588. export * from "babylonjs/Materials/Node/index";
  69589. export * from "babylonjs/Materials/effectRenderer";
  69590. export * from "babylonjs/Materials/shadowDepthWrapper";
  69591. }
  69592. declare module "babylonjs/Maths/index" {
  69593. export * from "babylonjs/Maths/math.scalar";
  69594. export * from "babylonjs/Maths/math";
  69595. export * from "babylonjs/Maths/sphericalPolynomial";
  69596. }
  69597. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69598. import { IDisposable } from "babylonjs/scene";
  69599. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69600. /**
  69601. * Configuration for Draco compression
  69602. */
  69603. export interface IDracoCompressionConfiguration {
  69604. /**
  69605. * Configuration for the decoder.
  69606. */
  69607. decoder: {
  69608. /**
  69609. * The url to the WebAssembly module.
  69610. */
  69611. wasmUrl?: string;
  69612. /**
  69613. * The url to the WebAssembly binary.
  69614. */
  69615. wasmBinaryUrl?: string;
  69616. /**
  69617. * The url to the fallback JavaScript module.
  69618. */
  69619. fallbackUrl?: string;
  69620. };
  69621. }
  69622. /**
  69623. * Draco compression (https://google.github.io/draco/)
  69624. *
  69625. * This class wraps the Draco module.
  69626. *
  69627. * **Encoder**
  69628. *
  69629. * The encoder is not currently implemented.
  69630. *
  69631. * **Decoder**
  69632. *
  69633. * 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.
  69634. *
  69635. * To update the configuration, use the following code:
  69636. * ```javascript
  69637. * DracoCompression.Configuration = {
  69638. * decoder: {
  69639. * wasmUrl: "<url to the WebAssembly library>",
  69640. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69641. * fallbackUrl: "<url to the fallback JavaScript library>",
  69642. * }
  69643. * };
  69644. * ```
  69645. *
  69646. * 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.
  69647. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69648. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69649. *
  69650. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69651. * ```javascript
  69652. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69653. * ```
  69654. *
  69655. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69656. */
  69657. export class DracoCompression implements IDisposable {
  69658. private _workerPoolPromise?;
  69659. private _decoderModulePromise?;
  69660. /**
  69661. * The configuration. Defaults to the following urls:
  69662. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69663. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69664. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69665. */
  69666. static Configuration: IDracoCompressionConfiguration;
  69667. /**
  69668. * Returns true if the decoder configuration is available.
  69669. */
  69670. static get DecoderAvailable(): boolean;
  69671. /**
  69672. * Default number of workers to create when creating the draco compression object.
  69673. */
  69674. static DefaultNumWorkers: number;
  69675. private static GetDefaultNumWorkers;
  69676. private static _Default;
  69677. /**
  69678. * Default instance for the draco compression object.
  69679. */
  69680. static get Default(): DracoCompression;
  69681. /**
  69682. * Constructor
  69683. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69684. */
  69685. constructor(numWorkers?: number);
  69686. /**
  69687. * Stop all async operations and release resources.
  69688. */
  69689. dispose(): void;
  69690. /**
  69691. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69692. * @returns a promise that resolves when ready
  69693. */
  69694. whenReadyAsync(): Promise<void>;
  69695. /**
  69696. * Decode Draco compressed mesh data to vertex data.
  69697. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69698. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69699. * @returns A promise that resolves with the decoded vertex data
  69700. */
  69701. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69702. [kind: string]: number;
  69703. }): Promise<VertexData>;
  69704. }
  69705. }
  69706. declare module "babylonjs/Meshes/Compression/index" {
  69707. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69708. }
  69709. declare module "babylonjs/Meshes/csg" {
  69710. import { Nullable } from "babylonjs/types";
  69711. import { Scene } from "babylonjs/scene";
  69712. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69713. import { Mesh } from "babylonjs/Meshes/mesh";
  69714. import { Material } from "babylonjs/Materials/material";
  69715. /**
  69716. * Class for building Constructive Solid Geometry
  69717. */
  69718. export class CSG {
  69719. private polygons;
  69720. /**
  69721. * The world matrix
  69722. */
  69723. matrix: Matrix;
  69724. /**
  69725. * Stores the position
  69726. */
  69727. position: Vector3;
  69728. /**
  69729. * Stores the rotation
  69730. */
  69731. rotation: Vector3;
  69732. /**
  69733. * Stores the rotation quaternion
  69734. */
  69735. rotationQuaternion: Nullable<Quaternion>;
  69736. /**
  69737. * Stores the scaling vector
  69738. */
  69739. scaling: Vector3;
  69740. /**
  69741. * Convert the Mesh to CSG
  69742. * @param mesh The Mesh to convert to CSG
  69743. * @returns A new CSG from the Mesh
  69744. */
  69745. static FromMesh(mesh: Mesh): CSG;
  69746. /**
  69747. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69748. * @param polygons Polygons used to construct a CSG solid
  69749. */
  69750. private static FromPolygons;
  69751. /**
  69752. * Clones, or makes a deep copy, of the CSG
  69753. * @returns A new CSG
  69754. */
  69755. clone(): CSG;
  69756. /**
  69757. * Unions this CSG with another CSG
  69758. * @param csg The CSG to union against this CSG
  69759. * @returns The unioned CSG
  69760. */
  69761. union(csg: CSG): CSG;
  69762. /**
  69763. * Unions this CSG with another CSG in place
  69764. * @param csg The CSG to union against this CSG
  69765. */
  69766. unionInPlace(csg: CSG): void;
  69767. /**
  69768. * Subtracts this CSG with another CSG
  69769. * @param csg The CSG to subtract against this CSG
  69770. * @returns A new CSG
  69771. */
  69772. subtract(csg: CSG): CSG;
  69773. /**
  69774. * Subtracts this CSG with another CSG in place
  69775. * @param csg The CSG to subtact against this CSG
  69776. */
  69777. subtractInPlace(csg: CSG): void;
  69778. /**
  69779. * Intersect this CSG with another CSG
  69780. * @param csg The CSG to intersect against this CSG
  69781. * @returns A new CSG
  69782. */
  69783. intersect(csg: CSG): CSG;
  69784. /**
  69785. * Intersects this CSG with another CSG in place
  69786. * @param csg The CSG to intersect against this CSG
  69787. */
  69788. intersectInPlace(csg: CSG): void;
  69789. /**
  69790. * Return a new CSG solid with solid and empty space switched. This solid is
  69791. * not modified.
  69792. * @returns A new CSG solid with solid and empty space switched
  69793. */
  69794. inverse(): CSG;
  69795. /**
  69796. * Inverses the CSG in place
  69797. */
  69798. inverseInPlace(): void;
  69799. /**
  69800. * This is used to keep meshes transformations so they can be restored
  69801. * when we build back a Babylon Mesh
  69802. * NB : All CSG operations are performed in world coordinates
  69803. * @param csg The CSG to copy the transform attributes from
  69804. * @returns This CSG
  69805. */
  69806. copyTransformAttributes(csg: CSG): CSG;
  69807. /**
  69808. * Build Raw mesh from CSG
  69809. * Coordinates here are in world space
  69810. * @param name The name of the mesh geometry
  69811. * @param scene The Scene
  69812. * @param keepSubMeshes Specifies if the submeshes should be kept
  69813. * @returns A new Mesh
  69814. */
  69815. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69816. /**
  69817. * Build Mesh from CSG taking material and transforms into account
  69818. * @param name The name of the Mesh
  69819. * @param material The material of the Mesh
  69820. * @param scene The Scene
  69821. * @param keepSubMeshes Specifies if submeshes should be kept
  69822. * @returns The new Mesh
  69823. */
  69824. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69825. }
  69826. }
  69827. declare module "babylonjs/Meshes/trailMesh" {
  69828. import { Mesh } from "babylonjs/Meshes/mesh";
  69829. import { Scene } from "babylonjs/scene";
  69830. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69831. /**
  69832. * Class used to create a trail following a mesh
  69833. */
  69834. export class TrailMesh extends Mesh {
  69835. private _generator;
  69836. private _autoStart;
  69837. private _running;
  69838. private _diameter;
  69839. private _length;
  69840. private _sectionPolygonPointsCount;
  69841. private _sectionVectors;
  69842. private _sectionNormalVectors;
  69843. private _beforeRenderObserver;
  69844. /**
  69845. * @constructor
  69846. * @param name The value used by scene.getMeshByName() to do a lookup.
  69847. * @param generator The mesh or transform node to generate a trail.
  69848. * @param scene The scene to add this mesh to.
  69849. * @param diameter Diameter of trailing mesh. Default is 1.
  69850. * @param length Length of trailing mesh. Default is 60.
  69851. * @param autoStart Automatically start trailing mesh. Default true.
  69852. */
  69853. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69854. /**
  69855. * "TrailMesh"
  69856. * @returns "TrailMesh"
  69857. */
  69858. getClassName(): string;
  69859. private _createMesh;
  69860. /**
  69861. * Start trailing mesh.
  69862. */
  69863. start(): void;
  69864. /**
  69865. * Stop trailing mesh.
  69866. */
  69867. stop(): void;
  69868. /**
  69869. * Update trailing mesh geometry.
  69870. */
  69871. update(): void;
  69872. /**
  69873. * Returns a new TrailMesh object.
  69874. * @param name is a string, the name given to the new mesh
  69875. * @param newGenerator use new generator object for cloned trail mesh
  69876. * @returns a new mesh
  69877. */
  69878. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69879. /**
  69880. * Serializes this trail mesh
  69881. * @param serializationObject object to write serialization to
  69882. */
  69883. serialize(serializationObject: any): void;
  69884. /**
  69885. * Parses a serialized trail mesh
  69886. * @param parsedMesh the serialized mesh
  69887. * @param scene the scene to create the trail mesh in
  69888. * @returns the created trail mesh
  69889. */
  69890. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69891. }
  69892. }
  69893. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69894. import { Nullable } from "babylonjs/types";
  69895. import { Scene } from "babylonjs/scene";
  69896. import { Vector4 } from "babylonjs/Maths/math.vector";
  69897. import { Color4 } from "babylonjs/Maths/math.color";
  69898. import { Mesh } from "babylonjs/Meshes/mesh";
  69899. /**
  69900. * Class containing static functions to help procedurally build meshes
  69901. */
  69902. export class TiledBoxBuilder {
  69903. /**
  69904. * Creates a box mesh
  69905. * 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)
  69906. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69910. * @param name defines the name of the mesh
  69911. * @param options defines the options used to create the mesh
  69912. * @param scene defines the hosting scene
  69913. * @returns the box mesh
  69914. */
  69915. static CreateTiledBox(name: string, options: {
  69916. pattern?: number;
  69917. width?: number;
  69918. height?: number;
  69919. depth?: number;
  69920. tileSize?: number;
  69921. tileWidth?: number;
  69922. tileHeight?: number;
  69923. alignHorizontal?: number;
  69924. alignVertical?: number;
  69925. faceUV?: Vector4[];
  69926. faceColors?: Color4[];
  69927. sideOrientation?: number;
  69928. updatable?: boolean;
  69929. }, scene?: Nullable<Scene>): Mesh;
  69930. }
  69931. }
  69932. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69933. import { Vector4 } from "babylonjs/Maths/math.vector";
  69934. import { Mesh } from "babylonjs/Meshes/mesh";
  69935. /**
  69936. * Class containing static functions to help procedurally build meshes
  69937. */
  69938. export class TorusKnotBuilder {
  69939. /**
  69940. * Creates a torus knot mesh
  69941. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69942. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69943. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69944. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69948. * @param name defines the name of the mesh
  69949. * @param options defines the options used to create the mesh
  69950. * @param scene defines the hosting scene
  69951. * @returns the torus knot mesh
  69952. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69953. */
  69954. static CreateTorusKnot(name: string, options: {
  69955. radius?: number;
  69956. tube?: number;
  69957. radialSegments?: number;
  69958. tubularSegments?: number;
  69959. p?: number;
  69960. q?: number;
  69961. updatable?: boolean;
  69962. sideOrientation?: number;
  69963. frontUVs?: Vector4;
  69964. backUVs?: Vector4;
  69965. }, scene: any): Mesh;
  69966. }
  69967. }
  69968. declare module "babylonjs/Meshes/polygonMesh" {
  69969. import { Scene } from "babylonjs/scene";
  69970. import { Vector2 } from "babylonjs/Maths/math.vector";
  69971. import { Mesh } from "babylonjs/Meshes/mesh";
  69972. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69973. import { Path2 } from "babylonjs/Maths/math.path";
  69974. /**
  69975. * Polygon
  69976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69977. */
  69978. export class Polygon {
  69979. /**
  69980. * Creates a rectangle
  69981. * @param xmin bottom X coord
  69982. * @param ymin bottom Y coord
  69983. * @param xmax top X coord
  69984. * @param ymax top Y coord
  69985. * @returns points that make the resulting rectation
  69986. */
  69987. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69988. /**
  69989. * Creates a circle
  69990. * @param radius radius of circle
  69991. * @param cx scale in x
  69992. * @param cy scale in y
  69993. * @param numberOfSides number of sides that make up the circle
  69994. * @returns points that make the resulting circle
  69995. */
  69996. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69997. /**
  69998. * Creates a polygon from input string
  69999. * @param input Input polygon data
  70000. * @returns the parsed points
  70001. */
  70002. static Parse(input: string): Vector2[];
  70003. /**
  70004. * Starts building a polygon from x and y coordinates
  70005. * @param x x coordinate
  70006. * @param y y coordinate
  70007. * @returns the started path2
  70008. */
  70009. static StartingAt(x: number, y: number): Path2;
  70010. }
  70011. /**
  70012. * Builds a polygon
  70013. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70014. */
  70015. export class PolygonMeshBuilder {
  70016. private _points;
  70017. private _outlinepoints;
  70018. private _holes;
  70019. private _name;
  70020. private _scene;
  70021. private _epoints;
  70022. private _eholes;
  70023. private _addToepoint;
  70024. /**
  70025. * Babylon reference to the earcut plugin.
  70026. */
  70027. bjsEarcut: any;
  70028. /**
  70029. * Creates a PolygonMeshBuilder
  70030. * @param name name of the builder
  70031. * @param contours Path of the polygon
  70032. * @param scene scene to add to when creating the mesh
  70033. * @param earcutInjection can be used to inject your own earcut reference
  70034. */
  70035. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70036. /**
  70037. * Adds a whole within the polygon
  70038. * @param hole Array of points defining the hole
  70039. * @returns this
  70040. */
  70041. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70042. /**
  70043. * Creates the polygon
  70044. * @param updatable If the mesh should be updatable
  70045. * @param depth The depth of the mesh created
  70046. * @returns the created mesh
  70047. */
  70048. build(updatable?: boolean, depth?: number): Mesh;
  70049. /**
  70050. * Creates the polygon
  70051. * @param depth The depth of the mesh created
  70052. * @returns the created VertexData
  70053. */
  70054. buildVertexData(depth?: number): VertexData;
  70055. /**
  70056. * Adds a side to the polygon
  70057. * @param positions points that make the polygon
  70058. * @param normals normals of the polygon
  70059. * @param uvs uvs of the polygon
  70060. * @param indices indices of the polygon
  70061. * @param bounds bounds of the polygon
  70062. * @param points points of the polygon
  70063. * @param depth depth of the polygon
  70064. * @param flip flip of the polygon
  70065. */
  70066. private addSide;
  70067. }
  70068. }
  70069. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  70070. import { Scene } from "babylonjs/scene";
  70071. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70072. import { Color4 } from "babylonjs/Maths/math.color";
  70073. import { Mesh } from "babylonjs/Meshes/mesh";
  70074. import { Nullable } from "babylonjs/types";
  70075. /**
  70076. * Class containing static functions to help procedurally build meshes
  70077. */
  70078. export class PolygonBuilder {
  70079. /**
  70080. * Creates a polygon mesh
  70081. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70082. * * 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
  70083. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70086. * * Remember you can only change the shape positions, not their number when updating a polygon
  70087. * @param name defines the name of the mesh
  70088. * @param options defines the options used to create the mesh
  70089. * @param scene defines the hosting scene
  70090. * @param earcutInjection can be used to inject your own earcut reference
  70091. * @returns the polygon mesh
  70092. */
  70093. static CreatePolygon(name: string, options: {
  70094. shape: Vector3[];
  70095. holes?: Vector3[][];
  70096. depth?: number;
  70097. faceUV?: Vector4[];
  70098. faceColors?: Color4[];
  70099. updatable?: boolean;
  70100. sideOrientation?: number;
  70101. frontUVs?: Vector4;
  70102. backUVs?: Vector4;
  70103. wrap?: boolean;
  70104. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70105. /**
  70106. * Creates an extruded polygon mesh, with depth in the Y direction.
  70107. * * 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)
  70108. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70109. * @param name defines the name of the mesh
  70110. * @param options defines the options used to create the mesh
  70111. * @param scene defines the hosting scene
  70112. * @param earcutInjection can be used to inject your own earcut reference
  70113. * @returns the polygon mesh
  70114. */
  70115. static ExtrudePolygon(name: string, options: {
  70116. shape: Vector3[];
  70117. holes?: Vector3[][];
  70118. depth?: number;
  70119. faceUV?: Vector4[];
  70120. faceColors?: Color4[];
  70121. updatable?: boolean;
  70122. sideOrientation?: number;
  70123. frontUVs?: Vector4;
  70124. backUVs?: Vector4;
  70125. wrap?: boolean;
  70126. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70127. }
  70128. }
  70129. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  70130. import { Scene } from "babylonjs/scene";
  70131. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70132. import { Mesh } from "babylonjs/Meshes/mesh";
  70133. import { Nullable } from "babylonjs/types";
  70134. /**
  70135. * Class containing static functions to help procedurally build meshes
  70136. */
  70137. export class LatheBuilder {
  70138. /**
  70139. * Creates lathe mesh.
  70140. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70141. * * 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
  70142. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70143. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70144. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70145. * * 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
  70146. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70147. * * 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
  70148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70152. * @param name defines the name of the mesh
  70153. * @param options defines the options used to create the mesh
  70154. * @param scene defines the hosting scene
  70155. * @returns the lathe mesh
  70156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70157. */
  70158. static CreateLathe(name: string, options: {
  70159. shape: Vector3[];
  70160. radius?: number;
  70161. tessellation?: number;
  70162. clip?: number;
  70163. arc?: number;
  70164. closed?: boolean;
  70165. updatable?: boolean;
  70166. sideOrientation?: number;
  70167. frontUVs?: Vector4;
  70168. backUVs?: Vector4;
  70169. cap?: number;
  70170. invertUV?: boolean;
  70171. }, scene?: Nullable<Scene>): Mesh;
  70172. }
  70173. }
  70174. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  70175. import { Nullable } from "babylonjs/types";
  70176. import { Scene } from "babylonjs/scene";
  70177. import { Vector4 } from "babylonjs/Maths/math.vector";
  70178. import { Mesh } from "babylonjs/Meshes/mesh";
  70179. /**
  70180. * Class containing static functions to help procedurally build meshes
  70181. */
  70182. export class TiledPlaneBuilder {
  70183. /**
  70184. * Creates a tiled plane mesh
  70185. * * The parameter `pattern` will, depending on value, do nothing or
  70186. * * * flip (reflect about central vertical) alternate tiles across and up
  70187. * * * flip every tile on alternate rows
  70188. * * * rotate (180 degs) alternate tiles across and up
  70189. * * * rotate every tile on alternate rows
  70190. * * * flip and rotate alternate tiles across and up
  70191. * * * flip and rotate every tile on alternate rows
  70192. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70193. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70195. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70196. * * 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)
  70197. * * 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)
  70198. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70199. * @param name defines the name of the mesh
  70200. * @param options defines the options used to create the mesh
  70201. * @param scene defines the hosting scene
  70202. * @returns the box mesh
  70203. */
  70204. static CreateTiledPlane(name: string, options: {
  70205. pattern?: number;
  70206. tileSize?: number;
  70207. tileWidth?: number;
  70208. tileHeight?: number;
  70209. size?: number;
  70210. width?: number;
  70211. height?: number;
  70212. alignHorizontal?: number;
  70213. alignVertical?: number;
  70214. sideOrientation?: number;
  70215. frontUVs?: Vector4;
  70216. backUVs?: Vector4;
  70217. updatable?: boolean;
  70218. }, scene?: Nullable<Scene>): Mesh;
  70219. }
  70220. }
  70221. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  70222. import { Nullable } from "babylonjs/types";
  70223. import { Scene } from "babylonjs/scene";
  70224. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70225. import { Mesh } from "babylonjs/Meshes/mesh";
  70226. /**
  70227. * Class containing static functions to help procedurally build meshes
  70228. */
  70229. export class TubeBuilder {
  70230. /**
  70231. * Creates a tube mesh.
  70232. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70233. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70234. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70235. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70236. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70237. * * 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)
  70238. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70239. * * 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
  70240. * * 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
  70241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70243. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70245. * @param name defines the name of the mesh
  70246. * @param options defines the options used to create the mesh
  70247. * @param scene defines the hosting scene
  70248. * @returns the tube mesh
  70249. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70250. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70251. */
  70252. static CreateTube(name: string, options: {
  70253. path: Vector3[];
  70254. radius?: number;
  70255. tessellation?: number;
  70256. radiusFunction?: {
  70257. (i: number, distance: number): number;
  70258. };
  70259. cap?: number;
  70260. arc?: number;
  70261. updatable?: boolean;
  70262. sideOrientation?: number;
  70263. frontUVs?: Vector4;
  70264. backUVs?: Vector4;
  70265. instance?: Mesh;
  70266. invertUV?: boolean;
  70267. }, scene?: Nullable<Scene>): Mesh;
  70268. }
  70269. }
  70270. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  70271. import { Scene } from "babylonjs/scene";
  70272. import { Vector4 } from "babylonjs/Maths/math.vector";
  70273. import { Mesh } from "babylonjs/Meshes/mesh";
  70274. import { Nullable } from "babylonjs/types";
  70275. /**
  70276. * Class containing static functions to help procedurally build meshes
  70277. */
  70278. export class IcoSphereBuilder {
  70279. /**
  70280. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70281. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70282. * * 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`)
  70283. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70284. * * 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
  70285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70286. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70288. * @param name defines the name of the mesh
  70289. * @param options defines the options used to create the mesh
  70290. * @param scene defines the hosting scene
  70291. * @returns the icosahedron mesh
  70292. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70293. */
  70294. static CreateIcoSphere(name: string, options: {
  70295. radius?: number;
  70296. radiusX?: number;
  70297. radiusY?: number;
  70298. radiusZ?: number;
  70299. flat?: boolean;
  70300. subdivisions?: number;
  70301. sideOrientation?: number;
  70302. frontUVs?: Vector4;
  70303. backUVs?: Vector4;
  70304. updatable?: boolean;
  70305. }, scene?: Nullable<Scene>): Mesh;
  70306. }
  70307. }
  70308. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  70309. import { Vector3 } from "babylonjs/Maths/math.vector";
  70310. import { Mesh } from "babylonjs/Meshes/mesh";
  70311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70312. /**
  70313. * Class containing static functions to help procedurally build meshes
  70314. */
  70315. export class DecalBuilder {
  70316. /**
  70317. * Creates a decal mesh.
  70318. * 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
  70319. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70320. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70321. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70322. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70323. * @param name defines the name of the mesh
  70324. * @param sourceMesh defines the mesh where the decal must be applied
  70325. * @param options defines the options used to create the mesh
  70326. * @param scene defines the hosting scene
  70327. * @returns the decal mesh
  70328. * @see https://doc.babylonjs.com/how_to/decals
  70329. */
  70330. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70331. position?: Vector3;
  70332. normal?: Vector3;
  70333. size?: Vector3;
  70334. angle?: number;
  70335. }): Mesh;
  70336. }
  70337. }
  70338. declare module "babylonjs/Meshes/meshBuilder" {
  70339. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  70340. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  70341. import { Nullable } from "babylonjs/types";
  70342. import { Scene } from "babylonjs/scene";
  70343. import { Mesh } from "babylonjs/Meshes/mesh";
  70344. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  70345. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  70346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70347. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70348. import { Plane } from "babylonjs/Maths/math.plane";
  70349. /**
  70350. * Class containing static functions to help procedurally build meshes
  70351. */
  70352. export class MeshBuilder {
  70353. /**
  70354. * Creates a box mesh
  70355. * * The parameter `size` sets the size (float) of each box side (default 1)
  70356. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70357. * * 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)
  70358. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70362. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70363. * @param name defines the name of the mesh
  70364. * @param options defines the options used to create the mesh
  70365. * @param scene defines the hosting scene
  70366. * @returns the box mesh
  70367. */
  70368. static CreateBox(name: string, options: {
  70369. size?: number;
  70370. width?: number;
  70371. height?: number;
  70372. depth?: number;
  70373. faceUV?: Vector4[];
  70374. faceColors?: Color4[];
  70375. sideOrientation?: number;
  70376. frontUVs?: Vector4;
  70377. backUVs?: Vector4;
  70378. wrap?: boolean;
  70379. topBaseAt?: number;
  70380. bottomBaseAt?: number;
  70381. updatable?: boolean;
  70382. }, scene?: Nullable<Scene>): Mesh;
  70383. /**
  70384. * Creates a tiled box mesh
  70385. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70387. * @param name defines the name of the mesh
  70388. * @param options defines the options used to create the mesh
  70389. * @param scene defines the hosting scene
  70390. * @returns the tiled box mesh
  70391. */
  70392. static CreateTiledBox(name: string, options: {
  70393. pattern?: number;
  70394. size?: number;
  70395. width?: number;
  70396. height?: number;
  70397. depth: number;
  70398. tileSize?: number;
  70399. tileWidth?: number;
  70400. tileHeight?: number;
  70401. faceUV?: Vector4[];
  70402. faceColors?: Color4[];
  70403. alignHorizontal?: number;
  70404. alignVertical?: number;
  70405. sideOrientation?: number;
  70406. updatable?: boolean;
  70407. }, scene?: Nullable<Scene>): Mesh;
  70408. /**
  70409. * Creates a sphere mesh
  70410. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70411. * * 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`)
  70412. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70413. * * 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
  70414. * * 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)
  70415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70418. * @param name defines the name of the mesh
  70419. * @param options defines the options used to create the mesh
  70420. * @param scene defines the hosting scene
  70421. * @returns the sphere mesh
  70422. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70423. */
  70424. static CreateSphere(name: string, options: {
  70425. segments?: number;
  70426. diameter?: number;
  70427. diameterX?: number;
  70428. diameterY?: number;
  70429. diameterZ?: number;
  70430. arc?: number;
  70431. slice?: number;
  70432. sideOrientation?: number;
  70433. frontUVs?: Vector4;
  70434. backUVs?: Vector4;
  70435. updatable?: boolean;
  70436. }, scene?: Nullable<Scene>): Mesh;
  70437. /**
  70438. * Creates a plane polygonal mesh. By default, this is a disc
  70439. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70440. * * 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
  70441. * * 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
  70442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70445. * @param name defines the name of the mesh
  70446. * @param options defines the options used to create the mesh
  70447. * @param scene defines the hosting scene
  70448. * @returns the plane polygonal mesh
  70449. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70450. */
  70451. static CreateDisc(name: string, options: {
  70452. radius?: number;
  70453. tessellation?: number;
  70454. arc?: number;
  70455. updatable?: boolean;
  70456. sideOrientation?: number;
  70457. frontUVs?: Vector4;
  70458. backUVs?: Vector4;
  70459. }, scene?: Nullable<Scene>): Mesh;
  70460. /**
  70461. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70462. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70463. * * 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`)
  70464. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70465. * * 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
  70466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70469. * @param name defines the name of the mesh
  70470. * @param options defines the options used to create the mesh
  70471. * @param scene defines the hosting scene
  70472. * @returns the icosahedron mesh
  70473. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70474. */
  70475. static CreateIcoSphere(name: string, options: {
  70476. radius?: number;
  70477. radiusX?: number;
  70478. radiusY?: number;
  70479. radiusZ?: number;
  70480. flat?: boolean;
  70481. subdivisions?: number;
  70482. sideOrientation?: number;
  70483. frontUVs?: Vector4;
  70484. backUVs?: Vector4;
  70485. updatable?: boolean;
  70486. }, scene?: Nullable<Scene>): Mesh;
  70487. /**
  70488. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70489. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70490. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70491. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70492. * * 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
  70493. * * 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
  70494. * * 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
  70495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70497. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70498. * * 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
  70499. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70500. * * 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
  70501. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70503. * @param name defines the name of the mesh
  70504. * @param options defines the options used to create the mesh
  70505. * @param scene defines the hosting scene
  70506. * @returns the ribbon mesh
  70507. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70508. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70509. */
  70510. static CreateRibbon(name: string, options: {
  70511. pathArray: Vector3[][];
  70512. closeArray?: boolean;
  70513. closePath?: boolean;
  70514. offset?: number;
  70515. updatable?: boolean;
  70516. sideOrientation?: number;
  70517. frontUVs?: Vector4;
  70518. backUVs?: Vector4;
  70519. instance?: Mesh;
  70520. invertUV?: boolean;
  70521. uvs?: Vector2[];
  70522. colors?: Color4[];
  70523. }, scene?: Nullable<Scene>): Mesh;
  70524. /**
  70525. * Creates a cylinder or a cone mesh
  70526. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70527. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70528. * * 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.
  70529. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70530. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70531. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70532. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70533. * * 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).
  70534. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70535. * * 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).
  70536. * * 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
  70537. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70538. * * 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
  70539. * * 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.
  70540. * * If `enclose` is false, a ring surface is one element.
  70541. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70542. * * 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
  70543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70546. * @param name defines the name of the mesh
  70547. * @param options defines the options used to create the mesh
  70548. * @param scene defines the hosting scene
  70549. * @returns the cylinder mesh
  70550. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70551. */
  70552. static CreateCylinder(name: string, options: {
  70553. height?: number;
  70554. diameterTop?: number;
  70555. diameterBottom?: number;
  70556. diameter?: number;
  70557. tessellation?: number;
  70558. subdivisions?: number;
  70559. arc?: number;
  70560. faceColors?: Color4[];
  70561. faceUV?: Vector4[];
  70562. updatable?: boolean;
  70563. hasRings?: boolean;
  70564. enclose?: boolean;
  70565. cap?: number;
  70566. sideOrientation?: number;
  70567. frontUVs?: Vector4;
  70568. backUVs?: Vector4;
  70569. }, scene?: Nullable<Scene>): Mesh;
  70570. /**
  70571. * Creates a torus mesh
  70572. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70573. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70574. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  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 torus mesh
  70582. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70583. */
  70584. static CreateTorus(name: string, options: {
  70585. diameter?: number;
  70586. thickness?: number;
  70587. tessellation?: number;
  70588. updatable?: boolean;
  70589. sideOrientation?: number;
  70590. frontUVs?: Vector4;
  70591. backUVs?: Vector4;
  70592. }, scene?: Nullable<Scene>): Mesh;
  70593. /**
  70594. * Creates a torus knot mesh
  70595. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70596. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70597. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70598. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70602. * @param name defines the name of the mesh
  70603. * @param options defines the options used to create the mesh
  70604. * @param scene defines the hosting scene
  70605. * @returns the torus knot mesh
  70606. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70607. */
  70608. static CreateTorusKnot(name: string, options: {
  70609. radius?: number;
  70610. tube?: number;
  70611. radialSegments?: number;
  70612. tubularSegments?: number;
  70613. p?: number;
  70614. q?: number;
  70615. updatable?: boolean;
  70616. sideOrientation?: number;
  70617. frontUVs?: Vector4;
  70618. backUVs?: Vector4;
  70619. }, scene?: Nullable<Scene>): Mesh;
  70620. /**
  70621. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70622. * * 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
  70623. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70624. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70625. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70626. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70627. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70628. * * 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
  70629. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70631. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70632. * @param name defines the name of the new line system
  70633. * @param options defines the options used to create the line system
  70634. * @param scene defines the hosting scene
  70635. * @returns a new line system mesh
  70636. */
  70637. static CreateLineSystem(name: string, options: {
  70638. lines: Vector3[][];
  70639. updatable?: boolean;
  70640. instance?: Nullable<LinesMesh>;
  70641. colors?: Nullable<Color4[][]>;
  70642. useVertexAlpha?: boolean;
  70643. }, scene: Nullable<Scene>): LinesMesh;
  70644. /**
  70645. * Creates a line mesh
  70646. * 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
  70647. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70648. * * The parameter `points` is an array successive Vector3
  70649. * * 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
  70650. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70651. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70652. * * When updating an instance, remember that only point positions can change, not the number of points
  70653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70655. * @param name defines the name of the new line system
  70656. * @param options defines the options used to create the line system
  70657. * @param scene defines the hosting scene
  70658. * @returns a new line mesh
  70659. */
  70660. static CreateLines(name: string, options: {
  70661. points: Vector3[];
  70662. updatable?: boolean;
  70663. instance?: Nullable<LinesMesh>;
  70664. colors?: Color4[];
  70665. useVertexAlpha?: boolean;
  70666. }, scene?: Nullable<Scene>): LinesMesh;
  70667. /**
  70668. * Creates a dashed line mesh
  70669. * * 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
  70670. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70671. * * The parameter `points` is an array successive Vector3
  70672. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70673. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70674. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70675. * * 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
  70676. * * When updating an instance, remember that only point positions can change, not the number of points
  70677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70678. * @param name defines the name of the mesh
  70679. * @param options defines the options used to create the mesh
  70680. * @param scene defines the hosting scene
  70681. * @returns the dashed line mesh
  70682. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70683. */
  70684. static CreateDashedLines(name: string, options: {
  70685. points: Vector3[];
  70686. dashSize?: number;
  70687. gapSize?: number;
  70688. dashNb?: number;
  70689. updatable?: boolean;
  70690. instance?: LinesMesh;
  70691. }, scene?: Nullable<Scene>): LinesMesh;
  70692. /**
  70693. * 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.
  70694. * * 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.
  70695. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70696. * * 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.
  70697. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70698. * * 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
  70699. * * 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
  70700. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70703. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70705. * @param name defines the name of the mesh
  70706. * @param options defines the options used to create the mesh
  70707. * @param scene defines the hosting scene
  70708. * @returns the extruded shape mesh
  70709. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70710. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70711. */
  70712. static ExtrudeShape(name: string, options: {
  70713. shape: Vector3[];
  70714. path: Vector3[];
  70715. scale?: number;
  70716. rotation?: number;
  70717. cap?: number;
  70718. updatable?: boolean;
  70719. sideOrientation?: number;
  70720. frontUVs?: Vector4;
  70721. backUVs?: Vector4;
  70722. instance?: Mesh;
  70723. invertUV?: boolean;
  70724. }, scene?: Nullable<Scene>): Mesh;
  70725. /**
  70726. * Creates an custom extruded shape mesh.
  70727. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70728. * * 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.
  70729. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70730. * * 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
  70731. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70732. * * 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
  70733. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70734. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70735. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70736. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  70737. * * 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
  70738. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70741. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70743. * @param name defines the name of the mesh
  70744. * @param options defines the options used to create the mesh
  70745. * @param scene defines the hosting scene
  70746. * @returns the custom extruded shape mesh
  70747. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70748. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70749. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70750. */
  70751. static ExtrudeShapeCustom(name: string, options: {
  70752. shape: Vector3[];
  70753. path: Vector3[];
  70754. scaleFunction?: any;
  70755. rotationFunction?: any;
  70756. ribbonCloseArray?: boolean;
  70757. ribbonClosePath?: boolean;
  70758. cap?: number;
  70759. updatable?: boolean;
  70760. sideOrientation?: number;
  70761. frontUVs?: Vector4;
  70762. backUVs?: Vector4;
  70763. instance?: Mesh;
  70764. invertUV?: boolean;
  70765. }, scene?: Nullable<Scene>): Mesh;
  70766. /**
  70767. * Creates lathe mesh.
  70768. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70769. * * 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
  70770. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70771. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70772. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70773. * * 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
  70774. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70775. * * 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
  70776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70778. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70780. * @param name defines the name of the mesh
  70781. * @param options defines the options used to create the mesh
  70782. * @param scene defines the hosting scene
  70783. * @returns the lathe mesh
  70784. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70785. */
  70786. static CreateLathe(name: string, options: {
  70787. shape: Vector3[];
  70788. radius?: number;
  70789. tessellation?: number;
  70790. clip?: number;
  70791. arc?: number;
  70792. closed?: boolean;
  70793. updatable?: boolean;
  70794. sideOrientation?: number;
  70795. frontUVs?: Vector4;
  70796. backUVs?: Vector4;
  70797. cap?: number;
  70798. invertUV?: boolean;
  70799. }, scene?: Nullable<Scene>): Mesh;
  70800. /**
  70801. * Creates a tiled plane mesh
  70802. * * You can set a limited pattern arrangement with the tiles
  70803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70806. * @param name defines the name of the mesh
  70807. * @param options defines the options used to create the mesh
  70808. * @param scene defines the hosting scene
  70809. * @returns the plane mesh
  70810. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70811. */
  70812. static CreateTiledPlane(name: string, options: {
  70813. pattern?: number;
  70814. tileSize?: number;
  70815. tileWidth?: number;
  70816. tileHeight?: number;
  70817. size?: number;
  70818. width?: number;
  70819. height?: number;
  70820. alignHorizontal?: number;
  70821. alignVertical?: number;
  70822. sideOrientation?: number;
  70823. frontUVs?: Vector4;
  70824. backUVs?: Vector4;
  70825. updatable?: boolean;
  70826. }, scene?: Nullable<Scene>): Mesh;
  70827. /**
  70828. * Creates a plane mesh
  70829. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70830. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70831. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70835. * @param name defines the name of the mesh
  70836. * @param options defines the options used to create the mesh
  70837. * @param scene defines the hosting scene
  70838. * @returns the plane mesh
  70839. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70840. */
  70841. static CreatePlane(name: string, options: {
  70842. size?: number;
  70843. width?: number;
  70844. height?: number;
  70845. sideOrientation?: number;
  70846. frontUVs?: Vector4;
  70847. backUVs?: Vector4;
  70848. updatable?: boolean;
  70849. sourcePlane?: Plane;
  70850. }, scene?: Nullable<Scene>): Mesh;
  70851. /**
  70852. * Creates a ground mesh
  70853. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70854. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70856. * @param name defines the name of the mesh
  70857. * @param options defines the options used to create the mesh
  70858. * @param scene defines the hosting scene
  70859. * @returns the ground mesh
  70860. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70861. */
  70862. static CreateGround(name: string, options: {
  70863. width?: number;
  70864. height?: number;
  70865. subdivisions?: number;
  70866. subdivisionsX?: number;
  70867. subdivisionsY?: number;
  70868. updatable?: boolean;
  70869. }, scene?: Nullable<Scene>): Mesh;
  70870. /**
  70871. * Creates a tiled ground mesh
  70872. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70873. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70874. * * 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
  70875. * * 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
  70876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70877. * @param name defines the name of the mesh
  70878. * @param options defines the options used to create the mesh
  70879. * @param scene defines the hosting scene
  70880. * @returns the tiled ground mesh
  70881. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70882. */
  70883. static CreateTiledGround(name: string, options: {
  70884. xmin: number;
  70885. zmin: number;
  70886. xmax: number;
  70887. zmax: number;
  70888. subdivisions?: {
  70889. w: number;
  70890. h: number;
  70891. };
  70892. precision?: {
  70893. w: number;
  70894. h: number;
  70895. };
  70896. updatable?: boolean;
  70897. }, scene?: Nullable<Scene>): Mesh;
  70898. /**
  70899. * Creates a ground mesh from a height map
  70900. * * The parameter `url` sets the URL of the height map image resource.
  70901. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70902. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70903. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70904. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70905. * * 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.
  70906. * * 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).
  70907. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70909. * @param name defines the name of the mesh
  70910. * @param url defines the url to the height map
  70911. * @param options defines the options used to create the mesh
  70912. * @param scene defines the hosting scene
  70913. * @returns the ground mesh
  70914. * @see https://doc.babylonjs.com/babylon101/height_map
  70915. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70916. */
  70917. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70918. width?: number;
  70919. height?: number;
  70920. subdivisions?: number;
  70921. minHeight?: number;
  70922. maxHeight?: number;
  70923. colorFilter?: Color3;
  70924. alphaFilter?: number;
  70925. updatable?: boolean;
  70926. onReady?: (mesh: GroundMesh) => void;
  70927. }, scene?: Nullable<Scene>): GroundMesh;
  70928. /**
  70929. * Creates a polygon mesh
  70930. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70931. * * 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
  70932. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70935. * * Remember you can only change the shape positions, not their number when updating a polygon
  70936. * @param name defines the name of the mesh
  70937. * @param options defines the options used to create the mesh
  70938. * @param scene defines the hosting scene
  70939. * @param earcutInjection can be used to inject your own earcut reference
  70940. * @returns the polygon mesh
  70941. */
  70942. static CreatePolygon(name: string, options: {
  70943. shape: Vector3[];
  70944. holes?: Vector3[][];
  70945. depth?: number;
  70946. faceUV?: Vector4[];
  70947. faceColors?: Color4[];
  70948. updatable?: boolean;
  70949. sideOrientation?: number;
  70950. frontUVs?: Vector4;
  70951. backUVs?: Vector4;
  70952. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70953. /**
  70954. * Creates an extruded polygon mesh, with depth in the Y direction.
  70955. * * 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)
  70956. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70957. * @param name defines the name of the mesh
  70958. * @param options defines the options used to create the mesh
  70959. * @param scene defines the hosting scene
  70960. * @param earcutInjection can be used to inject your own earcut reference
  70961. * @returns the polygon mesh
  70962. */
  70963. static ExtrudePolygon(name: string, options: {
  70964. shape: Vector3[];
  70965. holes?: Vector3[][];
  70966. depth?: number;
  70967. faceUV?: Vector4[];
  70968. faceColors?: Color4[];
  70969. updatable?: boolean;
  70970. sideOrientation?: number;
  70971. frontUVs?: Vector4;
  70972. backUVs?: Vector4;
  70973. wrap?: boolean;
  70974. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70975. /**
  70976. * Creates a tube mesh.
  70977. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70978. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70979. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70980. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70981. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70982. * * 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)
  70983. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70984. * * 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
  70985. * * 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
  70986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70988. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70990. * @param name defines the name of the mesh
  70991. * @param options defines the options used to create the mesh
  70992. * @param scene defines the hosting scene
  70993. * @returns the tube mesh
  70994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70995. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70996. */
  70997. static CreateTube(name: string, options: {
  70998. path: Vector3[];
  70999. radius?: number;
  71000. tessellation?: number;
  71001. radiusFunction?: {
  71002. (i: number, distance: number): number;
  71003. };
  71004. cap?: number;
  71005. arc?: number;
  71006. updatable?: boolean;
  71007. sideOrientation?: number;
  71008. frontUVs?: Vector4;
  71009. backUVs?: Vector4;
  71010. instance?: Mesh;
  71011. invertUV?: boolean;
  71012. }, scene?: Nullable<Scene>): Mesh;
  71013. /**
  71014. * Creates a polyhedron mesh
  71015. * * 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
  71016. * * The parameter `size` (positive float, default 1) sets the polygon size
  71017. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71018. * * 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`
  71019. * * 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
  71020. * * 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)`)
  71021. * * 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
  71022. * * 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
  71023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71026. * @param name defines the name of the mesh
  71027. * @param options defines the options used to create the mesh
  71028. * @param scene defines the hosting scene
  71029. * @returns the polyhedron mesh
  71030. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71031. */
  71032. static CreatePolyhedron(name: string, options: {
  71033. type?: number;
  71034. size?: number;
  71035. sizeX?: number;
  71036. sizeY?: number;
  71037. sizeZ?: number;
  71038. custom?: any;
  71039. faceUV?: Vector4[];
  71040. faceColors?: Color4[];
  71041. flat?: boolean;
  71042. updatable?: boolean;
  71043. sideOrientation?: number;
  71044. frontUVs?: Vector4;
  71045. backUVs?: Vector4;
  71046. }, scene?: Nullable<Scene>): Mesh;
  71047. /**
  71048. * Creates a decal mesh.
  71049. * 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
  71050. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71051. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71052. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71053. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71054. * @param name defines the name of the mesh
  71055. * @param sourceMesh defines the mesh where the decal must be applied
  71056. * @param options defines the options used to create the mesh
  71057. * @param scene defines the hosting scene
  71058. * @returns the decal mesh
  71059. * @see https://doc.babylonjs.com/how_to/decals
  71060. */
  71061. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71062. position?: Vector3;
  71063. normal?: Vector3;
  71064. size?: Vector3;
  71065. angle?: number;
  71066. }): Mesh;
  71067. /**
  71068. * Creates a Capsule Mesh
  71069. * @param name defines the name of the mesh.
  71070. * @param options the constructors options used to shape the mesh.
  71071. * @param scene defines the scene the mesh is scoped to.
  71072. * @returns the capsule mesh
  71073. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71074. */
  71075. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71076. }
  71077. }
  71078. declare module "babylonjs/Meshes/meshSimplification" {
  71079. import { Mesh } from "babylonjs/Meshes/mesh";
  71080. /**
  71081. * A simplifier interface for future simplification implementations
  71082. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71083. */
  71084. export interface ISimplifier {
  71085. /**
  71086. * Simplification of a given mesh according to the given settings.
  71087. * Since this requires computation, it is assumed that the function runs async.
  71088. * @param settings The settings of the simplification, including quality and distance
  71089. * @param successCallback A callback that will be called after the mesh was simplified.
  71090. * @param errorCallback in case of an error, this callback will be called. optional.
  71091. */
  71092. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71093. }
  71094. /**
  71095. * Expected simplification settings.
  71096. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71097. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71098. */
  71099. export interface ISimplificationSettings {
  71100. /**
  71101. * Gets or sets the expected quality
  71102. */
  71103. quality: number;
  71104. /**
  71105. * Gets or sets the distance when this optimized version should be used
  71106. */
  71107. distance: number;
  71108. /**
  71109. * Gets an already optimized mesh
  71110. */
  71111. optimizeMesh?: boolean;
  71112. }
  71113. /**
  71114. * Class used to specify simplification options
  71115. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71116. */
  71117. export class SimplificationSettings implements ISimplificationSettings {
  71118. /** expected quality */
  71119. quality: number;
  71120. /** distance when this optimized version should be used */
  71121. distance: number;
  71122. /** already optimized mesh */
  71123. optimizeMesh?: boolean | undefined;
  71124. /**
  71125. * Creates a SimplificationSettings
  71126. * @param quality expected quality
  71127. * @param distance distance when this optimized version should be used
  71128. * @param optimizeMesh already optimized mesh
  71129. */
  71130. constructor(
  71131. /** expected quality */
  71132. quality: number,
  71133. /** distance when this optimized version should be used */
  71134. distance: number,
  71135. /** already optimized mesh */
  71136. optimizeMesh?: boolean | undefined);
  71137. }
  71138. /**
  71139. * Interface used to define a simplification task
  71140. */
  71141. export interface ISimplificationTask {
  71142. /**
  71143. * Array of settings
  71144. */
  71145. settings: Array<ISimplificationSettings>;
  71146. /**
  71147. * Simplification type
  71148. */
  71149. simplificationType: SimplificationType;
  71150. /**
  71151. * Mesh to simplify
  71152. */
  71153. mesh: Mesh;
  71154. /**
  71155. * Callback called on success
  71156. */
  71157. successCallback?: () => void;
  71158. /**
  71159. * Defines if parallel processing can be used
  71160. */
  71161. parallelProcessing: boolean;
  71162. }
  71163. /**
  71164. * Queue used to order the simplification tasks
  71165. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71166. */
  71167. export class SimplificationQueue {
  71168. private _simplificationArray;
  71169. /**
  71170. * Gets a boolean indicating that the process is still running
  71171. */
  71172. running: boolean;
  71173. /**
  71174. * Creates a new queue
  71175. */
  71176. constructor();
  71177. /**
  71178. * Adds a new simplification task
  71179. * @param task defines a task to add
  71180. */
  71181. addTask(task: ISimplificationTask): void;
  71182. /**
  71183. * Execute next task
  71184. */
  71185. executeNext(): void;
  71186. /**
  71187. * Execute a simplification task
  71188. * @param task defines the task to run
  71189. */
  71190. runSimplification(task: ISimplificationTask): void;
  71191. private getSimplifier;
  71192. }
  71193. /**
  71194. * The implemented types of simplification
  71195. * At the moment only Quadratic Error Decimation is implemented
  71196. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71197. */
  71198. export enum SimplificationType {
  71199. /** Quadratic error decimation */
  71200. QUADRATIC = 0
  71201. }
  71202. /**
  71203. * An implementation of the Quadratic Error simplification algorithm.
  71204. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71205. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71206. * @author RaananW
  71207. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71208. */
  71209. export class QuadraticErrorSimplification implements ISimplifier {
  71210. private _mesh;
  71211. private triangles;
  71212. private vertices;
  71213. private references;
  71214. private _reconstructedMesh;
  71215. /** Gets or sets the number pf sync interations */
  71216. syncIterations: number;
  71217. /** Gets or sets the aggressiveness of the simplifier */
  71218. aggressiveness: number;
  71219. /** Gets or sets the number of allowed iterations for decimation */
  71220. decimationIterations: number;
  71221. /** Gets or sets the espilon to use for bounding box computation */
  71222. boundingBoxEpsilon: number;
  71223. /**
  71224. * Creates a new QuadraticErrorSimplification
  71225. * @param _mesh defines the target mesh
  71226. */
  71227. constructor(_mesh: Mesh);
  71228. /**
  71229. * Simplification of a given mesh according to the given settings.
  71230. * Since this requires computation, it is assumed that the function runs async.
  71231. * @param settings The settings of the simplification, including quality and distance
  71232. * @param successCallback A callback that will be called after the mesh was simplified.
  71233. */
  71234. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71235. private runDecimation;
  71236. private initWithMesh;
  71237. private init;
  71238. private reconstructMesh;
  71239. private initDecimatedMesh;
  71240. private isFlipped;
  71241. private updateTriangles;
  71242. private identifyBorder;
  71243. private updateMesh;
  71244. private vertexError;
  71245. private calculateError;
  71246. }
  71247. }
  71248. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  71249. import { Scene } from "babylonjs/scene";
  71250. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  71251. import { ISceneComponent } from "babylonjs/sceneComponent";
  71252. module "babylonjs/scene" {
  71253. interface Scene {
  71254. /** @hidden (Backing field) */
  71255. _simplificationQueue: SimplificationQueue;
  71256. /**
  71257. * Gets or sets the simplification queue attached to the scene
  71258. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71259. */
  71260. simplificationQueue: SimplificationQueue;
  71261. }
  71262. }
  71263. module "babylonjs/Meshes/mesh" {
  71264. interface Mesh {
  71265. /**
  71266. * Simplify the mesh according to the given array of settings.
  71267. * Function will return immediately and will simplify async
  71268. * @param settings a collection of simplification settings
  71269. * @param parallelProcessing should all levels calculate parallel or one after the other
  71270. * @param simplificationType the type of simplification to run
  71271. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71272. * @returns the current mesh
  71273. */
  71274. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71275. }
  71276. }
  71277. /**
  71278. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71279. * created in a scene
  71280. */
  71281. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71282. /**
  71283. * The component name helpfull to identify the component in the list of scene components.
  71284. */
  71285. readonly name: string;
  71286. /**
  71287. * The scene the component belongs to.
  71288. */
  71289. scene: Scene;
  71290. /**
  71291. * Creates a new instance of the component for the given scene
  71292. * @param scene Defines the scene to register the component in
  71293. */
  71294. constructor(scene: Scene);
  71295. /**
  71296. * Registers the component in a given scene
  71297. */
  71298. register(): void;
  71299. /**
  71300. * Rebuilds the elements related to this component in case of
  71301. * context lost for instance.
  71302. */
  71303. rebuild(): void;
  71304. /**
  71305. * Disposes the component and the associated ressources
  71306. */
  71307. dispose(): void;
  71308. private _beforeCameraUpdate;
  71309. }
  71310. }
  71311. declare module "babylonjs/Meshes/Builders/index" {
  71312. export * from "babylonjs/Meshes/Builders/boxBuilder";
  71313. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  71314. export * from "babylonjs/Meshes/Builders/discBuilder";
  71315. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  71316. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  71317. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  71318. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  71319. export * from "babylonjs/Meshes/Builders/torusBuilder";
  71320. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  71321. export * from "babylonjs/Meshes/Builders/linesBuilder";
  71322. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  71323. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  71324. export * from "babylonjs/Meshes/Builders/latheBuilder";
  71325. export * from "babylonjs/Meshes/Builders/planeBuilder";
  71326. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  71327. export * from "babylonjs/Meshes/Builders/groundBuilder";
  71328. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  71329. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  71330. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71331. export * from "babylonjs/Meshes/Builders/decalBuilder";
  71332. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71333. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  71334. }
  71335. declare module "babylonjs/Meshes/thinInstanceMesh" {
  71336. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  71337. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  71338. import { Matrix } from "babylonjs/Maths/math.vector";
  71339. module "babylonjs/Meshes/mesh" {
  71340. interface Mesh {
  71341. /**
  71342. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71343. */
  71344. thinInstanceEnablePicking: boolean;
  71345. /**
  71346. * Creates a new thin instance
  71347. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71348. * @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
  71349. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71350. */
  71351. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71352. /**
  71353. * Adds the transformation (matrix) of the current mesh as a thin instance
  71354. * @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
  71355. * @returns the thin instance index number
  71356. */
  71357. thinInstanceAddSelf(refresh: boolean): number;
  71358. /**
  71359. * Registers a custom attribute to be used with thin instances
  71360. * @param kind name of the attribute
  71361. * @param stride size in floats of the attribute
  71362. */
  71363. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71364. /**
  71365. * Sets the matrix of a thin instance
  71366. * @param index index of the thin instance
  71367. * @param matrix matrix to set
  71368. * @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
  71369. */
  71370. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71371. /**
  71372. * Sets the value of a custom attribute for a thin instance
  71373. * @param kind name of the attribute
  71374. * @param index index of the thin instance
  71375. * @param value value to set
  71376. * @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
  71377. */
  71378. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71379. /**
  71380. * 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.
  71381. */
  71382. thinInstanceCount: number;
  71383. /**
  71384. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71385. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71386. * @param buffer buffer to set
  71387. * @param stride size in floats of each value of the buffer
  71388. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71389. */
  71390. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71391. /**
  71392. * Gets the list of world matrices
  71393. * @return an array containing all the world matrices from the thin instances
  71394. */
  71395. thinInstanceGetWorldMatrices(): Matrix[];
  71396. /**
  71397. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71398. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71399. */
  71400. thinInstanceBufferUpdated(kind: string): void;
  71401. /**
  71402. * Applies a partial update to a buffer directly on the GPU
  71403. * 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
  71404. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71405. * @param data the data to set in the GPU buffer
  71406. * @param offset the offset in the GPU buffer where to update the data
  71407. */
  71408. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71409. /**
  71410. * Refreshes the bounding info, taking into account all the thin instances defined
  71411. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71412. */
  71413. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71414. /** @hidden */
  71415. _thinInstanceInitializeUserStorage(): void;
  71416. /** @hidden */
  71417. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71418. /** @hidden */
  71419. _userThinInstanceBuffersStorage: {
  71420. data: {
  71421. [key: string]: Float32Array;
  71422. };
  71423. sizes: {
  71424. [key: string]: number;
  71425. };
  71426. vertexBuffers: {
  71427. [key: string]: Nullable<VertexBuffer>;
  71428. };
  71429. strides: {
  71430. [key: string]: number;
  71431. };
  71432. };
  71433. }
  71434. }
  71435. }
  71436. declare module "babylonjs/Meshes/index" {
  71437. export * from "babylonjs/Meshes/abstractMesh";
  71438. export * from "babylonjs/Meshes/buffer";
  71439. export * from "babylonjs/Meshes/Compression/index";
  71440. export * from "babylonjs/Meshes/csg";
  71441. export * from "babylonjs/Meshes/geometry";
  71442. export * from "babylonjs/Meshes/groundMesh";
  71443. export * from "babylonjs/Meshes/trailMesh";
  71444. export * from "babylonjs/Meshes/instancedMesh";
  71445. export * from "babylonjs/Meshes/linesMesh";
  71446. export * from "babylonjs/Meshes/mesh";
  71447. export * from "babylonjs/Meshes/mesh.vertexData";
  71448. export * from "babylonjs/Meshes/meshBuilder";
  71449. export * from "babylonjs/Meshes/meshSimplification";
  71450. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71451. export * from "babylonjs/Meshes/polygonMesh";
  71452. export * from "babylonjs/Meshes/subMesh";
  71453. export * from "babylonjs/Meshes/meshLODLevel";
  71454. export * from "babylonjs/Meshes/transformNode";
  71455. export * from "babylonjs/Meshes/Builders/index";
  71456. export * from "babylonjs/Meshes/dataBuffer";
  71457. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71458. import "babylonjs/Meshes/thinInstanceMesh";
  71459. export * from "babylonjs/Meshes/thinInstanceMesh";
  71460. }
  71461. declare module "babylonjs/Morph/index" {
  71462. export * from "babylonjs/Morph/morphTarget";
  71463. export * from "babylonjs/Morph/morphTargetManager";
  71464. }
  71465. declare module "babylonjs/Navigation/INavigationEngine" {
  71466. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71467. import { Vector3 } from "babylonjs/Maths/math";
  71468. import { Mesh } from "babylonjs/Meshes/mesh";
  71469. import { Scene } from "babylonjs/scene";
  71470. /**
  71471. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71472. */
  71473. export interface INavigationEnginePlugin {
  71474. /**
  71475. * plugin name
  71476. */
  71477. name: string;
  71478. /**
  71479. * Creates a navigation mesh
  71480. * @param meshes array of all the geometry used to compute the navigatio mesh
  71481. * @param parameters bunch of parameters used to filter geometry
  71482. */
  71483. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71484. /**
  71485. * Create a navigation mesh debug mesh
  71486. * @param scene is where the mesh will be added
  71487. * @returns debug display mesh
  71488. */
  71489. createDebugNavMesh(scene: Scene): Mesh;
  71490. /**
  71491. * Get a navigation mesh constrained position, closest to the parameter position
  71492. * @param position world position
  71493. * @returns the closest point to position constrained by the navigation mesh
  71494. */
  71495. getClosestPoint(position: Vector3): Vector3;
  71496. /**
  71497. * Get a navigation mesh constrained position, closest to the parameter position
  71498. * @param position world position
  71499. * @param result output the closest point to position constrained by the navigation mesh
  71500. */
  71501. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71502. /**
  71503. * Get a navigation mesh constrained position, within a particular radius
  71504. * @param position world position
  71505. * @param maxRadius the maximum distance to the constrained world position
  71506. * @returns the closest point to position constrained by the navigation mesh
  71507. */
  71508. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71509. /**
  71510. * Get a navigation mesh constrained position, within a particular radius
  71511. * @param position world position
  71512. * @param maxRadius the maximum distance to the constrained world position
  71513. * @param result output the closest point to position constrained by the navigation mesh
  71514. */
  71515. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71516. /**
  71517. * Compute the final position from a segment made of destination-position
  71518. * @param position world position
  71519. * @param destination world position
  71520. * @returns the resulting point along the navmesh
  71521. */
  71522. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71523. /**
  71524. * Compute the final position from a segment made of destination-position
  71525. * @param position world position
  71526. * @param destination world position
  71527. * @param result output the resulting point along the navmesh
  71528. */
  71529. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71530. /**
  71531. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71532. * @param start world position
  71533. * @param end world position
  71534. * @returns array containing world position composing the path
  71535. */
  71536. computePath(start: Vector3, end: Vector3): Vector3[];
  71537. /**
  71538. * If this plugin is supported
  71539. * @returns true if plugin is supported
  71540. */
  71541. isSupported(): boolean;
  71542. /**
  71543. * Create a new Crowd so you can add agents
  71544. * @param maxAgents the maximum agent count in the crowd
  71545. * @param maxAgentRadius the maximum radius an agent can have
  71546. * @param scene to attach the crowd to
  71547. * @returns the crowd you can add agents to
  71548. */
  71549. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71550. /**
  71551. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71552. * The queries will try to find a solution within those bounds
  71553. * default is (1,1,1)
  71554. * @param extent x,y,z value that define the extent around the queries point of reference
  71555. */
  71556. setDefaultQueryExtent(extent: Vector3): void;
  71557. /**
  71558. * Get the Bounding box extent specified by setDefaultQueryExtent
  71559. * @returns the box extent values
  71560. */
  71561. getDefaultQueryExtent(): Vector3;
  71562. /**
  71563. * build the navmesh from a previously saved state using getNavmeshData
  71564. * @param data the Uint8Array returned by getNavmeshData
  71565. */
  71566. buildFromNavmeshData(data: Uint8Array): void;
  71567. /**
  71568. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71569. * @returns data the Uint8Array that can be saved and reused
  71570. */
  71571. getNavmeshData(): Uint8Array;
  71572. /**
  71573. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71574. * @param result output the box extent values
  71575. */
  71576. getDefaultQueryExtentToRef(result: Vector3): void;
  71577. /**
  71578. * Release all resources
  71579. */
  71580. dispose(): void;
  71581. }
  71582. /**
  71583. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71584. */
  71585. export interface ICrowd {
  71586. /**
  71587. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71588. * You can attach anything to that node. The node position is updated in the scene update tick.
  71589. * @param pos world position that will be constrained by the navigation mesh
  71590. * @param parameters agent parameters
  71591. * @param transform hooked to the agent that will be update by the scene
  71592. * @returns agent index
  71593. */
  71594. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71595. /**
  71596. * Returns the agent position in world space
  71597. * @param index agent index returned by addAgent
  71598. * @returns world space position
  71599. */
  71600. getAgentPosition(index: number): Vector3;
  71601. /**
  71602. * Gets the agent position result in world space
  71603. * @param index agent index returned by addAgent
  71604. * @param result output world space position
  71605. */
  71606. getAgentPositionToRef(index: number, result: Vector3): void;
  71607. /**
  71608. * Gets the agent velocity in world space
  71609. * @param index agent index returned by addAgent
  71610. * @returns world space velocity
  71611. */
  71612. getAgentVelocity(index: number): Vector3;
  71613. /**
  71614. * Gets the agent velocity result in world space
  71615. * @param index agent index returned by addAgent
  71616. * @param result output world space velocity
  71617. */
  71618. getAgentVelocityToRef(index: number, result: Vector3): void;
  71619. /**
  71620. * Gets the agent next target point on the path
  71621. * @param index agent index returned by addAgent
  71622. * @returns world space position
  71623. */
  71624. getAgentNextTargetPath(index: number): Vector3;
  71625. /**
  71626. * Gets the agent state
  71627. * @param index agent index returned by addAgent
  71628. * @returns agent state
  71629. */
  71630. getAgentState(index: number): number;
  71631. /**
  71632. * returns true if the agent in over an off mesh link connection
  71633. * @param index agent index returned by addAgent
  71634. * @returns true if over an off mesh link connection
  71635. */
  71636. overOffmeshConnection(index: number): boolean;
  71637. /**
  71638. * Gets the agent next target point on the path
  71639. * @param index agent index returned by addAgent
  71640. * @param result output world space position
  71641. */
  71642. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71643. /**
  71644. * remove a particular agent previously created
  71645. * @param index agent index returned by addAgent
  71646. */
  71647. removeAgent(index: number): void;
  71648. /**
  71649. * get the list of all agents attached to this crowd
  71650. * @returns list of agent indices
  71651. */
  71652. getAgents(): number[];
  71653. /**
  71654. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71655. * @param deltaTime in seconds
  71656. */
  71657. update(deltaTime: number): void;
  71658. /**
  71659. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71660. * @param index agent index returned by addAgent
  71661. * @param destination targeted world position
  71662. */
  71663. agentGoto(index: number, destination: Vector3): void;
  71664. /**
  71665. * Teleport the agent to a new position
  71666. * @param index agent index returned by addAgent
  71667. * @param destination targeted world position
  71668. */
  71669. agentTeleport(index: number, destination: Vector3): void;
  71670. /**
  71671. * Update agent parameters
  71672. * @param index agent index returned by addAgent
  71673. * @param parameters agent parameters
  71674. */
  71675. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71676. /**
  71677. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71678. * The queries will try to find a solution within those bounds
  71679. * default is (1,1,1)
  71680. * @param extent x,y,z value that define the extent around the queries point of reference
  71681. */
  71682. setDefaultQueryExtent(extent: Vector3): void;
  71683. /**
  71684. * Get the Bounding box extent specified by setDefaultQueryExtent
  71685. * @returns the box extent values
  71686. */
  71687. getDefaultQueryExtent(): Vector3;
  71688. /**
  71689. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71690. * @param result output the box extent values
  71691. */
  71692. getDefaultQueryExtentToRef(result: Vector3): void;
  71693. /**
  71694. * Release all resources
  71695. */
  71696. dispose(): void;
  71697. }
  71698. /**
  71699. * Configures an agent
  71700. */
  71701. export interface IAgentParameters {
  71702. /**
  71703. * Agent radius. [Limit: >= 0]
  71704. */
  71705. radius: number;
  71706. /**
  71707. * Agent height. [Limit: > 0]
  71708. */
  71709. height: number;
  71710. /**
  71711. * Maximum allowed acceleration. [Limit: >= 0]
  71712. */
  71713. maxAcceleration: number;
  71714. /**
  71715. * Maximum allowed speed. [Limit: >= 0]
  71716. */
  71717. maxSpeed: number;
  71718. /**
  71719. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71720. */
  71721. collisionQueryRange: number;
  71722. /**
  71723. * The path visibility optimization range. [Limit: > 0]
  71724. */
  71725. pathOptimizationRange: number;
  71726. /**
  71727. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71728. */
  71729. separationWeight: number;
  71730. }
  71731. /**
  71732. * Configures the navigation mesh creation
  71733. */
  71734. export interface INavMeshParameters {
  71735. /**
  71736. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71737. */
  71738. cs: number;
  71739. /**
  71740. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71741. */
  71742. ch: number;
  71743. /**
  71744. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71745. */
  71746. walkableSlopeAngle: number;
  71747. /**
  71748. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71749. * be considered walkable. [Limit: >= 3] [Units: vx]
  71750. */
  71751. walkableHeight: number;
  71752. /**
  71753. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71754. */
  71755. walkableClimb: number;
  71756. /**
  71757. * The distance to erode/shrink the walkable area of the heightfield away from
  71758. * obstructions. [Limit: >=0] [Units: vx]
  71759. */
  71760. walkableRadius: number;
  71761. /**
  71762. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71763. */
  71764. maxEdgeLen: number;
  71765. /**
  71766. * The maximum distance a simplfied contour's border edges should deviate
  71767. * the original raw contour. [Limit: >=0] [Units: vx]
  71768. */
  71769. maxSimplificationError: number;
  71770. /**
  71771. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71772. */
  71773. minRegionArea: number;
  71774. /**
  71775. * Any regions with a span count smaller than this value will, if possible,
  71776. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71777. */
  71778. mergeRegionArea: number;
  71779. /**
  71780. * The maximum number of vertices allowed for polygons generated during the
  71781. * contour to polygon conversion process. [Limit: >= 3]
  71782. */
  71783. maxVertsPerPoly: number;
  71784. /**
  71785. * Sets the sampling distance to use when generating the detail mesh.
  71786. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71787. */
  71788. detailSampleDist: number;
  71789. /**
  71790. * The maximum distance the detail mesh surface should deviate from heightfield
  71791. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71792. */
  71793. detailSampleMaxError: number;
  71794. }
  71795. }
  71796. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71797. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71798. import { Mesh } from "babylonjs/Meshes/mesh";
  71799. import { Scene } from "babylonjs/scene";
  71800. import { Vector3 } from "babylonjs/Maths/math";
  71801. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71802. /**
  71803. * RecastJS navigation plugin
  71804. */
  71805. export class RecastJSPlugin implements INavigationEnginePlugin {
  71806. /**
  71807. * Reference to the Recast library
  71808. */
  71809. bjsRECAST: any;
  71810. /**
  71811. * plugin name
  71812. */
  71813. name: string;
  71814. /**
  71815. * the first navmesh created. We might extend this to support multiple navmeshes
  71816. */
  71817. navMesh: any;
  71818. /**
  71819. * Initializes the recastJS plugin
  71820. * @param recastInjection can be used to inject your own recast reference
  71821. */
  71822. constructor(recastInjection?: any);
  71823. /**
  71824. * Creates a navigation mesh
  71825. * @param meshes array of all the geometry used to compute the navigatio mesh
  71826. * @param parameters bunch of parameters used to filter geometry
  71827. */
  71828. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71829. /**
  71830. * Create a navigation mesh debug mesh
  71831. * @param scene is where the mesh will be added
  71832. * @returns debug display mesh
  71833. */
  71834. createDebugNavMesh(scene: Scene): Mesh;
  71835. /**
  71836. * Get a navigation mesh constrained position, closest to the parameter position
  71837. * @param position world position
  71838. * @returns the closest point to position constrained by the navigation mesh
  71839. */
  71840. getClosestPoint(position: Vector3): Vector3;
  71841. /**
  71842. * Get a navigation mesh constrained position, closest to the parameter position
  71843. * @param position world position
  71844. * @param result output the closest point to position constrained by the navigation mesh
  71845. */
  71846. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71847. /**
  71848. * Get a navigation mesh constrained position, within a particular radius
  71849. * @param position world position
  71850. * @param maxRadius the maximum distance to the constrained world position
  71851. * @returns the closest point to position constrained by the navigation mesh
  71852. */
  71853. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71854. /**
  71855. * Get a navigation mesh constrained position, within a particular radius
  71856. * @param position world position
  71857. * @param maxRadius the maximum distance to the constrained world position
  71858. * @param result output the closest point to position constrained by the navigation mesh
  71859. */
  71860. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71861. /**
  71862. * Compute the final position from a segment made of destination-position
  71863. * @param position world position
  71864. * @param destination world position
  71865. * @returns the resulting point along the navmesh
  71866. */
  71867. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71868. /**
  71869. * Compute the final position from a segment made of destination-position
  71870. * @param position world position
  71871. * @param destination world position
  71872. * @param result output the resulting point along the navmesh
  71873. */
  71874. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71875. /**
  71876. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71877. * @param start world position
  71878. * @param end world position
  71879. * @returns array containing world position composing the path
  71880. */
  71881. computePath(start: Vector3, end: Vector3): Vector3[];
  71882. /**
  71883. * Create a new Crowd so you can add agents
  71884. * @param maxAgents the maximum agent count in the crowd
  71885. * @param maxAgentRadius the maximum radius an agent can have
  71886. * @param scene to attach the crowd to
  71887. * @returns the crowd you can add agents to
  71888. */
  71889. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71890. /**
  71891. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71892. * The queries will try to find a solution within those bounds
  71893. * default is (1,1,1)
  71894. * @param extent x,y,z value that define the extent around the queries point of reference
  71895. */
  71896. setDefaultQueryExtent(extent: Vector3): void;
  71897. /**
  71898. * Get the Bounding box extent specified by setDefaultQueryExtent
  71899. * @returns the box extent values
  71900. */
  71901. getDefaultQueryExtent(): Vector3;
  71902. /**
  71903. * build the navmesh from a previously saved state using getNavmeshData
  71904. * @param data the Uint8Array returned by getNavmeshData
  71905. */
  71906. buildFromNavmeshData(data: Uint8Array): void;
  71907. /**
  71908. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71909. * @returns data the Uint8Array that can be saved and reused
  71910. */
  71911. getNavmeshData(): Uint8Array;
  71912. /**
  71913. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71914. * @param result output the box extent values
  71915. */
  71916. getDefaultQueryExtentToRef(result: Vector3): void;
  71917. /**
  71918. * Disposes
  71919. */
  71920. dispose(): void;
  71921. /**
  71922. * If this plugin is supported
  71923. * @returns true if plugin is supported
  71924. */
  71925. isSupported(): boolean;
  71926. }
  71927. /**
  71928. * Recast detour crowd implementation
  71929. */
  71930. export class RecastJSCrowd implements ICrowd {
  71931. /**
  71932. * Recast/detour plugin
  71933. */
  71934. bjsRECASTPlugin: RecastJSPlugin;
  71935. /**
  71936. * Link to the detour crowd
  71937. */
  71938. recastCrowd: any;
  71939. /**
  71940. * One transform per agent
  71941. */
  71942. transforms: TransformNode[];
  71943. /**
  71944. * All agents created
  71945. */
  71946. agents: number[];
  71947. /**
  71948. * Link to the scene is kept to unregister the crowd from the scene
  71949. */
  71950. private _scene;
  71951. /**
  71952. * Observer for crowd updates
  71953. */
  71954. private _onBeforeAnimationsObserver;
  71955. /**
  71956. * Constructor
  71957. * @param plugin recastJS plugin
  71958. * @param maxAgents the maximum agent count in the crowd
  71959. * @param maxAgentRadius the maximum radius an agent can have
  71960. * @param scene to attach the crowd to
  71961. * @returns the crowd you can add agents to
  71962. */
  71963. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71964. /**
  71965. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71966. * You can attach anything to that node. The node position is updated in the scene update tick.
  71967. * @param pos world position that will be constrained by the navigation mesh
  71968. * @param parameters agent parameters
  71969. * @param transform hooked to the agent that will be update by the scene
  71970. * @returns agent index
  71971. */
  71972. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71973. /**
  71974. * Returns the agent position in world space
  71975. * @param index agent index returned by addAgent
  71976. * @returns world space position
  71977. */
  71978. getAgentPosition(index: number): Vector3;
  71979. /**
  71980. * Returns the agent position result in world space
  71981. * @param index agent index returned by addAgent
  71982. * @param result output world space position
  71983. */
  71984. getAgentPositionToRef(index: number, result: Vector3): void;
  71985. /**
  71986. * Returns the agent velocity in world space
  71987. * @param index agent index returned by addAgent
  71988. * @returns world space velocity
  71989. */
  71990. getAgentVelocity(index: number): Vector3;
  71991. /**
  71992. * Returns the agent velocity result in world space
  71993. * @param index agent index returned by addAgent
  71994. * @param result output world space velocity
  71995. */
  71996. getAgentVelocityToRef(index: number, result: Vector3): void;
  71997. /**
  71998. * Returns the agent next target point on the path
  71999. * @param index agent index returned by addAgent
  72000. * @returns world space position
  72001. */
  72002. getAgentNextTargetPath(index: number): Vector3;
  72003. /**
  72004. * Returns the agent next target point on the path
  72005. * @param index agent index returned by addAgent
  72006. * @param result output world space position
  72007. */
  72008. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72009. /**
  72010. * Gets the agent state
  72011. * @param index agent index returned by addAgent
  72012. * @returns agent state
  72013. */
  72014. getAgentState(index: number): number;
  72015. /**
  72016. * returns true if the agent in over an off mesh link connection
  72017. * @param index agent index returned by addAgent
  72018. * @returns true if over an off mesh link connection
  72019. */
  72020. overOffmeshConnection(index: number): boolean;
  72021. /**
  72022. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72023. * @param index agent index returned by addAgent
  72024. * @param destination targeted world position
  72025. */
  72026. agentGoto(index: number, destination: Vector3): void;
  72027. /**
  72028. * Teleport the agent to a new position
  72029. * @param index agent index returned by addAgent
  72030. * @param destination targeted world position
  72031. */
  72032. agentTeleport(index: number, destination: Vector3): void;
  72033. /**
  72034. * Update agent parameters
  72035. * @param index agent index returned by addAgent
  72036. * @param parameters agent parameters
  72037. */
  72038. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72039. /**
  72040. * remove a particular agent previously created
  72041. * @param index agent index returned by addAgent
  72042. */
  72043. removeAgent(index: number): void;
  72044. /**
  72045. * get the list of all agents attached to this crowd
  72046. * @returns list of agent indices
  72047. */
  72048. getAgents(): number[];
  72049. /**
  72050. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72051. * @param deltaTime in seconds
  72052. */
  72053. update(deltaTime: number): void;
  72054. /**
  72055. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72056. * The queries will try to find a solution within those bounds
  72057. * default is (1,1,1)
  72058. * @param extent x,y,z value that define the extent around the queries point of reference
  72059. */
  72060. setDefaultQueryExtent(extent: Vector3): void;
  72061. /**
  72062. * Get the Bounding box extent specified by setDefaultQueryExtent
  72063. * @returns the box extent values
  72064. */
  72065. getDefaultQueryExtent(): Vector3;
  72066. /**
  72067. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72068. * @param result output the box extent values
  72069. */
  72070. getDefaultQueryExtentToRef(result: Vector3): void;
  72071. /**
  72072. * Release all resources
  72073. */
  72074. dispose(): void;
  72075. }
  72076. }
  72077. declare module "babylonjs/Navigation/Plugins/index" {
  72078. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  72079. }
  72080. declare module "babylonjs/Navigation/index" {
  72081. export * from "babylonjs/Navigation/INavigationEngine";
  72082. export * from "babylonjs/Navigation/Plugins/index";
  72083. }
  72084. declare module "babylonjs/Offline/database" {
  72085. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  72086. /**
  72087. * Class used to enable access to IndexedDB
  72088. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72089. */
  72090. export class Database implements IOfflineProvider {
  72091. private _callbackManifestChecked;
  72092. private _currentSceneUrl;
  72093. private _db;
  72094. private _enableSceneOffline;
  72095. private _enableTexturesOffline;
  72096. private _manifestVersionFound;
  72097. private _mustUpdateRessources;
  72098. private _hasReachedQuota;
  72099. private _isSupported;
  72100. private _idbFactory;
  72101. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72102. private static IsUASupportingBlobStorage;
  72103. /**
  72104. * Gets a boolean indicating if Database storate is enabled (off by default)
  72105. */
  72106. static IDBStorageEnabled: boolean;
  72107. /**
  72108. * Gets a boolean indicating if scene must be saved in the database
  72109. */
  72110. get enableSceneOffline(): boolean;
  72111. /**
  72112. * Gets a boolean indicating if textures must be saved in the database
  72113. */
  72114. get enableTexturesOffline(): boolean;
  72115. /**
  72116. * Creates a new Database
  72117. * @param urlToScene defines the url to load the scene
  72118. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72119. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72120. */
  72121. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72122. private static _ParseURL;
  72123. private static _ReturnFullUrlLocation;
  72124. private _checkManifestFile;
  72125. /**
  72126. * Open the database and make it available
  72127. * @param successCallback defines the callback to call on success
  72128. * @param errorCallback defines the callback to call on error
  72129. */
  72130. open(successCallback: () => void, errorCallback: () => void): void;
  72131. /**
  72132. * Loads an image from the database
  72133. * @param url defines the url to load from
  72134. * @param image defines the target DOM image
  72135. */
  72136. loadImage(url: string, image: HTMLImageElement): void;
  72137. private _loadImageFromDBAsync;
  72138. private _saveImageIntoDBAsync;
  72139. private _checkVersionFromDB;
  72140. private _loadVersionFromDBAsync;
  72141. private _saveVersionIntoDBAsync;
  72142. /**
  72143. * Loads a file from database
  72144. * @param url defines the URL to load from
  72145. * @param sceneLoaded defines a callback to call on success
  72146. * @param progressCallBack defines a callback to call when progress changed
  72147. * @param errorCallback defines a callback to call on error
  72148. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72149. */
  72150. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72151. private _loadFileAsync;
  72152. private _saveFileAsync;
  72153. /**
  72154. * Validates if xhr data is correct
  72155. * @param xhr defines the request to validate
  72156. * @param dataType defines the expected data type
  72157. * @returns true if data is correct
  72158. */
  72159. private static _ValidateXHRData;
  72160. }
  72161. }
  72162. declare module "babylonjs/Offline/index" {
  72163. export * from "babylonjs/Offline/database";
  72164. export * from "babylonjs/Offline/IOfflineProvider";
  72165. }
  72166. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  72167. /** @hidden */
  72168. export var gpuUpdateParticlesPixelShader: {
  72169. name: string;
  72170. shader: string;
  72171. };
  72172. }
  72173. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  72174. /** @hidden */
  72175. export var gpuUpdateParticlesVertexShader: {
  72176. name: string;
  72177. shader: string;
  72178. };
  72179. }
  72180. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  72181. /** @hidden */
  72182. export var clipPlaneFragmentDeclaration2: {
  72183. name: string;
  72184. shader: string;
  72185. };
  72186. }
  72187. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  72188. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  72189. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  72190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72191. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  72192. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  72193. /** @hidden */
  72194. export var gpuRenderParticlesPixelShader: {
  72195. name: string;
  72196. shader: string;
  72197. };
  72198. }
  72199. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  72200. /** @hidden */
  72201. export var clipPlaneVertexDeclaration2: {
  72202. name: string;
  72203. shader: string;
  72204. };
  72205. }
  72206. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  72207. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  72208. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  72209. /** @hidden */
  72210. export var gpuRenderParticlesVertexShader: {
  72211. name: string;
  72212. shader: string;
  72213. };
  72214. }
  72215. declare module "babylonjs/Particles/gpuParticleSystem" {
  72216. import { Nullable } from "babylonjs/types";
  72217. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  72218. import { Observable } from "babylonjs/Misc/observable";
  72219. import { Matrix } from "babylonjs/Maths/math.vector";
  72220. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  72221. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72222. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  72223. import { IDisposable } from "babylonjs/scene";
  72224. import { Effect } from "babylonjs/Materials/effect";
  72225. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72226. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72227. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  72228. import { Scene } from "babylonjs/scene";
  72229. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  72230. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  72231. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  72232. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  72233. /**
  72234. * This represents a GPU particle system in Babylon
  72235. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72236. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72237. */
  72238. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72239. /**
  72240. * The layer mask we are rendering the particles through.
  72241. */
  72242. layerMask: number;
  72243. private _capacity;
  72244. private _activeCount;
  72245. private _currentActiveCount;
  72246. private _accumulatedCount;
  72247. private _renderEffect;
  72248. private _updateEffect;
  72249. private _buffer0;
  72250. private _buffer1;
  72251. private _spriteBuffer;
  72252. private _updateVAO;
  72253. private _renderVAO;
  72254. private _targetIndex;
  72255. private _sourceBuffer;
  72256. private _targetBuffer;
  72257. private _currentRenderId;
  72258. private _started;
  72259. private _stopped;
  72260. private _timeDelta;
  72261. private _randomTexture;
  72262. private _randomTexture2;
  72263. private _attributesStrideSize;
  72264. private _updateEffectOptions;
  72265. private _randomTextureSize;
  72266. private _actualFrame;
  72267. private _customEffect;
  72268. private readonly _rawTextureWidth;
  72269. /**
  72270. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72271. */
  72272. static get IsSupported(): boolean;
  72273. /**
  72274. * An event triggered when the system is disposed.
  72275. */
  72276. onDisposeObservable: Observable<IParticleSystem>;
  72277. /**
  72278. * An event triggered when the system is stopped
  72279. */
  72280. onStoppedObservable: Observable<IParticleSystem>;
  72281. /**
  72282. * Gets the maximum number of particles active at the same time.
  72283. * @returns The max number of active particles.
  72284. */
  72285. getCapacity(): number;
  72286. /**
  72287. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72288. * to override the particles.
  72289. */
  72290. forceDepthWrite: boolean;
  72291. /**
  72292. * Gets or set the number of active particles
  72293. */
  72294. get activeParticleCount(): number;
  72295. set activeParticleCount(value: number);
  72296. private _preWarmDone;
  72297. /**
  72298. * Specifies if the particles are updated in emitter local space or world space.
  72299. */
  72300. isLocal: boolean;
  72301. /** Gets or sets a matrix to use to compute projection */
  72302. defaultProjectionMatrix: Matrix;
  72303. /**
  72304. * Is this system ready to be used/rendered
  72305. * @return true if the system is ready
  72306. */
  72307. isReady(): boolean;
  72308. /**
  72309. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72310. * @returns True if it has been started, otherwise false.
  72311. */
  72312. isStarted(): boolean;
  72313. /**
  72314. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72315. * @returns True if it has been stopped, otherwise false.
  72316. */
  72317. isStopped(): boolean;
  72318. /**
  72319. * Gets a boolean indicating that the system is stopping
  72320. * @returns true if the system is currently stopping
  72321. */
  72322. isStopping(): boolean;
  72323. /**
  72324. * Gets the number of particles active at the same time.
  72325. * @returns The number of active particles.
  72326. */
  72327. getActiveCount(): number;
  72328. /**
  72329. * Starts the particle system and begins to emit
  72330. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72331. */
  72332. start(delay?: number): void;
  72333. /**
  72334. * Stops the particle system.
  72335. */
  72336. stop(): void;
  72337. /**
  72338. * Remove all active particles
  72339. */
  72340. reset(): void;
  72341. /**
  72342. * Returns the string "GPUParticleSystem"
  72343. * @returns a string containing the class name
  72344. */
  72345. getClassName(): string;
  72346. /**
  72347. * Gets the custom effect used to render the particles
  72348. * @param blendMode Blend mode for which the effect should be retrieved
  72349. * @returns The effect
  72350. */
  72351. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72352. /**
  72353. * Sets the custom effect used to render the particles
  72354. * @param effect The effect to set
  72355. * @param blendMode Blend mode for which the effect should be set
  72356. */
  72357. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72358. /** @hidden */
  72359. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72360. /**
  72361. * Observable that will be called just before the particles are drawn
  72362. */
  72363. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72364. /**
  72365. * Gets the name of the particle vertex shader
  72366. */
  72367. get vertexShaderName(): string;
  72368. private _colorGradientsTexture;
  72369. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72370. /**
  72371. * Adds a new color gradient
  72372. * @param gradient defines the gradient to use (between 0 and 1)
  72373. * @param color1 defines the color to affect to the specified gradient
  72374. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72375. * @returns the current particle system
  72376. */
  72377. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72378. private _refreshColorGradient;
  72379. /** Force the system to rebuild all gradients that need to be resync */
  72380. forceRefreshGradients(): void;
  72381. /**
  72382. * Remove a specific color gradient
  72383. * @param gradient defines the gradient to remove
  72384. * @returns the current particle system
  72385. */
  72386. removeColorGradient(gradient: number): GPUParticleSystem;
  72387. private _angularSpeedGradientsTexture;
  72388. private _sizeGradientsTexture;
  72389. private _velocityGradientsTexture;
  72390. private _limitVelocityGradientsTexture;
  72391. private _dragGradientsTexture;
  72392. private _addFactorGradient;
  72393. /**
  72394. * Adds a new size gradient
  72395. * @param gradient defines the gradient to use (between 0 and 1)
  72396. * @param factor defines the size factor to affect to the specified gradient
  72397. * @returns the current particle system
  72398. */
  72399. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72400. /**
  72401. * Remove a specific size gradient
  72402. * @param gradient defines the gradient to remove
  72403. * @returns the current particle system
  72404. */
  72405. removeSizeGradient(gradient: number): GPUParticleSystem;
  72406. private _refreshFactorGradient;
  72407. /**
  72408. * Adds a new angular speed gradient
  72409. * @param gradient defines the gradient to use (between 0 and 1)
  72410. * @param factor defines the angular speed to affect to the specified gradient
  72411. * @returns the current particle system
  72412. */
  72413. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72414. /**
  72415. * Remove a specific angular speed gradient
  72416. * @param gradient defines the gradient to remove
  72417. * @returns the current particle system
  72418. */
  72419. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72420. /**
  72421. * Adds a new velocity gradient
  72422. * @param gradient defines the gradient to use (between 0 and 1)
  72423. * @param factor defines the velocity to affect to the specified gradient
  72424. * @returns the current particle system
  72425. */
  72426. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72427. /**
  72428. * Remove a specific velocity gradient
  72429. * @param gradient defines the gradient to remove
  72430. * @returns the current particle system
  72431. */
  72432. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72433. /**
  72434. * Adds a new limit velocity gradient
  72435. * @param gradient defines the gradient to use (between 0 and 1)
  72436. * @param factor defines the limit velocity value to affect to the specified gradient
  72437. * @returns the current particle system
  72438. */
  72439. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72440. /**
  72441. * Remove a specific limit velocity gradient
  72442. * @param gradient defines the gradient to remove
  72443. * @returns the current particle system
  72444. */
  72445. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72446. /**
  72447. * Adds a new drag gradient
  72448. * @param gradient defines the gradient to use (between 0 and 1)
  72449. * @param factor defines the drag value to affect to the specified gradient
  72450. * @returns the current particle system
  72451. */
  72452. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72453. /**
  72454. * Remove a specific drag gradient
  72455. * @param gradient defines the gradient to remove
  72456. * @returns the current particle system
  72457. */
  72458. removeDragGradient(gradient: number): GPUParticleSystem;
  72459. /**
  72460. * Not supported by GPUParticleSystem
  72461. * @param gradient defines the gradient to use (between 0 and 1)
  72462. * @param factor defines the emit rate value to affect to the specified gradient
  72463. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72464. * @returns the current particle system
  72465. */
  72466. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72467. /**
  72468. * Not supported by GPUParticleSystem
  72469. * @param gradient defines the gradient to remove
  72470. * @returns the current particle system
  72471. */
  72472. removeEmitRateGradient(gradient: number): IParticleSystem;
  72473. /**
  72474. * Not supported by GPUParticleSystem
  72475. * @param gradient defines the gradient to use (between 0 and 1)
  72476. * @param factor defines the start size value to affect to the specified gradient
  72477. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72478. * @returns the current particle system
  72479. */
  72480. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72481. /**
  72482. * Not supported by GPUParticleSystem
  72483. * @param gradient defines the gradient to remove
  72484. * @returns the current particle system
  72485. */
  72486. removeStartSizeGradient(gradient: number): IParticleSystem;
  72487. /**
  72488. * Not supported by GPUParticleSystem
  72489. * @param gradient defines the gradient to use (between 0 and 1)
  72490. * @param min defines the color remap minimal range
  72491. * @param max defines the color remap maximal range
  72492. * @returns the current particle system
  72493. */
  72494. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72495. /**
  72496. * Not supported by GPUParticleSystem
  72497. * @param gradient defines the gradient to remove
  72498. * @returns the current particle system
  72499. */
  72500. removeColorRemapGradient(): IParticleSystem;
  72501. /**
  72502. * Not supported by GPUParticleSystem
  72503. * @param gradient defines the gradient to use (between 0 and 1)
  72504. * @param min defines the alpha remap minimal range
  72505. * @param max defines the alpha remap maximal range
  72506. * @returns the current particle system
  72507. */
  72508. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72509. /**
  72510. * Not supported by GPUParticleSystem
  72511. * @param gradient defines the gradient to remove
  72512. * @returns the current particle system
  72513. */
  72514. removeAlphaRemapGradient(): IParticleSystem;
  72515. /**
  72516. * Not supported by GPUParticleSystem
  72517. * @param gradient defines the gradient to use (between 0 and 1)
  72518. * @param color defines the color to affect to the specified gradient
  72519. * @returns the current particle system
  72520. */
  72521. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72522. /**
  72523. * Not supported by GPUParticleSystem
  72524. * @param gradient defines the gradient to remove
  72525. * @returns the current particle system
  72526. */
  72527. removeRampGradient(): IParticleSystem;
  72528. /**
  72529. * Not supported by GPUParticleSystem
  72530. * @returns the list of ramp gradients
  72531. */
  72532. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72533. /**
  72534. * Not supported by GPUParticleSystem
  72535. * Gets or sets a boolean indicating that ramp gradients must be used
  72536. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72537. */
  72538. get useRampGradients(): boolean;
  72539. set useRampGradients(value: boolean);
  72540. /**
  72541. * Not supported by GPUParticleSystem
  72542. * @param gradient defines the gradient to use (between 0 and 1)
  72543. * @param factor defines the life time factor to affect to the specified gradient
  72544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72545. * @returns the current particle system
  72546. */
  72547. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72548. /**
  72549. * Not supported by GPUParticleSystem
  72550. * @param gradient defines the gradient to remove
  72551. * @returns the current particle system
  72552. */
  72553. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72554. /**
  72555. * Instantiates a GPU particle system.
  72556. * 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.
  72557. * @param name The name of the particle system
  72558. * @param options The options used to create the system
  72559. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72560. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72561. * @param customEffect a custom effect used to change the way particles are rendered by default
  72562. */
  72563. constructor(name: string, options: Partial<{
  72564. capacity: number;
  72565. randomTextureSize: number;
  72566. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72567. protected _reset(): void;
  72568. private _createUpdateVAO;
  72569. private _createRenderVAO;
  72570. private _initialize;
  72571. /** @hidden */
  72572. _recreateUpdateEffect(): void;
  72573. private _getEffect;
  72574. /**
  72575. * Fill the defines array according to the current settings of the particle system
  72576. * @param defines Array to be updated
  72577. * @param blendMode blend mode to take into account when updating the array
  72578. */
  72579. fillDefines(defines: Array<string>, blendMode?: number): void;
  72580. /**
  72581. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72582. * @param uniforms Uniforms array to fill
  72583. * @param attributes Attributes array to fill
  72584. * @param samplers Samplers array to fill
  72585. */
  72586. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72587. /** @hidden */
  72588. _recreateRenderEffect(): Effect;
  72589. /**
  72590. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72591. * @param preWarm defines if we are in the pre-warmimg phase
  72592. */
  72593. animate(preWarm?: boolean): void;
  72594. private _createFactorGradientTexture;
  72595. private _createSizeGradientTexture;
  72596. private _createAngularSpeedGradientTexture;
  72597. private _createVelocityGradientTexture;
  72598. private _createLimitVelocityGradientTexture;
  72599. private _createDragGradientTexture;
  72600. private _createColorGradientTexture;
  72601. /**
  72602. * Renders the particle system in its current state
  72603. * @param preWarm defines if the system should only update the particles but not render them
  72604. * @returns the current number of particles
  72605. */
  72606. render(preWarm?: boolean): number;
  72607. /**
  72608. * Rebuilds the particle system
  72609. */
  72610. rebuild(): void;
  72611. private _releaseBuffers;
  72612. private _releaseVAOs;
  72613. /**
  72614. * Disposes the particle system and free the associated resources
  72615. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72616. */
  72617. dispose(disposeTexture?: boolean): void;
  72618. /**
  72619. * Clones the particle system.
  72620. * @param name The name of the cloned object
  72621. * @param newEmitter The new emitter to use
  72622. * @returns the cloned particle system
  72623. */
  72624. clone(name: string, newEmitter: any): GPUParticleSystem;
  72625. /**
  72626. * Serializes the particle system to a JSON object
  72627. * @param serializeTexture defines if the texture must be serialized as well
  72628. * @returns the JSON object
  72629. */
  72630. serialize(serializeTexture?: boolean): any;
  72631. /**
  72632. * Parses a JSON object to create a GPU particle system.
  72633. * @param parsedParticleSystem The JSON object to parse
  72634. * @param sceneOrEngine The scene or the engine to create the particle system in
  72635. * @param rootUrl The root url to use to load external dependencies like texture
  72636. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72637. * @returns the parsed GPU particle system
  72638. */
  72639. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72640. }
  72641. }
  72642. declare module "babylonjs/Particles/particleSystemSet" {
  72643. import { Nullable } from "babylonjs/types";
  72644. import { Color3 } from "babylonjs/Maths/math.color";
  72645. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72647. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72648. import { Scene, IDisposable } from "babylonjs/scene";
  72649. /**
  72650. * Represents a set of particle systems working together to create a specific effect
  72651. */
  72652. export class ParticleSystemSet implements IDisposable {
  72653. /**
  72654. * Gets or sets base Assets URL
  72655. */
  72656. static BaseAssetsUrl: string;
  72657. private _emitterCreationOptions;
  72658. private _emitterNode;
  72659. /**
  72660. * Gets the particle system list
  72661. */
  72662. systems: IParticleSystem[];
  72663. /**
  72664. * Gets the emitter node used with this set
  72665. */
  72666. get emitterNode(): Nullable<TransformNode>;
  72667. /**
  72668. * Creates a new emitter mesh as a sphere
  72669. * @param options defines the options used to create the sphere
  72670. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72671. * @param scene defines the hosting scene
  72672. */
  72673. setEmitterAsSphere(options: {
  72674. diameter: number;
  72675. segments: number;
  72676. color: Color3;
  72677. }, renderingGroupId: number, scene: Scene): void;
  72678. /**
  72679. * Starts all particle systems of the set
  72680. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72681. */
  72682. start(emitter?: AbstractMesh): void;
  72683. /**
  72684. * Release all associated resources
  72685. */
  72686. dispose(): void;
  72687. /**
  72688. * Serialize the set into a JSON compatible object
  72689. * @param serializeTexture defines if the texture must be serialized as well
  72690. * @returns a JSON compatible representation of the set
  72691. */
  72692. serialize(serializeTexture?: boolean): any;
  72693. /**
  72694. * Parse a new ParticleSystemSet from a serialized source
  72695. * @param data defines a JSON compatible representation of the set
  72696. * @param scene defines the hosting scene
  72697. * @param gpu defines if we want GPU particles or CPU particles
  72698. * @returns a new ParticleSystemSet
  72699. */
  72700. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72701. }
  72702. }
  72703. declare module "babylonjs/Particles/particleHelper" {
  72704. import { Nullable } from "babylonjs/types";
  72705. import { Scene } from "babylonjs/scene";
  72706. import { Vector3 } from "babylonjs/Maths/math.vector";
  72707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72708. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72709. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72710. /**
  72711. * This class is made for on one-liner static method to help creating particle system set.
  72712. */
  72713. export class ParticleHelper {
  72714. /**
  72715. * Gets or sets base Assets URL
  72716. */
  72717. static BaseAssetsUrl: string;
  72718. /** Define the Url to load snippets */
  72719. static SnippetUrl: string;
  72720. /**
  72721. * Create a default particle system that you can tweak
  72722. * @param emitter defines the emitter to use
  72723. * @param capacity defines the system capacity (default is 500 particles)
  72724. * @param scene defines the hosting scene
  72725. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72726. * @returns the new Particle system
  72727. */
  72728. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72729. /**
  72730. * This is the main static method (one-liner) of this helper to create different particle systems
  72731. * @param type This string represents the type to the particle system to create
  72732. * @param scene The scene where the particle system should live
  72733. * @param gpu If the system will use gpu
  72734. * @returns the ParticleSystemSet created
  72735. */
  72736. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72737. /**
  72738. * Static function used to export a particle system to a ParticleSystemSet variable.
  72739. * Please note that the emitter shape is not exported
  72740. * @param systems defines the particle systems to export
  72741. * @returns the created particle system set
  72742. */
  72743. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72744. /**
  72745. * Creates a particle system from a snippet saved in a remote file
  72746. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72747. * @param url defines the url to load from
  72748. * @param scene defines the hosting scene
  72749. * @param gpu If the system will use gpu
  72750. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72751. * @returns a promise that will resolve to the new particle system
  72752. */
  72753. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72754. /**
  72755. * Creates a particle system from a snippet saved by the particle system editor
  72756. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72757. * @param scene defines the hosting scene
  72758. * @param gpu If the system will use gpu
  72759. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72760. * @returns a promise that will resolve to the new particle system
  72761. */
  72762. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72763. }
  72764. }
  72765. declare module "babylonjs/Particles/particleSystemComponent" {
  72766. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72767. import { Effect } from "babylonjs/Materials/effect";
  72768. import "babylonjs/Shaders/particles.vertex";
  72769. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72770. module "babylonjs/Engines/engine" {
  72771. interface Engine {
  72772. /**
  72773. * Create an effect to use with particle systems.
  72774. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72775. * the particle system for which you want to create a custom effect in the last parameter
  72776. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72777. * @param uniformsNames defines a list of attribute names
  72778. * @param samplers defines an array of string used to represent textures
  72779. * @param defines defines the string containing the defines to use to compile the shaders
  72780. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72781. * @param onCompiled defines a function to call when the effect creation is successful
  72782. * @param onError defines a function to call when the effect creation has failed
  72783. * @param particleSystem the particle system you want to create the effect for
  72784. * @returns the new Effect
  72785. */
  72786. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72787. }
  72788. }
  72789. module "babylonjs/Meshes/mesh" {
  72790. interface Mesh {
  72791. /**
  72792. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72793. * @returns an array of IParticleSystem
  72794. */
  72795. getEmittedParticleSystems(): IParticleSystem[];
  72796. /**
  72797. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72798. * @returns an array of IParticleSystem
  72799. */
  72800. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72801. }
  72802. }
  72803. }
  72804. declare module "babylonjs/Particles/pointsCloudSystem" {
  72805. import { Color4 } from "babylonjs/Maths/math";
  72806. import { Mesh } from "babylonjs/Meshes/mesh";
  72807. import { Scene, IDisposable } from "babylonjs/scene";
  72808. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  72809. /** Defines the 4 color options */
  72810. export enum PointColor {
  72811. /** color value */
  72812. Color = 2,
  72813. /** uv value */
  72814. UV = 1,
  72815. /** random value */
  72816. Random = 0,
  72817. /** stated value */
  72818. Stated = 3
  72819. }
  72820. /**
  72821. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72822. * 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.
  72823. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72824. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72825. *
  72826. * Full documentation here : TO BE ENTERED
  72827. */
  72828. export class PointsCloudSystem implements IDisposable {
  72829. /**
  72830. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72831. * Example : var p = SPS.particles[i];
  72832. */
  72833. particles: CloudPoint[];
  72834. /**
  72835. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72836. */
  72837. nbParticles: number;
  72838. /**
  72839. * This a counter for your own usage. It's not set by any SPS functions.
  72840. */
  72841. counter: number;
  72842. /**
  72843. * The PCS name. This name is also given to the underlying mesh.
  72844. */
  72845. name: string;
  72846. /**
  72847. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72848. */
  72849. mesh: Mesh;
  72850. /**
  72851. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72852. * Please read :
  72853. */
  72854. vars: any;
  72855. /**
  72856. * @hidden
  72857. */
  72858. _size: number;
  72859. private _scene;
  72860. private _promises;
  72861. private _positions;
  72862. private _indices;
  72863. private _normals;
  72864. private _colors;
  72865. private _uvs;
  72866. private _indices32;
  72867. private _positions32;
  72868. private _colors32;
  72869. private _uvs32;
  72870. private _updatable;
  72871. private _isVisibilityBoxLocked;
  72872. private _alwaysVisible;
  72873. private _groups;
  72874. private _groupCounter;
  72875. private _computeParticleColor;
  72876. private _computeParticleTexture;
  72877. private _computeParticleRotation;
  72878. private _computeBoundingBox;
  72879. private _isReady;
  72880. /**
  72881. * Creates a PCS (Points Cloud System) object
  72882. * @param name (String) is the PCS name, this will be the underlying mesh name
  72883. * @param pointSize (number) is the size for each point
  72884. * @param scene (Scene) is the scene in which the PCS is added
  72885. * @param options defines the options of the PCS e.g.
  72886. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72887. */
  72888. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72889. updatable?: boolean;
  72890. });
  72891. /**
  72892. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72893. * If no points were added to the PCS, the returned mesh is just a single point.
  72894. * @returns a promise for the created mesh
  72895. */
  72896. buildMeshAsync(): Promise<Mesh>;
  72897. /**
  72898. * @hidden
  72899. */
  72900. private _buildMesh;
  72901. private _addParticle;
  72902. private _randomUnitVector;
  72903. private _getColorIndicesForCoord;
  72904. private _setPointsColorOrUV;
  72905. private _colorFromTexture;
  72906. private _calculateDensity;
  72907. /**
  72908. * Adds points to the PCS in random positions within a unit sphere
  72909. * @param nb (positive integer) the number of particles to be created from this model
  72910. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72911. * @returns the number of groups in the system
  72912. */
  72913. addPoints(nb: number, pointFunction?: any): number;
  72914. /**
  72915. * Adds points to the PCS from the surface of the model shape
  72916. * @param mesh is any Mesh object that will be used as a surface model for the points
  72917. * @param nb (positive integer) the number of particles to be created from this model
  72918. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72919. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72920. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72921. * @returns the number of groups in the system
  72922. */
  72923. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72924. /**
  72925. * Adds points to the PCS inside the model shape
  72926. * @param mesh is any Mesh object that will be used as a surface model for the points
  72927. * @param nb (positive integer) the number of particles to be created from this model
  72928. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72929. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72930. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72931. * @returns the number of groups in the system
  72932. */
  72933. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72934. /**
  72935. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72936. * This method calls `updateParticle()` for each particle of the SPS.
  72937. * For an animated SPS, it is usually called within the render loop.
  72938. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72939. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72940. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72941. * @returns the PCS.
  72942. */
  72943. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72944. /**
  72945. * Disposes the PCS.
  72946. */
  72947. dispose(): void;
  72948. /**
  72949. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72950. * doc :
  72951. * @returns the PCS.
  72952. */
  72953. refreshVisibleSize(): PointsCloudSystem;
  72954. /**
  72955. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72956. * @param size the size (float) of the visibility box
  72957. * note : this doesn't lock the PCS mesh bounding box.
  72958. * doc :
  72959. */
  72960. setVisibilityBox(size: number): void;
  72961. /**
  72962. * Gets whether the PCS is always visible or not
  72963. * doc :
  72964. */
  72965. get isAlwaysVisible(): boolean;
  72966. /**
  72967. * Sets the PCS as always visible or not
  72968. * doc :
  72969. */
  72970. set isAlwaysVisible(val: boolean);
  72971. /**
  72972. * Tells to `setParticles()` to compute the particle rotations or not
  72973. * Default value : false. The PCS is faster when it's set to false
  72974. * Note : particle rotations are only applied to parent particles
  72975. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72976. */
  72977. set computeParticleRotation(val: boolean);
  72978. /**
  72979. * Tells to `setParticles()` to compute the particle colors or not.
  72980. * Default value : true. The PCS is faster when it's set to false.
  72981. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72982. */
  72983. set computeParticleColor(val: boolean);
  72984. set computeParticleTexture(val: boolean);
  72985. /**
  72986. * Gets if `setParticles()` computes the particle colors or not.
  72987. * Default value : false. The PCS is faster when it's set to false.
  72988. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72989. */
  72990. get computeParticleColor(): boolean;
  72991. /**
  72992. * Gets if `setParticles()` computes the particle textures or not.
  72993. * Default value : false. The PCS is faster when it's set to false.
  72994. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72995. */
  72996. get computeParticleTexture(): boolean;
  72997. /**
  72998. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72999. */
  73000. set computeBoundingBox(val: boolean);
  73001. /**
  73002. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73003. */
  73004. get computeBoundingBox(): boolean;
  73005. /**
  73006. * This function does nothing. It may be overwritten to set all the particle first values.
  73007. * The PCS doesn't call this function, you may have to call it by your own.
  73008. * doc :
  73009. */
  73010. initParticles(): void;
  73011. /**
  73012. * This function does nothing. It may be overwritten to recycle a particle
  73013. * The PCS doesn't call this function, you can to call it
  73014. * doc :
  73015. * @param particle The particle to recycle
  73016. * @returns the recycled particle
  73017. */
  73018. recycleParticle(particle: CloudPoint): CloudPoint;
  73019. /**
  73020. * Updates a particle : this function should be overwritten by the user.
  73021. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73022. * doc :
  73023. * @example : just set a particle position or velocity and recycle conditions
  73024. * @param particle The particle to update
  73025. * @returns the updated particle
  73026. */
  73027. updateParticle(particle: CloudPoint): CloudPoint;
  73028. /**
  73029. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73030. * This does nothing and may be overwritten by the user.
  73031. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73032. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73033. * @param update the boolean update value actually passed to setParticles()
  73034. */
  73035. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73036. /**
  73037. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73038. * This will be passed three parameters.
  73039. * This does nothing and may be overwritten by the user.
  73040. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73041. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73042. * @param update the boolean update value actually passed to setParticles()
  73043. */
  73044. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73045. }
  73046. }
  73047. declare module "babylonjs/Particles/cloudPoint" {
  73048. import { Nullable } from "babylonjs/types";
  73049. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  73050. import { Mesh } from "babylonjs/Meshes/mesh";
  73051. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  73052. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  73053. /**
  73054. * Represents one particle of a points cloud system.
  73055. */
  73056. export class CloudPoint {
  73057. /**
  73058. * particle global index
  73059. */
  73060. idx: number;
  73061. /**
  73062. * The color of the particle
  73063. */
  73064. color: Nullable<Color4>;
  73065. /**
  73066. * The world space position of the particle.
  73067. */
  73068. position: Vector3;
  73069. /**
  73070. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73071. */
  73072. rotation: Vector3;
  73073. /**
  73074. * The world space rotation quaternion of the particle.
  73075. */
  73076. rotationQuaternion: Nullable<Quaternion>;
  73077. /**
  73078. * The uv of the particle.
  73079. */
  73080. uv: Nullable<Vector2>;
  73081. /**
  73082. * The current speed of the particle.
  73083. */
  73084. velocity: Vector3;
  73085. /**
  73086. * The pivot point in the particle local space.
  73087. */
  73088. pivot: Vector3;
  73089. /**
  73090. * Must the particle be translated from its pivot point in its local space ?
  73091. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73092. * Default : false
  73093. */
  73094. translateFromPivot: boolean;
  73095. /**
  73096. * Index of this particle in the global "positions" array (Internal use)
  73097. * @hidden
  73098. */
  73099. _pos: number;
  73100. /**
  73101. * @hidden Index of this particle in the global "indices" array (Internal use)
  73102. */
  73103. _ind: number;
  73104. /**
  73105. * Group this particle belongs to
  73106. */
  73107. _group: PointsGroup;
  73108. /**
  73109. * Group id of this particle
  73110. */
  73111. groupId: number;
  73112. /**
  73113. * Index of the particle in its group id (Internal use)
  73114. */
  73115. idxInGroup: number;
  73116. /**
  73117. * @hidden Particle BoundingInfo object (Internal use)
  73118. */
  73119. _boundingInfo: BoundingInfo;
  73120. /**
  73121. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73122. */
  73123. _pcs: PointsCloudSystem;
  73124. /**
  73125. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73126. */
  73127. _stillInvisible: boolean;
  73128. /**
  73129. * @hidden Last computed particle rotation matrix
  73130. */
  73131. _rotationMatrix: number[];
  73132. /**
  73133. * Parent particle Id, if any.
  73134. * Default null.
  73135. */
  73136. parentId: Nullable<number>;
  73137. /**
  73138. * @hidden Internal global position in the PCS.
  73139. */
  73140. _globalPosition: Vector3;
  73141. /**
  73142. * Creates a Point Cloud object.
  73143. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73144. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73145. * @param group (PointsGroup) is the group the particle belongs to
  73146. * @param groupId (integer) is the group identifier in the PCS.
  73147. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73148. * @param pcs defines the PCS it is associated to
  73149. */
  73150. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73151. /**
  73152. * get point size
  73153. */
  73154. get size(): Vector3;
  73155. /**
  73156. * Set point size
  73157. */
  73158. set size(scale: Vector3);
  73159. /**
  73160. * Legacy support, changed quaternion to rotationQuaternion
  73161. */
  73162. get quaternion(): Nullable<Quaternion>;
  73163. /**
  73164. * Legacy support, changed quaternion to rotationQuaternion
  73165. */
  73166. set quaternion(q: Nullable<Quaternion>);
  73167. /**
  73168. * Returns a boolean. True if the particle intersects a mesh, else false
  73169. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73170. * @param target is the object (point or mesh) what the intersection is computed against
  73171. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  73172. * @returns true if it intersects
  73173. */
  73174. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73175. /**
  73176. * get the rotation matrix of the particle
  73177. * @hidden
  73178. */
  73179. getRotationMatrix(m: Matrix): void;
  73180. }
  73181. /**
  73182. * Represents a group of points in a points cloud system
  73183. * * PCS internal tool, don't use it manually.
  73184. */
  73185. export class PointsGroup {
  73186. /**
  73187. * The group id
  73188. * @hidden
  73189. */
  73190. groupID: number;
  73191. /**
  73192. * image data for group (internal use)
  73193. * @hidden
  73194. */
  73195. _groupImageData: Nullable<ArrayBufferView>;
  73196. /**
  73197. * Image Width (internal use)
  73198. * @hidden
  73199. */
  73200. _groupImgWidth: number;
  73201. /**
  73202. * Image Height (internal use)
  73203. * @hidden
  73204. */
  73205. _groupImgHeight: number;
  73206. /**
  73207. * Custom position function (internal use)
  73208. * @hidden
  73209. */
  73210. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73211. /**
  73212. * density per facet for surface points
  73213. * @hidden
  73214. */
  73215. _groupDensity: number[];
  73216. /**
  73217. * Only when points are colored by texture carries pointer to texture list array
  73218. * @hidden
  73219. */
  73220. _textureNb: number;
  73221. /**
  73222. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73223. * PCS internal tool, don't use it manually.
  73224. * @hidden
  73225. */
  73226. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73227. }
  73228. }
  73229. declare module "babylonjs/Particles/index" {
  73230. export * from "babylonjs/Particles/baseParticleSystem";
  73231. export * from "babylonjs/Particles/EmitterTypes/index";
  73232. export * from "babylonjs/Particles/gpuParticleSystem";
  73233. export * from "babylonjs/Particles/IParticleSystem";
  73234. export * from "babylonjs/Particles/particle";
  73235. export * from "babylonjs/Particles/particleHelper";
  73236. export * from "babylonjs/Particles/particleSystem";
  73237. import "babylonjs/Particles/particleSystemComponent";
  73238. export * from "babylonjs/Particles/particleSystemComponent";
  73239. export * from "babylonjs/Particles/particleSystemSet";
  73240. export * from "babylonjs/Particles/solidParticle";
  73241. export * from "babylonjs/Particles/solidParticleSystem";
  73242. export * from "babylonjs/Particles/cloudPoint";
  73243. export * from "babylonjs/Particles/pointsCloudSystem";
  73244. export * from "babylonjs/Particles/subEmitter";
  73245. }
  73246. declare module "babylonjs/Physics/physicsEngineComponent" {
  73247. import { Nullable } from "babylonjs/types";
  73248. import { Observable, Observer } from "babylonjs/Misc/observable";
  73249. import { Vector3 } from "babylonjs/Maths/math.vector";
  73250. import { Mesh } from "babylonjs/Meshes/mesh";
  73251. import { ISceneComponent } from "babylonjs/sceneComponent";
  73252. import { Scene } from "babylonjs/scene";
  73253. import { Node } from "babylonjs/node";
  73254. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  73255. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73256. module "babylonjs/scene" {
  73257. interface Scene {
  73258. /** @hidden (Backing field) */
  73259. _physicsEngine: Nullable<IPhysicsEngine>;
  73260. /** @hidden */
  73261. _physicsTimeAccumulator: number;
  73262. /**
  73263. * Gets the current physics engine
  73264. * @returns a IPhysicsEngine or null if none attached
  73265. */
  73266. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73267. /**
  73268. * Enables physics to the current scene
  73269. * @param gravity defines the scene's gravity for the physics engine
  73270. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73271. * @return a boolean indicating if the physics engine was initialized
  73272. */
  73273. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73274. /**
  73275. * Disables and disposes the physics engine associated with the scene
  73276. */
  73277. disablePhysicsEngine(): void;
  73278. /**
  73279. * Gets a boolean indicating if there is an active physics engine
  73280. * @returns a boolean indicating if there is an active physics engine
  73281. */
  73282. isPhysicsEnabled(): boolean;
  73283. /**
  73284. * Deletes a physics compound impostor
  73285. * @param compound defines the compound to delete
  73286. */
  73287. deleteCompoundImpostor(compound: any): void;
  73288. /**
  73289. * An event triggered when physic simulation is about to be run
  73290. */
  73291. onBeforePhysicsObservable: Observable<Scene>;
  73292. /**
  73293. * An event triggered when physic simulation has been done
  73294. */
  73295. onAfterPhysicsObservable: Observable<Scene>;
  73296. }
  73297. }
  73298. module "babylonjs/Meshes/abstractMesh" {
  73299. interface AbstractMesh {
  73300. /** @hidden */
  73301. _physicsImpostor: Nullable<PhysicsImpostor>;
  73302. /**
  73303. * Gets or sets impostor used for physic simulation
  73304. * @see https://doc.babylonjs.com/features/physics_engine
  73305. */
  73306. physicsImpostor: Nullable<PhysicsImpostor>;
  73307. /**
  73308. * Gets the current physics impostor
  73309. * @see https://doc.babylonjs.com/features/physics_engine
  73310. * @returns a physics impostor or null
  73311. */
  73312. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73313. /** Apply a physic impulse to the mesh
  73314. * @param force defines the force to apply
  73315. * @param contactPoint defines where to apply the force
  73316. * @returns the current mesh
  73317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73318. */
  73319. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73320. /**
  73321. * Creates a physic joint between two meshes
  73322. * @param otherMesh defines the other mesh to use
  73323. * @param pivot1 defines the pivot to use on this mesh
  73324. * @param pivot2 defines the pivot to use on the other mesh
  73325. * @param options defines additional options (can be plugin dependent)
  73326. * @returns the current mesh
  73327. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73328. */
  73329. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73330. /** @hidden */
  73331. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73332. }
  73333. }
  73334. /**
  73335. * Defines the physics engine scene component responsible to manage a physics engine
  73336. */
  73337. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73338. /**
  73339. * The component name helpful to identify the component in the list of scene components.
  73340. */
  73341. readonly name: string;
  73342. /**
  73343. * The scene the component belongs to.
  73344. */
  73345. scene: Scene;
  73346. /**
  73347. * Creates a new instance of the component for the given scene
  73348. * @param scene Defines the scene to register the component in
  73349. */
  73350. constructor(scene: Scene);
  73351. /**
  73352. * Registers the component in a given scene
  73353. */
  73354. register(): void;
  73355. /**
  73356. * Rebuilds the elements related to this component in case of
  73357. * context lost for instance.
  73358. */
  73359. rebuild(): void;
  73360. /**
  73361. * Disposes the component and the associated ressources
  73362. */
  73363. dispose(): void;
  73364. }
  73365. }
  73366. declare module "babylonjs/Physics/physicsHelper" {
  73367. import { Nullable } from "babylonjs/types";
  73368. import { Vector3 } from "babylonjs/Maths/math.vector";
  73369. import { Mesh } from "babylonjs/Meshes/mesh";
  73370. import { Scene } from "babylonjs/scene";
  73371. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73372. /**
  73373. * A helper for physics simulations
  73374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73375. */
  73376. export class PhysicsHelper {
  73377. private _scene;
  73378. private _physicsEngine;
  73379. /**
  73380. * Initializes the Physics helper
  73381. * @param scene Babylon.js scene
  73382. */
  73383. constructor(scene: Scene);
  73384. /**
  73385. * Applies a radial explosion impulse
  73386. * @param origin the origin of the explosion
  73387. * @param radiusOrEventOptions the radius or the options of radial explosion
  73388. * @param strength the explosion strength
  73389. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73390. * @returns A physics radial explosion event, or null
  73391. */
  73392. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73393. /**
  73394. * Applies a radial explosion force
  73395. * @param origin the origin of the explosion
  73396. * @param radiusOrEventOptions the radius or the options of radial explosion
  73397. * @param strength the explosion strength
  73398. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73399. * @returns A physics radial explosion event, or null
  73400. */
  73401. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73402. /**
  73403. * Creates a gravitational field
  73404. * @param origin the origin of the explosion
  73405. * @param radiusOrEventOptions the radius or the options of radial explosion
  73406. * @param strength the explosion strength
  73407. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73408. * @returns A physics gravitational field event, or null
  73409. */
  73410. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73411. /**
  73412. * Creates a physics updraft event
  73413. * @param origin the origin of the updraft
  73414. * @param radiusOrEventOptions the radius or the options of the updraft
  73415. * @param strength the strength of the updraft
  73416. * @param height the height of the updraft
  73417. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73418. * @returns A physics updraft event, or null
  73419. */
  73420. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73421. /**
  73422. * Creates a physics vortex event
  73423. * @param origin the of the vortex
  73424. * @param radiusOrEventOptions the radius or the options of the vortex
  73425. * @param strength the strength of the vortex
  73426. * @param height the height of the vortex
  73427. * @returns a Physics vortex event, or null
  73428. * A physics vortex event or null
  73429. */
  73430. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73431. }
  73432. /**
  73433. * Represents a physics radial explosion event
  73434. */
  73435. class PhysicsRadialExplosionEvent {
  73436. private _scene;
  73437. private _options;
  73438. private _sphere;
  73439. private _dataFetched;
  73440. /**
  73441. * Initializes a radial explosioin event
  73442. * @param _scene BabylonJS scene
  73443. * @param _options The options for the vortex event
  73444. */
  73445. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73446. /**
  73447. * Returns the data related to the radial explosion event (sphere).
  73448. * @returns The radial explosion event data
  73449. */
  73450. getData(): PhysicsRadialExplosionEventData;
  73451. /**
  73452. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73453. * @param impostor A physics imposter
  73454. * @param origin the origin of the explosion
  73455. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73456. */
  73457. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73458. /**
  73459. * Triggers affecterd impostors callbacks
  73460. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73461. */
  73462. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73463. /**
  73464. * Disposes the sphere.
  73465. * @param force Specifies if the sphere should be disposed by force
  73466. */
  73467. dispose(force?: boolean): void;
  73468. /*** Helpers ***/
  73469. private _prepareSphere;
  73470. private _intersectsWithSphere;
  73471. }
  73472. /**
  73473. * Represents a gravitational field event
  73474. */
  73475. class PhysicsGravitationalFieldEvent {
  73476. private _physicsHelper;
  73477. private _scene;
  73478. private _origin;
  73479. private _options;
  73480. private _tickCallback;
  73481. private _sphere;
  73482. private _dataFetched;
  73483. /**
  73484. * Initializes the physics gravitational field event
  73485. * @param _physicsHelper A physics helper
  73486. * @param _scene BabylonJS scene
  73487. * @param _origin The origin position of the gravitational field event
  73488. * @param _options The options for the vortex event
  73489. */
  73490. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73491. /**
  73492. * Returns the data related to the gravitational field event (sphere).
  73493. * @returns A gravitational field event
  73494. */
  73495. getData(): PhysicsGravitationalFieldEventData;
  73496. /**
  73497. * Enables the gravitational field.
  73498. */
  73499. enable(): void;
  73500. /**
  73501. * Disables the gravitational field.
  73502. */
  73503. disable(): void;
  73504. /**
  73505. * Disposes the sphere.
  73506. * @param force The force to dispose from the gravitational field event
  73507. */
  73508. dispose(force?: boolean): void;
  73509. private _tick;
  73510. }
  73511. /**
  73512. * Represents a physics updraft event
  73513. */
  73514. class PhysicsUpdraftEvent {
  73515. private _scene;
  73516. private _origin;
  73517. private _options;
  73518. private _physicsEngine;
  73519. private _originTop;
  73520. private _originDirection;
  73521. private _tickCallback;
  73522. private _cylinder;
  73523. private _cylinderPosition;
  73524. private _dataFetched;
  73525. /**
  73526. * Initializes the physics updraft event
  73527. * @param _scene BabylonJS scene
  73528. * @param _origin The origin position of the updraft
  73529. * @param _options The options for the updraft event
  73530. */
  73531. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73532. /**
  73533. * Returns the data related to the updraft event (cylinder).
  73534. * @returns A physics updraft event
  73535. */
  73536. getData(): PhysicsUpdraftEventData;
  73537. /**
  73538. * Enables the updraft.
  73539. */
  73540. enable(): void;
  73541. /**
  73542. * Disables the updraft.
  73543. */
  73544. disable(): void;
  73545. /**
  73546. * Disposes the cylinder.
  73547. * @param force Specifies if the updraft should be disposed by force
  73548. */
  73549. dispose(force?: boolean): void;
  73550. private getImpostorHitData;
  73551. private _tick;
  73552. /*** Helpers ***/
  73553. private _prepareCylinder;
  73554. private _intersectsWithCylinder;
  73555. }
  73556. /**
  73557. * Represents a physics vortex event
  73558. */
  73559. class PhysicsVortexEvent {
  73560. private _scene;
  73561. private _origin;
  73562. private _options;
  73563. private _physicsEngine;
  73564. private _originTop;
  73565. private _tickCallback;
  73566. private _cylinder;
  73567. private _cylinderPosition;
  73568. private _dataFetched;
  73569. /**
  73570. * Initializes the physics vortex event
  73571. * @param _scene The BabylonJS scene
  73572. * @param _origin The origin position of the vortex
  73573. * @param _options The options for the vortex event
  73574. */
  73575. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73576. /**
  73577. * Returns the data related to the vortex event (cylinder).
  73578. * @returns The physics vortex event data
  73579. */
  73580. getData(): PhysicsVortexEventData;
  73581. /**
  73582. * Enables the vortex.
  73583. */
  73584. enable(): void;
  73585. /**
  73586. * Disables the cortex.
  73587. */
  73588. disable(): void;
  73589. /**
  73590. * Disposes the sphere.
  73591. * @param force
  73592. */
  73593. dispose(force?: boolean): void;
  73594. private getImpostorHitData;
  73595. private _tick;
  73596. /*** Helpers ***/
  73597. private _prepareCylinder;
  73598. private _intersectsWithCylinder;
  73599. }
  73600. /**
  73601. * Options fot the radial explosion event
  73602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73603. */
  73604. export class PhysicsRadialExplosionEventOptions {
  73605. /**
  73606. * The radius of the sphere for the radial explosion.
  73607. */
  73608. radius: number;
  73609. /**
  73610. * The strenth of the explosion.
  73611. */
  73612. strength: number;
  73613. /**
  73614. * The strenght of the force in correspondence to the distance of the affected object
  73615. */
  73616. falloff: PhysicsRadialImpulseFalloff;
  73617. /**
  73618. * Sphere options for the radial explosion.
  73619. */
  73620. sphere: {
  73621. segments: number;
  73622. diameter: number;
  73623. };
  73624. /**
  73625. * Sphere options for the radial explosion.
  73626. */
  73627. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73628. }
  73629. /**
  73630. * Options fot the updraft event
  73631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73632. */
  73633. export class PhysicsUpdraftEventOptions {
  73634. /**
  73635. * The radius of the cylinder for the vortex
  73636. */
  73637. radius: number;
  73638. /**
  73639. * The strenth of the updraft.
  73640. */
  73641. strength: number;
  73642. /**
  73643. * The height of the cylinder for the updraft.
  73644. */
  73645. height: number;
  73646. /**
  73647. * The mode for the the updraft.
  73648. */
  73649. updraftMode: PhysicsUpdraftMode;
  73650. }
  73651. /**
  73652. * Options fot the vortex event
  73653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73654. */
  73655. export class PhysicsVortexEventOptions {
  73656. /**
  73657. * The radius of the cylinder for the vortex
  73658. */
  73659. radius: number;
  73660. /**
  73661. * The strenth of the vortex.
  73662. */
  73663. strength: number;
  73664. /**
  73665. * The height of the cylinder for the vortex.
  73666. */
  73667. height: number;
  73668. /**
  73669. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73670. */
  73671. centripetalForceThreshold: number;
  73672. /**
  73673. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73674. */
  73675. centripetalForceMultiplier: number;
  73676. /**
  73677. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73678. */
  73679. centrifugalForceMultiplier: number;
  73680. /**
  73681. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73682. */
  73683. updraftForceMultiplier: number;
  73684. }
  73685. /**
  73686. * The strenght of the force in correspondence to the distance of the affected object
  73687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73688. */
  73689. export enum PhysicsRadialImpulseFalloff {
  73690. /** Defines that impulse is constant in strength across it's whole radius */
  73691. Constant = 0,
  73692. /** Defines that impulse gets weaker if it's further from the origin */
  73693. Linear = 1
  73694. }
  73695. /**
  73696. * The strength of the force in correspondence to the distance of the affected object
  73697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73698. */
  73699. export enum PhysicsUpdraftMode {
  73700. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73701. Center = 0,
  73702. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73703. Perpendicular = 1
  73704. }
  73705. /**
  73706. * Interface for a physics hit data
  73707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73708. */
  73709. export interface PhysicsHitData {
  73710. /**
  73711. * The force applied at the contact point
  73712. */
  73713. force: Vector3;
  73714. /**
  73715. * The contact point
  73716. */
  73717. contactPoint: Vector3;
  73718. /**
  73719. * The distance from the origin to the contact point
  73720. */
  73721. distanceFromOrigin: number;
  73722. }
  73723. /**
  73724. * Interface for radial explosion event data
  73725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73726. */
  73727. export interface PhysicsRadialExplosionEventData {
  73728. /**
  73729. * A sphere used for the radial explosion event
  73730. */
  73731. sphere: Mesh;
  73732. }
  73733. /**
  73734. * Interface for gravitational field event data
  73735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73736. */
  73737. export interface PhysicsGravitationalFieldEventData {
  73738. /**
  73739. * A sphere mesh used for the gravitational field event
  73740. */
  73741. sphere: Mesh;
  73742. }
  73743. /**
  73744. * Interface for updraft event data
  73745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73746. */
  73747. export interface PhysicsUpdraftEventData {
  73748. /**
  73749. * A cylinder used for the updraft event
  73750. */
  73751. cylinder: Mesh;
  73752. }
  73753. /**
  73754. * Interface for vortex event data
  73755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73756. */
  73757. export interface PhysicsVortexEventData {
  73758. /**
  73759. * A cylinder used for the vortex event
  73760. */
  73761. cylinder: Mesh;
  73762. }
  73763. /**
  73764. * Interface for an affected physics impostor
  73765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73766. */
  73767. export interface PhysicsAffectedImpostorWithData {
  73768. /**
  73769. * The impostor affected by the effect
  73770. */
  73771. impostor: PhysicsImpostor;
  73772. /**
  73773. * The data about the hit/horce from the explosion
  73774. */
  73775. hitData: PhysicsHitData;
  73776. }
  73777. }
  73778. declare module "babylonjs/Physics/Plugins/index" {
  73779. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73780. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73781. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73782. }
  73783. declare module "babylonjs/Physics/index" {
  73784. export * from "babylonjs/Physics/IPhysicsEngine";
  73785. export * from "babylonjs/Physics/physicsEngine";
  73786. export * from "babylonjs/Physics/physicsEngineComponent";
  73787. export * from "babylonjs/Physics/physicsHelper";
  73788. export * from "babylonjs/Physics/physicsImpostor";
  73789. export * from "babylonjs/Physics/physicsJoint";
  73790. export * from "babylonjs/Physics/Plugins/index";
  73791. }
  73792. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73793. /** @hidden */
  73794. export var blackAndWhitePixelShader: {
  73795. name: string;
  73796. shader: string;
  73797. };
  73798. }
  73799. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73800. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73801. import { Camera } from "babylonjs/Cameras/camera";
  73802. import { Engine } from "babylonjs/Engines/engine";
  73803. import "babylonjs/Shaders/blackAndWhite.fragment";
  73804. import { Nullable } from "babylonjs/types";
  73805. import { Scene } from "babylonjs/scene";
  73806. /**
  73807. * Post process used to render in black and white
  73808. */
  73809. export class BlackAndWhitePostProcess extends PostProcess {
  73810. /**
  73811. * Linear about to convert he result to black and white (default: 1)
  73812. */
  73813. degree: number;
  73814. /**
  73815. * Gets a string identifying the name of the class
  73816. * @returns "BlackAndWhitePostProcess" string
  73817. */
  73818. getClassName(): string;
  73819. /**
  73820. * Creates a black and white post process
  73821. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73822. * @param name The name of the effect.
  73823. * @param options The required width/height ratio to downsize to before computing the render pass.
  73824. * @param camera The camera to apply the render pass to.
  73825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73826. * @param engine The engine which the post process will be applied. (default: current engine)
  73827. * @param reusable If the post process can be reused on the same frame. (default: false)
  73828. */
  73829. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73830. /** @hidden */
  73831. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73832. }
  73833. }
  73834. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  73835. import { Nullable } from "babylonjs/types";
  73836. import { Camera } from "babylonjs/Cameras/camera";
  73837. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73838. import { Engine } from "babylonjs/Engines/engine";
  73839. /**
  73840. * This represents a set of one or more post processes in Babylon.
  73841. * A post process can be used to apply a shader to a texture after it is rendered.
  73842. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73843. */
  73844. export class PostProcessRenderEffect {
  73845. private _postProcesses;
  73846. private _getPostProcesses;
  73847. private _singleInstance;
  73848. private _cameras;
  73849. private _indicesForCamera;
  73850. /**
  73851. * Name of the effect
  73852. * @hidden
  73853. */
  73854. _name: string;
  73855. /**
  73856. * Instantiates a post process render effect.
  73857. * A post process can be used to apply a shader to a texture after it is rendered.
  73858. * @param engine The engine the effect is tied to
  73859. * @param name The name of the effect
  73860. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73861. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73862. */
  73863. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73864. /**
  73865. * Checks if all the post processes in the effect are supported.
  73866. */
  73867. get isSupported(): boolean;
  73868. /**
  73869. * Updates the current state of the effect
  73870. * @hidden
  73871. */
  73872. _update(): void;
  73873. /**
  73874. * Attaches the effect on cameras
  73875. * @param cameras The camera to attach to.
  73876. * @hidden
  73877. */
  73878. _attachCameras(cameras: Camera): void;
  73879. /**
  73880. * Attaches the effect on cameras
  73881. * @param cameras The camera to attach to.
  73882. * @hidden
  73883. */
  73884. _attachCameras(cameras: Camera[]): void;
  73885. /**
  73886. * Detaches the effect on cameras
  73887. * @param cameras The camera to detatch from.
  73888. * @hidden
  73889. */
  73890. _detachCameras(cameras: Camera): void;
  73891. /**
  73892. * Detatches the effect on cameras
  73893. * @param cameras The camera to detatch from.
  73894. * @hidden
  73895. */
  73896. _detachCameras(cameras: Camera[]): void;
  73897. /**
  73898. * Enables the effect on given cameras
  73899. * @param cameras The camera to enable.
  73900. * @hidden
  73901. */
  73902. _enable(cameras: Camera): void;
  73903. /**
  73904. * Enables the effect on given cameras
  73905. * @param cameras The camera to enable.
  73906. * @hidden
  73907. */
  73908. _enable(cameras: Nullable<Camera[]>): void;
  73909. /**
  73910. * Disables the effect on the given cameras
  73911. * @param cameras The camera to disable.
  73912. * @hidden
  73913. */
  73914. _disable(cameras: Camera): void;
  73915. /**
  73916. * Disables the effect on the given cameras
  73917. * @param cameras The camera to disable.
  73918. * @hidden
  73919. */
  73920. _disable(cameras: Nullable<Camera[]>): void;
  73921. /**
  73922. * Gets a list of the post processes contained in the effect.
  73923. * @param camera The camera to get the post processes on.
  73924. * @returns The list of the post processes in the effect.
  73925. */
  73926. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73927. }
  73928. }
  73929. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73930. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73931. /** @hidden */
  73932. export var extractHighlightsPixelShader: {
  73933. name: string;
  73934. shader: string;
  73935. };
  73936. }
  73937. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73938. import { Nullable } from "babylonjs/types";
  73939. import { Camera } from "babylonjs/Cameras/camera";
  73940. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73941. import { Engine } from "babylonjs/Engines/engine";
  73942. import "babylonjs/Shaders/extractHighlights.fragment";
  73943. /**
  73944. * 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.
  73945. */
  73946. export class ExtractHighlightsPostProcess extends PostProcess {
  73947. /**
  73948. * The luminance threshold, pixels below this value will be set to black.
  73949. */
  73950. threshold: number;
  73951. /** @hidden */
  73952. _exposure: number;
  73953. /**
  73954. * Post process which has the input texture to be used when performing highlight extraction
  73955. * @hidden
  73956. */
  73957. _inputPostProcess: Nullable<PostProcess>;
  73958. /**
  73959. * Gets a string identifying the name of the class
  73960. * @returns "ExtractHighlightsPostProcess" string
  73961. */
  73962. getClassName(): string;
  73963. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73964. }
  73965. }
  73966. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73967. /** @hidden */
  73968. export var bloomMergePixelShader: {
  73969. name: string;
  73970. shader: string;
  73971. };
  73972. }
  73973. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73974. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73975. import { Nullable } from "babylonjs/types";
  73976. import { Engine } from "babylonjs/Engines/engine";
  73977. import { Camera } from "babylonjs/Cameras/camera";
  73978. import "babylonjs/Shaders/bloomMerge.fragment";
  73979. /**
  73980. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73981. */
  73982. export class BloomMergePostProcess extends PostProcess {
  73983. /** Weight of the bloom to be added to the original input. */
  73984. weight: number;
  73985. /**
  73986. * Gets a string identifying the name of the class
  73987. * @returns "BloomMergePostProcess" string
  73988. */
  73989. getClassName(): string;
  73990. /**
  73991. * Creates a new instance of @see BloomMergePostProcess
  73992. * @param name The name of the effect.
  73993. * @param originalFromInput Post process which's input will be used for the merge.
  73994. * @param blurred Blurred highlights post process which's output will be used.
  73995. * @param weight Weight of the bloom to be added to the original input.
  73996. * @param options The required width/height ratio to downsize to before computing the render pass.
  73997. * @param camera The camera to apply the render pass to.
  73998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73999. * @param engine The engine which the post process will be applied. (default: current engine)
  74000. * @param reusable If the post process can be reused on the same frame. (default: false)
  74001. * @param textureType Type of textures used when performing the post process. (default: 0)
  74002. * @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)
  74003. */
  74004. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  74005. /** Weight of the bloom to be added to the original input. */
  74006. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74007. }
  74008. }
  74009. declare module "babylonjs/PostProcesses/bloomEffect" {
  74010. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74011. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74012. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74013. import { Camera } from "babylonjs/Cameras/camera";
  74014. import { Scene } from "babylonjs/scene";
  74015. /**
  74016. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74017. */
  74018. export class BloomEffect extends PostProcessRenderEffect {
  74019. private bloomScale;
  74020. /**
  74021. * @hidden Internal
  74022. */
  74023. _effects: Array<PostProcess>;
  74024. /**
  74025. * @hidden Internal
  74026. */
  74027. _downscale: ExtractHighlightsPostProcess;
  74028. private _blurX;
  74029. private _blurY;
  74030. private _merge;
  74031. /**
  74032. * The luminance threshold to find bright areas of the image to bloom.
  74033. */
  74034. get threshold(): number;
  74035. set threshold(value: number);
  74036. /**
  74037. * The strength of the bloom.
  74038. */
  74039. get weight(): number;
  74040. set weight(value: number);
  74041. /**
  74042. * Specifies the size of the bloom blur kernel, relative to the final output size
  74043. */
  74044. get kernel(): number;
  74045. set kernel(value: number);
  74046. /**
  74047. * Creates a new instance of @see BloomEffect
  74048. * @param scene The scene the effect belongs to.
  74049. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74050. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74051. * @param bloomWeight The the strength of bloom.
  74052. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74053. * @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)
  74054. */
  74055. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74056. /**
  74057. * Disposes each of the internal effects for a given camera.
  74058. * @param camera The camera to dispose the effect on.
  74059. */
  74060. disposeEffects(camera: Camera): void;
  74061. /**
  74062. * @hidden Internal
  74063. */
  74064. _updateEffects(): void;
  74065. /**
  74066. * Internal
  74067. * @returns if all the contained post processes are ready.
  74068. * @hidden
  74069. */
  74070. _isReady(): boolean;
  74071. }
  74072. }
  74073. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  74074. /** @hidden */
  74075. export var chromaticAberrationPixelShader: {
  74076. name: string;
  74077. shader: string;
  74078. };
  74079. }
  74080. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  74081. import { Vector2 } from "babylonjs/Maths/math.vector";
  74082. import { Nullable } from "babylonjs/types";
  74083. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74084. import { Camera } from "babylonjs/Cameras/camera";
  74085. import { Engine } from "babylonjs/Engines/engine";
  74086. import "babylonjs/Shaders/chromaticAberration.fragment";
  74087. import { Scene } from "babylonjs/scene";
  74088. /**
  74089. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74090. */
  74091. export class ChromaticAberrationPostProcess extends PostProcess {
  74092. /**
  74093. * The amount of seperation of rgb channels (default: 30)
  74094. */
  74095. aberrationAmount: number;
  74096. /**
  74097. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74098. */
  74099. radialIntensity: number;
  74100. /**
  74101. * 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))
  74102. */
  74103. direction: Vector2;
  74104. /**
  74105. * 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))
  74106. */
  74107. centerPosition: Vector2;
  74108. /** The width of the screen to apply the effect on */
  74109. screenWidth: number;
  74110. /** The height of the screen to apply the effect on */
  74111. screenHeight: number;
  74112. /**
  74113. * Gets a string identifying the name of the class
  74114. * @returns "ChromaticAberrationPostProcess" string
  74115. */
  74116. getClassName(): string;
  74117. /**
  74118. * Creates a new instance ChromaticAberrationPostProcess
  74119. * @param name The name of the effect.
  74120. * @param screenWidth The width of the screen to apply the effect on.
  74121. * @param screenHeight The height of the screen to apply the effect on.
  74122. * @param options The required width/height ratio to downsize to before computing the render pass.
  74123. * @param camera The camera to apply the render pass to.
  74124. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74125. * @param engine The engine which the post process will be applied. (default: current engine)
  74126. * @param reusable If the post process can be reused on the same frame. (default: false)
  74127. * @param textureType Type of textures used when performing the post process. (default: 0)
  74128. * @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)
  74129. */
  74130. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74131. /** @hidden */
  74132. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74133. }
  74134. }
  74135. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  74136. /** @hidden */
  74137. export var circleOfConfusionPixelShader: {
  74138. name: string;
  74139. shader: string;
  74140. };
  74141. }
  74142. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  74143. import { Nullable } from "babylonjs/types";
  74144. import { Engine } from "babylonjs/Engines/engine";
  74145. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74146. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74147. import { Camera } from "babylonjs/Cameras/camera";
  74148. import "babylonjs/Shaders/circleOfConfusion.fragment";
  74149. /**
  74150. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74151. */
  74152. export class CircleOfConfusionPostProcess extends PostProcess {
  74153. /**
  74154. * 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.
  74155. */
  74156. lensSize: number;
  74157. /**
  74158. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74159. */
  74160. fStop: number;
  74161. /**
  74162. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74163. */
  74164. focusDistance: number;
  74165. /**
  74166. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74167. */
  74168. focalLength: number;
  74169. /**
  74170. * Gets a string identifying the name of the class
  74171. * @returns "CircleOfConfusionPostProcess" string
  74172. */
  74173. getClassName(): string;
  74174. private _depthTexture;
  74175. /**
  74176. * Creates a new instance CircleOfConfusionPostProcess
  74177. * @param name The name of the effect.
  74178. * @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.
  74179. * @param options The required width/height ratio to downsize to before computing the render pass.
  74180. * @param camera The camera to apply the render pass to.
  74181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74182. * @param engine The engine which the post process will be applied. (default: current engine)
  74183. * @param reusable If the post process can be reused on the same frame. (default: false)
  74184. * @param textureType Type of textures used when performing the post process. (default: 0)
  74185. * @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)
  74186. */
  74187. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74188. /**
  74189. * 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.
  74190. */
  74191. set depthTexture(value: RenderTargetTexture);
  74192. }
  74193. }
  74194. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  74195. /** @hidden */
  74196. export var colorCorrectionPixelShader: {
  74197. name: string;
  74198. shader: string;
  74199. };
  74200. }
  74201. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  74202. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74203. import { Engine } from "babylonjs/Engines/engine";
  74204. import { Camera } from "babylonjs/Cameras/camera";
  74205. import "babylonjs/Shaders/colorCorrection.fragment";
  74206. import { Nullable } from "babylonjs/types";
  74207. import { Scene } from "babylonjs/scene";
  74208. /**
  74209. *
  74210. * This post-process allows the modification of rendered colors by using
  74211. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74212. *
  74213. * The object needs to be provided an url to a texture containing the color
  74214. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74215. * Use an image editing software to tweak the LUT to match your needs.
  74216. *
  74217. * For an example of a color LUT, see here:
  74218. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74219. * For explanations on color grading, see here:
  74220. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74221. *
  74222. */
  74223. export class ColorCorrectionPostProcess extends PostProcess {
  74224. private _colorTableTexture;
  74225. /**
  74226. * Gets the color table url used to create the LUT texture
  74227. */
  74228. colorTableUrl: string;
  74229. /**
  74230. * Gets a string identifying the name of the class
  74231. * @returns "ColorCorrectionPostProcess" string
  74232. */
  74233. getClassName(): string;
  74234. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74235. /** @hidden */
  74236. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74237. }
  74238. }
  74239. declare module "babylonjs/Shaders/convolution.fragment" {
  74240. /** @hidden */
  74241. export var convolutionPixelShader: {
  74242. name: string;
  74243. shader: string;
  74244. };
  74245. }
  74246. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  74247. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74248. import { Nullable } from "babylonjs/types";
  74249. import { Camera } from "babylonjs/Cameras/camera";
  74250. import { Engine } from "babylonjs/Engines/engine";
  74251. import "babylonjs/Shaders/convolution.fragment";
  74252. import { Scene } from "babylonjs/scene";
  74253. /**
  74254. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74255. * input texture to perform effects such as edge detection or sharpening
  74256. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74257. */
  74258. export class ConvolutionPostProcess extends PostProcess {
  74259. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74260. kernel: number[];
  74261. /**
  74262. * Gets a string identifying the name of the class
  74263. * @returns "ConvolutionPostProcess" string
  74264. */
  74265. getClassName(): string;
  74266. /**
  74267. * Creates a new instance ConvolutionPostProcess
  74268. * @param name The name of the effect.
  74269. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74270. * @param options The required width/height ratio to downsize to before computing the render pass.
  74271. * @param camera The camera to apply the render pass to.
  74272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74273. * @param engine The engine which the post process will be applied. (default: current engine)
  74274. * @param reusable If the post process can be reused on the same frame. (default: false)
  74275. * @param textureType Type of textures used when performing the post process. (default: 0)
  74276. */
  74277. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74278. /** @hidden */
  74279. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74280. /**
  74281. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74282. */
  74283. static EdgeDetect0Kernel: number[];
  74284. /**
  74285. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74286. */
  74287. static EdgeDetect1Kernel: number[];
  74288. /**
  74289. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74290. */
  74291. static EdgeDetect2Kernel: number[];
  74292. /**
  74293. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74294. */
  74295. static SharpenKernel: number[];
  74296. /**
  74297. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74298. */
  74299. static EmbossKernel: number[];
  74300. /**
  74301. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74302. */
  74303. static GaussianKernel: number[];
  74304. }
  74305. }
  74306. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  74307. import { Nullable } from "babylonjs/types";
  74308. import { Vector2 } from "babylonjs/Maths/math.vector";
  74309. import { Camera } from "babylonjs/Cameras/camera";
  74310. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74311. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74312. import { Engine } from "babylonjs/Engines/engine";
  74313. import { Scene } from "babylonjs/scene";
  74314. /**
  74315. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74316. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74317. * based on samples that have a large difference in distance than the center pixel.
  74318. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74319. */
  74320. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74321. /**
  74322. * The direction the blur should be applied
  74323. */
  74324. direction: Vector2;
  74325. /**
  74326. * Gets a string identifying the name of the class
  74327. * @returns "DepthOfFieldBlurPostProcess" string
  74328. */
  74329. getClassName(): string;
  74330. /**
  74331. * Creates a new instance CircleOfConfusionPostProcess
  74332. * @param name The name of the effect.
  74333. * @param scene The scene the effect belongs to.
  74334. * @param direction The direction the blur should be applied.
  74335. * @param kernel The size of the kernel used to blur.
  74336. * @param options The required width/height ratio to downsize to before computing the render pass.
  74337. * @param camera The camera to apply the render pass to.
  74338. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  74339. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74341. * @param engine The engine which the post process will be applied. (default: current engine)
  74342. * @param reusable If the post process can be reused on the same frame. (default: false)
  74343. * @param textureType Type of textures used when performing the post process. (default: 0)
  74344. * @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)
  74345. */
  74346. 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);
  74347. }
  74348. }
  74349. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  74350. /** @hidden */
  74351. export var depthOfFieldMergePixelShader: {
  74352. name: string;
  74353. shader: string;
  74354. };
  74355. }
  74356. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  74357. import { Nullable } from "babylonjs/types";
  74358. import { Camera } from "babylonjs/Cameras/camera";
  74359. import { Effect } from "babylonjs/Materials/effect";
  74360. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74361. import { Engine } from "babylonjs/Engines/engine";
  74362. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  74363. /**
  74364. * Options to be set when merging outputs from the default pipeline.
  74365. */
  74366. export class DepthOfFieldMergePostProcessOptions {
  74367. /**
  74368. * The original image to merge on top of
  74369. */
  74370. originalFromInput: PostProcess;
  74371. /**
  74372. * Parameters to perform the merge of the depth of field effect
  74373. */
  74374. depthOfField?: {
  74375. circleOfConfusion: PostProcess;
  74376. blurSteps: Array<PostProcess>;
  74377. };
  74378. /**
  74379. * Parameters to perform the merge of bloom effect
  74380. */
  74381. bloom?: {
  74382. blurred: PostProcess;
  74383. weight: number;
  74384. };
  74385. }
  74386. /**
  74387. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74388. */
  74389. export class DepthOfFieldMergePostProcess extends PostProcess {
  74390. private blurSteps;
  74391. /**
  74392. * Gets a string identifying the name of the class
  74393. * @returns "DepthOfFieldMergePostProcess" string
  74394. */
  74395. getClassName(): string;
  74396. /**
  74397. * Creates a new instance of DepthOfFieldMergePostProcess
  74398. * @param name The name of the effect.
  74399. * @param originalFromInput Post process which's input will be used for the merge.
  74400. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74401. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74402. * @param options The required width/height ratio to downsize to before computing the render pass.
  74403. * @param camera The camera to apply the render pass to.
  74404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74405. * @param engine The engine which the post process will be applied. (default: current engine)
  74406. * @param reusable If the post process can be reused on the same frame. (default: false)
  74407. * @param textureType Type of textures used when performing the post process. (default: 0)
  74408. * @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)
  74409. */
  74410. 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);
  74411. /**
  74412. * Updates the effect with the current post process compile time values and recompiles the shader.
  74413. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74414. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74415. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74416. * @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
  74417. * @param onCompiled Called when the shader has been compiled.
  74418. * @param onError Called if there is an error when compiling a shader.
  74419. */
  74420. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74421. }
  74422. }
  74423. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  74424. import { Nullable } from "babylonjs/types";
  74425. import { Camera } from "babylonjs/Cameras/camera";
  74426. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74427. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74428. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74429. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74430. import { Scene } from "babylonjs/scene";
  74431. /**
  74432. * Specifies the level of max blur that should be applied when using the depth of field effect
  74433. */
  74434. export enum DepthOfFieldEffectBlurLevel {
  74435. /**
  74436. * Subtle blur
  74437. */
  74438. Low = 0,
  74439. /**
  74440. * Medium blur
  74441. */
  74442. Medium = 1,
  74443. /**
  74444. * Large blur
  74445. */
  74446. High = 2
  74447. }
  74448. /**
  74449. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74450. */
  74451. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74452. private _circleOfConfusion;
  74453. /**
  74454. * @hidden Internal, blurs from high to low
  74455. */
  74456. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74457. private _depthOfFieldBlurY;
  74458. private _dofMerge;
  74459. /**
  74460. * @hidden Internal post processes in depth of field effect
  74461. */
  74462. _effects: Array<PostProcess>;
  74463. /**
  74464. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74465. */
  74466. set focalLength(value: number);
  74467. get focalLength(): number;
  74468. /**
  74469. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74470. */
  74471. set fStop(value: number);
  74472. get fStop(): number;
  74473. /**
  74474. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74475. */
  74476. set focusDistance(value: number);
  74477. get focusDistance(): number;
  74478. /**
  74479. * 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.
  74480. */
  74481. set lensSize(value: number);
  74482. get lensSize(): number;
  74483. /**
  74484. * Creates a new instance DepthOfFieldEffect
  74485. * @param scene The scene the effect belongs to.
  74486. * @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.
  74487. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74488. * @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)
  74489. */
  74490. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74491. /**
  74492. * Get the current class name of the current effet
  74493. * @returns "DepthOfFieldEffect"
  74494. */
  74495. getClassName(): string;
  74496. /**
  74497. * 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.
  74498. */
  74499. set depthTexture(value: RenderTargetTexture);
  74500. /**
  74501. * Disposes each of the internal effects for a given camera.
  74502. * @param camera The camera to dispose the effect on.
  74503. */
  74504. disposeEffects(camera: Camera): void;
  74505. /**
  74506. * @hidden Internal
  74507. */
  74508. _updateEffects(): void;
  74509. /**
  74510. * Internal
  74511. * @returns if all the contained post processes are ready.
  74512. * @hidden
  74513. */
  74514. _isReady(): boolean;
  74515. }
  74516. }
  74517. declare module "babylonjs/Shaders/displayPass.fragment" {
  74518. /** @hidden */
  74519. export var displayPassPixelShader: {
  74520. name: string;
  74521. shader: string;
  74522. };
  74523. }
  74524. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74525. import { Nullable } from "babylonjs/types";
  74526. import { Camera } from "babylonjs/Cameras/camera";
  74527. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74528. import { Engine } from "babylonjs/Engines/engine";
  74529. import "babylonjs/Shaders/displayPass.fragment";
  74530. import { Scene } from "babylonjs/scene";
  74531. /**
  74532. * DisplayPassPostProcess which produces an output the same as it's input
  74533. */
  74534. export class DisplayPassPostProcess extends PostProcess {
  74535. /**
  74536. * Gets a string identifying the name of the class
  74537. * @returns "DisplayPassPostProcess" string
  74538. */
  74539. getClassName(): string;
  74540. /**
  74541. * Creates the DisplayPassPostProcess
  74542. * @param name The name of the effect.
  74543. * @param options The required width/height ratio to downsize to before computing the render pass.
  74544. * @param camera The camera to apply the render pass to.
  74545. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74546. * @param engine The engine which the post process will be applied. (default: current engine)
  74547. * @param reusable If the post process can be reused on the same frame. (default: false)
  74548. */
  74549. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74550. /** @hidden */
  74551. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74552. }
  74553. }
  74554. declare module "babylonjs/Shaders/filter.fragment" {
  74555. /** @hidden */
  74556. export var filterPixelShader: {
  74557. name: string;
  74558. shader: string;
  74559. };
  74560. }
  74561. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74562. import { Nullable } from "babylonjs/types";
  74563. import { Matrix } from "babylonjs/Maths/math.vector";
  74564. import { Camera } from "babylonjs/Cameras/camera";
  74565. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74566. import { Engine } from "babylonjs/Engines/engine";
  74567. import "babylonjs/Shaders/filter.fragment";
  74568. import { Scene } from "babylonjs/scene";
  74569. /**
  74570. * Applies a kernel filter to the image
  74571. */
  74572. export class FilterPostProcess extends PostProcess {
  74573. /** The matrix to be applied to the image */
  74574. kernelMatrix: Matrix;
  74575. /**
  74576. * Gets a string identifying the name of the class
  74577. * @returns "FilterPostProcess" string
  74578. */
  74579. getClassName(): string;
  74580. /**
  74581. *
  74582. * @param name The name of the effect.
  74583. * @param kernelMatrix The matrix to be applied to the image
  74584. * @param options The required width/height ratio to downsize to before computing the render pass.
  74585. * @param camera The camera to apply the render pass to.
  74586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74587. * @param engine The engine which the post process will be applied. (default: current engine)
  74588. * @param reusable If the post process can be reused on the same frame. (default: false)
  74589. */
  74590. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74591. /** @hidden */
  74592. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74593. }
  74594. }
  74595. declare module "babylonjs/Shaders/fxaa.fragment" {
  74596. /** @hidden */
  74597. export var fxaaPixelShader: {
  74598. name: string;
  74599. shader: string;
  74600. };
  74601. }
  74602. declare module "babylonjs/Shaders/fxaa.vertex" {
  74603. /** @hidden */
  74604. export var fxaaVertexShader: {
  74605. name: string;
  74606. shader: string;
  74607. };
  74608. }
  74609. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74610. import { Nullable } from "babylonjs/types";
  74611. import { Camera } from "babylonjs/Cameras/camera";
  74612. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74613. import { Engine } from "babylonjs/Engines/engine";
  74614. import "babylonjs/Shaders/fxaa.fragment";
  74615. import "babylonjs/Shaders/fxaa.vertex";
  74616. import { Scene } from "babylonjs/scene";
  74617. /**
  74618. * Fxaa post process
  74619. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74620. */
  74621. export class FxaaPostProcess extends PostProcess {
  74622. /**
  74623. * Gets a string identifying the name of the class
  74624. * @returns "FxaaPostProcess" string
  74625. */
  74626. getClassName(): string;
  74627. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74628. private _getDefines;
  74629. /** @hidden */
  74630. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74631. }
  74632. }
  74633. declare module "babylonjs/Shaders/grain.fragment" {
  74634. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74635. /** @hidden */
  74636. export var grainPixelShader: {
  74637. name: string;
  74638. shader: string;
  74639. };
  74640. }
  74641. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74642. import { Nullable } from "babylonjs/types";
  74643. import { Camera } from "babylonjs/Cameras/camera";
  74644. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74645. import { Engine } from "babylonjs/Engines/engine";
  74646. import "babylonjs/Shaders/grain.fragment";
  74647. import { Scene } from "babylonjs/scene";
  74648. /**
  74649. * The GrainPostProcess adds noise to the image at mid luminance levels
  74650. */
  74651. export class GrainPostProcess extends PostProcess {
  74652. /**
  74653. * The intensity of the grain added (default: 30)
  74654. */
  74655. intensity: number;
  74656. /**
  74657. * If the grain should be randomized on every frame
  74658. */
  74659. animated: boolean;
  74660. /**
  74661. * Gets a string identifying the name of the class
  74662. * @returns "GrainPostProcess" string
  74663. */
  74664. getClassName(): string;
  74665. /**
  74666. * Creates a new instance of @see GrainPostProcess
  74667. * @param name The name of the effect.
  74668. * @param options The required width/height ratio to downsize to before computing the render pass.
  74669. * @param camera The camera to apply the render pass to.
  74670. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74671. * @param engine The engine which the post process will be applied. (default: current engine)
  74672. * @param reusable If the post process can be reused on the same frame. (default: false)
  74673. * @param textureType Type of textures used when performing the post process. (default: 0)
  74674. * @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)
  74675. */
  74676. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74677. /** @hidden */
  74678. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74679. }
  74680. }
  74681. declare module "babylonjs/Shaders/highlights.fragment" {
  74682. /** @hidden */
  74683. export var highlightsPixelShader: {
  74684. name: string;
  74685. shader: string;
  74686. };
  74687. }
  74688. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74689. import { Nullable } from "babylonjs/types";
  74690. import { Camera } from "babylonjs/Cameras/camera";
  74691. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74692. import { Engine } from "babylonjs/Engines/engine";
  74693. import "babylonjs/Shaders/highlights.fragment";
  74694. /**
  74695. * Extracts highlights from the image
  74696. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74697. */
  74698. export class HighlightsPostProcess extends PostProcess {
  74699. /**
  74700. * Gets a string identifying the name of the class
  74701. * @returns "HighlightsPostProcess" string
  74702. */
  74703. getClassName(): string;
  74704. /**
  74705. * Extracts highlights from the image
  74706. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74707. * @param name The name of the effect.
  74708. * @param options The required width/height ratio to downsize to before computing the render pass.
  74709. * @param camera The camera to apply the render pass to.
  74710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74711. * @param engine The engine which the post process will be applied. (default: current engine)
  74712. * @param reusable If the post process can be reused on the same frame. (default: false)
  74713. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74714. */
  74715. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74716. }
  74717. }
  74718. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74719. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74720. /**
  74721. * Contains all parameters needed for the prepass to perform
  74722. * motion blur
  74723. */
  74724. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74725. /**
  74726. * Is motion blur enabled
  74727. */
  74728. enabled: boolean;
  74729. /**
  74730. * Name of the configuration
  74731. */
  74732. name: string;
  74733. /**
  74734. * Textures that should be present in the MRT for this effect to work
  74735. */
  74736. readonly texturesRequired: number[];
  74737. }
  74738. }
  74739. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74740. import { Nullable } from "babylonjs/types";
  74741. import { Scene } from "babylonjs/scene";
  74742. import { ISceneComponent } from "babylonjs/sceneComponent";
  74743. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74744. module "babylonjs/scene" {
  74745. interface Scene {
  74746. /** @hidden (Backing field) */
  74747. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74748. /**
  74749. * Gets or Sets the current geometry buffer associated to the scene.
  74750. */
  74751. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74752. /**
  74753. * Enables a GeometryBufferRender and associates it with the scene
  74754. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74755. * @returns the GeometryBufferRenderer
  74756. */
  74757. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74758. /**
  74759. * Disables the GeometryBufferRender associated with the scene
  74760. */
  74761. disableGeometryBufferRenderer(): void;
  74762. }
  74763. }
  74764. /**
  74765. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74766. * in several rendering techniques.
  74767. */
  74768. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74769. /**
  74770. * The component name helpful to identify the component in the list of scene components.
  74771. */
  74772. readonly name: string;
  74773. /**
  74774. * The scene the component belongs to.
  74775. */
  74776. scene: Scene;
  74777. /**
  74778. * Creates a new instance of the component for the given scene
  74779. * @param scene Defines the scene to register the component in
  74780. */
  74781. constructor(scene: Scene);
  74782. /**
  74783. * Registers the component in a given scene
  74784. */
  74785. register(): void;
  74786. /**
  74787. * Rebuilds the elements related to this component in case of
  74788. * context lost for instance.
  74789. */
  74790. rebuild(): void;
  74791. /**
  74792. * Disposes the component and the associated ressources
  74793. */
  74794. dispose(): void;
  74795. private _gatherRenderTargets;
  74796. }
  74797. }
  74798. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74799. /** @hidden */
  74800. export var motionBlurPixelShader: {
  74801. name: string;
  74802. shader: string;
  74803. };
  74804. }
  74805. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74806. import { Nullable } from "babylonjs/types";
  74807. import { Camera } from "babylonjs/Cameras/camera";
  74808. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74810. import "babylonjs/Animations/animatable";
  74811. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74812. import "babylonjs/Shaders/motionBlur.fragment";
  74813. import { Engine } from "babylonjs/Engines/engine";
  74814. import { Scene } from "babylonjs/scene";
  74815. /**
  74816. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74817. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74818. * As an example, all you have to do is to create the post-process:
  74819. * var mb = new BABYLON.MotionBlurPostProcess(
  74820. * 'mb', // The name of the effect.
  74821. * scene, // The scene containing the objects to blur according to their velocity.
  74822. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74823. * camera // The camera to apply the render pass to.
  74824. * );
  74825. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74826. */
  74827. export class MotionBlurPostProcess extends PostProcess {
  74828. /**
  74829. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74830. */
  74831. motionStrength: number;
  74832. /**
  74833. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74834. */
  74835. get motionBlurSamples(): number;
  74836. /**
  74837. * Sets the number of iterations to be used for motion blur quality
  74838. */
  74839. set motionBlurSamples(samples: number);
  74840. private _motionBlurSamples;
  74841. private _forceGeometryBuffer;
  74842. private _geometryBufferRenderer;
  74843. private _prePassRenderer;
  74844. /**
  74845. * Gets a string identifying the name of the class
  74846. * @returns "MotionBlurPostProcess" string
  74847. */
  74848. getClassName(): string;
  74849. /**
  74850. * Creates a new instance MotionBlurPostProcess
  74851. * @param name The name of the effect.
  74852. * @param scene The scene containing the objects to blur according to their velocity.
  74853. * @param options The required width/height ratio to downsize to before computing the render pass.
  74854. * @param camera The camera to apply the render pass to.
  74855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74856. * @param engine The engine which the post process will be applied. (default: current engine)
  74857. * @param reusable If the post process can be reused on the same frame. (default: false)
  74858. * @param textureType Type of textures used when performing the post process. (default: 0)
  74859. * @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)
  74860. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74861. */
  74862. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74863. /**
  74864. * Excludes the given skinned mesh from computing bones velocities.
  74865. * 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.
  74866. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74867. */
  74868. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74869. /**
  74870. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74871. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74872. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74873. */
  74874. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74875. /**
  74876. * Disposes the post process.
  74877. * @param camera The camera to dispose the post process on.
  74878. */
  74879. dispose(camera?: Camera): void;
  74880. /** @hidden */
  74881. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74882. }
  74883. }
  74884. declare module "babylonjs/Shaders/refraction.fragment" {
  74885. /** @hidden */
  74886. export var refractionPixelShader: {
  74887. name: string;
  74888. shader: string;
  74889. };
  74890. }
  74891. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74892. import { Color3 } from "babylonjs/Maths/math.color";
  74893. import { Camera } from "babylonjs/Cameras/camera";
  74894. import { Texture } from "babylonjs/Materials/Textures/texture";
  74895. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74896. import { Engine } from "babylonjs/Engines/engine";
  74897. import "babylonjs/Shaders/refraction.fragment";
  74898. import { Scene } from "babylonjs/scene";
  74899. /**
  74900. * Post process which applies a refractin texture
  74901. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74902. */
  74903. export class RefractionPostProcess extends PostProcess {
  74904. private _refTexture;
  74905. private _ownRefractionTexture;
  74906. /** the base color of the refraction (used to taint the rendering) */
  74907. color: Color3;
  74908. /** simulated refraction depth */
  74909. depth: number;
  74910. /** the coefficient of the base color (0 to remove base color tainting) */
  74911. colorLevel: number;
  74912. /** Gets the url used to load the refraction texture */
  74913. refractionTextureUrl: string;
  74914. /**
  74915. * Gets or sets the refraction texture
  74916. * Please note that you are responsible for disposing the texture if you set it manually
  74917. */
  74918. get refractionTexture(): Texture;
  74919. set refractionTexture(value: Texture);
  74920. /**
  74921. * Gets a string identifying the name of the class
  74922. * @returns "RefractionPostProcess" string
  74923. */
  74924. getClassName(): string;
  74925. /**
  74926. * Initializes the RefractionPostProcess
  74927. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74928. * @param name The name of the effect.
  74929. * @param refractionTextureUrl Url of the refraction texture to use
  74930. * @param color the base color of the refraction (used to taint the rendering)
  74931. * @param depth simulated refraction depth
  74932. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74933. * @param camera The camera to apply the render pass to.
  74934. * @param options The required width/height ratio to downsize to before computing the render pass.
  74935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74936. * @param engine The engine which the post process will be applied. (default: current engine)
  74937. * @param reusable If the post process can be reused on the same frame. (default: false)
  74938. */
  74939. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74940. /**
  74941. * Disposes of the post process
  74942. * @param camera Camera to dispose post process on
  74943. */
  74944. dispose(camera: Camera): void;
  74945. /** @hidden */
  74946. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74947. }
  74948. }
  74949. declare module "babylonjs/Shaders/sharpen.fragment" {
  74950. /** @hidden */
  74951. export var sharpenPixelShader: {
  74952. name: string;
  74953. shader: string;
  74954. };
  74955. }
  74956. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74957. import { Nullable } from "babylonjs/types";
  74958. import { Camera } from "babylonjs/Cameras/camera";
  74959. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74960. import "babylonjs/Shaders/sharpen.fragment";
  74961. import { Engine } from "babylonjs/Engines/engine";
  74962. import { Scene } from "babylonjs/scene";
  74963. /**
  74964. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74965. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74966. */
  74967. export class SharpenPostProcess extends PostProcess {
  74968. /**
  74969. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74970. */
  74971. colorAmount: number;
  74972. /**
  74973. * How much sharpness should be applied (default: 0.3)
  74974. */
  74975. edgeAmount: number;
  74976. /**
  74977. * Gets a string identifying the name of the class
  74978. * @returns "SharpenPostProcess" string
  74979. */
  74980. getClassName(): string;
  74981. /**
  74982. * Creates a new instance ConvolutionPostProcess
  74983. * @param name The name of the effect.
  74984. * @param options The required width/height ratio to downsize to before computing the render pass.
  74985. * @param camera The camera to apply the render pass to.
  74986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74987. * @param engine The engine which the post process will be applied. (default: current engine)
  74988. * @param reusable If the post process can be reused on the same frame. (default: false)
  74989. * @param textureType Type of textures used when performing the post process. (default: 0)
  74990. * @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)
  74991. */
  74992. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74993. /** @hidden */
  74994. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74995. }
  74996. }
  74997. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74998. import { Nullable } from "babylonjs/types";
  74999. import { Camera } from "babylonjs/Cameras/camera";
  75000. import { Engine } from "babylonjs/Engines/engine";
  75001. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75002. import { IInspectable } from "babylonjs/Misc/iInspectable";
  75003. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75004. /**
  75005. * PostProcessRenderPipeline
  75006. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75007. */
  75008. export class PostProcessRenderPipeline {
  75009. private engine;
  75010. private _renderEffects;
  75011. private _renderEffectsForIsolatedPass;
  75012. /**
  75013. * List of inspectable custom properties (used by the Inspector)
  75014. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75015. */
  75016. inspectableCustomProperties: IInspectable[];
  75017. /**
  75018. * @hidden
  75019. */
  75020. protected _cameras: Camera[];
  75021. /** @hidden */
  75022. _name: string;
  75023. /**
  75024. * Gets pipeline name
  75025. */
  75026. get name(): string;
  75027. /** Gets the list of attached cameras */
  75028. get cameras(): Camera[];
  75029. /**
  75030. * Initializes a PostProcessRenderPipeline
  75031. * @param engine engine to add the pipeline to
  75032. * @param name name of the pipeline
  75033. */
  75034. constructor(engine: Engine, name: string);
  75035. /**
  75036. * Gets the class name
  75037. * @returns "PostProcessRenderPipeline"
  75038. */
  75039. getClassName(): string;
  75040. /**
  75041. * If all the render effects in the pipeline are supported
  75042. */
  75043. get isSupported(): boolean;
  75044. /**
  75045. * Adds an effect to the pipeline
  75046. * @param renderEffect the effect to add
  75047. */
  75048. addEffect(renderEffect: PostProcessRenderEffect): void;
  75049. /** @hidden */
  75050. _rebuild(): void;
  75051. /** @hidden */
  75052. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75053. /** @hidden */
  75054. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75055. /** @hidden */
  75056. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75057. /** @hidden */
  75058. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75059. /** @hidden */
  75060. _attachCameras(cameras: Camera, unique: boolean): void;
  75061. /** @hidden */
  75062. _attachCameras(cameras: Camera[], unique: boolean): void;
  75063. /** @hidden */
  75064. _detachCameras(cameras: Camera): void;
  75065. /** @hidden */
  75066. _detachCameras(cameras: Nullable<Camera[]>): void;
  75067. /** @hidden */
  75068. _update(): void;
  75069. /** @hidden */
  75070. _reset(): void;
  75071. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75072. /**
  75073. * Sets the required values to the prepass renderer.
  75074. * @param prePassRenderer defines the prepass renderer to setup.
  75075. * @returns true if the pre pass is needed.
  75076. */
  75077. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75078. /**
  75079. * Disposes of the pipeline
  75080. */
  75081. dispose(): void;
  75082. }
  75083. }
  75084. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  75085. import { Camera } from "babylonjs/Cameras/camera";
  75086. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75087. /**
  75088. * PostProcessRenderPipelineManager class
  75089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75090. */
  75091. export class PostProcessRenderPipelineManager {
  75092. private _renderPipelines;
  75093. /**
  75094. * Initializes a PostProcessRenderPipelineManager
  75095. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75096. */
  75097. constructor();
  75098. /**
  75099. * Gets the list of supported render pipelines
  75100. */
  75101. get supportedPipelines(): PostProcessRenderPipeline[];
  75102. /**
  75103. * Adds a pipeline to the manager
  75104. * @param renderPipeline The pipeline to add
  75105. */
  75106. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75107. /**
  75108. * Attaches a camera to the pipeline
  75109. * @param renderPipelineName The name of the pipeline to attach to
  75110. * @param cameras the camera to attach
  75111. * @param unique if the camera can be attached multiple times to the pipeline
  75112. */
  75113. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75114. /**
  75115. * Detaches a camera from the pipeline
  75116. * @param renderPipelineName The name of the pipeline to detach from
  75117. * @param cameras the camera to detach
  75118. */
  75119. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75120. /**
  75121. * Enables an effect by name on a pipeline
  75122. * @param renderPipelineName the name of the pipeline to enable the effect in
  75123. * @param renderEffectName the name of the effect to enable
  75124. * @param cameras the cameras that the effect should be enabled on
  75125. */
  75126. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75127. /**
  75128. * Disables an effect by name on a pipeline
  75129. * @param renderPipelineName the name of the pipeline to disable the effect in
  75130. * @param renderEffectName the name of the effect to disable
  75131. * @param cameras the cameras that the effect should be disabled on
  75132. */
  75133. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75134. /**
  75135. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75136. */
  75137. update(): void;
  75138. /** @hidden */
  75139. _rebuild(): void;
  75140. /**
  75141. * Disposes of the manager and pipelines
  75142. */
  75143. dispose(): void;
  75144. }
  75145. }
  75146. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  75147. import { ISceneComponent } from "babylonjs/sceneComponent";
  75148. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75149. import { Scene } from "babylonjs/scene";
  75150. module "babylonjs/scene" {
  75151. interface Scene {
  75152. /** @hidden (Backing field) */
  75153. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75154. /**
  75155. * Gets the postprocess render pipeline manager
  75156. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75157. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75158. */
  75159. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75160. }
  75161. }
  75162. /**
  75163. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75164. */
  75165. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75166. /**
  75167. * The component name helpfull to identify the component in the list of scene components.
  75168. */
  75169. readonly name: string;
  75170. /**
  75171. * The scene the component belongs to.
  75172. */
  75173. scene: Scene;
  75174. /**
  75175. * Creates a new instance of the component for the given scene
  75176. * @param scene Defines the scene to register the component in
  75177. */
  75178. constructor(scene: Scene);
  75179. /**
  75180. * Registers the component in a given scene
  75181. */
  75182. register(): void;
  75183. /**
  75184. * Rebuilds the elements related to this component in case of
  75185. * context lost for instance.
  75186. */
  75187. rebuild(): void;
  75188. /**
  75189. * Disposes the component and the associated ressources
  75190. */
  75191. dispose(): void;
  75192. private _gatherRenderTargets;
  75193. }
  75194. }
  75195. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  75196. import { Nullable } from "babylonjs/types";
  75197. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75198. import { Camera } from "babylonjs/Cameras/camera";
  75199. import { IDisposable } from "babylonjs/scene";
  75200. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  75201. import { Scene } from "babylonjs/scene";
  75202. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  75203. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75204. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75205. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  75206. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75207. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75208. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  75209. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75210. import { Animation } from "babylonjs/Animations/animation";
  75211. /**
  75212. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75213. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75214. */
  75215. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75216. private _scene;
  75217. private _camerasToBeAttached;
  75218. /**
  75219. * ID of the sharpen post process,
  75220. */
  75221. private readonly SharpenPostProcessId;
  75222. /**
  75223. * @ignore
  75224. * ID of the image processing post process;
  75225. */
  75226. readonly ImageProcessingPostProcessId: string;
  75227. /**
  75228. * @ignore
  75229. * ID of the Fast Approximate Anti-Aliasing post process;
  75230. */
  75231. readonly FxaaPostProcessId: string;
  75232. /**
  75233. * ID of the chromatic aberration post process,
  75234. */
  75235. private readonly ChromaticAberrationPostProcessId;
  75236. /**
  75237. * ID of the grain post process
  75238. */
  75239. private readonly GrainPostProcessId;
  75240. /**
  75241. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75242. */
  75243. sharpen: SharpenPostProcess;
  75244. private _sharpenEffect;
  75245. private bloom;
  75246. /**
  75247. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75248. */
  75249. depthOfField: DepthOfFieldEffect;
  75250. /**
  75251. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75252. */
  75253. fxaa: FxaaPostProcess;
  75254. /**
  75255. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75256. */
  75257. imageProcessing: ImageProcessingPostProcess;
  75258. /**
  75259. * Chromatic aberration post process which will shift rgb colors in the image
  75260. */
  75261. chromaticAberration: ChromaticAberrationPostProcess;
  75262. private _chromaticAberrationEffect;
  75263. /**
  75264. * Grain post process which add noise to the image
  75265. */
  75266. grain: GrainPostProcess;
  75267. private _grainEffect;
  75268. /**
  75269. * Glow post process which adds a glow to emissive areas of the image
  75270. */
  75271. private _glowLayer;
  75272. /**
  75273. * Animations which can be used to tweak settings over a period of time
  75274. */
  75275. animations: Animation[];
  75276. private _imageProcessingConfigurationObserver;
  75277. private _sharpenEnabled;
  75278. private _bloomEnabled;
  75279. private _depthOfFieldEnabled;
  75280. private _depthOfFieldBlurLevel;
  75281. private _fxaaEnabled;
  75282. private _imageProcessingEnabled;
  75283. private _defaultPipelineTextureType;
  75284. private _bloomScale;
  75285. private _chromaticAberrationEnabled;
  75286. private _grainEnabled;
  75287. private _buildAllowed;
  75288. /**
  75289. * Gets active scene
  75290. */
  75291. get scene(): Scene;
  75292. /**
  75293. * Enable or disable the sharpen process from the pipeline
  75294. */
  75295. set sharpenEnabled(enabled: boolean);
  75296. get sharpenEnabled(): boolean;
  75297. private _resizeObserver;
  75298. private _hardwareScaleLevel;
  75299. private _bloomKernel;
  75300. /**
  75301. * Specifies the size of the bloom blur kernel, relative to the final output size
  75302. */
  75303. get bloomKernel(): number;
  75304. set bloomKernel(value: number);
  75305. /**
  75306. * Specifies the weight of the bloom in the final rendering
  75307. */
  75308. private _bloomWeight;
  75309. /**
  75310. * Specifies the luma threshold for the area that will be blurred by the bloom
  75311. */
  75312. private _bloomThreshold;
  75313. private _hdr;
  75314. /**
  75315. * The strength of the bloom.
  75316. */
  75317. set bloomWeight(value: number);
  75318. get bloomWeight(): number;
  75319. /**
  75320. * The strength of the bloom.
  75321. */
  75322. set bloomThreshold(value: number);
  75323. get bloomThreshold(): number;
  75324. /**
  75325. * The scale of the bloom, lower value will provide better performance.
  75326. */
  75327. set bloomScale(value: number);
  75328. get bloomScale(): number;
  75329. /**
  75330. * Enable or disable the bloom from the pipeline
  75331. */
  75332. set bloomEnabled(enabled: boolean);
  75333. get bloomEnabled(): boolean;
  75334. private _rebuildBloom;
  75335. /**
  75336. * If the depth of field is enabled.
  75337. */
  75338. get depthOfFieldEnabled(): boolean;
  75339. set depthOfFieldEnabled(enabled: boolean);
  75340. /**
  75341. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75342. */
  75343. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75344. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75345. /**
  75346. * If the anti aliasing is enabled.
  75347. */
  75348. set fxaaEnabled(enabled: boolean);
  75349. get fxaaEnabled(): boolean;
  75350. private _samples;
  75351. /**
  75352. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75353. */
  75354. set samples(sampleCount: number);
  75355. get samples(): number;
  75356. /**
  75357. * If image processing is enabled.
  75358. */
  75359. set imageProcessingEnabled(enabled: boolean);
  75360. get imageProcessingEnabled(): boolean;
  75361. /**
  75362. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75363. */
  75364. set glowLayerEnabled(enabled: boolean);
  75365. get glowLayerEnabled(): boolean;
  75366. /**
  75367. * Gets the glow layer (or null if not defined)
  75368. */
  75369. get glowLayer(): Nullable<GlowLayer>;
  75370. /**
  75371. * Enable or disable the chromaticAberration process from the pipeline
  75372. */
  75373. set chromaticAberrationEnabled(enabled: boolean);
  75374. get chromaticAberrationEnabled(): boolean;
  75375. /**
  75376. * Enable or disable the grain process from the pipeline
  75377. */
  75378. set grainEnabled(enabled: boolean);
  75379. get grainEnabled(): boolean;
  75380. /**
  75381. * @constructor
  75382. * @param name - The rendering pipeline name (default: "")
  75383. * @param hdr - If high dynamic range textures should be used (default: true)
  75384. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75385. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75386. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75387. */
  75388. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75389. /**
  75390. * Get the class name
  75391. * @returns "DefaultRenderingPipeline"
  75392. */
  75393. getClassName(): string;
  75394. /**
  75395. * Force the compilation of the entire pipeline.
  75396. */
  75397. prepare(): void;
  75398. private _hasCleared;
  75399. private _prevPostProcess;
  75400. private _prevPrevPostProcess;
  75401. private _setAutoClearAndTextureSharing;
  75402. private _depthOfFieldSceneObserver;
  75403. private _buildPipeline;
  75404. private _disposePostProcesses;
  75405. /**
  75406. * Adds a camera to the pipeline
  75407. * @param camera the camera to be added
  75408. */
  75409. addCamera(camera: Camera): void;
  75410. /**
  75411. * Removes a camera from the pipeline
  75412. * @param camera the camera to remove
  75413. */
  75414. removeCamera(camera: Camera): void;
  75415. /**
  75416. * Dispose of the pipeline and stop all post processes
  75417. */
  75418. dispose(): void;
  75419. /**
  75420. * Serialize the rendering pipeline (Used when exporting)
  75421. * @returns the serialized object
  75422. */
  75423. serialize(): any;
  75424. /**
  75425. * Parse the serialized pipeline
  75426. * @param source Source pipeline.
  75427. * @param scene The scene to load the pipeline to.
  75428. * @param rootUrl The URL of the serialized pipeline.
  75429. * @returns An instantiated pipeline from the serialized object.
  75430. */
  75431. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75432. }
  75433. }
  75434. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75435. /** @hidden */
  75436. export var lensHighlightsPixelShader: {
  75437. name: string;
  75438. shader: string;
  75439. };
  75440. }
  75441. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75442. /** @hidden */
  75443. export var depthOfFieldPixelShader: {
  75444. name: string;
  75445. shader: string;
  75446. };
  75447. }
  75448. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75449. import { Camera } from "babylonjs/Cameras/camera";
  75450. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75451. import { Scene } from "babylonjs/scene";
  75452. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75453. import "babylonjs/Shaders/chromaticAberration.fragment";
  75454. import "babylonjs/Shaders/lensHighlights.fragment";
  75455. import "babylonjs/Shaders/depthOfField.fragment";
  75456. /**
  75457. * BABYLON.JS Chromatic Aberration GLSL Shader
  75458. * Author: Olivier Guyot
  75459. * Separates very slightly R, G and B colors on the edges of the screen
  75460. * Inspired by Francois Tarlier & Martins Upitis
  75461. */
  75462. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75463. /**
  75464. * @ignore
  75465. * The chromatic aberration PostProcess id in the pipeline
  75466. */
  75467. LensChromaticAberrationEffect: string;
  75468. /**
  75469. * @ignore
  75470. * The highlights enhancing PostProcess id in the pipeline
  75471. */
  75472. HighlightsEnhancingEffect: string;
  75473. /**
  75474. * @ignore
  75475. * The depth-of-field PostProcess id in the pipeline
  75476. */
  75477. LensDepthOfFieldEffect: string;
  75478. private _scene;
  75479. private _depthTexture;
  75480. private _grainTexture;
  75481. private _chromaticAberrationPostProcess;
  75482. private _highlightsPostProcess;
  75483. private _depthOfFieldPostProcess;
  75484. private _edgeBlur;
  75485. private _grainAmount;
  75486. private _chromaticAberration;
  75487. private _distortion;
  75488. private _highlightsGain;
  75489. private _highlightsThreshold;
  75490. private _dofDistance;
  75491. private _dofAperture;
  75492. private _dofDarken;
  75493. private _dofPentagon;
  75494. private _blurNoise;
  75495. /**
  75496. * @constructor
  75497. *
  75498. * Effect parameters are as follow:
  75499. * {
  75500. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75501. * edge_blur: number; // from 0 to x (1 for realism)
  75502. * distortion: number; // from 0 to x (1 for realism)
  75503. * grain_amount: number; // from 0 to 1
  75504. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75505. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75506. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75507. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75508. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75509. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75510. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75511. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75512. * }
  75513. * Note: if an effect parameter is unset, effect is disabled
  75514. *
  75515. * @param name The rendering pipeline name
  75516. * @param parameters - An object containing all parameters (see above)
  75517. * @param scene The scene linked to this pipeline
  75518. * @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)
  75519. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75520. */
  75521. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75522. /**
  75523. * Get the class name
  75524. * @returns "LensRenderingPipeline"
  75525. */
  75526. getClassName(): string;
  75527. /**
  75528. * Gets associated scene
  75529. */
  75530. get scene(): Scene;
  75531. /**
  75532. * Gets or sets the edge blur
  75533. */
  75534. get edgeBlur(): number;
  75535. set edgeBlur(value: number);
  75536. /**
  75537. * Gets or sets the grain amount
  75538. */
  75539. get grainAmount(): number;
  75540. set grainAmount(value: number);
  75541. /**
  75542. * Gets or sets the chromatic aberration amount
  75543. */
  75544. get chromaticAberration(): number;
  75545. set chromaticAberration(value: number);
  75546. /**
  75547. * Gets or sets the depth of field aperture
  75548. */
  75549. get dofAperture(): number;
  75550. set dofAperture(value: number);
  75551. /**
  75552. * Gets or sets the edge distortion
  75553. */
  75554. get edgeDistortion(): number;
  75555. set edgeDistortion(value: number);
  75556. /**
  75557. * Gets or sets the depth of field distortion
  75558. */
  75559. get dofDistortion(): number;
  75560. set dofDistortion(value: number);
  75561. /**
  75562. * Gets or sets the darken out of focus amount
  75563. */
  75564. get darkenOutOfFocus(): number;
  75565. set darkenOutOfFocus(value: number);
  75566. /**
  75567. * Gets or sets a boolean indicating if blur noise is enabled
  75568. */
  75569. get blurNoise(): boolean;
  75570. set blurNoise(value: boolean);
  75571. /**
  75572. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75573. */
  75574. get pentagonBokeh(): boolean;
  75575. set pentagonBokeh(value: boolean);
  75576. /**
  75577. * Gets or sets the highlight grain amount
  75578. */
  75579. get highlightsGain(): number;
  75580. set highlightsGain(value: number);
  75581. /**
  75582. * Gets or sets the highlight threshold
  75583. */
  75584. get highlightsThreshold(): number;
  75585. set highlightsThreshold(value: number);
  75586. /**
  75587. * Sets the amount of blur at the edges
  75588. * @param amount blur amount
  75589. */
  75590. setEdgeBlur(amount: number): void;
  75591. /**
  75592. * Sets edge blur to 0
  75593. */
  75594. disableEdgeBlur(): void;
  75595. /**
  75596. * Sets the amout of grain
  75597. * @param amount Amount of grain
  75598. */
  75599. setGrainAmount(amount: number): void;
  75600. /**
  75601. * Set grain amount to 0
  75602. */
  75603. disableGrain(): void;
  75604. /**
  75605. * Sets the chromatic aberration amount
  75606. * @param amount amount of chromatic aberration
  75607. */
  75608. setChromaticAberration(amount: number): void;
  75609. /**
  75610. * Sets chromatic aberration amount to 0
  75611. */
  75612. disableChromaticAberration(): void;
  75613. /**
  75614. * Sets the EdgeDistortion amount
  75615. * @param amount amount of EdgeDistortion
  75616. */
  75617. setEdgeDistortion(amount: number): void;
  75618. /**
  75619. * Sets edge distortion to 0
  75620. */
  75621. disableEdgeDistortion(): void;
  75622. /**
  75623. * Sets the FocusDistance amount
  75624. * @param amount amount of FocusDistance
  75625. */
  75626. setFocusDistance(amount: number): void;
  75627. /**
  75628. * Disables depth of field
  75629. */
  75630. disableDepthOfField(): void;
  75631. /**
  75632. * Sets the Aperture amount
  75633. * @param amount amount of Aperture
  75634. */
  75635. setAperture(amount: number): void;
  75636. /**
  75637. * Sets the DarkenOutOfFocus amount
  75638. * @param amount amount of DarkenOutOfFocus
  75639. */
  75640. setDarkenOutOfFocus(amount: number): void;
  75641. private _pentagonBokehIsEnabled;
  75642. /**
  75643. * Creates a pentagon bokeh effect
  75644. */
  75645. enablePentagonBokeh(): void;
  75646. /**
  75647. * Disables the pentagon bokeh effect
  75648. */
  75649. disablePentagonBokeh(): void;
  75650. /**
  75651. * Enables noise blur
  75652. */
  75653. enableNoiseBlur(): void;
  75654. /**
  75655. * Disables noise blur
  75656. */
  75657. disableNoiseBlur(): void;
  75658. /**
  75659. * Sets the HighlightsGain amount
  75660. * @param amount amount of HighlightsGain
  75661. */
  75662. setHighlightsGain(amount: number): void;
  75663. /**
  75664. * Sets the HighlightsThreshold amount
  75665. * @param amount amount of HighlightsThreshold
  75666. */
  75667. setHighlightsThreshold(amount: number): void;
  75668. /**
  75669. * Disables highlights
  75670. */
  75671. disableHighlights(): void;
  75672. /**
  75673. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75674. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75675. */
  75676. dispose(disableDepthRender?: boolean): void;
  75677. private _createChromaticAberrationPostProcess;
  75678. private _createHighlightsPostProcess;
  75679. private _createDepthOfFieldPostProcess;
  75680. private _createGrainTexture;
  75681. }
  75682. }
  75683. declare module "babylonjs/Rendering/ssao2Configuration" {
  75684. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75685. /**
  75686. * Contains all parameters needed for the prepass to perform
  75687. * screen space subsurface scattering
  75688. */
  75689. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75690. /**
  75691. * Is subsurface enabled
  75692. */
  75693. enabled: boolean;
  75694. /**
  75695. * Name of the configuration
  75696. */
  75697. name: string;
  75698. /**
  75699. * Textures that should be present in the MRT for this effect to work
  75700. */
  75701. readonly texturesRequired: number[];
  75702. }
  75703. }
  75704. declare module "babylonjs/Shaders/ssao2.fragment" {
  75705. /** @hidden */
  75706. export var ssao2PixelShader: {
  75707. name: string;
  75708. shader: string;
  75709. };
  75710. }
  75711. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75712. /** @hidden */
  75713. export var ssaoCombinePixelShader: {
  75714. name: string;
  75715. shader: string;
  75716. };
  75717. }
  75718. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75719. import { Camera } from "babylonjs/Cameras/camera";
  75720. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75721. import { Scene } from "babylonjs/scene";
  75722. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75723. import "babylonjs/Shaders/ssao2.fragment";
  75724. import "babylonjs/Shaders/ssaoCombine.fragment";
  75725. /**
  75726. * Render pipeline to produce ssao effect
  75727. */
  75728. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75729. /**
  75730. * @ignore
  75731. * The PassPostProcess id in the pipeline that contains the original scene color
  75732. */
  75733. SSAOOriginalSceneColorEffect: string;
  75734. /**
  75735. * @ignore
  75736. * The SSAO PostProcess id in the pipeline
  75737. */
  75738. SSAORenderEffect: string;
  75739. /**
  75740. * @ignore
  75741. * The horizontal blur PostProcess id in the pipeline
  75742. */
  75743. SSAOBlurHRenderEffect: string;
  75744. /**
  75745. * @ignore
  75746. * The vertical blur PostProcess id in the pipeline
  75747. */
  75748. SSAOBlurVRenderEffect: string;
  75749. /**
  75750. * @ignore
  75751. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75752. */
  75753. SSAOCombineRenderEffect: string;
  75754. /**
  75755. * The output strength of the SSAO post-process. Default value is 1.0.
  75756. */
  75757. totalStrength: number;
  75758. /**
  75759. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75760. */
  75761. maxZ: number;
  75762. /**
  75763. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75764. */
  75765. minZAspect: number;
  75766. private _samples;
  75767. /**
  75768. * Number of samples used for the SSAO calculations. Default value is 8
  75769. */
  75770. set samples(n: number);
  75771. get samples(): number;
  75772. private _textureSamples;
  75773. /**
  75774. * Number of samples to use for antialiasing
  75775. */
  75776. set textureSamples(n: number);
  75777. get textureSamples(): number;
  75778. /**
  75779. * Force rendering the geometry through geometry buffer
  75780. */
  75781. private _forceGeometryBuffer;
  75782. /**
  75783. * Ratio object used for SSAO ratio and blur ratio
  75784. */
  75785. private _ratio;
  75786. /**
  75787. * Dynamically generated sphere sampler.
  75788. */
  75789. private _sampleSphere;
  75790. /**
  75791. * Blur filter offsets
  75792. */
  75793. private _samplerOffsets;
  75794. private _expensiveBlur;
  75795. /**
  75796. * If bilateral blur should be used
  75797. */
  75798. set expensiveBlur(b: boolean);
  75799. get expensiveBlur(): boolean;
  75800. /**
  75801. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75802. */
  75803. radius: number;
  75804. /**
  75805. * The base color of the SSAO post-process
  75806. * The final result is "base + ssao" between [0, 1]
  75807. */
  75808. base: number;
  75809. /**
  75810. * Support test.
  75811. */
  75812. static get IsSupported(): boolean;
  75813. private _scene;
  75814. private _randomTexture;
  75815. private _originalColorPostProcess;
  75816. private _ssaoPostProcess;
  75817. private _blurHPostProcess;
  75818. private _blurVPostProcess;
  75819. private _ssaoCombinePostProcess;
  75820. private _prePassRenderer;
  75821. /**
  75822. * Gets active scene
  75823. */
  75824. get scene(): Scene;
  75825. /**
  75826. * @constructor
  75827. * @param name The rendering pipeline name
  75828. * @param scene The scene linked to this pipeline
  75829. * @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 }
  75830. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75831. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75832. */
  75833. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75834. /**
  75835. * Get the class name
  75836. * @returns "SSAO2RenderingPipeline"
  75837. */
  75838. getClassName(): string;
  75839. /**
  75840. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75841. */
  75842. dispose(disableGeometryBufferRenderer?: boolean): void;
  75843. private _createBlurPostProcess;
  75844. /** @hidden */
  75845. _rebuild(): void;
  75846. private _bits;
  75847. private _radicalInverse_VdC;
  75848. private _hammersley;
  75849. private _hemisphereSample_uniform;
  75850. private _generateHemisphere;
  75851. private _getDefinesForSSAO;
  75852. private _createSSAOPostProcess;
  75853. private _createSSAOCombinePostProcess;
  75854. private _createRandomTexture;
  75855. /**
  75856. * Serialize the rendering pipeline (Used when exporting)
  75857. * @returns the serialized object
  75858. */
  75859. serialize(): any;
  75860. /**
  75861. * Parse the serialized pipeline
  75862. * @param source Source pipeline.
  75863. * @param scene The scene to load the pipeline to.
  75864. * @param rootUrl The URL of the serialized pipeline.
  75865. * @returns An instantiated pipeline from the serialized object.
  75866. */
  75867. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75868. }
  75869. }
  75870. declare module "babylonjs/Shaders/ssao.fragment" {
  75871. /** @hidden */
  75872. export var ssaoPixelShader: {
  75873. name: string;
  75874. shader: string;
  75875. };
  75876. }
  75877. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75878. import { Camera } from "babylonjs/Cameras/camera";
  75879. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75880. import { Scene } from "babylonjs/scene";
  75881. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75882. import "babylonjs/Shaders/ssao.fragment";
  75883. import "babylonjs/Shaders/ssaoCombine.fragment";
  75884. /**
  75885. * Render pipeline to produce ssao effect
  75886. */
  75887. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75888. /**
  75889. * @ignore
  75890. * The PassPostProcess id in the pipeline that contains the original scene color
  75891. */
  75892. SSAOOriginalSceneColorEffect: string;
  75893. /**
  75894. * @ignore
  75895. * The SSAO PostProcess id in the pipeline
  75896. */
  75897. SSAORenderEffect: string;
  75898. /**
  75899. * @ignore
  75900. * The horizontal blur PostProcess id in the pipeline
  75901. */
  75902. SSAOBlurHRenderEffect: string;
  75903. /**
  75904. * @ignore
  75905. * The vertical blur PostProcess id in the pipeline
  75906. */
  75907. SSAOBlurVRenderEffect: string;
  75908. /**
  75909. * @ignore
  75910. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75911. */
  75912. SSAOCombineRenderEffect: string;
  75913. /**
  75914. * The output strength of the SSAO post-process. Default value is 1.0.
  75915. */
  75916. totalStrength: number;
  75917. /**
  75918. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75919. */
  75920. radius: number;
  75921. /**
  75922. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75923. * Must not be equal to fallOff and superior to fallOff.
  75924. * Default value is 0.0075
  75925. */
  75926. area: number;
  75927. /**
  75928. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75929. * Must not be equal to area and inferior to area.
  75930. * Default value is 0.000001
  75931. */
  75932. fallOff: number;
  75933. /**
  75934. * The base color of the SSAO post-process
  75935. * The final result is "base + ssao" between [0, 1]
  75936. */
  75937. base: number;
  75938. private _scene;
  75939. private _depthTexture;
  75940. private _randomTexture;
  75941. private _originalColorPostProcess;
  75942. private _ssaoPostProcess;
  75943. private _blurHPostProcess;
  75944. private _blurVPostProcess;
  75945. private _ssaoCombinePostProcess;
  75946. private _firstUpdate;
  75947. /**
  75948. * Gets active scene
  75949. */
  75950. get scene(): Scene;
  75951. /**
  75952. * @constructor
  75953. * @param name - The rendering pipeline name
  75954. * @param scene - The scene linked to this pipeline
  75955. * @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 }
  75956. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75957. */
  75958. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75959. /**
  75960. * Get the class name
  75961. * @returns "SSAORenderingPipeline"
  75962. */
  75963. getClassName(): string;
  75964. /**
  75965. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75966. */
  75967. dispose(disableDepthRender?: boolean): void;
  75968. private _createBlurPostProcess;
  75969. /** @hidden */
  75970. _rebuild(): void;
  75971. private _createSSAOPostProcess;
  75972. private _createSSAOCombinePostProcess;
  75973. private _createRandomTexture;
  75974. }
  75975. }
  75976. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75977. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75978. /**
  75979. * Contains all parameters needed for the prepass to perform
  75980. * screen space reflections
  75981. */
  75982. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75983. /**
  75984. * Is ssr enabled
  75985. */
  75986. enabled: boolean;
  75987. /**
  75988. * Name of the configuration
  75989. */
  75990. name: string;
  75991. /**
  75992. * Textures that should be present in the MRT for this effect to work
  75993. */
  75994. readonly texturesRequired: number[];
  75995. }
  75996. }
  75997. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75998. /** @hidden */
  75999. export var screenSpaceReflectionPixelShader: {
  76000. name: string;
  76001. shader: string;
  76002. };
  76003. }
  76004. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  76005. import { Nullable } from "babylonjs/types";
  76006. import { Camera } from "babylonjs/Cameras/camera";
  76007. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76008. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  76009. import { Engine } from "babylonjs/Engines/engine";
  76010. import { Scene } from "babylonjs/scene";
  76011. /**
  76012. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  76013. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  76014. */
  76015. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  76016. /**
  76017. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  76018. */
  76019. threshold: number;
  76020. /**
  76021. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  76022. */
  76023. strength: number;
  76024. /**
  76025. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  76026. */
  76027. reflectionSpecularFalloffExponent: number;
  76028. /**
  76029. * 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]
  76030. */
  76031. step: number;
  76032. /**
  76033. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  76034. */
  76035. roughnessFactor: number;
  76036. private _forceGeometryBuffer;
  76037. private _geometryBufferRenderer;
  76038. private _prePassRenderer;
  76039. private _enableSmoothReflections;
  76040. private _reflectionSamples;
  76041. private _smoothSteps;
  76042. /**
  76043. * Gets a string identifying the name of the class
  76044. * @returns "ScreenSpaceReflectionPostProcess" string
  76045. */
  76046. getClassName(): string;
  76047. /**
  76048. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  76049. * @param name The name of the effect.
  76050. * @param scene The scene containing the objects to calculate reflections.
  76051. * @param options The required width/height ratio to downsize to before computing the render pass.
  76052. * @param camera The camera to apply the render pass to.
  76053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76054. * @param engine The engine which the post process will be applied. (default: current engine)
  76055. * @param reusable If the post process can be reused on the same frame. (default: false)
  76056. * @param textureType Type of textures used when performing the post process. (default: 0)
  76057. * @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)
  76058. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  76059. */
  76060. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  76061. /**
  76062. * Gets wether or not smoothing reflections is enabled.
  76063. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76064. */
  76065. get enableSmoothReflections(): boolean;
  76066. /**
  76067. * Sets wether or not smoothing reflections is enabled.
  76068. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76069. */
  76070. set enableSmoothReflections(enabled: boolean);
  76071. /**
  76072. * Gets the number of samples taken while computing reflections. More samples count is high,
  76073. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76074. */
  76075. get reflectionSamples(): number;
  76076. /**
  76077. * Sets the number of samples taken while computing reflections. More samples count is high,
  76078. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76079. */
  76080. set reflectionSamples(samples: number);
  76081. /**
  76082. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76083. * more the post-process will require GPU power and can generate a drop in FPS.
  76084. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76085. */
  76086. get smoothSteps(): number;
  76087. set smoothSteps(steps: number);
  76088. private _updateEffectDefines;
  76089. /** @hidden */
  76090. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76091. }
  76092. }
  76093. declare module "babylonjs/Shaders/standard.fragment" {
  76094. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  76095. /** @hidden */
  76096. export var standardPixelShader: {
  76097. name: string;
  76098. shader: string;
  76099. };
  76100. }
  76101. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  76102. import { Nullable } from "babylonjs/types";
  76103. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  76104. import { Camera } from "babylonjs/Cameras/camera";
  76105. import { Texture } from "babylonjs/Materials/Textures/texture";
  76106. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76107. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76108. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  76109. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  76110. import { IDisposable } from "babylonjs/scene";
  76111. import { SpotLight } from "babylonjs/Lights/spotLight";
  76112. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  76113. import { Scene } from "babylonjs/scene";
  76114. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76115. import { Animation } from "babylonjs/Animations/animation";
  76116. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76117. import "babylonjs/Shaders/standard.fragment";
  76118. /**
  76119. * Standard rendering pipeline
  76120. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76121. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76122. */
  76123. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76124. /**
  76125. * Public members
  76126. */
  76127. /**
  76128. * Post-process which contains the original scene color before the pipeline applies all the effects
  76129. */
  76130. originalPostProcess: Nullable<PostProcess>;
  76131. /**
  76132. * Post-process used to down scale an image x4
  76133. */
  76134. downSampleX4PostProcess: Nullable<PostProcess>;
  76135. /**
  76136. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76137. */
  76138. brightPassPostProcess: Nullable<PostProcess>;
  76139. /**
  76140. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76141. */
  76142. blurHPostProcesses: PostProcess[];
  76143. /**
  76144. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76145. */
  76146. blurVPostProcesses: PostProcess[];
  76147. /**
  76148. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76149. */
  76150. textureAdderPostProcess: Nullable<PostProcess>;
  76151. /**
  76152. * Post-process used to create volumetric lighting effect
  76153. */
  76154. volumetricLightPostProcess: Nullable<PostProcess>;
  76155. /**
  76156. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76157. */
  76158. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76159. /**
  76160. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76161. */
  76162. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76163. /**
  76164. * Post-process used to merge the volumetric light effect and the real scene color
  76165. */
  76166. volumetricLightMergePostProces: Nullable<PostProcess>;
  76167. /**
  76168. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76169. */
  76170. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76171. /**
  76172. * Base post-process used to calculate the average luminance of the final image for HDR
  76173. */
  76174. luminancePostProcess: Nullable<PostProcess>;
  76175. /**
  76176. * Post-processes used to create down sample post-processes in order to get
  76177. * the average luminance of the final image for HDR
  76178. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76179. */
  76180. luminanceDownSamplePostProcesses: PostProcess[];
  76181. /**
  76182. * Post-process used to create a HDR effect (light adaptation)
  76183. */
  76184. hdrPostProcess: Nullable<PostProcess>;
  76185. /**
  76186. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76187. */
  76188. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76189. /**
  76190. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76191. */
  76192. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76193. /**
  76194. * Post-process used to merge the final HDR post-process and the real scene color
  76195. */
  76196. hdrFinalPostProcess: Nullable<PostProcess>;
  76197. /**
  76198. * Post-process used to create a lens flare effect
  76199. */
  76200. lensFlarePostProcess: Nullable<PostProcess>;
  76201. /**
  76202. * Post-process that merges the result of the lens flare post-process and the real scene color
  76203. */
  76204. lensFlareComposePostProcess: Nullable<PostProcess>;
  76205. /**
  76206. * Post-process used to create a motion blur effect
  76207. */
  76208. motionBlurPostProcess: Nullable<PostProcess>;
  76209. /**
  76210. * Post-process used to create a depth of field effect
  76211. */
  76212. depthOfFieldPostProcess: Nullable<PostProcess>;
  76213. /**
  76214. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  76215. */
  76216. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76217. /**
  76218. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76219. */
  76220. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76221. /**
  76222. * Represents the brightness threshold in order to configure the illuminated surfaces
  76223. */
  76224. brightThreshold: number;
  76225. /**
  76226. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76227. */
  76228. blurWidth: number;
  76229. /**
  76230. * Sets if the blur for highlighted surfaces must be only horizontal
  76231. */
  76232. horizontalBlur: boolean;
  76233. /**
  76234. * Gets the overall exposure used by the pipeline
  76235. */
  76236. get exposure(): number;
  76237. /**
  76238. * Sets the overall exposure used by the pipeline
  76239. */
  76240. set exposure(value: number);
  76241. /**
  76242. * Texture used typically to simulate "dirty" on camera lens
  76243. */
  76244. lensTexture: Nullable<Texture>;
  76245. /**
  76246. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76247. */
  76248. volumetricLightCoefficient: number;
  76249. /**
  76250. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76251. */
  76252. volumetricLightPower: number;
  76253. /**
  76254. * Used the set the blur intensity to smooth the volumetric lights
  76255. */
  76256. volumetricLightBlurScale: number;
  76257. /**
  76258. * Light (spot or directional) used to generate the volumetric lights rays
  76259. * The source light must have a shadow generate so the pipeline can get its
  76260. * depth map
  76261. */
  76262. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76263. /**
  76264. * For eye adaptation, represents the minimum luminance the eye can see
  76265. */
  76266. hdrMinimumLuminance: number;
  76267. /**
  76268. * For eye adaptation, represents the decrease luminance speed
  76269. */
  76270. hdrDecreaseRate: number;
  76271. /**
  76272. * For eye adaptation, represents the increase luminance speed
  76273. */
  76274. hdrIncreaseRate: number;
  76275. /**
  76276. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76277. */
  76278. get hdrAutoExposure(): boolean;
  76279. /**
  76280. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76281. */
  76282. set hdrAutoExposure(value: boolean);
  76283. /**
  76284. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76285. */
  76286. lensColorTexture: Nullable<Texture>;
  76287. /**
  76288. * The overall strengh for the lens flare effect
  76289. */
  76290. lensFlareStrength: number;
  76291. /**
  76292. * Dispersion coefficient for lens flare ghosts
  76293. */
  76294. lensFlareGhostDispersal: number;
  76295. /**
  76296. * Main lens flare halo width
  76297. */
  76298. lensFlareHaloWidth: number;
  76299. /**
  76300. * Based on the lens distortion effect, defines how much the lens flare result
  76301. * is distorted
  76302. */
  76303. lensFlareDistortionStrength: number;
  76304. /**
  76305. * Configures the blur intensity used for for lens flare (halo)
  76306. */
  76307. lensFlareBlurWidth: number;
  76308. /**
  76309. * Lens star texture must be used to simulate rays on the flares and is available
  76310. * in the documentation
  76311. */
  76312. lensStarTexture: Nullable<Texture>;
  76313. /**
  76314. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76315. * flare effect by taking account of the dirt texture
  76316. */
  76317. lensFlareDirtTexture: Nullable<Texture>;
  76318. /**
  76319. * Represents the focal length for the depth of field effect
  76320. */
  76321. depthOfFieldDistance: number;
  76322. /**
  76323. * Represents the blur intensity for the blurred part of the depth of field effect
  76324. */
  76325. depthOfFieldBlurWidth: number;
  76326. /**
  76327. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76328. */
  76329. get motionStrength(): number;
  76330. /**
  76331. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76332. */
  76333. set motionStrength(strength: number);
  76334. /**
  76335. * Gets wether or not the motion blur post-process is object based or screen based.
  76336. */
  76337. get objectBasedMotionBlur(): boolean;
  76338. /**
  76339. * Sets wether or not the motion blur post-process should be object based or screen based
  76340. */
  76341. set objectBasedMotionBlur(value: boolean);
  76342. /**
  76343. * List of animations for the pipeline (IAnimatable implementation)
  76344. */
  76345. animations: Animation[];
  76346. /**
  76347. * Private members
  76348. */
  76349. private _scene;
  76350. private _currentDepthOfFieldSource;
  76351. private _basePostProcess;
  76352. private _fixedExposure;
  76353. private _currentExposure;
  76354. private _hdrAutoExposure;
  76355. private _hdrCurrentLuminance;
  76356. private _motionStrength;
  76357. private _isObjectBasedMotionBlur;
  76358. private _floatTextureType;
  76359. private _camerasToBeAttached;
  76360. private _ratio;
  76361. private _bloomEnabled;
  76362. private _depthOfFieldEnabled;
  76363. private _vlsEnabled;
  76364. private _lensFlareEnabled;
  76365. private _hdrEnabled;
  76366. private _motionBlurEnabled;
  76367. private _fxaaEnabled;
  76368. private _screenSpaceReflectionsEnabled;
  76369. private _motionBlurSamples;
  76370. private _volumetricLightStepsCount;
  76371. private _samples;
  76372. /**
  76373. * @ignore
  76374. * Specifies if the bloom pipeline is enabled
  76375. */
  76376. get BloomEnabled(): boolean;
  76377. set BloomEnabled(enabled: boolean);
  76378. /**
  76379. * @ignore
  76380. * Specifies if the depth of field pipeline is enabed
  76381. */
  76382. get DepthOfFieldEnabled(): boolean;
  76383. set DepthOfFieldEnabled(enabled: boolean);
  76384. /**
  76385. * @ignore
  76386. * Specifies if the lens flare pipeline is enabed
  76387. */
  76388. get LensFlareEnabled(): boolean;
  76389. set LensFlareEnabled(enabled: boolean);
  76390. /**
  76391. * @ignore
  76392. * Specifies if the HDR pipeline is enabled
  76393. */
  76394. get HDREnabled(): boolean;
  76395. set HDREnabled(enabled: boolean);
  76396. /**
  76397. * @ignore
  76398. * Specifies if the volumetric lights scattering effect is enabled
  76399. */
  76400. get VLSEnabled(): boolean;
  76401. set VLSEnabled(enabled: boolean);
  76402. /**
  76403. * @ignore
  76404. * Specifies if the motion blur effect is enabled
  76405. */
  76406. get MotionBlurEnabled(): boolean;
  76407. set MotionBlurEnabled(enabled: boolean);
  76408. /**
  76409. * Specifies if anti-aliasing is enabled
  76410. */
  76411. get fxaaEnabled(): boolean;
  76412. set fxaaEnabled(enabled: boolean);
  76413. /**
  76414. * Specifies if screen space reflections are enabled.
  76415. */
  76416. get screenSpaceReflectionsEnabled(): boolean;
  76417. set screenSpaceReflectionsEnabled(enabled: boolean);
  76418. /**
  76419. * Specifies the number of steps used to calculate the volumetric lights
  76420. * Typically in interval [50, 200]
  76421. */
  76422. get volumetricLightStepsCount(): number;
  76423. set volumetricLightStepsCount(count: number);
  76424. /**
  76425. * Specifies the number of samples used for the motion blur effect
  76426. * Typically in interval [16, 64]
  76427. */
  76428. get motionBlurSamples(): number;
  76429. set motionBlurSamples(samples: number);
  76430. /**
  76431. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76432. */
  76433. get samples(): number;
  76434. set samples(sampleCount: number);
  76435. /**
  76436. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76437. * @constructor
  76438. * @param name The rendering pipeline name
  76439. * @param scene The scene linked to this pipeline
  76440. * @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)
  76441. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76442. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76443. */
  76444. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76445. private _buildPipeline;
  76446. private _createDownSampleX4PostProcess;
  76447. private _createBrightPassPostProcess;
  76448. private _createBlurPostProcesses;
  76449. private _createTextureAdderPostProcess;
  76450. private _createVolumetricLightPostProcess;
  76451. private _createLuminancePostProcesses;
  76452. private _createHdrPostProcess;
  76453. private _createLensFlarePostProcess;
  76454. private _createDepthOfFieldPostProcess;
  76455. private _createMotionBlurPostProcess;
  76456. private _getDepthTexture;
  76457. private _disposePostProcesses;
  76458. /**
  76459. * Dispose of the pipeline and stop all post processes
  76460. */
  76461. dispose(): void;
  76462. /**
  76463. * Serialize the rendering pipeline (Used when exporting)
  76464. * @returns the serialized object
  76465. */
  76466. serialize(): any;
  76467. /**
  76468. * Parse the serialized pipeline
  76469. * @param source Source pipeline.
  76470. * @param scene The scene to load the pipeline to.
  76471. * @param rootUrl The URL of the serialized pipeline.
  76472. * @returns An instantiated pipeline from the serialized object.
  76473. */
  76474. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76475. /**
  76476. * Luminance steps
  76477. */
  76478. static LuminanceSteps: number;
  76479. }
  76480. }
  76481. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76482. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76483. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76484. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76485. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76486. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76487. }
  76488. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76489. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76490. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76491. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76492. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76493. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76494. }
  76495. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76496. /** @hidden */
  76497. export var stereoscopicInterlacePixelShader: {
  76498. name: string;
  76499. shader: string;
  76500. };
  76501. }
  76502. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76503. import { Camera } from "babylonjs/Cameras/camera";
  76504. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76505. import { Engine } from "babylonjs/Engines/engine";
  76506. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76507. /**
  76508. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76509. */
  76510. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76511. private _stepSize;
  76512. private _passedProcess;
  76513. /**
  76514. * Gets a string identifying the name of the class
  76515. * @returns "StereoscopicInterlacePostProcessI" string
  76516. */
  76517. getClassName(): string;
  76518. /**
  76519. * Initializes a StereoscopicInterlacePostProcessI
  76520. * @param name The name of the effect.
  76521. * @param rigCameras The rig cameras to be appled to the post process
  76522. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76523. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76525. * @param engine The engine which the post process will be applied. (default: current engine)
  76526. * @param reusable If the post process can be reused on the same frame. (default: false)
  76527. */
  76528. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76529. }
  76530. /**
  76531. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76532. */
  76533. export class StereoscopicInterlacePostProcess extends PostProcess {
  76534. private _stepSize;
  76535. private _passedProcess;
  76536. /**
  76537. * Gets a string identifying the name of the class
  76538. * @returns "StereoscopicInterlacePostProcess" string
  76539. */
  76540. getClassName(): string;
  76541. /**
  76542. * Initializes a StereoscopicInterlacePostProcess
  76543. * @param name The name of the effect.
  76544. * @param rigCameras The rig cameras to be appled to the post process
  76545. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76547. * @param engine The engine which the post process will be applied. (default: current engine)
  76548. * @param reusable If the post process can be reused on the same frame. (default: false)
  76549. */
  76550. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76551. }
  76552. }
  76553. declare module "babylonjs/Shaders/tonemap.fragment" {
  76554. /** @hidden */
  76555. export var tonemapPixelShader: {
  76556. name: string;
  76557. shader: string;
  76558. };
  76559. }
  76560. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76561. import { Camera } from "babylonjs/Cameras/camera";
  76562. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76563. import "babylonjs/Shaders/tonemap.fragment";
  76564. import { Engine } from "babylonjs/Engines/engine";
  76565. /** Defines operator used for tonemapping */
  76566. export enum TonemappingOperator {
  76567. /** Hable */
  76568. Hable = 0,
  76569. /** Reinhard */
  76570. Reinhard = 1,
  76571. /** HejiDawson */
  76572. HejiDawson = 2,
  76573. /** Photographic */
  76574. Photographic = 3
  76575. }
  76576. /**
  76577. * Defines a post process to apply tone mapping
  76578. */
  76579. export class TonemapPostProcess extends PostProcess {
  76580. private _operator;
  76581. /** Defines the required exposure adjustement */
  76582. exposureAdjustment: number;
  76583. /**
  76584. * Gets a string identifying the name of the class
  76585. * @returns "TonemapPostProcess" string
  76586. */
  76587. getClassName(): string;
  76588. /**
  76589. * Creates a new TonemapPostProcess
  76590. * @param name defines the name of the postprocess
  76591. * @param _operator defines the operator to use
  76592. * @param exposureAdjustment defines the required exposure adjustement
  76593. * @param camera defines the camera to use (can be null)
  76594. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76595. * @param engine defines the hosting engine (can be ignore if camera is set)
  76596. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76597. */
  76598. constructor(name: string, _operator: TonemappingOperator,
  76599. /** Defines the required exposure adjustement */
  76600. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76601. }
  76602. }
  76603. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76604. /** @hidden */
  76605. export var volumetricLightScatteringPixelShader: {
  76606. name: string;
  76607. shader: string;
  76608. };
  76609. }
  76610. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76611. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76612. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76613. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76614. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76615. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76616. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76617. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76618. /** @hidden */
  76619. export var volumetricLightScatteringPassVertexShader: {
  76620. name: string;
  76621. shader: string;
  76622. };
  76623. }
  76624. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76625. /** @hidden */
  76626. export var volumetricLightScatteringPassPixelShader: {
  76627. name: string;
  76628. shader: string;
  76629. };
  76630. }
  76631. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76632. import { Vector3 } from "babylonjs/Maths/math.vector";
  76633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76634. import { Mesh } from "babylonjs/Meshes/mesh";
  76635. import { Camera } from "babylonjs/Cameras/camera";
  76636. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76637. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76638. import { Scene } from "babylonjs/scene";
  76639. import "babylonjs/Meshes/Builders/planeBuilder";
  76640. import "babylonjs/Shaders/depth.vertex";
  76641. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76642. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76643. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76644. import { Engine } from "babylonjs/Engines/engine";
  76645. /**
  76646. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76647. */
  76648. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76649. private _volumetricLightScatteringPass;
  76650. private _volumetricLightScatteringRTT;
  76651. private _viewPort;
  76652. private _screenCoordinates;
  76653. private _cachedDefines;
  76654. /**
  76655. * If not undefined, the mesh position is computed from the attached node position
  76656. */
  76657. attachedNode: {
  76658. position: Vector3;
  76659. };
  76660. /**
  76661. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76662. */
  76663. customMeshPosition: Vector3;
  76664. /**
  76665. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76666. */
  76667. useCustomMeshPosition: boolean;
  76668. /**
  76669. * If the post-process should inverse the light scattering direction
  76670. */
  76671. invert: boolean;
  76672. /**
  76673. * The internal mesh used by the post-process
  76674. */
  76675. mesh: Mesh;
  76676. /**
  76677. * @hidden
  76678. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76679. */
  76680. get useDiffuseColor(): boolean;
  76681. set useDiffuseColor(useDiffuseColor: boolean);
  76682. /**
  76683. * Array containing the excluded meshes not rendered in the internal pass
  76684. */
  76685. excludedMeshes: AbstractMesh[];
  76686. /**
  76687. * Controls the overall intensity of the post-process
  76688. */
  76689. exposure: number;
  76690. /**
  76691. * Dissipates each sample's contribution in range [0, 1]
  76692. */
  76693. decay: number;
  76694. /**
  76695. * Controls the overall intensity of each sample
  76696. */
  76697. weight: number;
  76698. /**
  76699. * Controls the density of each sample
  76700. */
  76701. density: number;
  76702. /**
  76703. * @constructor
  76704. * @param name The post-process name
  76705. * @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)
  76706. * @param camera The camera that the post-process will be attached to
  76707. * @param mesh The mesh used to create the light scattering
  76708. * @param samples The post-process quality, default 100
  76709. * @param samplingModeThe post-process filtering mode
  76710. * @param engine The babylon engine
  76711. * @param reusable If the post-process is reusable
  76712. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76713. */
  76714. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76715. /**
  76716. * Returns the string "VolumetricLightScatteringPostProcess"
  76717. * @returns "VolumetricLightScatteringPostProcess"
  76718. */
  76719. getClassName(): string;
  76720. private _isReady;
  76721. /**
  76722. * Sets the new light position for light scattering effect
  76723. * @param position The new custom light position
  76724. */
  76725. setCustomMeshPosition(position: Vector3): void;
  76726. /**
  76727. * Returns the light position for light scattering effect
  76728. * @return Vector3 The custom light position
  76729. */
  76730. getCustomMeshPosition(): Vector3;
  76731. /**
  76732. * Disposes the internal assets and detaches the post-process from the camera
  76733. */
  76734. dispose(camera: Camera): void;
  76735. /**
  76736. * Returns the render target texture used by the post-process
  76737. * @return the render target texture used by the post-process
  76738. */
  76739. getPass(): RenderTargetTexture;
  76740. private _meshExcluded;
  76741. private _createPass;
  76742. private _updateMeshScreenCoordinates;
  76743. /**
  76744. * Creates a default mesh for the Volumeric Light Scattering post-process
  76745. * @param name The mesh name
  76746. * @param scene The scene where to create the mesh
  76747. * @return the default mesh
  76748. */
  76749. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76750. }
  76751. }
  76752. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76753. /** @hidden */
  76754. export var screenSpaceCurvaturePixelShader: {
  76755. name: string;
  76756. shader: string;
  76757. };
  76758. }
  76759. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76760. import { Nullable } from "babylonjs/types";
  76761. import { Camera } from "babylonjs/Cameras/camera";
  76762. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76763. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76764. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76765. import { Engine } from "babylonjs/Engines/engine";
  76766. import { Scene } from "babylonjs/scene";
  76767. /**
  76768. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76769. */
  76770. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76771. /**
  76772. * Defines how much ridge the curvature effect displays.
  76773. */
  76774. ridge: number;
  76775. /**
  76776. * Defines how much valley the curvature effect displays.
  76777. */
  76778. valley: number;
  76779. private _geometryBufferRenderer;
  76780. /**
  76781. * Gets a string identifying the name of the class
  76782. * @returns "ScreenSpaceCurvaturePostProcess" string
  76783. */
  76784. getClassName(): string;
  76785. /**
  76786. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76787. * @param name The name of the effect.
  76788. * @param scene The scene containing the objects to blur according to their velocity.
  76789. * @param options The required width/height ratio to downsize to before computing the render pass.
  76790. * @param camera The camera to apply the render pass to.
  76791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76792. * @param engine The engine which the post process will be applied. (default: current engine)
  76793. * @param reusable If the post process can be reused on the same frame. (default: false)
  76794. * @param textureType Type of textures used when performing the post process. (default: 0)
  76795. * @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)
  76796. */
  76797. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76798. /**
  76799. * Support test.
  76800. */
  76801. static get IsSupported(): boolean;
  76802. /** @hidden */
  76803. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76804. }
  76805. }
  76806. declare module "babylonjs/PostProcesses/index" {
  76807. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76808. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76809. export * from "babylonjs/PostProcesses/bloomEffect";
  76810. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76811. export * from "babylonjs/PostProcesses/blurPostProcess";
  76812. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76813. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76814. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76815. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76816. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76817. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76818. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76819. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76820. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76821. export * from "babylonjs/PostProcesses/filterPostProcess";
  76822. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76823. export * from "babylonjs/PostProcesses/grainPostProcess";
  76824. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76825. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76826. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76827. export * from "babylonjs/PostProcesses/passPostProcess";
  76828. export * from "babylonjs/PostProcesses/postProcess";
  76829. export * from "babylonjs/PostProcesses/postProcessManager";
  76830. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76831. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76832. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76833. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76834. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76835. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76836. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76837. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76838. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76839. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76840. }
  76841. declare module "babylonjs/Probes/index" {
  76842. export * from "babylonjs/Probes/reflectionProbe";
  76843. }
  76844. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76845. import { Scene } from "babylonjs/scene";
  76846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76847. import { SmartArray } from "babylonjs/Misc/smartArray";
  76848. import { ISceneComponent } from "babylonjs/sceneComponent";
  76849. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76850. import "babylonjs/Meshes/Builders/boxBuilder";
  76851. import "babylonjs/Shaders/color.fragment";
  76852. import "babylonjs/Shaders/color.vertex";
  76853. import { Color3 } from "babylonjs/Maths/math.color";
  76854. import { Observable } from "babylonjs/Misc/observable";
  76855. module "babylonjs/scene" {
  76856. interface Scene {
  76857. /** @hidden (Backing field) */
  76858. _boundingBoxRenderer: BoundingBoxRenderer;
  76859. /** @hidden (Backing field) */
  76860. _forceShowBoundingBoxes: boolean;
  76861. /**
  76862. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76863. */
  76864. forceShowBoundingBoxes: boolean;
  76865. /**
  76866. * Gets the bounding box renderer associated with the scene
  76867. * @returns a BoundingBoxRenderer
  76868. */
  76869. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76870. }
  76871. }
  76872. module "babylonjs/Meshes/abstractMesh" {
  76873. interface AbstractMesh {
  76874. /** @hidden (Backing field) */
  76875. _showBoundingBox: boolean;
  76876. /**
  76877. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76878. */
  76879. showBoundingBox: boolean;
  76880. }
  76881. }
  76882. /**
  76883. * Component responsible of rendering the bounding box of the meshes in a scene.
  76884. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76885. */
  76886. export class BoundingBoxRenderer implements ISceneComponent {
  76887. /**
  76888. * The component name helpfull to identify the component in the list of scene components.
  76889. */
  76890. readonly name: string;
  76891. /**
  76892. * The scene the component belongs to.
  76893. */
  76894. scene: Scene;
  76895. /**
  76896. * Color of the bounding box lines placed in front of an object
  76897. */
  76898. frontColor: Color3;
  76899. /**
  76900. * Color of the bounding box lines placed behind an object
  76901. */
  76902. backColor: Color3;
  76903. /**
  76904. * Defines if the renderer should show the back lines or not
  76905. */
  76906. showBackLines: boolean;
  76907. /**
  76908. * Observable raised before rendering a bounding box
  76909. */
  76910. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76911. /**
  76912. * Observable raised after rendering a bounding box
  76913. */
  76914. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76915. /**
  76916. * Observable raised after resources are created
  76917. */
  76918. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76919. /**
  76920. * When false, no bounding boxes will be rendered
  76921. */
  76922. enabled: boolean;
  76923. /**
  76924. * @hidden
  76925. */
  76926. renderList: SmartArray<BoundingBox>;
  76927. private _colorShader;
  76928. private _vertexBuffers;
  76929. private _indexBuffer;
  76930. private _fillIndexBuffer;
  76931. private _fillIndexData;
  76932. /**
  76933. * Instantiates a new bounding box renderer in a scene.
  76934. * @param scene the scene the renderer renders in
  76935. */
  76936. constructor(scene: Scene);
  76937. /**
  76938. * Registers the component in a given scene
  76939. */
  76940. register(): void;
  76941. private _evaluateSubMesh;
  76942. private _preActiveMesh;
  76943. private _prepareResources;
  76944. private _createIndexBuffer;
  76945. /**
  76946. * Rebuilds the elements related to this component in case of
  76947. * context lost for instance.
  76948. */
  76949. rebuild(): void;
  76950. /**
  76951. * @hidden
  76952. */
  76953. reset(): void;
  76954. /**
  76955. * Render the bounding boxes of a specific rendering group
  76956. * @param renderingGroupId defines the rendering group to render
  76957. */
  76958. render(renderingGroupId: number): void;
  76959. /**
  76960. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76961. * @param mesh Define the mesh to render the occlusion bounding box for
  76962. */
  76963. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76964. /**
  76965. * Dispose and release the resources attached to this renderer.
  76966. */
  76967. dispose(): void;
  76968. }
  76969. }
  76970. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76971. import { Nullable } from "babylonjs/types";
  76972. import { Scene } from "babylonjs/scene";
  76973. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76974. import { Camera } from "babylonjs/Cameras/camera";
  76975. import { ISceneComponent } from "babylonjs/sceneComponent";
  76976. module "babylonjs/scene" {
  76977. interface Scene {
  76978. /** @hidden (Backing field) */
  76979. _depthRenderer: {
  76980. [id: string]: DepthRenderer;
  76981. };
  76982. /**
  76983. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76984. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76985. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76986. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76987. * @returns the created depth renderer
  76988. */
  76989. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76990. /**
  76991. * Disables a depth renderer for a given camera
  76992. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76993. */
  76994. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76995. }
  76996. }
  76997. /**
  76998. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76999. * in several rendering techniques.
  77000. */
  77001. export class DepthRendererSceneComponent implements ISceneComponent {
  77002. /**
  77003. * The component name helpfull to identify the component in the list of scene components.
  77004. */
  77005. readonly name: string;
  77006. /**
  77007. * The scene the component belongs to.
  77008. */
  77009. scene: Scene;
  77010. /**
  77011. * Creates a new instance of the component for the given scene
  77012. * @param scene Defines the scene to register the component in
  77013. */
  77014. constructor(scene: Scene);
  77015. /**
  77016. * Registers the component in a given scene
  77017. */
  77018. register(): void;
  77019. /**
  77020. * Rebuilds the elements related to this component in case of
  77021. * context lost for instance.
  77022. */
  77023. rebuild(): void;
  77024. /**
  77025. * Disposes the component and the associated ressources
  77026. */
  77027. dispose(): void;
  77028. private _gatherRenderTargets;
  77029. private _gatherActiveCameraRenderTargets;
  77030. }
  77031. }
  77032. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  77033. import { Nullable } from "babylonjs/types";
  77034. import { Scene } from "babylonjs/scene";
  77035. import { ISceneComponent } from "babylonjs/sceneComponent";
  77036. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  77037. module "babylonjs/abstractScene" {
  77038. interface AbstractScene {
  77039. /** @hidden (Backing field) */
  77040. _prePassRenderer: Nullable<PrePassRenderer>;
  77041. /**
  77042. * Gets or Sets the current prepass renderer associated to the scene.
  77043. */
  77044. prePassRenderer: Nullable<PrePassRenderer>;
  77045. /**
  77046. * Enables the prepass and associates it with the scene
  77047. * @returns the PrePassRenderer
  77048. */
  77049. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  77050. /**
  77051. * Disables the prepass associated with the scene
  77052. */
  77053. disablePrePassRenderer(): void;
  77054. }
  77055. }
  77056. /**
  77057. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77058. * in several rendering techniques.
  77059. */
  77060. export class PrePassRendererSceneComponent implements ISceneComponent {
  77061. /**
  77062. * The component name helpful to identify the component in the list of scene components.
  77063. */
  77064. readonly name: string;
  77065. /**
  77066. * The scene the component belongs to.
  77067. */
  77068. scene: Scene;
  77069. /**
  77070. * Creates a new instance of the component for the given scene
  77071. * @param scene Defines the scene to register the component in
  77072. */
  77073. constructor(scene: Scene);
  77074. /**
  77075. * Registers the component in a given scene
  77076. */
  77077. register(): void;
  77078. private _beforeCameraDraw;
  77079. private _afterCameraDraw;
  77080. private _beforeClearStage;
  77081. /**
  77082. * Rebuilds the elements related to this component in case of
  77083. * context lost for instance.
  77084. */
  77085. rebuild(): void;
  77086. /**
  77087. * Disposes the component and the associated ressources
  77088. */
  77089. dispose(): void;
  77090. }
  77091. }
  77092. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  77093. /** @hidden */
  77094. export var fibonacci: {
  77095. name: string;
  77096. shader: string;
  77097. };
  77098. }
  77099. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  77100. /** @hidden */
  77101. export var diffusionProfile: {
  77102. name: string;
  77103. shader: string;
  77104. };
  77105. }
  77106. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  77107. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  77108. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77109. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  77110. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  77111. /** @hidden */
  77112. export var subSurfaceScatteringPixelShader: {
  77113. name: string;
  77114. shader: string;
  77115. };
  77116. }
  77117. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  77118. import { Nullable } from "babylonjs/types";
  77119. import { Camera } from "babylonjs/Cameras/camera";
  77120. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77121. import { Engine } from "babylonjs/Engines/engine";
  77122. import { Scene } from "babylonjs/scene";
  77123. import "babylonjs/Shaders/imageProcessing.fragment";
  77124. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  77125. import "babylonjs/Shaders/postprocess.vertex";
  77126. /**
  77127. * Sub surface scattering post process
  77128. */
  77129. export class SubSurfaceScatteringPostProcess extends PostProcess {
  77130. /**
  77131. * Gets a string identifying the name of the class
  77132. * @returns "SubSurfaceScatteringPostProcess" string
  77133. */
  77134. getClassName(): string;
  77135. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77136. }
  77137. }
  77138. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  77139. import { Scene } from "babylonjs/scene";
  77140. import { Color3 } from "babylonjs/Maths/math.color";
  77141. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  77142. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  77143. /**
  77144. * Contains all parameters needed for the prepass to perform
  77145. * screen space subsurface scattering
  77146. */
  77147. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  77148. /** @hidden */
  77149. static _SceneComponentInitialization: (scene: Scene) => void;
  77150. private _ssDiffusionS;
  77151. private _ssFilterRadii;
  77152. private _ssDiffusionD;
  77153. /**
  77154. * Post process to attach for screen space subsurface scattering
  77155. */
  77156. postProcess: SubSurfaceScatteringPostProcess;
  77157. /**
  77158. * Diffusion profile color for subsurface scattering
  77159. */
  77160. get ssDiffusionS(): number[];
  77161. /**
  77162. * Diffusion profile max color channel value for subsurface scattering
  77163. */
  77164. get ssDiffusionD(): number[];
  77165. /**
  77166. * Diffusion profile filter radius for subsurface scattering
  77167. */
  77168. get ssFilterRadii(): number[];
  77169. /**
  77170. * Is subsurface enabled
  77171. */
  77172. enabled: boolean;
  77173. /**
  77174. * Name of the configuration
  77175. */
  77176. name: string;
  77177. /**
  77178. * Diffusion profile colors for subsurface scattering
  77179. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  77180. * See ...
  77181. * Note that you can only store up to 5 of them
  77182. */
  77183. ssDiffusionProfileColors: Color3[];
  77184. /**
  77185. * Defines the ratio real world => scene units.
  77186. * Used for subsurface scattering
  77187. */
  77188. metersPerUnit: number;
  77189. /**
  77190. * Textures that should be present in the MRT for this effect to work
  77191. */
  77192. readonly texturesRequired: number[];
  77193. private _scene;
  77194. /**
  77195. * Builds a subsurface configuration object
  77196. * @param scene The scene
  77197. */
  77198. constructor(scene: Scene);
  77199. /**
  77200. * Adds a new diffusion profile.
  77201. * Useful for more realistic subsurface scattering on diverse materials.
  77202. * @param color The color of the diffusion profile. Should be the average color of the material.
  77203. * @return The index of the diffusion profile for the material subsurface configuration
  77204. */
  77205. addDiffusionProfile(color: Color3): number;
  77206. /**
  77207. * Creates the sss post process
  77208. * @return The created post process
  77209. */
  77210. createPostProcess(): SubSurfaceScatteringPostProcess;
  77211. /**
  77212. * Deletes all diffusion profiles.
  77213. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  77214. */
  77215. clearAllDiffusionProfiles(): void;
  77216. /**
  77217. * Disposes this object
  77218. */
  77219. dispose(): void;
  77220. /**
  77221. * @hidden
  77222. * https://zero-radiance.github.io/post/sampling-diffusion/
  77223. *
  77224. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  77225. * ------------------------------------------------------------------------------------
  77226. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  77227. * PDF[r, phi, s] = r * R[r, phi, s]
  77228. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  77229. * ------------------------------------------------------------------------------------
  77230. * We importance sample the color channel with the widest scattering distance.
  77231. */
  77232. getDiffusionProfileParameters(color: Color3): number;
  77233. /**
  77234. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77235. * 'u' is the random number (the value of the CDF): [0, 1).
  77236. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77237. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77238. */
  77239. private _sampleBurleyDiffusionProfile;
  77240. }
  77241. }
  77242. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  77243. import { Nullable } from "babylonjs/types";
  77244. import { Scene } from "babylonjs/scene";
  77245. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  77246. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  77247. import { AbstractScene } from "babylonjs/abstractScene";
  77248. module "babylonjs/abstractScene" {
  77249. interface AbstractScene {
  77250. /** @hidden (Backing field) */
  77251. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77252. /**
  77253. * Gets or Sets the current prepass renderer associated to the scene.
  77254. */
  77255. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77256. /**
  77257. * Enables the subsurface effect for prepass
  77258. * @returns the SubSurfaceConfiguration
  77259. */
  77260. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77261. /**
  77262. * Disables the subsurface effect for prepass
  77263. */
  77264. disableSubSurfaceForPrePass(): void;
  77265. }
  77266. }
  77267. /**
  77268. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77269. * in several rendering techniques.
  77270. */
  77271. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77272. /**
  77273. * The component name helpful to identify the component in the list of scene components.
  77274. */
  77275. readonly name: string;
  77276. /**
  77277. * The scene the component belongs to.
  77278. */
  77279. scene: Scene;
  77280. /**
  77281. * Creates a new instance of the component for the given scene
  77282. * @param scene Defines the scene to register the component in
  77283. */
  77284. constructor(scene: Scene);
  77285. /**
  77286. * Registers the component in a given scene
  77287. */
  77288. register(): void;
  77289. /**
  77290. * Serializes the component data to the specified json object
  77291. * @param serializationObject The object to serialize to
  77292. */
  77293. serialize(serializationObject: any): void;
  77294. /**
  77295. * Adds all the elements from the container to the scene
  77296. * @param container the container holding the elements
  77297. */
  77298. addFromContainer(container: AbstractScene): void;
  77299. /**
  77300. * Removes all the elements in the container from the scene
  77301. * @param container contains the elements to remove
  77302. * @param dispose if the removed element should be disposed (default: false)
  77303. */
  77304. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77305. /**
  77306. * Rebuilds the elements related to this component in case of
  77307. * context lost for instance.
  77308. */
  77309. rebuild(): void;
  77310. /**
  77311. * Disposes the component and the associated ressources
  77312. */
  77313. dispose(): void;
  77314. }
  77315. }
  77316. declare module "babylonjs/Shaders/outline.fragment" {
  77317. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77318. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  77319. /** @hidden */
  77320. export var outlinePixelShader: {
  77321. name: string;
  77322. shader: string;
  77323. };
  77324. }
  77325. declare module "babylonjs/Shaders/outline.vertex" {
  77326. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  77327. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  77328. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  77329. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  77330. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77331. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  77332. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  77333. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  77334. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  77335. /** @hidden */
  77336. export var outlineVertexShader: {
  77337. name: string;
  77338. shader: string;
  77339. };
  77340. }
  77341. declare module "babylonjs/Rendering/outlineRenderer" {
  77342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  77343. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  77344. import { Scene } from "babylonjs/scene";
  77345. import { ISceneComponent } from "babylonjs/sceneComponent";
  77346. import "babylonjs/Shaders/outline.fragment";
  77347. import "babylonjs/Shaders/outline.vertex";
  77348. module "babylonjs/scene" {
  77349. interface Scene {
  77350. /** @hidden */
  77351. _outlineRenderer: OutlineRenderer;
  77352. /**
  77353. * Gets the outline renderer associated with the scene
  77354. * @returns a OutlineRenderer
  77355. */
  77356. getOutlineRenderer(): OutlineRenderer;
  77357. }
  77358. }
  77359. module "babylonjs/Meshes/abstractMesh" {
  77360. interface AbstractMesh {
  77361. /** @hidden (Backing field) */
  77362. _renderOutline: boolean;
  77363. /**
  77364. * Gets or sets a boolean indicating if the outline must be rendered as well
  77365. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77366. */
  77367. renderOutline: boolean;
  77368. /** @hidden (Backing field) */
  77369. _renderOverlay: boolean;
  77370. /**
  77371. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77372. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77373. */
  77374. renderOverlay: boolean;
  77375. }
  77376. }
  77377. /**
  77378. * This class is responsible to draw bothe outline/overlay of meshes.
  77379. * It should not be used directly but through the available method on mesh.
  77380. */
  77381. export class OutlineRenderer implements ISceneComponent {
  77382. /**
  77383. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77384. */
  77385. private static _StencilReference;
  77386. /**
  77387. * The name of the component. Each component must have a unique name.
  77388. */
  77389. name: string;
  77390. /**
  77391. * The scene the component belongs to.
  77392. */
  77393. scene: Scene;
  77394. /**
  77395. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77396. */
  77397. zOffset: number;
  77398. private _engine;
  77399. private _effect;
  77400. private _cachedDefines;
  77401. private _savedDepthWrite;
  77402. /**
  77403. * Instantiates a new outline renderer. (There could be only one per scene).
  77404. * @param scene Defines the scene it belongs to
  77405. */
  77406. constructor(scene: Scene);
  77407. /**
  77408. * Register the component to one instance of a scene.
  77409. */
  77410. register(): void;
  77411. /**
  77412. * Rebuilds the elements related to this component in case of
  77413. * context lost for instance.
  77414. */
  77415. rebuild(): void;
  77416. /**
  77417. * Disposes the component and the associated ressources.
  77418. */
  77419. dispose(): void;
  77420. /**
  77421. * Renders the outline in the canvas.
  77422. * @param subMesh Defines the sumesh to render
  77423. * @param batch Defines the batch of meshes in case of instances
  77424. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77425. */
  77426. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77427. /**
  77428. * Returns whether or not the outline renderer is ready for a given submesh.
  77429. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77430. * @param subMesh Defines the submesh to check readyness for
  77431. * @param useInstances Defines wheter wee are trying to render instances or not
  77432. * @returns true if ready otherwise false
  77433. */
  77434. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77435. private _beforeRenderingMesh;
  77436. private _afterRenderingMesh;
  77437. }
  77438. }
  77439. declare module "babylonjs/Rendering/index" {
  77440. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77441. export * from "babylonjs/Rendering/depthRenderer";
  77442. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77443. export * from "babylonjs/Rendering/edgesRenderer";
  77444. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77445. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77446. export * from "babylonjs/Rendering/prePassRenderer";
  77447. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77448. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77449. export * from "babylonjs/Rendering/outlineRenderer";
  77450. export * from "babylonjs/Rendering/renderingGroup";
  77451. export * from "babylonjs/Rendering/renderingManager";
  77452. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77453. }
  77454. declare module "babylonjs/Sprites/ISprites" {
  77455. /**
  77456. * Defines the basic options interface of a Sprite Frame Source Size.
  77457. */
  77458. export interface ISpriteJSONSpriteSourceSize {
  77459. /**
  77460. * number of the original width of the Frame
  77461. */
  77462. w: number;
  77463. /**
  77464. * number of the original height of the Frame
  77465. */
  77466. h: number;
  77467. }
  77468. /**
  77469. * Defines the basic options interface of a Sprite Frame Data.
  77470. */
  77471. export interface ISpriteJSONSpriteFrameData {
  77472. /**
  77473. * number of the x offset of the Frame
  77474. */
  77475. x: number;
  77476. /**
  77477. * number of the y offset of the Frame
  77478. */
  77479. y: number;
  77480. /**
  77481. * number of the width of the Frame
  77482. */
  77483. w: number;
  77484. /**
  77485. * number of the height of the Frame
  77486. */
  77487. h: number;
  77488. }
  77489. /**
  77490. * Defines the basic options interface of a JSON Sprite.
  77491. */
  77492. export interface ISpriteJSONSprite {
  77493. /**
  77494. * string name of the Frame
  77495. */
  77496. filename: string;
  77497. /**
  77498. * ISpriteJSONSpriteFrame basic object of the frame data
  77499. */
  77500. frame: ISpriteJSONSpriteFrameData;
  77501. /**
  77502. * boolean to flag is the frame was rotated.
  77503. */
  77504. rotated: boolean;
  77505. /**
  77506. * boolean to flag is the frame was trimmed.
  77507. */
  77508. trimmed: boolean;
  77509. /**
  77510. * ISpriteJSONSpriteFrame basic object of the source data
  77511. */
  77512. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77513. /**
  77514. * ISpriteJSONSpriteFrame basic object of the source data
  77515. */
  77516. sourceSize: ISpriteJSONSpriteSourceSize;
  77517. }
  77518. /**
  77519. * Defines the basic options interface of a JSON atlas.
  77520. */
  77521. export interface ISpriteJSONAtlas {
  77522. /**
  77523. * Array of objects that contain the frame data.
  77524. */
  77525. frames: Array<ISpriteJSONSprite>;
  77526. /**
  77527. * object basic object containing the sprite meta data.
  77528. */
  77529. meta?: object;
  77530. }
  77531. }
  77532. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77533. /** @hidden */
  77534. export var spriteMapPixelShader: {
  77535. name: string;
  77536. shader: string;
  77537. };
  77538. }
  77539. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77540. /** @hidden */
  77541. export var spriteMapVertexShader: {
  77542. name: string;
  77543. shader: string;
  77544. };
  77545. }
  77546. declare module "babylonjs/Sprites/spriteMap" {
  77547. import { IDisposable, Scene } from "babylonjs/scene";
  77548. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77549. import { Texture } from "babylonjs/Materials/Textures/texture";
  77550. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77551. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77552. import "babylonjs/Meshes/Builders/planeBuilder";
  77553. import "babylonjs/Shaders/spriteMap.fragment";
  77554. import "babylonjs/Shaders/spriteMap.vertex";
  77555. /**
  77556. * Defines the basic options interface of a SpriteMap
  77557. */
  77558. export interface ISpriteMapOptions {
  77559. /**
  77560. * Vector2 of the number of cells in the grid.
  77561. */
  77562. stageSize?: Vector2;
  77563. /**
  77564. * Vector2 of the size of the output plane in World Units.
  77565. */
  77566. outputSize?: Vector2;
  77567. /**
  77568. * Vector3 of the position of the output plane in World Units.
  77569. */
  77570. outputPosition?: Vector3;
  77571. /**
  77572. * Vector3 of the rotation of the output plane.
  77573. */
  77574. outputRotation?: Vector3;
  77575. /**
  77576. * number of layers that the system will reserve in resources.
  77577. */
  77578. layerCount?: number;
  77579. /**
  77580. * number of max animation frames a single cell will reserve in resources.
  77581. */
  77582. maxAnimationFrames?: number;
  77583. /**
  77584. * number cell index of the base tile when the system compiles.
  77585. */
  77586. baseTile?: number;
  77587. /**
  77588. * boolean flip the sprite after its been repositioned by the framing data.
  77589. */
  77590. flipU?: boolean;
  77591. /**
  77592. * Vector3 scalar of the global RGB values of the SpriteMap.
  77593. */
  77594. colorMultiply?: Vector3;
  77595. }
  77596. /**
  77597. * Defines the IDisposable interface in order to be cleanable from resources.
  77598. */
  77599. export interface ISpriteMap extends IDisposable {
  77600. /**
  77601. * String name of the SpriteMap.
  77602. */
  77603. name: string;
  77604. /**
  77605. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77606. */
  77607. atlasJSON: ISpriteJSONAtlas;
  77608. /**
  77609. * Texture of the SpriteMap.
  77610. */
  77611. spriteSheet: Texture;
  77612. /**
  77613. * The parameters to initialize the SpriteMap with.
  77614. */
  77615. options: ISpriteMapOptions;
  77616. }
  77617. /**
  77618. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77619. */
  77620. export class SpriteMap implements ISpriteMap {
  77621. /** The Name of the spriteMap */
  77622. name: string;
  77623. /** The JSON file with the frame and meta data */
  77624. atlasJSON: ISpriteJSONAtlas;
  77625. /** The systems Sprite Sheet Texture */
  77626. spriteSheet: Texture;
  77627. /** Arguments passed with the Constructor */
  77628. options: ISpriteMapOptions;
  77629. /** Public Sprite Storage array, parsed from atlasJSON */
  77630. sprites: Array<ISpriteJSONSprite>;
  77631. /** Returns the Number of Sprites in the System */
  77632. get spriteCount(): number;
  77633. /** Returns the Position of Output Plane*/
  77634. get position(): Vector3;
  77635. /** Returns the Position of Output Plane*/
  77636. set position(v: Vector3);
  77637. /** Returns the Rotation of Output Plane*/
  77638. get rotation(): Vector3;
  77639. /** Returns the Rotation of Output Plane*/
  77640. set rotation(v: Vector3);
  77641. /** Sets the AnimationMap*/
  77642. get animationMap(): RawTexture;
  77643. /** Sets the AnimationMap*/
  77644. set animationMap(v: RawTexture);
  77645. /** Scene that the SpriteMap was created in */
  77646. private _scene;
  77647. /** Texture Buffer of Float32 that holds tile frame data*/
  77648. private _frameMap;
  77649. /** Texture Buffers of Float32 that holds tileMap data*/
  77650. private _tileMaps;
  77651. /** Texture Buffer of Float32 that holds Animation Data*/
  77652. private _animationMap;
  77653. /** Custom ShaderMaterial Central to the System*/
  77654. private _material;
  77655. /** Custom ShaderMaterial Central to the System*/
  77656. private _output;
  77657. /** Systems Time Ticker*/
  77658. private _time;
  77659. /**
  77660. * Creates a new SpriteMap
  77661. * @param name defines the SpriteMaps Name
  77662. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77663. * @param spriteSheet is the Texture that the Sprites are on.
  77664. * @param options a basic deployment configuration
  77665. * @param scene The Scene that the map is deployed on
  77666. */
  77667. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77668. /**
  77669. * Returns tileID location
  77670. * @returns Vector2 the cell position ID
  77671. */
  77672. getTileID(): Vector2;
  77673. /**
  77674. * Gets the UV location of the mouse over the SpriteMap.
  77675. * @returns Vector2 the UV position of the mouse interaction
  77676. */
  77677. getMousePosition(): Vector2;
  77678. /**
  77679. * Creates the "frame" texture Buffer
  77680. * -------------------------------------
  77681. * Structure of frames
  77682. * "filename": "Falling-Water-2.png",
  77683. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77684. * "rotated": true,
  77685. * "trimmed": true,
  77686. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77687. * "sourceSize": {"w":32,"h":32}
  77688. * @returns RawTexture of the frameMap
  77689. */
  77690. private _createFrameBuffer;
  77691. /**
  77692. * Creates the tileMap texture Buffer
  77693. * @param buffer normally and array of numbers, or a false to generate from scratch
  77694. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77695. * @returns RawTexture of the tileMap
  77696. */
  77697. private _createTileBuffer;
  77698. /**
  77699. * Modifies the data of the tileMaps
  77700. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77701. * @param pos is the iVector2 Coordinates of the Tile
  77702. * @param tile The SpriteIndex of the new Tile
  77703. */
  77704. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77705. /**
  77706. * Creates the animationMap texture Buffer
  77707. * @param buffer normally and array of numbers, or a false to generate from scratch
  77708. * @returns RawTexture of the animationMap
  77709. */
  77710. private _createTileAnimationBuffer;
  77711. /**
  77712. * Modifies the data of the animationMap
  77713. * @param cellID is the Index of the Sprite
  77714. * @param _frame is the target Animation frame
  77715. * @param toCell is the Target Index of the next frame of the animation
  77716. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77717. * @param speed is a global scalar of the time variable on the map.
  77718. */
  77719. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77720. /**
  77721. * Exports the .tilemaps file
  77722. */
  77723. saveTileMaps(): void;
  77724. /**
  77725. * Imports the .tilemaps file
  77726. * @param url of the .tilemaps file
  77727. */
  77728. loadTileMaps(url: string): void;
  77729. /**
  77730. * Release associated resources
  77731. */
  77732. dispose(): void;
  77733. }
  77734. }
  77735. declare module "babylonjs/Sprites/spritePackedManager" {
  77736. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77737. import { Scene } from "babylonjs/scene";
  77738. /**
  77739. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77740. * @see https://doc.babylonjs.com/babylon101/sprites
  77741. */
  77742. export class SpritePackedManager extends SpriteManager {
  77743. /** defines the packed manager's name */
  77744. name: string;
  77745. /**
  77746. * Creates a new sprite manager from a packed sprite sheet
  77747. * @param name defines the manager's name
  77748. * @param imgUrl defines the sprite sheet url
  77749. * @param capacity defines the maximum allowed number of sprites
  77750. * @param scene defines the hosting scene
  77751. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77752. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77753. * @param samplingMode defines the smapling mode to use with spritesheet
  77754. * @param fromPacked set to true; do not alter
  77755. */
  77756. constructor(
  77757. /** defines the packed manager's name */
  77758. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77759. }
  77760. }
  77761. declare module "babylonjs/Sprites/index" {
  77762. export * from "babylonjs/Sprites/sprite";
  77763. export * from "babylonjs/Sprites/ISprites";
  77764. export * from "babylonjs/Sprites/spriteManager";
  77765. export * from "babylonjs/Sprites/spriteMap";
  77766. export * from "babylonjs/Sprites/spritePackedManager";
  77767. export * from "babylonjs/Sprites/spriteSceneComponent";
  77768. }
  77769. declare module "babylonjs/States/index" {
  77770. export * from "babylonjs/States/alphaCullingState";
  77771. export * from "babylonjs/States/depthCullingState";
  77772. export * from "babylonjs/States/stencilState";
  77773. }
  77774. declare module "babylonjs/Misc/assetsManager" {
  77775. import { Scene } from "babylonjs/scene";
  77776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77777. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77778. import { Skeleton } from "babylonjs/Bones/skeleton";
  77779. import { Observable } from "babylonjs/Misc/observable";
  77780. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77781. import { Texture } from "babylonjs/Materials/Textures/texture";
  77782. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77783. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77784. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77785. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77786. import { AssetContainer } from "babylonjs/assetContainer";
  77787. /**
  77788. * Defines the list of states available for a task inside a AssetsManager
  77789. */
  77790. export enum AssetTaskState {
  77791. /**
  77792. * Initialization
  77793. */
  77794. INIT = 0,
  77795. /**
  77796. * Running
  77797. */
  77798. RUNNING = 1,
  77799. /**
  77800. * Done
  77801. */
  77802. DONE = 2,
  77803. /**
  77804. * Error
  77805. */
  77806. ERROR = 3
  77807. }
  77808. /**
  77809. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77810. */
  77811. export abstract class AbstractAssetTask {
  77812. /**
  77813. * Task name
  77814. */ name: string;
  77815. /**
  77816. * Callback called when the task is successful
  77817. */
  77818. onSuccess: (task: any) => void;
  77819. /**
  77820. * Callback called when the task is not successful
  77821. */
  77822. onError: (task: any, message?: string, exception?: any) => void;
  77823. /**
  77824. * Creates a new AssetsManager
  77825. * @param name defines the name of the task
  77826. */
  77827. constructor(
  77828. /**
  77829. * Task name
  77830. */ name: string);
  77831. private _isCompleted;
  77832. private _taskState;
  77833. private _errorObject;
  77834. /**
  77835. * Get if the task is completed
  77836. */
  77837. get isCompleted(): boolean;
  77838. /**
  77839. * Gets the current state of the task
  77840. */
  77841. get taskState(): AssetTaskState;
  77842. /**
  77843. * Gets the current error object (if task is in error)
  77844. */
  77845. get errorObject(): {
  77846. message?: string;
  77847. exception?: any;
  77848. };
  77849. /**
  77850. * Internal only
  77851. * @hidden
  77852. */
  77853. _setErrorObject(message?: string, exception?: any): void;
  77854. /**
  77855. * Execute the current task
  77856. * @param scene defines the scene where you want your assets to be loaded
  77857. * @param onSuccess is a callback called when the task is successfully executed
  77858. * @param onError is a callback called if an error occurs
  77859. */
  77860. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77861. /**
  77862. * Execute the current task
  77863. * @param scene defines the scene where you want your assets to be loaded
  77864. * @param onSuccess is a callback called when the task is successfully executed
  77865. * @param onError is a callback called if an error occurs
  77866. */
  77867. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77868. /**
  77869. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77870. * This can be used with failed tasks that have the reason for failure fixed.
  77871. */
  77872. reset(): void;
  77873. private onErrorCallback;
  77874. private onDoneCallback;
  77875. }
  77876. /**
  77877. * Define the interface used by progress events raised during assets loading
  77878. */
  77879. export interface IAssetsProgressEvent {
  77880. /**
  77881. * Defines the number of remaining tasks to process
  77882. */
  77883. remainingCount: number;
  77884. /**
  77885. * Defines the total number of tasks
  77886. */
  77887. totalCount: number;
  77888. /**
  77889. * Defines the task that was just processed
  77890. */
  77891. task: AbstractAssetTask;
  77892. }
  77893. /**
  77894. * Class used to share progress information about assets loading
  77895. */
  77896. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77897. /**
  77898. * Defines the number of remaining tasks to process
  77899. */
  77900. remainingCount: number;
  77901. /**
  77902. * Defines the total number of tasks
  77903. */
  77904. totalCount: number;
  77905. /**
  77906. * Defines the task that was just processed
  77907. */
  77908. task: AbstractAssetTask;
  77909. /**
  77910. * Creates a AssetsProgressEvent
  77911. * @param remainingCount defines the number of remaining tasks to process
  77912. * @param totalCount defines the total number of tasks
  77913. * @param task defines the task that was just processed
  77914. */
  77915. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77916. }
  77917. /**
  77918. * Define a task used by AssetsManager to load assets into a container
  77919. */
  77920. export class ContainerAssetTask extends AbstractAssetTask {
  77921. /**
  77922. * Defines the name of the task
  77923. */
  77924. name: string;
  77925. /**
  77926. * Defines the list of mesh's names you want to load
  77927. */
  77928. meshesNames: any;
  77929. /**
  77930. * Defines the root url to use as a base to load your meshes and associated resources
  77931. */
  77932. rootUrl: string;
  77933. /**
  77934. * Defines the filename or File of the scene to load from
  77935. */
  77936. sceneFilename: string | File;
  77937. /**
  77938. * Get the loaded asset container
  77939. */
  77940. loadedContainer: AssetContainer;
  77941. /**
  77942. * Gets the list of loaded meshes
  77943. */
  77944. loadedMeshes: Array<AbstractMesh>;
  77945. /**
  77946. * Gets the list of loaded particle systems
  77947. */
  77948. loadedParticleSystems: Array<IParticleSystem>;
  77949. /**
  77950. * Gets the list of loaded skeletons
  77951. */
  77952. loadedSkeletons: Array<Skeleton>;
  77953. /**
  77954. * Gets the list of loaded animation groups
  77955. */
  77956. loadedAnimationGroups: Array<AnimationGroup>;
  77957. /**
  77958. * Callback called when the task is successful
  77959. */
  77960. onSuccess: (task: ContainerAssetTask) => void;
  77961. /**
  77962. * Callback called when the task is successful
  77963. */
  77964. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77965. /**
  77966. * Creates a new ContainerAssetTask
  77967. * @param name defines the name of the task
  77968. * @param meshesNames defines the list of mesh's names you want to load
  77969. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77970. * @param sceneFilename defines the filename or File of the scene to load from
  77971. */
  77972. constructor(
  77973. /**
  77974. * Defines the name of the task
  77975. */
  77976. name: string,
  77977. /**
  77978. * Defines the list of mesh's names you want to load
  77979. */
  77980. meshesNames: any,
  77981. /**
  77982. * Defines the root url to use as a base to load your meshes and associated resources
  77983. */
  77984. rootUrl: string,
  77985. /**
  77986. * Defines the filename or File of the scene to load from
  77987. */
  77988. sceneFilename: string | File);
  77989. /**
  77990. * Execute the current task
  77991. * @param scene defines the scene where you want your assets to be loaded
  77992. * @param onSuccess is a callback called when the task is successfully executed
  77993. * @param onError is a callback called if an error occurs
  77994. */
  77995. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77996. }
  77997. /**
  77998. * Define a task used by AssetsManager to load meshes
  77999. */
  78000. export class MeshAssetTask extends AbstractAssetTask {
  78001. /**
  78002. * Defines the name of the task
  78003. */
  78004. name: string;
  78005. /**
  78006. * Defines the list of mesh's names you want to load
  78007. */
  78008. meshesNames: any;
  78009. /**
  78010. * Defines the root url to use as a base to load your meshes and associated resources
  78011. */
  78012. rootUrl: string;
  78013. /**
  78014. * Defines the filename or File of the scene to load from
  78015. */
  78016. sceneFilename: string | File;
  78017. /**
  78018. * Gets the list of loaded meshes
  78019. */
  78020. loadedMeshes: Array<AbstractMesh>;
  78021. /**
  78022. * Gets the list of loaded particle systems
  78023. */
  78024. loadedParticleSystems: Array<IParticleSystem>;
  78025. /**
  78026. * Gets the list of loaded skeletons
  78027. */
  78028. loadedSkeletons: Array<Skeleton>;
  78029. /**
  78030. * Gets the list of loaded animation groups
  78031. */
  78032. loadedAnimationGroups: Array<AnimationGroup>;
  78033. /**
  78034. * Callback called when the task is successful
  78035. */
  78036. onSuccess: (task: MeshAssetTask) => void;
  78037. /**
  78038. * Callback called when the task is successful
  78039. */
  78040. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  78041. /**
  78042. * Creates a new MeshAssetTask
  78043. * @param name defines the name of the task
  78044. * @param meshesNames defines the list of mesh's names you want to load
  78045. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78046. * @param sceneFilename defines the filename or File of the scene to load from
  78047. */
  78048. constructor(
  78049. /**
  78050. * Defines the name of the task
  78051. */
  78052. name: string,
  78053. /**
  78054. * Defines the list of mesh's names you want to load
  78055. */
  78056. meshesNames: any,
  78057. /**
  78058. * Defines the root url to use as a base to load your meshes and associated resources
  78059. */
  78060. rootUrl: string,
  78061. /**
  78062. * Defines the filename or File of the scene to load from
  78063. */
  78064. sceneFilename: string | File);
  78065. /**
  78066. * Execute the current task
  78067. * @param scene defines the scene where you want your assets to be loaded
  78068. * @param onSuccess is a callback called when the task is successfully executed
  78069. * @param onError is a callback called if an error occurs
  78070. */
  78071. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78072. }
  78073. /**
  78074. * Define a task used by AssetsManager to load text content
  78075. */
  78076. export class TextFileAssetTask extends AbstractAssetTask {
  78077. /**
  78078. * Defines the name of the task
  78079. */
  78080. name: string;
  78081. /**
  78082. * Defines the location of the file to load
  78083. */
  78084. url: string;
  78085. /**
  78086. * Gets the loaded text string
  78087. */
  78088. text: string;
  78089. /**
  78090. * Callback called when the task is successful
  78091. */
  78092. onSuccess: (task: TextFileAssetTask) => void;
  78093. /**
  78094. * Callback called when the task is successful
  78095. */
  78096. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  78097. /**
  78098. * Creates a new TextFileAssetTask object
  78099. * @param name defines the name of the task
  78100. * @param url defines the location of the file to load
  78101. */
  78102. constructor(
  78103. /**
  78104. * Defines the name of the task
  78105. */
  78106. name: string,
  78107. /**
  78108. * Defines the location of the file to load
  78109. */
  78110. url: string);
  78111. /**
  78112. * Execute the current task
  78113. * @param scene defines the scene where you want your assets to be loaded
  78114. * @param onSuccess is a callback called when the task is successfully executed
  78115. * @param onError is a callback called if an error occurs
  78116. */
  78117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78118. }
  78119. /**
  78120. * Define a task used by AssetsManager to load binary data
  78121. */
  78122. export class BinaryFileAssetTask extends AbstractAssetTask {
  78123. /**
  78124. * Defines the name of the task
  78125. */
  78126. name: string;
  78127. /**
  78128. * Defines the location of the file to load
  78129. */
  78130. url: string;
  78131. /**
  78132. * Gets the lodaded data (as an array buffer)
  78133. */
  78134. data: ArrayBuffer;
  78135. /**
  78136. * Callback called when the task is successful
  78137. */
  78138. onSuccess: (task: BinaryFileAssetTask) => void;
  78139. /**
  78140. * Callback called when the task is successful
  78141. */
  78142. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  78143. /**
  78144. * Creates a new BinaryFileAssetTask object
  78145. * @param name defines the name of the new task
  78146. * @param url defines the location of the file to load
  78147. */
  78148. constructor(
  78149. /**
  78150. * Defines the name of the task
  78151. */
  78152. name: string,
  78153. /**
  78154. * Defines the location of the file to load
  78155. */
  78156. url: string);
  78157. /**
  78158. * Execute the current task
  78159. * @param scene defines the scene where you want your assets to be loaded
  78160. * @param onSuccess is a callback called when the task is successfully executed
  78161. * @param onError is a callback called if an error occurs
  78162. */
  78163. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78164. }
  78165. /**
  78166. * Define a task used by AssetsManager to load images
  78167. */
  78168. export class ImageAssetTask extends AbstractAssetTask {
  78169. /**
  78170. * Defines the name of the task
  78171. */
  78172. name: string;
  78173. /**
  78174. * Defines the location of the image to load
  78175. */
  78176. url: string;
  78177. /**
  78178. * Gets the loaded images
  78179. */
  78180. image: HTMLImageElement;
  78181. /**
  78182. * Callback called when the task is successful
  78183. */
  78184. onSuccess: (task: ImageAssetTask) => void;
  78185. /**
  78186. * Callback called when the task is successful
  78187. */
  78188. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  78189. /**
  78190. * Creates a new ImageAssetTask
  78191. * @param name defines the name of the task
  78192. * @param url defines the location of the image to load
  78193. */
  78194. constructor(
  78195. /**
  78196. * Defines the name of the task
  78197. */
  78198. name: string,
  78199. /**
  78200. * Defines the location of the image to load
  78201. */
  78202. url: string);
  78203. /**
  78204. * Execute the current task
  78205. * @param scene defines the scene where you want your assets to be loaded
  78206. * @param onSuccess is a callback called when the task is successfully executed
  78207. * @param onError is a callback called if an error occurs
  78208. */
  78209. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78210. }
  78211. /**
  78212. * Defines the interface used by texture loading tasks
  78213. */
  78214. export interface ITextureAssetTask<TEX extends BaseTexture> {
  78215. /**
  78216. * Gets the loaded texture
  78217. */
  78218. texture: TEX;
  78219. }
  78220. /**
  78221. * Define a task used by AssetsManager to load 2D textures
  78222. */
  78223. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  78224. /**
  78225. * Defines the name of the task
  78226. */
  78227. name: string;
  78228. /**
  78229. * Defines the location of the file to load
  78230. */
  78231. url: string;
  78232. /**
  78233. * Defines if mipmap should not be generated (default is false)
  78234. */
  78235. noMipmap?: boolean | undefined;
  78236. /**
  78237. * Defines if texture must be inverted on Y axis (default is true)
  78238. */
  78239. invertY: boolean;
  78240. /**
  78241. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78242. */
  78243. samplingMode: number;
  78244. /**
  78245. * Gets the loaded texture
  78246. */
  78247. texture: Texture;
  78248. /**
  78249. * Callback called when the task is successful
  78250. */
  78251. onSuccess: (task: TextureAssetTask) => void;
  78252. /**
  78253. * Callback called when the task is successful
  78254. */
  78255. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  78256. /**
  78257. * Creates a new TextureAssetTask object
  78258. * @param name defines the name of the task
  78259. * @param url defines the location of the file to load
  78260. * @param noMipmap defines if mipmap should not be generated (default is false)
  78261. * @param invertY defines if texture must be inverted on Y axis (default is true)
  78262. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78263. */
  78264. constructor(
  78265. /**
  78266. * Defines the name of the task
  78267. */
  78268. name: string,
  78269. /**
  78270. * Defines the location of the file to load
  78271. */
  78272. url: string,
  78273. /**
  78274. * Defines if mipmap should not be generated (default is false)
  78275. */
  78276. noMipmap?: boolean | undefined,
  78277. /**
  78278. * Defines if texture must be inverted on Y axis (default is true)
  78279. */
  78280. invertY?: boolean,
  78281. /**
  78282. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78283. */
  78284. samplingMode?: number);
  78285. /**
  78286. * Execute the current task
  78287. * @param scene defines the scene where you want your assets to be loaded
  78288. * @param onSuccess is a callback called when the task is successfully executed
  78289. * @param onError is a callback called if an error occurs
  78290. */
  78291. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78292. }
  78293. /**
  78294. * Define a task used by AssetsManager to load cube textures
  78295. */
  78296. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  78297. /**
  78298. * Defines the name of the task
  78299. */
  78300. name: string;
  78301. /**
  78302. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78303. */
  78304. url: string;
  78305. /**
  78306. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78307. */
  78308. extensions?: string[] | undefined;
  78309. /**
  78310. * Defines if mipmaps should not be generated (default is false)
  78311. */
  78312. noMipmap?: boolean | undefined;
  78313. /**
  78314. * Defines the explicit list of files (undefined by default)
  78315. */
  78316. files?: string[] | undefined;
  78317. /**
  78318. * Gets the loaded texture
  78319. */
  78320. texture: CubeTexture;
  78321. /**
  78322. * Callback called when the task is successful
  78323. */
  78324. onSuccess: (task: CubeTextureAssetTask) => void;
  78325. /**
  78326. * Callback called when the task is successful
  78327. */
  78328. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78329. /**
  78330. * Creates a new CubeTextureAssetTask
  78331. * @param name defines the name of the task
  78332. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78333. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78334. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78335. * @param files defines the explicit list of files (undefined by default)
  78336. */
  78337. constructor(
  78338. /**
  78339. * Defines the name of the task
  78340. */
  78341. name: string,
  78342. /**
  78343. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78344. */
  78345. url: string,
  78346. /**
  78347. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78348. */
  78349. extensions?: string[] | undefined,
  78350. /**
  78351. * Defines if mipmaps should not be generated (default is false)
  78352. */
  78353. noMipmap?: boolean | undefined,
  78354. /**
  78355. * Defines the explicit list of files (undefined by default)
  78356. */
  78357. files?: string[] | undefined);
  78358. /**
  78359. * Execute the current task
  78360. * @param scene defines the scene where you want your assets to be loaded
  78361. * @param onSuccess is a callback called when the task is successfully executed
  78362. * @param onError is a callback called if an error occurs
  78363. */
  78364. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78365. }
  78366. /**
  78367. * Define a task used by AssetsManager to load HDR cube textures
  78368. */
  78369. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78370. /**
  78371. * Defines the name of the task
  78372. */
  78373. name: string;
  78374. /**
  78375. * Defines the location of the file to load
  78376. */
  78377. url: string;
  78378. /**
  78379. * Defines the desired size (the more it increases the longer the generation will be)
  78380. */
  78381. size: number;
  78382. /**
  78383. * Defines if mipmaps should not be generated (default is false)
  78384. */
  78385. noMipmap: boolean;
  78386. /**
  78387. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78388. */
  78389. generateHarmonics: boolean;
  78390. /**
  78391. * 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)
  78392. */
  78393. gammaSpace: boolean;
  78394. /**
  78395. * Internal Use Only
  78396. */
  78397. reserved: boolean;
  78398. /**
  78399. * Gets the loaded texture
  78400. */
  78401. texture: HDRCubeTexture;
  78402. /**
  78403. * Callback called when the task is successful
  78404. */
  78405. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78406. /**
  78407. * Callback called when the task is successful
  78408. */
  78409. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78410. /**
  78411. * Creates a new HDRCubeTextureAssetTask object
  78412. * @param name defines the name of the task
  78413. * @param url defines the location of the file to load
  78414. * @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.
  78415. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78416. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78417. * @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)
  78418. * @param reserved Internal use only
  78419. */
  78420. constructor(
  78421. /**
  78422. * Defines the name of the task
  78423. */
  78424. name: string,
  78425. /**
  78426. * Defines the location of the file to load
  78427. */
  78428. url: string,
  78429. /**
  78430. * Defines the desired size (the more it increases the longer the generation will be)
  78431. */
  78432. size: number,
  78433. /**
  78434. * Defines if mipmaps should not be generated (default is false)
  78435. */
  78436. noMipmap?: boolean,
  78437. /**
  78438. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78439. */
  78440. generateHarmonics?: boolean,
  78441. /**
  78442. * 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)
  78443. */
  78444. gammaSpace?: boolean,
  78445. /**
  78446. * Internal Use Only
  78447. */
  78448. reserved?: boolean);
  78449. /**
  78450. * Execute the current task
  78451. * @param scene defines the scene where you want your assets to be loaded
  78452. * @param onSuccess is a callback called when the task is successfully executed
  78453. * @param onError is a callback called if an error occurs
  78454. */
  78455. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78456. }
  78457. /**
  78458. * Define a task used by AssetsManager to load Equirectangular cube textures
  78459. */
  78460. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78461. /**
  78462. * Defines the name of the task
  78463. */
  78464. name: string;
  78465. /**
  78466. * Defines the location of the file to load
  78467. */
  78468. url: string;
  78469. /**
  78470. * Defines the desired size (the more it increases the longer the generation will be)
  78471. */
  78472. size: number;
  78473. /**
  78474. * Defines if mipmaps should not be generated (default is false)
  78475. */
  78476. noMipmap: boolean;
  78477. /**
  78478. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78479. * but the standard material would require them in Gamma space) (default is true)
  78480. */
  78481. gammaSpace: boolean;
  78482. /**
  78483. * Gets the loaded texture
  78484. */
  78485. texture: EquiRectangularCubeTexture;
  78486. /**
  78487. * Callback called when the task is successful
  78488. */
  78489. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78490. /**
  78491. * Callback called when the task is successful
  78492. */
  78493. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78494. /**
  78495. * Creates a new EquiRectangularCubeTextureAssetTask object
  78496. * @param name defines the name of the task
  78497. * @param url defines the location of the file to load
  78498. * @param size defines the desired size (the more it increases the longer the generation will be)
  78499. * If the size is omitted this implies you are using a preprocessed cubemap.
  78500. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78501. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78502. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78503. * (default is true)
  78504. */
  78505. constructor(
  78506. /**
  78507. * Defines the name of the task
  78508. */
  78509. name: string,
  78510. /**
  78511. * Defines the location of the file to load
  78512. */
  78513. url: string,
  78514. /**
  78515. * Defines the desired size (the more it increases the longer the generation will be)
  78516. */
  78517. size: number,
  78518. /**
  78519. * Defines if mipmaps should not be generated (default is false)
  78520. */
  78521. noMipmap?: boolean,
  78522. /**
  78523. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78524. * but the standard material would require them in Gamma space) (default is true)
  78525. */
  78526. gammaSpace?: boolean);
  78527. /**
  78528. * Execute the current task
  78529. * @param scene defines the scene where you want your assets to be loaded
  78530. * @param onSuccess is a callback called when the task is successfully executed
  78531. * @param onError is a callback called if an error occurs
  78532. */
  78533. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78534. }
  78535. /**
  78536. * This class can be used to easily import assets into a scene
  78537. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78538. */
  78539. export class AssetsManager {
  78540. private _scene;
  78541. private _isLoading;
  78542. protected _tasks: AbstractAssetTask[];
  78543. protected _waitingTasksCount: number;
  78544. protected _totalTasksCount: number;
  78545. /**
  78546. * Callback called when all tasks are processed
  78547. */
  78548. onFinish: (tasks: AbstractAssetTask[]) => void;
  78549. /**
  78550. * Callback called when a task is successful
  78551. */
  78552. onTaskSuccess: (task: AbstractAssetTask) => void;
  78553. /**
  78554. * Callback called when a task had an error
  78555. */
  78556. onTaskError: (task: AbstractAssetTask) => void;
  78557. /**
  78558. * Callback called when a task is done (whatever the result is)
  78559. */
  78560. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78561. /**
  78562. * Observable called when all tasks are processed
  78563. */
  78564. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78565. /**
  78566. * Observable called when a task had an error
  78567. */
  78568. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78569. /**
  78570. * Observable called when all tasks were executed
  78571. */
  78572. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78573. /**
  78574. * Observable called when a task is done (whatever the result is)
  78575. */
  78576. onProgressObservable: Observable<IAssetsProgressEvent>;
  78577. /**
  78578. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78579. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78580. */
  78581. useDefaultLoadingScreen: boolean;
  78582. /**
  78583. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78584. * when all assets have been downloaded.
  78585. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78586. */
  78587. autoHideLoadingUI: boolean;
  78588. /**
  78589. * Creates a new AssetsManager
  78590. * @param scene defines the scene to work on
  78591. */
  78592. constructor(scene: Scene);
  78593. /**
  78594. * Add a ContainerAssetTask to the list of active tasks
  78595. * @param taskName defines the name of the new task
  78596. * @param meshesNames defines the name of meshes to load
  78597. * @param rootUrl defines the root url to use to locate files
  78598. * @param sceneFilename defines the filename of the scene file
  78599. * @returns a new ContainerAssetTask object
  78600. */
  78601. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78602. /**
  78603. * Add a MeshAssetTask to the list of active tasks
  78604. * @param taskName defines the name of the new task
  78605. * @param meshesNames defines the name of meshes to load
  78606. * @param rootUrl defines the root url to use to locate files
  78607. * @param sceneFilename defines the filename of the scene file
  78608. * @returns a new MeshAssetTask object
  78609. */
  78610. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78611. /**
  78612. * Add a TextFileAssetTask to the list of active tasks
  78613. * @param taskName defines the name of the new task
  78614. * @param url defines the url of the file to load
  78615. * @returns a new TextFileAssetTask object
  78616. */
  78617. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78618. /**
  78619. * Add a BinaryFileAssetTask to the list of active tasks
  78620. * @param taskName defines the name of the new task
  78621. * @param url defines the url of the file to load
  78622. * @returns a new BinaryFileAssetTask object
  78623. */
  78624. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78625. /**
  78626. * Add a ImageAssetTask to the list of active tasks
  78627. * @param taskName defines the name of the new task
  78628. * @param url defines the url of the file to load
  78629. * @returns a new ImageAssetTask object
  78630. */
  78631. addImageTask(taskName: string, url: string): ImageAssetTask;
  78632. /**
  78633. * Add a TextureAssetTask to the list of active tasks
  78634. * @param taskName defines the name of the new task
  78635. * @param url defines the url of the file to load
  78636. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78637. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78638. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78639. * @returns a new TextureAssetTask object
  78640. */
  78641. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78642. /**
  78643. * Add a CubeTextureAssetTask to the list of active tasks
  78644. * @param taskName defines the name of the new task
  78645. * @param url defines the url of the file to load
  78646. * @param extensions defines the extension to use to load the cube map (can be null)
  78647. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78648. * @param files defines the list of files to load (can be null)
  78649. * @returns a new CubeTextureAssetTask object
  78650. */
  78651. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78652. /**
  78653. *
  78654. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78655. * @param taskName defines the name of the new task
  78656. * @param url defines the url of the file to load
  78657. * @param size defines the size you want for the cubemap (can be null)
  78658. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78659. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78660. * @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)
  78661. * @param reserved Internal use only
  78662. * @returns a new HDRCubeTextureAssetTask object
  78663. */
  78664. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78665. /**
  78666. *
  78667. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78668. * @param taskName defines the name of the new task
  78669. * @param url defines the url of the file to load
  78670. * @param size defines the size you want for the cubemap (can be null)
  78671. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78672. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78673. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78674. * @returns a new EquiRectangularCubeTextureAssetTask object
  78675. */
  78676. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78677. /**
  78678. * Remove a task from the assets manager.
  78679. * @param task the task to remove
  78680. */
  78681. removeTask(task: AbstractAssetTask): void;
  78682. private _decreaseWaitingTasksCount;
  78683. private _runTask;
  78684. /**
  78685. * Reset the AssetsManager and remove all tasks
  78686. * @return the current instance of the AssetsManager
  78687. */
  78688. reset(): AssetsManager;
  78689. /**
  78690. * Start the loading process
  78691. * @return the current instance of the AssetsManager
  78692. */
  78693. load(): AssetsManager;
  78694. /**
  78695. * Start the loading process as an async operation
  78696. * @return a promise returning the list of failed tasks
  78697. */
  78698. loadAsync(): Promise<void>;
  78699. }
  78700. }
  78701. declare module "babylonjs/Misc/deferred" {
  78702. /**
  78703. * Wrapper class for promise with external resolve and reject.
  78704. */
  78705. export class Deferred<T> {
  78706. /**
  78707. * The promise associated with this deferred object.
  78708. */
  78709. readonly promise: Promise<T>;
  78710. private _resolve;
  78711. private _reject;
  78712. /**
  78713. * The resolve method of the promise associated with this deferred object.
  78714. */
  78715. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78716. /**
  78717. * The reject method of the promise associated with this deferred object.
  78718. */
  78719. get reject(): (reason?: any) => void;
  78720. /**
  78721. * Constructor for this deferred object.
  78722. */
  78723. constructor();
  78724. }
  78725. }
  78726. declare module "babylonjs/Misc/meshExploder" {
  78727. import { Mesh } from "babylonjs/Meshes/mesh";
  78728. /**
  78729. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78730. */
  78731. export class MeshExploder {
  78732. private _centerMesh;
  78733. private _meshes;
  78734. private _meshesOrigins;
  78735. private _toCenterVectors;
  78736. private _scaledDirection;
  78737. private _newPosition;
  78738. private _centerPosition;
  78739. /**
  78740. * Explodes meshes from a center mesh.
  78741. * @param meshes The meshes to explode.
  78742. * @param centerMesh The mesh to be center of explosion.
  78743. */
  78744. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78745. private _setCenterMesh;
  78746. /**
  78747. * Get class name
  78748. * @returns "MeshExploder"
  78749. */
  78750. getClassName(): string;
  78751. /**
  78752. * "Exploded meshes"
  78753. * @returns Array of meshes with the centerMesh at index 0.
  78754. */
  78755. getMeshes(): Array<Mesh>;
  78756. /**
  78757. * Explodes meshes giving a specific direction
  78758. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78759. */
  78760. explode(direction?: number): void;
  78761. }
  78762. }
  78763. declare module "babylonjs/Misc/filesInput" {
  78764. import { Engine } from "babylonjs/Engines/engine";
  78765. import { Scene } from "babylonjs/scene";
  78766. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78767. import { Nullable } from "babylonjs/types";
  78768. /**
  78769. * Class used to help managing file picking and drag'n'drop
  78770. */
  78771. export class FilesInput {
  78772. /**
  78773. * List of files ready to be loaded
  78774. */
  78775. static get FilesToLoad(): {
  78776. [key: string]: File;
  78777. };
  78778. /**
  78779. * Callback called when a file is processed
  78780. */
  78781. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78782. private _engine;
  78783. private _currentScene;
  78784. private _sceneLoadedCallback;
  78785. private _progressCallback;
  78786. private _additionalRenderLoopLogicCallback;
  78787. private _textureLoadingCallback;
  78788. private _startingProcessingFilesCallback;
  78789. private _onReloadCallback;
  78790. private _errorCallback;
  78791. private _elementToMonitor;
  78792. private _sceneFileToLoad;
  78793. private _filesToLoad;
  78794. /**
  78795. * Creates a new FilesInput
  78796. * @param engine defines the rendering engine
  78797. * @param scene defines the hosting scene
  78798. * @param sceneLoadedCallback callback called when scene is loaded
  78799. * @param progressCallback callback called to track progress
  78800. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78801. * @param textureLoadingCallback callback called when a texture is loading
  78802. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78803. * @param onReloadCallback callback called when a reload is requested
  78804. * @param errorCallback callback call if an error occurs
  78805. */
  78806. 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>);
  78807. private _dragEnterHandler;
  78808. private _dragOverHandler;
  78809. private _dropHandler;
  78810. /**
  78811. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78812. * @param elementToMonitor defines the DOM element to track
  78813. */
  78814. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78815. /** Gets the current list of files to load */
  78816. get filesToLoad(): File[];
  78817. /**
  78818. * Release all associated resources
  78819. */
  78820. dispose(): void;
  78821. private renderFunction;
  78822. private drag;
  78823. private drop;
  78824. private _traverseFolder;
  78825. private _processFiles;
  78826. /**
  78827. * Load files from a drop event
  78828. * @param event defines the drop event to use as source
  78829. */
  78830. loadFiles(event: any): void;
  78831. private _processReload;
  78832. /**
  78833. * Reload the current scene from the loaded files
  78834. */
  78835. reload(): void;
  78836. }
  78837. }
  78838. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78839. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78840. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78841. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78842. }
  78843. declare module "babylonjs/Misc/sceneOptimizer" {
  78844. import { Scene, IDisposable } from "babylonjs/scene";
  78845. import { Observable } from "babylonjs/Misc/observable";
  78846. /**
  78847. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78848. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78849. */
  78850. export class SceneOptimization {
  78851. /**
  78852. * Defines the priority of this optimization (0 by default which means first in the list)
  78853. */
  78854. priority: number;
  78855. /**
  78856. * Gets a string describing the action executed by the current optimization
  78857. * @returns description string
  78858. */
  78859. getDescription(): string;
  78860. /**
  78861. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78862. * @param scene defines the current scene where to apply this optimization
  78863. * @param optimizer defines the current optimizer
  78864. * @returns true if everything that can be done was applied
  78865. */
  78866. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78867. /**
  78868. * Creates the SceneOptimization object
  78869. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78870. * @param desc defines the description associated with the optimization
  78871. */
  78872. constructor(
  78873. /**
  78874. * Defines the priority of this optimization (0 by default which means first in the list)
  78875. */
  78876. priority?: number);
  78877. }
  78878. /**
  78879. * Defines an optimization used to reduce the size of render target textures
  78880. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78881. */
  78882. export class TextureOptimization extends SceneOptimization {
  78883. /**
  78884. * Defines the priority of this optimization (0 by default which means first in the list)
  78885. */
  78886. priority: number;
  78887. /**
  78888. * 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
  78889. */
  78890. maximumSize: number;
  78891. /**
  78892. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78893. */
  78894. step: number;
  78895. /**
  78896. * Gets a string describing the action executed by the current optimization
  78897. * @returns description string
  78898. */
  78899. getDescription(): string;
  78900. /**
  78901. * Creates the TextureOptimization object
  78902. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78903. * @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
  78904. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78905. */
  78906. constructor(
  78907. /**
  78908. * Defines the priority of this optimization (0 by default which means first in the list)
  78909. */
  78910. priority?: number,
  78911. /**
  78912. * 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
  78913. */
  78914. maximumSize?: number,
  78915. /**
  78916. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78917. */
  78918. step?: number);
  78919. /**
  78920. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78921. * @param scene defines the current scene where to apply this optimization
  78922. * @param optimizer defines the current optimizer
  78923. * @returns true if everything that can be done was applied
  78924. */
  78925. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78926. }
  78927. /**
  78928. * Defines an optimization used to increase or decrease the rendering resolution
  78929. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78930. */
  78931. export class HardwareScalingOptimization extends SceneOptimization {
  78932. /**
  78933. * Defines the priority of this optimization (0 by default which means first in the list)
  78934. */
  78935. priority: number;
  78936. /**
  78937. * Defines the maximum scale to use (2 by default)
  78938. */
  78939. maximumScale: number;
  78940. /**
  78941. * Defines the step to use between two passes (0.5 by default)
  78942. */
  78943. step: number;
  78944. private _currentScale;
  78945. private _directionOffset;
  78946. /**
  78947. * Gets a string describing the action executed by the current optimization
  78948. * @return description string
  78949. */
  78950. getDescription(): string;
  78951. /**
  78952. * Creates the HardwareScalingOptimization object
  78953. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78954. * @param maximumScale defines the maximum scale to use (2 by default)
  78955. * @param step defines the step to use between two passes (0.5 by default)
  78956. */
  78957. constructor(
  78958. /**
  78959. * Defines the priority of this optimization (0 by default which means first in the list)
  78960. */
  78961. priority?: number,
  78962. /**
  78963. * Defines the maximum scale to use (2 by default)
  78964. */
  78965. maximumScale?: number,
  78966. /**
  78967. * Defines the step to use between two passes (0.5 by default)
  78968. */
  78969. step?: number);
  78970. /**
  78971. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78972. * @param scene defines the current scene where to apply this optimization
  78973. * @param optimizer defines the current optimizer
  78974. * @returns true if everything that can be done was applied
  78975. */
  78976. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78977. }
  78978. /**
  78979. * Defines an optimization used to remove shadows
  78980. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78981. */
  78982. export class ShadowsOptimization extends SceneOptimization {
  78983. /**
  78984. * Gets a string describing the action executed by the current optimization
  78985. * @return description string
  78986. */
  78987. getDescription(): string;
  78988. /**
  78989. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78990. * @param scene defines the current scene where to apply this optimization
  78991. * @param optimizer defines the current optimizer
  78992. * @returns true if everything that can be done was applied
  78993. */
  78994. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78995. }
  78996. /**
  78997. * Defines an optimization used to turn post-processes off
  78998. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78999. */
  79000. export class PostProcessesOptimization extends SceneOptimization {
  79001. /**
  79002. * Gets a string describing the action executed by the current optimization
  79003. * @return description string
  79004. */
  79005. getDescription(): string;
  79006. /**
  79007. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79008. * @param scene defines the current scene where to apply this optimization
  79009. * @param optimizer defines the current optimizer
  79010. * @returns true if everything that can be done was applied
  79011. */
  79012. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79013. }
  79014. /**
  79015. * Defines an optimization used to turn lens flares off
  79016. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79017. */
  79018. export class LensFlaresOptimization extends SceneOptimization {
  79019. /**
  79020. * Gets a string describing the action executed by the current optimization
  79021. * @return description string
  79022. */
  79023. getDescription(): string;
  79024. /**
  79025. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79026. * @param scene defines the current scene where to apply this optimization
  79027. * @param optimizer defines the current optimizer
  79028. * @returns true if everything that can be done was applied
  79029. */
  79030. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79031. }
  79032. /**
  79033. * Defines an optimization based on user defined callback.
  79034. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79035. */
  79036. export class CustomOptimization extends SceneOptimization {
  79037. /**
  79038. * Callback called to apply the custom optimization.
  79039. */
  79040. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  79041. /**
  79042. * Callback called to get custom description
  79043. */
  79044. onGetDescription: () => string;
  79045. /**
  79046. * Gets a string describing the action executed by the current optimization
  79047. * @returns description string
  79048. */
  79049. getDescription(): string;
  79050. /**
  79051. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79052. * @param scene defines the current scene where to apply this optimization
  79053. * @param optimizer defines the current optimizer
  79054. * @returns true if everything that can be done was applied
  79055. */
  79056. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79057. }
  79058. /**
  79059. * Defines an optimization used to turn particles off
  79060. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79061. */
  79062. export class ParticlesOptimization extends SceneOptimization {
  79063. /**
  79064. * Gets a string describing the action executed by the current optimization
  79065. * @return description string
  79066. */
  79067. getDescription(): string;
  79068. /**
  79069. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79070. * @param scene defines the current scene where to apply this optimization
  79071. * @param optimizer defines the current optimizer
  79072. * @returns true if everything that can be done was applied
  79073. */
  79074. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79075. }
  79076. /**
  79077. * Defines an optimization used to turn render targets off
  79078. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79079. */
  79080. export class RenderTargetsOptimization extends SceneOptimization {
  79081. /**
  79082. * Gets a string describing the action executed by the current optimization
  79083. * @return description string
  79084. */
  79085. getDescription(): string;
  79086. /**
  79087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79088. * @param scene defines the current scene where to apply this optimization
  79089. * @param optimizer defines the current optimizer
  79090. * @returns true if everything that can be done was applied
  79091. */
  79092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79093. }
  79094. /**
  79095. * Defines an optimization used to merge meshes with compatible materials
  79096. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79097. */
  79098. export class MergeMeshesOptimization extends SceneOptimization {
  79099. private static _UpdateSelectionTree;
  79100. /**
  79101. * Gets or sets a boolean which defines if optimization octree has to be updated
  79102. */
  79103. static get UpdateSelectionTree(): boolean;
  79104. /**
  79105. * Gets or sets a boolean which defines if optimization octree has to be updated
  79106. */
  79107. static set UpdateSelectionTree(value: boolean);
  79108. /**
  79109. * Gets a string describing the action executed by the current optimization
  79110. * @return description string
  79111. */
  79112. getDescription(): string;
  79113. private _canBeMerged;
  79114. /**
  79115. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79116. * @param scene defines the current scene where to apply this optimization
  79117. * @param optimizer defines the current optimizer
  79118. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  79119. * @returns true if everything that can be done was applied
  79120. */
  79121. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  79122. }
  79123. /**
  79124. * Defines a list of options used by SceneOptimizer
  79125. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79126. */
  79127. export class SceneOptimizerOptions {
  79128. /**
  79129. * Defines the target frame rate to reach (60 by default)
  79130. */
  79131. targetFrameRate: number;
  79132. /**
  79133. * Defines the interval between two checkes (2000ms by default)
  79134. */
  79135. trackerDuration: number;
  79136. /**
  79137. * Gets the list of optimizations to apply
  79138. */
  79139. optimizations: SceneOptimization[];
  79140. /**
  79141. * Creates a new list of options used by SceneOptimizer
  79142. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  79143. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  79144. */
  79145. constructor(
  79146. /**
  79147. * Defines the target frame rate to reach (60 by default)
  79148. */
  79149. targetFrameRate?: number,
  79150. /**
  79151. * Defines the interval between two checkes (2000ms by default)
  79152. */
  79153. trackerDuration?: number);
  79154. /**
  79155. * Add a new optimization
  79156. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  79157. * @returns the current SceneOptimizerOptions
  79158. */
  79159. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  79160. /**
  79161. * Add a new custom optimization
  79162. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  79163. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  79164. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79165. * @returns the current SceneOptimizerOptions
  79166. */
  79167. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  79168. /**
  79169. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  79170. * @param targetFrameRate defines the target frame rate (60 by default)
  79171. * @returns a SceneOptimizerOptions object
  79172. */
  79173. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79174. /**
  79175. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  79176. * @param targetFrameRate defines the target frame rate (60 by default)
  79177. * @returns a SceneOptimizerOptions object
  79178. */
  79179. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79180. /**
  79181. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  79182. * @param targetFrameRate defines the target frame rate (60 by default)
  79183. * @returns a SceneOptimizerOptions object
  79184. */
  79185. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79186. }
  79187. /**
  79188. * Class used to run optimizations in order to reach a target frame rate
  79189. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79190. */
  79191. export class SceneOptimizer implements IDisposable {
  79192. private _isRunning;
  79193. private _options;
  79194. private _scene;
  79195. private _currentPriorityLevel;
  79196. private _targetFrameRate;
  79197. private _trackerDuration;
  79198. private _currentFrameRate;
  79199. private _sceneDisposeObserver;
  79200. private _improvementMode;
  79201. /**
  79202. * Defines an observable called when the optimizer reaches the target frame rate
  79203. */
  79204. onSuccessObservable: Observable<SceneOptimizer>;
  79205. /**
  79206. * Defines an observable called when the optimizer enables an optimization
  79207. */
  79208. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  79209. /**
  79210. * Defines an observable called when the optimizer is not able to reach the target frame rate
  79211. */
  79212. onFailureObservable: Observable<SceneOptimizer>;
  79213. /**
  79214. * Gets a boolean indicating if the optimizer is in improvement mode
  79215. */
  79216. get isInImprovementMode(): boolean;
  79217. /**
  79218. * Gets the current priority level (0 at start)
  79219. */
  79220. get currentPriorityLevel(): number;
  79221. /**
  79222. * Gets the current frame rate checked by the SceneOptimizer
  79223. */
  79224. get currentFrameRate(): number;
  79225. /**
  79226. * Gets or sets the current target frame rate (60 by default)
  79227. */
  79228. get targetFrameRate(): number;
  79229. /**
  79230. * Gets or sets the current target frame rate (60 by default)
  79231. */
  79232. set targetFrameRate(value: number);
  79233. /**
  79234. * Gets or sets the current interval between two checks (every 2000ms by default)
  79235. */
  79236. get trackerDuration(): number;
  79237. /**
  79238. * Gets or sets the current interval between two checks (every 2000ms by default)
  79239. */
  79240. set trackerDuration(value: number);
  79241. /**
  79242. * Gets the list of active optimizations
  79243. */
  79244. get optimizations(): SceneOptimization[];
  79245. /**
  79246. * Creates a new SceneOptimizer
  79247. * @param scene defines the scene to work on
  79248. * @param options defines the options to use with the SceneOptimizer
  79249. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  79250. * @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)
  79251. */
  79252. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  79253. /**
  79254. * Stops the current optimizer
  79255. */
  79256. stop(): void;
  79257. /**
  79258. * Reset the optimizer to initial step (current priority level = 0)
  79259. */
  79260. reset(): void;
  79261. /**
  79262. * Start the optimizer. By default it will try to reach a specific framerate
  79263. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  79264. */
  79265. start(): void;
  79266. private _checkCurrentState;
  79267. /**
  79268. * Release all resources
  79269. */
  79270. dispose(): void;
  79271. /**
  79272. * Helper function to create a SceneOptimizer with one single line of code
  79273. * @param scene defines the scene to work on
  79274. * @param options defines the options to use with the SceneOptimizer
  79275. * @param onSuccess defines a callback to call on success
  79276. * @param onFailure defines a callback to call on failure
  79277. * @returns the new SceneOptimizer object
  79278. */
  79279. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  79280. }
  79281. }
  79282. declare module "babylonjs/Misc/sceneSerializer" {
  79283. import { Scene } from "babylonjs/scene";
  79284. /**
  79285. * Class used to serialize a scene into a string
  79286. */
  79287. export class SceneSerializer {
  79288. /**
  79289. * Clear cache used by a previous serialization
  79290. */
  79291. static ClearCache(): void;
  79292. /**
  79293. * Serialize a scene into a JSON compatible object
  79294. * @param scene defines the scene to serialize
  79295. * @returns a JSON compatible object
  79296. */
  79297. static Serialize(scene: Scene): any;
  79298. /**
  79299. * Serialize a mesh into a JSON compatible object
  79300. * @param toSerialize defines the mesh to serialize
  79301. * @param withParents defines if parents must be serialized as well
  79302. * @param withChildren defines if children must be serialized as well
  79303. * @returns a JSON compatible object
  79304. */
  79305. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  79306. }
  79307. }
  79308. declare module "babylonjs/Misc/textureTools" {
  79309. import { Texture } from "babylonjs/Materials/Textures/texture";
  79310. /**
  79311. * Class used to host texture specific utilities
  79312. */
  79313. export class TextureTools {
  79314. /**
  79315. * Uses the GPU to create a copy texture rescaled at a given size
  79316. * @param texture Texture to copy from
  79317. * @param width defines the desired width
  79318. * @param height defines the desired height
  79319. * @param useBilinearMode defines if bilinear mode has to be used
  79320. * @return the generated texture
  79321. */
  79322. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  79323. }
  79324. }
  79325. declare module "babylonjs/Misc/videoRecorder" {
  79326. import { Nullable } from "babylonjs/types";
  79327. import { Engine } from "babylonjs/Engines/engine";
  79328. /**
  79329. * This represents the different options available for the video capture.
  79330. */
  79331. export interface VideoRecorderOptions {
  79332. /** Defines the mime type of the video. */
  79333. mimeType: string;
  79334. /** Defines the FPS the video should be recorded at. */
  79335. fps: number;
  79336. /** Defines the chunk size for the recording data. */
  79337. recordChunckSize: number;
  79338. /** The audio tracks to attach to the recording. */
  79339. audioTracks?: MediaStreamTrack[];
  79340. }
  79341. /**
  79342. * This can help with recording videos from BabylonJS.
  79343. * This is based on the available WebRTC functionalities of the browser.
  79344. *
  79345. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79346. */
  79347. export class VideoRecorder {
  79348. private static readonly _defaultOptions;
  79349. /**
  79350. * Returns whether or not the VideoRecorder is available in your browser.
  79351. * @param engine Defines the Babylon Engine.
  79352. * @returns true if supported otherwise false.
  79353. */
  79354. static IsSupported(engine: Engine): boolean;
  79355. private readonly _options;
  79356. private _canvas;
  79357. private _mediaRecorder;
  79358. private _recordedChunks;
  79359. private _fileName;
  79360. private _resolve;
  79361. private _reject;
  79362. /**
  79363. * True when a recording is already in progress.
  79364. */
  79365. get isRecording(): boolean;
  79366. /**
  79367. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79368. * @param engine Defines the BabylonJS Engine you wish to record.
  79369. * @param options Defines options that can be used to customize the capture.
  79370. */
  79371. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79372. /**
  79373. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79374. */
  79375. stopRecording(): void;
  79376. /**
  79377. * Starts recording the canvas for a max duration specified in parameters.
  79378. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79379. * If null no automatic download will start and you can rely on the promise to get the data back.
  79380. * @param maxDuration Defines the maximum recording time in seconds.
  79381. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79382. * @return A promise callback at the end of the recording with the video data in Blob.
  79383. */
  79384. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79385. /**
  79386. * Releases internal resources used during the recording.
  79387. */
  79388. dispose(): void;
  79389. private _handleDataAvailable;
  79390. private _handleError;
  79391. private _handleStop;
  79392. }
  79393. }
  79394. declare module "babylonjs/Misc/screenshotTools" {
  79395. import { Camera } from "babylonjs/Cameras/camera";
  79396. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  79397. import { Engine } from "babylonjs/Engines/engine";
  79398. /**
  79399. * Class containing a set of static utilities functions for screenshots
  79400. */
  79401. export class ScreenshotTools {
  79402. /**
  79403. * Captures a screenshot of the current rendering
  79404. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79405. * @param engine defines the rendering engine
  79406. * @param camera defines the source camera
  79407. * @param size This parameter can be set to a single number or to an object with the
  79408. * following (optional) properties: precision, width, height. If a single number is passed,
  79409. * it will be used for both width and height. If an object is passed, the screenshot size
  79410. * will be derived from the parameters. The precision property is a multiplier allowing
  79411. * rendering at a higher or lower resolution
  79412. * @param successCallback defines the callback receives a single parameter which contains the
  79413. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79414. * src parameter of an <img> to display it
  79415. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79416. * Check your browser for supported MIME types
  79417. */
  79418. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  79419. /**
  79420. * Captures a screenshot of the current rendering
  79421. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79422. * @param engine defines the rendering engine
  79423. * @param camera defines the source camera
  79424. * @param size This parameter can be set to a single number or to an object with the
  79425. * following (optional) properties: precision, width, height. If a single number is passed,
  79426. * it will be used for both width and height. If an object is passed, the screenshot size
  79427. * will be derived from the parameters. The precision property is a multiplier allowing
  79428. * rendering at a higher or lower resolution
  79429. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79430. * Check your browser for supported MIME types
  79431. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79432. * to the src parameter of an <img> to display it
  79433. */
  79434. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79435. /**
  79436. * Generates an image screenshot from the specified camera.
  79437. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79438. * @param engine The engine to use for rendering
  79439. * @param camera The camera to use for rendering
  79440. * @param size This parameter can be set to a single number or to an object with the
  79441. * following (optional) properties: precision, width, height. If a single number is passed,
  79442. * it will be used for both width and height. If an object is passed, the screenshot size
  79443. * will be derived from the parameters. The precision property is a multiplier allowing
  79444. * rendering at a higher or lower resolution
  79445. * @param successCallback The callback receives a single parameter which contains the
  79446. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79447. * src parameter of an <img> to display it
  79448. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79449. * Check your browser for supported MIME types
  79450. * @param samples Texture samples (default: 1)
  79451. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79452. * @param fileName A name for for the downloaded file.
  79453. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79454. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79455. */
  79456. 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;
  79457. /**
  79458. * Generates an image screenshot from the specified camera.
  79459. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79460. * @param engine The engine to use for rendering
  79461. * @param camera The camera to use for rendering
  79462. * @param size This parameter can be set to a single number or to an object with the
  79463. * following (optional) properties: precision, width, height. If a single number is passed,
  79464. * it will be used for both width and height. If an object is passed, the screenshot size
  79465. * will be derived from the parameters. The precision property is a multiplier allowing
  79466. * rendering at a higher or lower resolution
  79467. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79468. * Check your browser for supported MIME types
  79469. * @param samples Texture samples (default: 1)
  79470. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79471. * @param fileName A name for for the downloaded file.
  79472. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79473. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79474. * to the src parameter of an <img> to display it
  79475. */
  79476. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79477. /**
  79478. * Gets height and width for screenshot size
  79479. * @private
  79480. */
  79481. private static _getScreenshotSize;
  79482. }
  79483. }
  79484. declare module "babylonjs/Misc/dataReader" {
  79485. /**
  79486. * Interface for a data buffer
  79487. */
  79488. export interface IDataBuffer {
  79489. /**
  79490. * Reads bytes from the data buffer.
  79491. * @param byteOffset The byte offset to read
  79492. * @param byteLength The byte length to read
  79493. * @returns A promise that resolves when the bytes are read
  79494. */
  79495. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79496. /**
  79497. * The byte length of the buffer.
  79498. */
  79499. readonly byteLength: number;
  79500. }
  79501. /**
  79502. * Utility class for reading from a data buffer
  79503. */
  79504. export class DataReader {
  79505. /**
  79506. * The data buffer associated with this data reader.
  79507. */
  79508. readonly buffer: IDataBuffer;
  79509. /**
  79510. * The current byte offset from the beginning of the data buffer.
  79511. */
  79512. byteOffset: number;
  79513. private _dataView;
  79514. private _dataByteOffset;
  79515. /**
  79516. * Constructor
  79517. * @param buffer The buffer to read
  79518. */
  79519. constructor(buffer: IDataBuffer);
  79520. /**
  79521. * Loads the given byte length.
  79522. * @param byteLength The byte length to load
  79523. * @returns A promise that resolves when the load is complete
  79524. */
  79525. loadAsync(byteLength: number): Promise<void>;
  79526. /**
  79527. * Read a unsigned 32-bit integer from the currently loaded data range.
  79528. * @returns The 32-bit integer read
  79529. */
  79530. readUint32(): number;
  79531. /**
  79532. * Read a byte array from the currently loaded data range.
  79533. * @param byteLength The byte length to read
  79534. * @returns The byte array read
  79535. */
  79536. readUint8Array(byteLength: number): Uint8Array;
  79537. /**
  79538. * Read a string from the currently loaded data range.
  79539. * @param byteLength The byte length to read
  79540. * @returns The string read
  79541. */
  79542. readString(byteLength: number): string;
  79543. /**
  79544. * Skips the given byte length the currently loaded data range.
  79545. * @param byteLength The byte length to skip
  79546. */
  79547. skipBytes(byteLength: number): void;
  79548. }
  79549. }
  79550. declare module "babylonjs/Misc/dataStorage" {
  79551. /**
  79552. * Class for storing data to local storage if available or in-memory storage otherwise
  79553. */
  79554. export class DataStorage {
  79555. private static _Storage;
  79556. private static _GetStorage;
  79557. /**
  79558. * Reads a string from the data storage
  79559. * @param key The key to read
  79560. * @param defaultValue The value if the key doesn't exist
  79561. * @returns The string value
  79562. */
  79563. static ReadString(key: string, defaultValue: string): string;
  79564. /**
  79565. * Writes a string to the data storage
  79566. * @param key The key to write
  79567. * @param value The value to write
  79568. */
  79569. static WriteString(key: string, value: string): void;
  79570. /**
  79571. * Reads a boolean from the data storage
  79572. * @param key The key to read
  79573. * @param defaultValue The value if the key doesn't exist
  79574. * @returns The boolean value
  79575. */
  79576. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79577. /**
  79578. * Writes a boolean to the data storage
  79579. * @param key The key to write
  79580. * @param value The value to write
  79581. */
  79582. static WriteBoolean(key: string, value: boolean): void;
  79583. /**
  79584. * Reads a number from the data storage
  79585. * @param key The key to read
  79586. * @param defaultValue The value if the key doesn't exist
  79587. * @returns The number value
  79588. */
  79589. static ReadNumber(key: string, defaultValue: number): number;
  79590. /**
  79591. * Writes a number to the data storage
  79592. * @param key The key to write
  79593. * @param value The value to write
  79594. */
  79595. static WriteNumber(key: string, value: number): void;
  79596. }
  79597. }
  79598. declare module "babylonjs/Misc/sceneRecorder" {
  79599. import { Scene } from "babylonjs/scene";
  79600. /**
  79601. * Class used to record delta files between 2 scene states
  79602. */
  79603. export class SceneRecorder {
  79604. private _trackedScene;
  79605. private _savedJSON;
  79606. /**
  79607. * Track a given scene. This means the current scene state will be considered the original state
  79608. * @param scene defines the scene to track
  79609. */
  79610. track(scene: Scene): void;
  79611. /**
  79612. * Get the delta between current state and original state
  79613. * @returns a string containing the delta
  79614. */
  79615. getDelta(): any;
  79616. private _compareArray;
  79617. private _compareObjects;
  79618. private _compareCollections;
  79619. private static GetShadowGeneratorById;
  79620. /**
  79621. * Apply a given delta to a given scene
  79622. * @param deltaJSON defines the JSON containing the delta
  79623. * @param scene defines the scene to apply the delta to
  79624. */
  79625. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79626. private static _ApplyPropertiesToEntity;
  79627. private static _ApplyDeltaForEntity;
  79628. }
  79629. }
  79630. declare module "babylonjs/Misc/trajectoryClassifier" {
  79631. import { DeepImmutable, Nullable } from "babylonjs/types";
  79632. import { Vector3 } from "babylonjs/Maths/math.vector";
  79633. /**
  79634. * A 3D trajectory consisting of an order list of vectors describing a
  79635. * path of motion through 3D space.
  79636. */
  79637. export class Trajectory {
  79638. private _points;
  79639. private readonly _segmentLength;
  79640. /**
  79641. * Serialize to JSON.
  79642. * @returns serialized JSON string
  79643. */
  79644. serialize(): string;
  79645. /**
  79646. * Deserialize from JSON.
  79647. * @param json serialized JSON string
  79648. * @returns deserialized Trajectory
  79649. */
  79650. static Deserialize(json: string): Trajectory;
  79651. /**
  79652. * Create a new empty Trajectory.
  79653. * @param segmentLength radius of discretization for Trajectory points
  79654. */
  79655. constructor(segmentLength?: number);
  79656. /**
  79657. * Get the length of the Trajectory.
  79658. * @returns length of the Trajectory
  79659. */
  79660. getLength(): number;
  79661. /**
  79662. * Append a new point to the Trajectory.
  79663. * NOTE: This implementation has many allocations.
  79664. * @param point point to append to the Trajectory
  79665. */
  79666. add(point: DeepImmutable<Vector3>): void;
  79667. /**
  79668. * Create a new Trajectory with a segment length chosen to make it
  79669. * probable that the new Trajectory will have a specified number of
  79670. * segments. This operation is imprecise.
  79671. * @param targetResolution number of segments desired
  79672. * @returns new Trajectory with approximately the requested number of segments
  79673. */
  79674. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79675. /**
  79676. * Convert Trajectory segments into tokenized representation. This
  79677. * representation is an array of numbers where each nth number is the
  79678. * index of the token which is most similar to the nth segment of the
  79679. * Trajectory.
  79680. * @param tokens list of vectors which serve as discrete tokens
  79681. * @returns list of indices of most similar token per segment
  79682. */
  79683. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79684. private static _forwardDir;
  79685. private static _inverseFromVec;
  79686. private static _upDir;
  79687. private static _fromToVec;
  79688. private static _lookMatrix;
  79689. /**
  79690. * Transform the rotation (i.e., direction) of a segment to isolate
  79691. * the relative transformation represented by the segment. This operation
  79692. * may or may not succeed due to singularities in the equations that define
  79693. * motion relativity in this context.
  79694. * @param priorVec the origin of the prior segment
  79695. * @param fromVec the origin of the current segment
  79696. * @param toVec the destination of the current segment
  79697. * @param result reference to output variable
  79698. * @returns whether or not transformation was successful
  79699. */
  79700. private static _transformSegmentDirToRef;
  79701. private static _bestMatch;
  79702. private static _score;
  79703. private static _bestScore;
  79704. /**
  79705. * Determine which token vector is most similar to the
  79706. * segment vector.
  79707. * @param segment segment vector
  79708. * @param tokens token vector list
  79709. * @returns index of the most similar token to the segment
  79710. */
  79711. private static _tokenizeSegment;
  79712. }
  79713. /**
  79714. * Class representing a set of known, named trajectories to which Trajectories can be
  79715. * added and using which Trajectories can be recognized.
  79716. */
  79717. export class TrajectoryClassifier {
  79718. private _maximumAllowableMatchCost;
  79719. private _vector3Alphabet;
  79720. private _levenshteinAlphabet;
  79721. private _nameToDescribedTrajectory;
  79722. /**
  79723. * Serialize to JSON.
  79724. * @returns JSON serialization
  79725. */
  79726. serialize(): string;
  79727. /**
  79728. * Deserialize from JSON.
  79729. * @param json JSON serialization
  79730. * @returns deserialized TrajectorySet
  79731. */
  79732. static Deserialize(json: string): TrajectoryClassifier;
  79733. /**
  79734. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79735. * VERY naive, need to be generating these things from known
  79736. * sets. Better version later, probably eliminating this one.
  79737. * @returns auto-generated TrajectorySet
  79738. */
  79739. static Generate(): TrajectoryClassifier;
  79740. private constructor();
  79741. /**
  79742. * Add a new Trajectory to the set with a given name.
  79743. * @param trajectory new Trajectory to be added
  79744. * @param classification name to which to add the Trajectory
  79745. */
  79746. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79747. /**
  79748. * Remove a known named trajectory and all Trajectories associated with it.
  79749. * @param classification name to remove
  79750. * @returns whether anything was removed
  79751. */
  79752. deleteClassification(classification: string): boolean;
  79753. /**
  79754. * Attempt to recognize a Trajectory from among all the classifications
  79755. * already known to the classifier.
  79756. * @param trajectory Trajectory to be recognized
  79757. * @returns classification of Trajectory if recognized, null otherwise
  79758. */
  79759. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79760. }
  79761. }
  79762. declare module "babylonjs/Misc/index" {
  79763. export * from "babylonjs/Misc/andOrNotEvaluator";
  79764. export * from "babylonjs/Misc/assetsManager";
  79765. export * from "babylonjs/Misc/basis";
  79766. export * from "babylonjs/Misc/dds";
  79767. export * from "babylonjs/Misc/decorators";
  79768. export * from "babylonjs/Misc/deferred";
  79769. export * from "babylonjs/Misc/environmentTextureTools";
  79770. export * from "babylonjs/Misc/meshExploder";
  79771. export * from "babylonjs/Misc/filesInput";
  79772. export * from "babylonjs/Misc/HighDynamicRange/index";
  79773. export * from "babylonjs/Misc/khronosTextureContainer";
  79774. export * from "babylonjs/Misc/observable";
  79775. export * from "babylonjs/Misc/performanceMonitor";
  79776. export * from "babylonjs/Misc/promise";
  79777. export * from "babylonjs/Misc/sceneOptimizer";
  79778. export * from "babylonjs/Misc/sceneSerializer";
  79779. export * from "babylonjs/Misc/smartArray";
  79780. export * from "babylonjs/Misc/stringDictionary";
  79781. export * from "babylonjs/Misc/tags";
  79782. export * from "babylonjs/Misc/textureTools";
  79783. export * from "babylonjs/Misc/tga";
  79784. export * from "babylonjs/Misc/tools";
  79785. export * from "babylonjs/Misc/videoRecorder";
  79786. export * from "babylonjs/Misc/virtualJoystick";
  79787. export * from "babylonjs/Misc/workerPool";
  79788. export * from "babylonjs/Misc/logger";
  79789. export * from "babylonjs/Misc/typeStore";
  79790. export * from "babylonjs/Misc/filesInputStore";
  79791. export * from "babylonjs/Misc/deepCopier";
  79792. export * from "babylonjs/Misc/pivotTools";
  79793. export * from "babylonjs/Misc/precisionDate";
  79794. export * from "babylonjs/Misc/screenshotTools";
  79795. export * from "babylonjs/Misc/typeStore";
  79796. export * from "babylonjs/Misc/webRequest";
  79797. export * from "babylonjs/Misc/iInspectable";
  79798. export * from "babylonjs/Misc/brdfTextureTools";
  79799. export * from "babylonjs/Misc/rgbdTextureTools";
  79800. export * from "babylonjs/Misc/gradients";
  79801. export * from "babylonjs/Misc/perfCounter";
  79802. export * from "babylonjs/Misc/fileRequest";
  79803. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79804. export * from "babylonjs/Misc/retryStrategy";
  79805. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79806. export * from "babylonjs/Misc/canvasGenerator";
  79807. export * from "babylonjs/Misc/fileTools";
  79808. export * from "babylonjs/Misc/stringTools";
  79809. export * from "babylonjs/Misc/dataReader";
  79810. export * from "babylonjs/Misc/minMaxReducer";
  79811. export * from "babylonjs/Misc/depthReducer";
  79812. export * from "babylonjs/Misc/dataStorage";
  79813. export * from "babylonjs/Misc/sceneRecorder";
  79814. export * from "babylonjs/Misc/khronosTextureContainer2";
  79815. export * from "babylonjs/Misc/trajectoryClassifier";
  79816. export * from "babylonjs/Misc/timer";
  79817. export * from "babylonjs/Misc/copyTools";
  79818. }
  79819. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79820. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79821. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79822. import { Observable } from "babylonjs/Misc/observable";
  79823. import { Matrix } from "babylonjs/Maths/math.vector";
  79824. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79825. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79826. /**
  79827. * An interface for all Hit test features
  79828. */
  79829. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79830. /**
  79831. * Triggered when new babylon (transformed) hit test results are available
  79832. */
  79833. onHitTestResultObservable: Observable<T[]>;
  79834. }
  79835. /**
  79836. * Options used for hit testing
  79837. */
  79838. export interface IWebXRLegacyHitTestOptions {
  79839. /**
  79840. * Only test when user interacted with the scene. Default - hit test every frame
  79841. */
  79842. testOnPointerDownOnly?: boolean;
  79843. /**
  79844. * The node to use to transform the local results to world coordinates
  79845. */
  79846. worldParentNode?: TransformNode;
  79847. }
  79848. /**
  79849. * Interface defining the babylon result of raycasting/hit-test
  79850. */
  79851. export interface IWebXRLegacyHitResult {
  79852. /**
  79853. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79854. */
  79855. transformationMatrix: Matrix;
  79856. /**
  79857. * The native hit test result
  79858. */
  79859. xrHitResult: XRHitResult | XRHitTestResult;
  79860. }
  79861. /**
  79862. * The currently-working hit-test module.
  79863. * Hit test (or Ray-casting) is used to interact with the real world.
  79864. * For further information read here - https://github.com/immersive-web/hit-test
  79865. */
  79866. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79867. /**
  79868. * options to use when constructing this feature
  79869. */
  79870. readonly options: IWebXRLegacyHitTestOptions;
  79871. private _direction;
  79872. private _mat;
  79873. private _onSelectEnabled;
  79874. private _origin;
  79875. /**
  79876. * The module's name
  79877. */
  79878. static readonly Name: string;
  79879. /**
  79880. * The (Babylon) version of this module.
  79881. * This is an integer representing the implementation version.
  79882. * This number does not correspond to the WebXR specs version
  79883. */
  79884. static readonly Version: number;
  79885. /**
  79886. * Populated with the last native XR Hit Results
  79887. */
  79888. lastNativeXRHitResults: XRHitResult[];
  79889. /**
  79890. * Triggered when new babylon (transformed) hit test results are available
  79891. */
  79892. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79893. /**
  79894. * Creates a new instance of the (legacy version) hit test feature
  79895. * @param _xrSessionManager an instance of WebXRSessionManager
  79896. * @param options options to use when constructing this feature
  79897. */
  79898. constructor(_xrSessionManager: WebXRSessionManager,
  79899. /**
  79900. * options to use when constructing this feature
  79901. */
  79902. options?: IWebXRLegacyHitTestOptions);
  79903. /**
  79904. * execute a hit test with an XR Ray
  79905. *
  79906. * @param xrSession a native xrSession that will execute this hit test
  79907. * @param xrRay the ray (position and direction) to use for ray-casting
  79908. * @param referenceSpace native XR reference space to use for the hit-test
  79909. * @param filter filter function that will filter the results
  79910. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79911. */
  79912. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79913. /**
  79914. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79915. * @param event the (select) event to use to select with
  79916. * @param referenceSpace the reference space to use for this hit test
  79917. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79918. */
  79919. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79920. /**
  79921. * attach this feature
  79922. * Will usually be called by the features manager
  79923. *
  79924. * @returns true if successful.
  79925. */
  79926. attach(): boolean;
  79927. /**
  79928. * detach this feature.
  79929. * Will usually be called by the features manager
  79930. *
  79931. * @returns true if successful.
  79932. */
  79933. detach(): boolean;
  79934. /**
  79935. * Dispose this feature and all of the resources attached
  79936. */
  79937. dispose(): void;
  79938. protected _onXRFrame(frame: XRFrame): void;
  79939. private _onHitTestResults;
  79940. private _onSelect;
  79941. }
  79942. }
  79943. declare module "babylonjs/XR/features/WebXRHitTest" {
  79944. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79945. import { Observable } from "babylonjs/Misc/observable";
  79946. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79947. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79948. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79949. /**
  79950. * Options used for hit testing (version 2)
  79951. */
  79952. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79953. /**
  79954. * Do not create a permanent hit test. Will usually be used when only
  79955. * transient inputs are needed.
  79956. */
  79957. disablePermanentHitTest?: boolean;
  79958. /**
  79959. * Enable transient (for example touch-based) hit test inspections
  79960. */
  79961. enableTransientHitTest?: boolean;
  79962. /**
  79963. * Offset ray for the permanent hit test
  79964. */
  79965. offsetRay?: Vector3;
  79966. /**
  79967. * Offset ray for the transient hit test
  79968. */
  79969. transientOffsetRay?: Vector3;
  79970. /**
  79971. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79972. */
  79973. useReferenceSpace?: boolean;
  79974. /**
  79975. * Override the default entity type(s) of the hit-test result
  79976. */
  79977. entityTypes?: XRHitTestTrackableType[];
  79978. }
  79979. /**
  79980. * Interface defining the babylon result of hit-test
  79981. */
  79982. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79983. /**
  79984. * The input source that generated this hit test (if transient)
  79985. */
  79986. inputSource?: XRInputSource;
  79987. /**
  79988. * Is this a transient hit test
  79989. */
  79990. isTransient?: boolean;
  79991. /**
  79992. * Position of the hit test result
  79993. */
  79994. position: Vector3;
  79995. /**
  79996. * Rotation of the hit test result
  79997. */
  79998. rotationQuaternion: Quaternion;
  79999. /**
  80000. * The native hit test result
  80001. */
  80002. xrHitResult: XRHitTestResult;
  80003. }
  80004. /**
  80005. * The currently-working hit-test module.
  80006. * Hit test (or Ray-casting) is used to interact with the real world.
  80007. * For further information read here - https://github.com/immersive-web/hit-test
  80008. *
  80009. * Tested on chrome (mobile) 80.
  80010. */
  80011. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  80012. /**
  80013. * options to use when constructing this feature
  80014. */
  80015. readonly options: IWebXRHitTestOptions;
  80016. private _tmpMat;
  80017. private _tmpPos;
  80018. private _tmpQuat;
  80019. private _transientXrHitTestSource;
  80020. private _xrHitTestSource;
  80021. private initHitTestSource;
  80022. /**
  80023. * The module's name
  80024. */
  80025. static readonly Name: string;
  80026. /**
  80027. * The (Babylon) version of this module.
  80028. * This is an integer representing the implementation version.
  80029. * This number does not correspond to the WebXR specs version
  80030. */
  80031. static readonly Version: number;
  80032. /**
  80033. * When set to true, each hit test will have its own position/rotation objects
  80034. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  80035. * the developers will clone them or copy them as they see fit.
  80036. */
  80037. autoCloneTransformation: boolean;
  80038. /**
  80039. * Triggered when new babylon (transformed) hit test results are available
  80040. * Note - this will be called when results come back from the device. It can be an empty array!!
  80041. */
  80042. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  80043. /**
  80044. * Use this to temporarily pause hit test checks.
  80045. */
  80046. paused: boolean;
  80047. /**
  80048. * Creates a new instance of the hit test feature
  80049. * @param _xrSessionManager an instance of WebXRSessionManager
  80050. * @param options options to use when constructing this feature
  80051. */
  80052. constructor(_xrSessionManager: WebXRSessionManager,
  80053. /**
  80054. * options to use when constructing this feature
  80055. */
  80056. options?: IWebXRHitTestOptions);
  80057. /**
  80058. * attach this feature
  80059. * Will usually be called by the features manager
  80060. *
  80061. * @returns true if successful.
  80062. */
  80063. attach(): boolean;
  80064. /**
  80065. * detach this feature.
  80066. * Will usually be called by the features manager
  80067. *
  80068. * @returns true if successful.
  80069. */
  80070. detach(): boolean;
  80071. /**
  80072. * Dispose this feature and all of the resources attached
  80073. */
  80074. dispose(): void;
  80075. protected _onXRFrame(frame: XRFrame): void;
  80076. private _processWebXRHitTestResult;
  80077. }
  80078. }
  80079. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  80080. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80081. import { Observable } from "babylonjs/Misc/observable";
  80082. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80083. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80084. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80085. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  80086. /**
  80087. * Configuration options of the anchor system
  80088. */
  80089. export interface IWebXRAnchorSystemOptions {
  80090. /**
  80091. * a node that will be used to convert local to world coordinates
  80092. */
  80093. worldParentNode?: TransformNode;
  80094. /**
  80095. * If set to true a reference of the created anchors will be kept until the next session starts
  80096. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  80097. */
  80098. doNotRemoveAnchorsOnSessionEnded?: boolean;
  80099. }
  80100. /**
  80101. * A babylon container for an XR Anchor
  80102. */
  80103. export interface IWebXRAnchor {
  80104. /**
  80105. * A babylon-assigned ID for this anchor
  80106. */
  80107. id: number;
  80108. /**
  80109. * Transformation matrix to apply to an object attached to this anchor
  80110. */
  80111. transformationMatrix: Matrix;
  80112. /**
  80113. * The native anchor object
  80114. */
  80115. xrAnchor: XRAnchor;
  80116. /**
  80117. * if defined, this object will be constantly updated by the anchor's position and rotation
  80118. */
  80119. attachedNode?: TransformNode;
  80120. }
  80121. /**
  80122. * An implementation of the anchor system for WebXR.
  80123. * For further information see https://github.com/immersive-web/anchors/
  80124. */
  80125. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  80126. private _options;
  80127. private _lastFrameDetected;
  80128. private _trackedAnchors;
  80129. private _referenceSpaceForFrameAnchors;
  80130. private _futureAnchors;
  80131. /**
  80132. * The module's name
  80133. */
  80134. static readonly Name: string;
  80135. /**
  80136. * The (Babylon) version of this module.
  80137. * This is an integer representing the implementation version.
  80138. * This number does not correspond to the WebXR specs version
  80139. */
  80140. static readonly Version: number;
  80141. /**
  80142. * Observers registered here will be executed when a new anchor was added to the session
  80143. */
  80144. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  80145. /**
  80146. * Observers registered here will be executed when an anchor was removed from the session
  80147. */
  80148. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  80149. /**
  80150. * Observers registered here will be executed when an existing anchor updates
  80151. * This can execute N times every frame
  80152. */
  80153. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  80154. /**
  80155. * Set the reference space to use for anchor creation, when not using a hit test.
  80156. * Will default to the session's reference space if not defined
  80157. */
  80158. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  80159. /**
  80160. * constructs a new anchor system
  80161. * @param _xrSessionManager an instance of WebXRSessionManager
  80162. * @param _options configuration object for this feature
  80163. */
  80164. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  80165. private _tmpVector;
  80166. private _tmpQuaternion;
  80167. private _populateTmpTransformation;
  80168. /**
  80169. * Create a new anchor point using a hit test result at a specific point in the scene
  80170. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80171. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80172. *
  80173. * @param hitTestResult The hit test result to use for this anchor creation
  80174. * @param position an optional position offset for this anchor
  80175. * @param rotationQuaternion an optional rotation offset for this anchor
  80176. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  80177. */
  80178. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  80179. /**
  80180. * Add a new anchor at a specific position and rotation
  80181. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  80182. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  80183. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80184. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80185. *
  80186. * @param position the position in which to add an anchor
  80187. * @param rotationQuaternion an optional rotation for the anchor transformation
  80188. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  80189. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  80190. */
  80191. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  80192. /**
  80193. * detach this feature.
  80194. * Will usually be called by the features manager
  80195. *
  80196. * @returns true if successful.
  80197. */
  80198. detach(): boolean;
  80199. /**
  80200. * Dispose this feature and all of the resources attached
  80201. */
  80202. dispose(): void;
  80203. protected _onXRFrame(frame: XRFrame): void;
  80204. /**
  80205. * avoiding using Array.find for global support.
  80206. * @param xrAnchor the plane to find in the array
  80207. */
  80208. private _findIndexInAnchorArray;
  80209. private _updateAnchorWithXRFrame;
  80210. private _createAnchorAtTransformation;
  80211. }
  80212. }
  80213. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  80214. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80215. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80216. import { Observable } from "babylonjs/Misc/observable";
  80217. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  80218. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80219. /**
  80220. * Options used in the plane detector module
  80221. */
  80222. export interface IWebXRPlaneDetectorOptions {
  80223. /**
  80224. * The node to use to transform the local results to world coordinates
  80225. */
  80226. worldParentNode?: TransformNode;
  80227. /**
  80228. * If set to true a reference of the created planes will be kept until the next session starts
  80229. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  80230. */
  80231. doNotRemovePlanesOnSessionEnded?: boolean;
  80232. }
  80233. /**
  80234. * A babylon interface for a WebXR plane.
  80235. * A Plane is actually a polygon, built from N points in space
  80236. *
  80237. * Supported in chrome 79, not supported in canary 81 ATM
  80238. */
  80239. export interface IWebXRPlane {
  80240. /**
  80241. * a babylon-assigned ID for this polygon
  80242. */
  80243. id: number;
  80244. /**
  80245. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  80246. */
  80247. polygonDefinition: Array<Vector3>;
  80248. /**
  80249. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  80250. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  80251. */
  80252. transformationMatrix: Matrix;
  80253. /**
  80254. * the native xr-plane object
  80255. */
  80256. xrPlane: XRPlane;
  80257. }
  80258. /**
  80259. * The plane detector is used to detect planes in the real world when in AR
  80260. * For more information see https://github.com/immersive-web/real-world-geometry/
  80261. */
  80262. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  80263. private _options;
  80264. private _detectedPlanes;
  80265. private _enabled;
  80266. private _lastFrameDetected;
  80267. /**
  80268. * The module's name
  80269. */
  80270. static readonly Name: string;
  80271. /**
  80272. * The (Babylon) version of this module.
  80273. * This is an integer representing the implementation version.
  80274. * This number does not correspond to the WebXR specs version
  80275. */
  80276. static readonly Version: number;
  80277. /**
  80278. * Observers registered here will be executed when a new plane was added to the session
  80279. */
  80280. onPlaneAddedObservable: Observable<IWebXRPlane>;
  80281. /**
  80282. * Observers registered here will be executed when a plane is no longer detected in the session
  80283. */
  80284. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  80285. /**
  80286. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  80287. * This can execute N times every frame
  80288. */
  80289. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  80290. /**
  80291. * construct a new Plane Detector
  80292. * @param _xrSessionManager an instance of xr Session manager
  80293. * @param _options configuration to use when constructing this feature
  80294. */
  80295. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  80296. /**
  80297. * detach this feature.
  80298. * Will usually be called by the features manager
  80299. *
  80300. * @returns true if successful.
  80301. */
  80302. detach(): boolean;
  80303. /**
  80304. * Dispose this feature and all of the resources attached
  80305. */
  80306. dispose(): void;
  80307. /**
  80308. * Check if the needed objects are defined.
  80309. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80310. */
  80311. isCompatible(): boolean;
  80312. protected _onXRFrame(frame: XRFrame): void;
  80313. private _init;
  80314. private _updatePlaneWithXRPlane;
  80315. /**
  80316. * avoiding using Array.find for global support.
  80317. * @param xrPlane the plane to find in the array
  80318. */
  80319. private findIndexInPlaneArray;
  80320. }
  80321. }
  80322. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  80323. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80325. import { Observable } from "babylonjs/Misc/observable";
  80326. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80327. /**
  80328. * Options interface for the background remover plugin
  80329. */
  80330. export interface IWebXRBackgroundRemoverOptions {
  80331. /**
  80332. * Further background meshes to disable when entering AR
  80333. */
  80334. backgroundMeshes?: AbstractMesh[];
  80335. /**
  80336. * flags to configure the removal of the environment helper.
  80337. * If not set, the entire background will be removed. If set, flags should be set as well.
  80338. */
  80339. environmentHelperRemovalFlags?: {
  80340. /**
  80341. * Should the skybox be removed (default false)
  80342. */
  80343. skyBox?: boolean;
  80344. /**
  80345. * Should the ground be removed (default false)
  80346. */
  80347. ground?: boolean;
  80348. };
  80349. /**
  80350. * don't disable the environment helper
  80351. */
  80352. ignoreEnvironmentHelper?: boolean;
  80353. }
  80354. /**
  80355. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  80356. */
  80357. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  80358. /**
  80359. * read-only options to be used in this module
  80360. */
  80361. readonly options: IWebXRBackgroundRemoverOptions;
  80362. /**
  80363. * The module's name
  80364. */
  80365. static readonly Name: string;
  80366. /**
  80367. * The (Babylon) version of this module.
  80368. * This is an integer representing the implementation version.
  80369. * This number does not correspond to the WebXR specs version
  80370. */
  80371. static readonly Version: number;
  80372. /**
  80373. * registered observers will be triggered when the background state changes
  80374. */
  80375. onBackgroundStateChangedObservable: Observable<boolean>;
  80376. /**
  80377. * constructs a new background remover module
  80378. * @param _xrSessionManager the session manager for this module
  80379. * @param options read-only options to be used in this module
  80380. */
  80381. constructor(_xrSessionManager: WebXRSessionManager,
  80382. /**
  80383. * read-only options to be used in this module
  80384. */
  80385. options?: IWebXRBackgroundRemoverOptions);
  80386. /**
  80387. * attach this feature
  80388. * Will usually be called by the features manager
  80389. *
  80390. * @returns true if successful.
  80391. */
  80392. attach(): boolean;
  80393. /**
  80394. * detach this feature.
  80395. * Will usually be called by the features manager
  80396. *
  80397. * @returns true if successful.
  80398. */
  80399. detach(): boolean;
  80400. /**
  80401. * Dispose this feature and all of the resources attached
  80402. */
  80403. dispose(): void;
  80404. protected _onXRFrame(_xrFrame: XRFrame): void;
  80405. private _setBackgroundState;
  80406. }
  80407. }
  80408. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  80409. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80410. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80411. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  80412. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80413. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80414. import { Nullable } from "babylonjs/types";
  80415. /**
  80416. * Options for the controller physics feature
  80417. */
  80418. export class IWebXRControllerPhysicsOptions {
  80419. /**
  80420. * Should the headset get its own impostor
  80421. */
  80422. enableHeadsetImpostor?: boolean;
  80423. /**
  80424. * Optional parameters for the headset impostor
  80425. */
  80426. headsetImpostorParams?: {
  80427. /**
  80428. * The type of impostor to create. Default is sphere
  80429. */
  80430. impostorType: number;
  80431. /**
  80432. * the size of the impostor. Defaults to 10cm
  80433. */
  80434. impostorSize?: number | {
  80435. width: number;
  80436. height: number;
  80437. depth: number;
  80438. };
  80439. /**
  80440. * Friction definitions
  80441. */
  80442. friction?: number;
  80443. /**
  80444. * Restitution
  80445. */
  80446. restitution?: number;
  80447. };
  80448. /**
  80449. * The physics properties of the future impostors
  80450. */
  80451. physicsProperties?: {
  80452. /**
  80453. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80454. * Note that this requires a physics engine that supports mesh impostors!
  80455. */
  80456. useControllerMesh?: boolean;
  80457. /**
  80458. * The type of impostor to create. Default is sphere
  80459. */
  80460. impostorType?: number;
  80461. /**
  80462. * the size of the impostor. Defaults to 10cm
  80463. */
  80464. impostorSize?: number | {
  80465. width: number;
  80466. height: number;
  80467. depth: number;
  80468. };
  80469. /**
  80470. * Friction definitions
  80471. */
  80472. friction?: number;
  80473. /**
  80474. * Restitution
  80475. */
  80476. restitution?: number;
  80477. };
  80478. /**
  80479. * the xr input to use with this pointer selection
  80480. */
  80481. xrInput: WebXRInput;
  80482. }
  80483. /**
  80484. * Add physics impostor to your webxr controllers,
  80485. * including naive calculation of their linear and angular velocity
  80486. */
  80487. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80488. private readonly _options;
  80489. private _attachController;
  80490. private _controllers;
  80491. private _debugMode;
  80492. private _delta;
  80493. private _headsetImpostor?;
  80494. private _headsetMesh?;
  80495. private _lastTimestamp;
  80496. private _tmpQuaternion;
  80497. private _tmpVector;
  80498. /**
  80499. * The module's name
  80500. */
  80501. static readonly Name: string;
  80502. /**
  80503. * The (Babylon) version of this module.
  80504. * This is an integer representing the implementation version.
  80505. * This number does not correspond to the webxr specs version
  80506. */
  80507. static readonly Version: number;
  80508. /**
  80509. * Construct a new Controller Physics Feature
  80510. * @param _xrSessionManager the corresponding xr session manager
  80511. * @param _options options to create this feature with
  80512. */
  80513. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80514. /**
  80515. * @hidden
  80516. * enable debugging - will show console outputs and the impostor mesh
  80517. */
  80518. _enablePhysicsDebug(): void;
  80519. /**
  80520. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80521. * @param xrController the controller to add
  80522. */
  80523. addController(xrController: WebXRInputSource): void;
  80524. /**
  80525. * attach this feature
  80526. * Will usually be called by the features manager
  80527. *
  80528. * @returns true if successful.
  80529. */
  80530. attach(): boolean;
  80531. /**
  80532. * detach this feature.
  80533. * Will usually be called by the features manager
  80534. *
  80535. * @returns true if successful.
  80536. */
  80537. detach(): boolean;
  80538. /**
  80539. * Get the headset impostor, if enabled
  80540. * @returns the impostor
  80541. */
  80542. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80543. /**
  80544. * Get the physics impostor of a specific controller.
  80545. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80546. * @param controller the controller or the controller id of which to get the impostor
  80547. * @returns the impostor or null
  80548. */
  80549. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80550. /**
  80551. * Update the physics properties provided in the constructor
  80552. * @param newProperties the new properties object
  80553. */
  80554. setPhysicsProperties(newProperties: {
  80555. impostorType?: number;
  80556. impostorSize?: number | {
  80557. width: number;
  80558. height: number;
  80559. depth: number;
  80560. };
  80561. friction?: number;
  80562. restitution?: number;
  80563. }): void;
  80564. protected _onXRFrame(_xrFrame: any): void;
  80565. private _detachController;
  80566. }
  80567. }
  80568. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80569. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80570. import { Observable } from "babylonjs/Misc/observable";
  80571. import { Vector3 } from "babylonjs/Maths/math.vector";
  80572. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80573. /**
  80574. * A babylon interface for a "WebXR" feature point.
  80575. * Represents the position and confidence value of a given feature point.
  80576. */
  80577. export interface IWebXRFeaturePoint {
  80578. /**
  80579. * Represents the position of the feature point in world space.
  80580. */
  80581. position: Vector3;
  80582. /**
  80583. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80584. */
  80585. confidenceValue: number;
  80586. }
  80587. /**
  80588. * The feature point system is used to detect feature points from real world geometry.
  80589. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80590. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80591. */
  80592. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80593. private _enabled;
  80594. private _featurePointCloud;
  80595. /**
  80596. * The module's name
  80597. */
  80598. static readonly Name: string;
  80599. /**
  80600. * The (Babylon) version of this module.
  80601. * This is an integer representing the implementation version.
  80602. * This number does not correspond to the WebXR specs version
  80603. */
  80604. static readonly Version: number;
  80605. /**
  80606. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80607. * Will notify the observers about which feature points have been added.
  80608. */
  80609. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80610. /**
  80611. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80612. * Will notify the observers about which feature points have been updated.
  80613. */
  80614. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80615. /**
  80616. * The current feature point cloud maintained across frames.
  80617. */
  80618. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80619. /**
  80620. * construct the feature point system
  80621. * @param _xrSessionManager an instance of xr Session manager
  80622. */
  80623. constructor(_xrSessionManager: WebXRSessionManager);
  80624. /**
  80625. * Detach this feature.
  80626. * Will usually be called by the features manager
  80627. *
  80628. * @returns true if successful.
  80629. */
  80630. detach(): boolean;
  80631. /**
  80632. * Dispose this feature and all of the resources attached
  80633. */
  80634. dispose(): void;
  80635. /**
  80636. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80637. */
  80638. protected _onXRFrame(frame: XRFrame): void;
  80639. /**
  80640. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80641. */
  80642. private _init;
  80643. }
  80644. }
  80645. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80646. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80647. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80649. import { Mesh } from "babylonjs/Meshes/mesh";
  80650. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80651. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80652. import { Nullable } from "babylonjs/types";
  80653. import { IDisposable } from "babylonjs/scene";
  80654. import { Observable } from "babylonjs/Misc/observable";
  80655. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80656. /**
  80657. * Configuration interface for the hand tracking feature
  80658. */
  80659. export interface IWebXRHandTrackingOptions {
  80660. /**
  80661. * The xrInput that will be used as source for new hands
  80662. */
  80663. xrInput: WebXRInput;
  80664. /**
  80665. * Configuration object for the joint meshes
  80666. */
  80667. jointMeshes?: {
  80668. /**
  80669. * Should the meshes created be invisible (defaults to false)
  80670. */
  80671. invisible?: boolean;
  80672. /**
  80673. * A source mesh to be used to create instances. Defaults to a sphere.
  80674. * This mesh will be the source for all other (25) meshes.
  80675. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80676. */
  80677. sourceMesh?: Mesh;
  80678. /**
  80679. * This function will be called after a mesh was created for a specific joint.
  80680. * Using this function you can either manipulate the instance or return a new mesh.
  80681. * When returning a new mesh the instance created before will be disposed
  80682. */
  80683. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80684. /**
  80685. * Should the source mesh stay visible. Defaults to false
  80686. */
  80687. keepOriginalVisible?: boolean;
  80688. /**
  80689. * Scale factor for all instances (defaults to 2)
  80690. */
  80691. scaleFactor?: number;
  80692. /**
  80693. * Should each instance have its own physics impostor
  80694. */
  80695. enablePhysics?: boolean;
  80696. /**
  80697. * If enabled, override default physics properties
  80698. */
  80699. physicsProps?: {
  80700. friction?: number;
  80701. restitution?: number;
  80702. impostorType?: number;
  80703. };
  80704. /**
  80705. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80706. */
  80707. handMesh?: AbstractMesh;
  80708. };
  80709. }
  80710. /**
  80711. * Parts of the hands divided to writs and finger names
  80712. */
  80713. export const enum HandPart {
  80714. /**
  80715. * HandPart - Wrist
  80716. */
  80717. WRIST = "wrist",
  80718. /**
  80719. * HandPart - The THumb
  80720. */
  80721. THUMB = "thumb",
  80722. /**
  80723. * HandPart - Index finger
  80724. */
  80725. INDEX = "index",
  80726. /**
  80727. * HandPart - Middle finger
  80728. */
  80729. MIDDLE = "middle",
  80730. /**
  80731. * HandPart - Ring finger
  80732. */
  80733. RING = "ring",
  80734. /**
  80735. * HandPart - Little finger
  80736. */
  80737. LITTLE = "little"
  80738. }
  80739. /**
  80740. * Representing a single hand (with its corresponding native XRHand object)
  80741. */
  80742. export class WebXRHand implements IDisposable {
  80743. /** the controller to which the hand correlates */
  80744. readonly xrController: WebXRInputSource;
  80745. /** the meshes to be used to track the hand joints */
  80746. readonly trackedMeshes: AbstractMesh[];
  80747. /**
  80748. * Hand-parts definition (key is HandPart)
  80749. */
  80750. handPartsDefinition: {
  80751. [key: string]: number[];
  80752. };
  80753. /**
  80754. * Populate the HandPartsDefinition object.
  80755. * This is called as a side effect since certain browsers don't have XRHand defined.
  80756. */
  80757. private generateHandPartsDefinition;
  80758. /**
  80759. * Construct a new hand object
  80760. * @param xrController the controller to which the hand correlates
  80761. * @param trackedMeshes the meshes to be used to track the hand joints
  80762. */
  80763. constructor(
  80764. /** the controller to which the hand correlates */
  80765. xrController: WebXRInputSource,
  80766. /** the meshes to be used to track the hand joints */
  80767. trackedMeshes: AbstractMesh[]);
  80768. /**
  80769. * Update this hand from the latest xr frame
  80770. * @param xrFrame xrFrame to update from
  80771. * @param referenceSpace The current viewer reference space
  80772. * @param scaleFactor optional scale factor for the meshes
  80773. */
  80774. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80775. /**
  80776. * Get meshes of part of the hand
  80777. * @param part the part of hand to get
  80778. * @returns An array of meshes that correlate to the hand part requested
  80779. */
  80780. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80781. /**
  80782. * Dispose this Hand object
  80783. */
  80784. dispose(): void;
  80785. }
  80786. /**
  80787. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80788. */
  80789. export class WebXRHandTracking extends WebXRAbstractFeature {
  80790. /**
  80791. * options to use when constructing this feature
  80792. */
  80793. readonly options: IWebXRHandTrackingOptions;
  80794. private static _idCounter;
  80795. /**
  80796. * The module's name
  80797. */
  80798. static readonly Name: string;
  80799. /**
  80800. * The (Babylon) version of this module.
  80801. * This is an integer representing the implementation version.
  80802. * This number does not correspond to the WebXR specs version
  80803. */
  80804. static readonly Version: number;
  80805. /**
  80806. * This observable will notify registered observers when a new hand object was added and initialized
  80807. */
  80808. onHandAddedObservable: Observable<WebXRHand>;
  80809. /**
  80810. * This observable will notify its observers right before the hand object is disposed
  80811. */
  80812. onHandRemovedObservable: Observable<WebXRHand>;
  80813. private _hands;
  80814. /**
  80815. * Creates a new instance of the hit test feature
  80816. * @param _xrSessionManager an instance of WebXRSessionManager
  80817. * @param options options to use when constructing this feature
  80818. */
  80819. constructor(_xrSessionManager: WebXRSessionManager,
  80820. /**
  80821. * options to use when constructing this feature
  80822. */
  80823. options: IWebXRHandTrackingOptions);
  80824. /**
  80825. * Check if the needed objects are defined.
  80826. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80827. */
  80828. isCompatible(): boolean;
  80829. /**
  80830. * attach this feature
  80831. * Will usually be called by the features manager
  80832. *
  80833. * @returns true if successful.
  80834. */
  80835. attach(): boolean;
  80836. /**
  80837. * detach this feature.
  80838. * Will usually be called by the features manager
  80839. *
  80840. * @returns true if successful.
  80841. */
  80842. detach(): boolean;
  80843. /**
  80844. * Dispose this feature and all of the resources attached
  80845. */
  80846. dispose(): void;
  80847. /**
  80848. * Get the hand object according to the controller id
  80849. * @param controllerId the controller id to which we want to get the hand
  80850. * @returns null if not found or the WebXRHand object if found
  80851. */
  80852. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80853. /**
  80854. * Get a hand object according to the requested handedness
  80855. * @param handedness the handedness to request
  80856. * @returns null if not found or the WebXRHand object if found
  80857. */
  80858. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80859. protected _onXRFrame(_xrFrame: XRFrame): void;
  80860. private _attachHand;
  80861. private _detachHand;
  80862. }
  80863. }
  80864. declare module "babylonjs/XR/features/index" {
  80865. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  80866. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80867. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80868. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80869. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80870. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80871. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80872. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80873. export * from "babylonjs/XR/features/WebXRHitTest";
  80874. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80875. export * from "babylonjs/XR/features/WebXRHandTracking";
  80876. }
  80877. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80878. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80880. import { Scene } from "babylonjs/scene";
  80881. /**
  80882. * The motion controller class for all microsoft mixed reality controllers
  80883. */
  80884. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80885. protected readonly _mapping: {
  80886. defaultButton: {
  80887. valueNodeName: string;
  80888. unpressedNodeName: string;
  80889. pressedNodeName: string;
  80890. };
  80891. defaultAxis: {
  80892. valueNodeName: string;
  80893. minNodeName: string;
  80894. maxNodeName: string;
  80895. };
  80896. buttons: {
  80897. "xr-standard-trigger": {
  80898. rootNodeName: string;
  80899. componentProperty: string;
  80900. states: string[];
  80901. };
  80902. "xr-standard-squeeze": {
  80903. rootNodeName: string;
  80904. componentProperty: string;
  80905. states: string[];
  80906. };
  80907. "xr-standard-touchpad": {
  80908. rootNodeName: string;
  80909. labelAnchorNodeName: string;
  80910. touchPointNodeName: string;
  80911. };
  80912. "xr-standard-thumbstick": {
  80913. rootNodeName: string;
  80914. componentProperty: string;
  80915. states: string[];
  80916. };
  80917. };
  80918. axes: {
  80919. "xr-standard-touchpad": {
  80920. "x-axis": {
  80921. rootNodeName: string;
  80922. };
  80923. "y-axis": {
  80924. rootNodeName: string;
  80925. };
  80926. };
  80927. "xr-standard-thumbstick": {
  80928. "x-axis": {
  80929. rootNodeName: string;
  80930. };
  80931. "y-axis": {
  80932. rootNodeName: string;
  80933. };
  80934. };
  80935. };
  80936. };
  80937. /**
  80938. * The base url used to load the left and right controller models
  80939. */
  80940. static MODEL_BASE_URL: string;
  80941. /**
  80942. * The name of the left controller model file
  80943. */
  80944. static MODEL_LEFT_FILENAME: string;
  80945. /**
  80946. * The name of the right controller model file
  80947. */
  80948. static MODEL_RIGHT_FILENAME: string;
  80949. profileId: string;
  80950. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80951. protected _getFilenameAndPath(): {
  80952. filename: string;
  80953. path: string;
  80954. };
  80955. protected _getModelLoadingConstraints(): boolean;
  80956. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80957. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80958. protected _updateModel(): void;
  80959. }
  80960. }
  80961. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80962. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80964. import { Scene } from "babylonjs/scene";
  80965. /**
  80966. * The motion controller class for oculus touch (quest, rift).
  80967. * This class supports legacy mapping as well the standard xr mapping
  80968. */
  80969. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80970. private _forceLegacyControllers;
  80971. private _modelRootNode;
  80972. /**
  80973. * The base url used to load the left and right controller models
  80974. */
  80975. static MODEL_BASE_URL: string;
  80976. /**
  80977. * The name of the left controller model file
  80978. */
  80979. static MODEL_LEFT_FILENAME: string;
  80980. /**
  80981. * The name of the right controller model file
  80982. */
  80983. static MODEL_RIGHT_FILENAME: string;
  80984. /**
  80985. * Base Url for the Quest controller model.
  80986. */
  80987. static QUEST_MODEL_BASE_URL: string;
  80988. profileId: string;
  80989. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80990. protected _getFilenameAndPath(): {
  80991. filename: string;
  80992. path: string;
  80993. };
  80994. protected _getModelLoadingConstraints(): boolean;
  80995. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80996. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80997. protected _updateModel(): void;
  80998. /**
  80999. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  81000. * between the touch and touch 2.
  81001. */
  81002. private _isQuest;
  81003. }
  81004. }
  81005. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  81006. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81007. import { Scene } from "babylonjs/scene";
  81008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81009. /**
  81010. * The motion controller class for the standard HTC-Vive controllers
  81011. */
  81012. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  81013. private _modelRootNode;
  81014. /**
  81015. * The base url used to load the left and right controller models
  81016. */
  81017. static MODEL_BASE_URL: string;
  81018. /**
  81019. * File name for the controller model.
  81020. */
  81021. static MODEL_FILENAME: string;
  81022. profileId: string;
  81023. /**
  81024. * Create a new Vive motion controller object
  81025. * @param scene the scene to use to create this controller
  81026. * @param gamepadObject the corresponding gamepad object
  81027. * @param handedness the handedness of the controller
  81028. */
  81029. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81030. protected _getFilenameAndPath(): {
  81031. filename: string;
  81032. path: string;
  81033. };
  81034. protected _getModelLoadingConstraints(): boolean;
  81035. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81036. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81037. protected _updateModel(): void;
  81038. }
  81039. }
  81040. declare module "babylonjs/XR/motionController/index" {
  81041. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81042. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  81043. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  81044. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  81045. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  81046. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  81047. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  81048. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  81049. }
  81050. declare module "babylonjs/XR/index" {
  81051. export * from "babylonjs/XR/webXRCamera";
  81052. export * from "babylonjs/XR/webXREnterExitUI";
  81053. export * from "babylonjs/XR/webXRExperienceHelper";
  81054. export * from "babylonjs/XR/webXRInput";
  81055. export * from "babylonjs/XR/webXRInputSource";
  81056. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  81057. export * from "babylonjs/XR/webXRTypes";
  81058. export * from "babylonjs/XR/webXRSessionManager";
  81059. export * from "babylonjs/XR/webXRDefaultExperience";
  81060. export * from "babylonjs/XR/webXRFeaturesManager";
  81061. export * from "babylonjs/XR/features/index";
  81062. export * from "babylonjs/XR/motionController/index";
  81063. }
  81064. declare module "babylonjs/index" {
  81065. export * from "babylonjs/abstractScene";
  81066. export * from "babylonjs/Actions/index";
  81067. export * from "babylonjs/Animations/index";
  81068. export * from "babylonjs/assetContainer";
  81069. export * from "babylonjs/Audio/index";
  81070. export * from "babylonjs/Behaviors/index";
  81071. export * from "babylonjs/Bones/index";
  81072. export * from "babylonjs/Cameras/index";
  81073. export * from "babylonjs/Collisions/index";
  81074. export * from "babylonjs/Culling/index";
  81075. export * from "babylonjs/Debug/index";
  81076. export * from "babylonjs/DeviceInput/index";
  81077. export * from "babylonjs/Engines/index";
  81078. export * from "babylonjs/Events/index";
  81079. export * from "babylonjs/Gamepads/index";
  81080. export * from "babylonjs/Gizmos/index";
  81081. export * from "babylonjs/Helpers/index";
  81082. export * from "babylonjs/Instrumentation/index";
  81083. export * from "babylonjs/Layers/index";
  81084. export * from "babylonjs/LensFlares/index";
  81085. export * from "babylonjs/Lights/index";
  81086. export * from "babylonjs/Loading/index";
  81087. export * from "babylonjs/Materials/index";
  81088. export * from "babylonjs/Maths/index";
  81089. export * from "babylonjs/Meshes/index";
  81090. export * from "babylonjs/Morph/index";
  81091. export * from "babylonjs/Navigation/index";
  81092. export * from "babylonjs/node";
  81093. export * from "babylonjs/Offline/index";
  81094. export * from "babylonjs/Particles/index";
  81095. export * from "babylonjs/Physics/index";
  81096. export * from "babylonjs/PostProcesses/index";
  81097. export * from "babylonjs/Probes/index";
  81098. export * from "babylonjs/Rendering/index";
  81099. export * from "babylonjs/scene";
  81100. export * from "babylonjs/sceneComponent";
  81101. export * from "babylonjs/Sprites/index";
  81102. export * from "babylonjs/States/index";
  81103. export * from "babylonjs/Misc/index";
  81104. export * from "babylonjs/XR/index";
  81105. export * from "babylonjs/types";
  81106. }
  81107. declare module "babylonjs/Animations/pathCursor" {
  81108. import { Vector3 } from "babylonjs/Maths/math.vector";
  81109. import { Path2 } from "babylonjs/Maths/math.path";
  81110. /**
  81111. * A cursor which tracks a point on a path
  81112. */
  81113. export class PathCursor {
  81114. private path;
  81115. /**
  81116. * Stores path cursor callbacks for when an onchange event is triggered
  81117. */
  81118. private _onchange;
  81119. /**
  81120. * The value of the path cursor
  81121. */
  81122. value: number;
  81123. /**
  81124. * The animation array of the path cursor
  81125. */
  81126. animations: Animation[];
  81127. /**
  81128. * Initializes the path cursor
  81129. * @param path The path to track
  81130. */
  81131. constructor(path: Path2);
  81132. /**
  81133. * Gets the cursor point on the path
  81134. * @returns A point on the path cursor at the cursor location
  81135. */
  81136. getPoint(): Vector3;
  81137. /**
  81138. * Moves the cursor ahead by the step amount
  81139. * @param step The amount to move the cursor forward
  81140. * @returns This path cursor
  81141. */
  81142. moveAhead(step?: number): PathCursor;
  81143. /**
  81144. * Moves the cursor behind by the step amount
  81145. * @param step The amount to move the cursor back
  81146. * @returns This path cursor
  81147. */
  81148. moveBack(step?: number): PathCursor;
  81149. /**
  81150. * Moves the cursor by the step amount
  81151. * If the step amount is greater than one, an exception is thrown
  81152. * @param step The amount to move the cursor
  81153. * @returns This path cursor
  81154. */
  81155. move(step: number): PathCursor;
  81156. /**
  81157. * Ensures that the value is limited between zero and one
  81158. * @returns This path cursor
  81159. */
  81160. private ensureLimits;
  81161. /**
  81162. * Runs onchange callbacks on change (used by the animation engine)
  81163. * @returns This path cursor
  81164. */
  81165. private raiseOnChange;
  81166. /**
  81167. * Executes a function on change
  81168. * @param f A path cursor onchange callback
  81169. * @returns This path cursor
  81170. */
  81171. onchange(f: (cursor: PathCursor) => void): PathCursor;
  81172. }
  81173. }
  81174. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  81175. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  81176. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  81177. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  81178. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  81179. }
  81180. declare module "babylonjs/Engines/Processors/Expressions/index" {
  81181. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  81182. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  81183. }
  81184. declare module "babylonjs/Engines/Processors/index" {
  81185. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  81186. export * from "babylonjs/Engines/Processors/Expressions/index";
  81187. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  81188. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  81189. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  81190. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  81191. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  81192. export * from "babylonjs/Engines/Processors/shaderProcessor";
  81193. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  81194. }
  81195. declare module "babylonjs/Legacy/legacy" {
  81196. import * as Babylon from "babylonjs/index";
  81197. export * from "babylonjs/index";
  81198. }
  81199. declare module "babylonjs/Shaders/blur.fragment" {
  81200. /** @hidden */
  81201. export var blurPixelShader: {
  81202. name: string;
  81203. shader: string;
  81204. };
  81205. }
  81206. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  81207. /** @hidden */
  81208. export var pointCloudVertexDeclaration: {
  81209. name: string;
  81210. shader: string;
  81211. };
  81212. }
  81213. declare module "babylonjs" {
  81214. export * from "babylonjs/Legacy/legacy";
  81215. }
  81216. declare module BABYLON {
  81217. /** Alias type for value that can be null */
  81218. export type Nullable<T> = T | null;
  81219. /**
  81220. * Alias type for number that are floats
  81221. * @ignorenaming
  81222. */
  81223. export type float = number;
  81224. /**
  81225. * Alias type for number that are doubles.
  81226. * @ignorenaming
  81227. */
  81228. export type double = number;
  81229. /**
  81230. * Alias type for number that are integer
  81231. * @ignorenaming
  81232. */
  81233. export type int = number;
  81234. /** Alias type for number array or Float32Array */
  81235. export type FloatArray = number[] | Float32Array;
  81236. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  81237. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  81238. /**
  81239. * Alias for types that can be used by a Buffer or VertexBuffer.
  81240. */
  81241. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  81242. /**
  81243. * Alias type for primitive types
  81244. * @ignorenaming
  81245. */
  81246. type Primitive = undefined | null | boolean | string | number | Function;
  81247. /**
  81248. * Type modifier to make all the properties of an object Readonly
  81249. */
  81250. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  81251. /**
  81252. * Type modifier to make all the properties of an object Readonly recursively
  81253. */
  81254. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  81255. /**
  81256. * Type modifier to make object properties readonly.
  81257. */
  81258. export type DeepImmutableObject<T> = {
  81259. readonly [K in keyof T]: DeepImmutable<T[K]>;
  81260. };
  81261. /** @hidden */
  81262. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  81263. }
  81264. }
  81265. declare module BABYLON {
  81266. /**
  81267. * A class serves as a medium between the observable and its observers
  81268. */
  81269. export class EventState {
  81270. /**
  81271. * Create a new EventState
  81272. * @param mask defines the mask associated with this state
  81273. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81274. * @param target defines the original target of the state
  81275. * @param currentTarget defines the current target of the state
  81276. */
  81277. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  81278. /**
  81279. * Initialize the current event state
  81280. * @param mask defines the mask associated with this state
  81281. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81282. * @param target defines the original target of the state
  81283. * @param currentTarget defines the current target of the state
  81284. * @returns the current event state
  81285. */
  81286. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  81287. /**
  81288. * An Observer can set this property to true to prevent subsequent observers of being notified
  81289. */
  81290. skipNextObservers: boolean;
  81291. /**
  81292. * Get the mask value that were used to trigger the event corresponding to this EventState object
  81293. */
  81294. mask: number;
  81295. /**
  81296. * The object that originally notified the event
  81297. */
  81298. target?: any;
  81299. /**
  81300. * The current object in the bubbling phase
  81301. */
  81302. currentTarget?: any;
  81303. /**
  81304. * This will be populated with the return value of the last function that was executed.
  81305. * If it is the first function in the callback chain it will be the event data.
  81306. */
  81307. lastReturnValue?: any;
  81308. /**
  81309. * User defined information that will be sent to observers
  81310. */
  81311. userInfo?: any;
  81312. }
  81313. /**
  81314. * Represent an Observer registered to a given Observable object.
  81315. */
  81316. export class Observer<T> {
  81317. /**
  81318. * Defines the callback to call when the observer is notified
  81319. */
  81320. callback: (eventData: T, eventState: EventState) => void;
  81321. /**
  81322. * Defines the mask of the observer (used to filter notifications)
  81323. */
  81324. mask: number;
  81325. /**
  81326. * Defines the current scope used to restore the JS context
  81327. */
  81328. scope: any;
  81329. /** @hidden */
  81330. _willBeUnregistered: boolean;
  81331. /**
  81332. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  81333. */
  81334. unregisterOnNextCall: boolean;
  81335. /**
  81336. * Creates a new observer
  81337. * @param callback defines the callback to call when the observer is notified
  81338. * @param mask defines the mask of the observer (used to filter notifications)
  81339. * @param scope defines the current scope used to restore the JS context
  81340. */
  81341. constructor(
  81342. /**
  81343. * Defines the callback to call when the observer is notified
  81344. */
  81345. callback: (eventData: T, eventState: EventState) => void,
  81346. /**
  81347. * Defines the mask of the observer (used to filter notifications)
  81348. */
  81349. mask: number,
  81350. /**
  81351. * Defines the current scope used to restore the JS context
  81352. */
  81353. scope?: any);
  81354. }
  81355. /**
  81356. * Represent a list of observers registered to multiple Observables object.
  81357. */
  81358. export class MultiObserver<T> {
  81359. private _observers;
  81360. private _observables;
  81361. /**
  81362. * Release associated resources
  81363. */
  81364. dispose(): void;
  81365. /**
  81366. * Raise a callback when one of the observable will notify
  81367. * @param observables defines a list of observables to watch
  81368. * @param callback defines the callback to call on notification
  81369. * @param mask defines the mask used to filter notifications
  81370. * @param scope defines the current scope used to restore the JS context
  81371. * @returns the new MultiObserver
  81372. */
  81373. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  81374. }
  81375. /**
  81376. * The Observable class is a simple implementation of the Observable pattern.
  81377. *
  81378. * 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.
  81379. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  81380. * 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).
  81381. * 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.
  81382. */
  81383. export class Observable<T> {
  81384. private _observers;
  81385. private _eventState;
  81386. private _onObserverAdded;
  81387. /**
  81388. * Gets the list of observers
  81389. */
  81390. get observers(): Array<Observer<T>>;
  81391. /**
  81392. * Creates a new observable
  81393. * @param onObserverAdded defines a callback to call when a new observer is added
  81394. */
  81395. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  81396. /**
  81397. * Create a new Observer with the specified callback
  81398. * @param callback the callback that will be executed for that Observer
  81399. * @param mask the mask used to filter observers
  81400. * @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.
  81401. * @param scope optional scope for the callback to be called from
  81402. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  81403. * @returns the new observer created for the callback
  81404. */
  81405. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  81406. /**
  81407. * Create a new Observer with the specified callback and unregisters after the next notification
  81408. * @param callback the callback that will be executed for that Observer
  81409. * @returns the new observer created for the callback
  81410. */
  81411. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  81412. /**
  81413. * Remove an Observer from the Observable object
  81414. * @param observer the instance of the Observer to remove
  81415. * @returns false if it doesn't belong to this Observable
  81416. */
  81417. remove(observer: Nullable<Observer<T>>): boolean;
  81418. /**
  81419. * Remove a callback from the Observable object
  81420. * @param callback the callback to remove
  81421. * @param scope optional scope. If used only the callbacks with this scope will be removed
  81422. * @returns false if it doesn't belong to this Observable
  81423. */
  81424. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  81425. private _deferUnregister;
  81426. private _remove;
  81427. /**
  81428. * Moves the observable to the top of the observer list making it get called first when notified
  81429. * @param observer the observer to move
  81430. */
  81431. makeObserverTopPriority(observer: Observer<T>): void;
  81432. /**
  81433. * Moves the observable to the bottom of the observer list making it get called last when notified
  81434. * @param observer the observer to move
  81435. */
  81436. makeObserverBottomPriority(observer: Observer<T>): void;
  81437. /**
  81438. * Notify all Observers by calling their respective callback with the given data
  81439. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  81440. * @param eventData defines the data to send to all observers
  81441. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  81442. * @param target defines the original target of the state
  81443. * @param currentTarget defines the current target of the state
  81444. * @param userInfo defines any user info to send to observers
  81445. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81446. */
  81447. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81448. /**
  81449. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81450. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81451. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81452. * and it is crucial that all callbacks will be executed.
  81453. * The order of the callbacks is kept, callbacks are not executed parallel.
  81454. *
  81455. * @param eventData The data to be sent to each callback
  81456. * @param mask is used to filter observers defaults to -1
  81457. * @param target defines the callback target (see EventState)
  81458. * @param currentTarget defines he current object in the bubbling phase
  81459. * @param userInfo defines any user info to send to observers
  81460. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81461. */
  81462. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81463. /**
  81464. * Notify a specific observer
  81465. * @param observer defines the observer to notify
  81466. * @param eventData defines the data to be sent to each callback
  81467. * @param mask is used to filter observers defaults to -1
  81468. */
  81469. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81470. /**
  81471. * Gets a boolean indicating if the observable has at least one observer
  81472. * @returns true is the Observable has at least one Observer registered
  81473. */
  81474. hasObservers(): boolean;
  81475. /**
  81476. * Clear the list of observers
  81477. */
  81478. clear(): void;
  81479. /**
  81480. * Clone the current observable
  81481. * @returns a new observable
  81482. */
  81483. clone(): Observable<T>;
  81484. /**
  81485. * Does this observable handles observer registered with a given mask
  81486. * @param mask defines the mask to be tested
  81487. * @return whether or not one observer registered with the given mask is handeled
  81488. **/
  81489. hasSpecificMask(mask?: number): boolean;
  81490. }
  81491. }
  81492. declare module BABYLON {
  81493. /**
  81494. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81495. * Babylon.js
  81496. */
  81497. export class DomManagement {
  81498. /**
  81499. * Checks if the window object exists
  81500. * @returns true if the window object exists
  81501. */
  81502. static IsWindowObjectExist(): boolean;
  81503. /**
  81504. * Checks if the navigator object exists
  81505. * @returns true if the navigator object exists
  81506. */
  81507. static IsNavigatorAvailable(): boolean;
  81508. /**
  81509. * Check if the document object exists
  81510. * @returns true if the document object exists
  81511. */
  81512. static IsDocumentAvailable(): boolean;
  81513. /**
  81514. * Extracts text content from a DOM element hierarchy
  81515. * @param element defines the root element
  81516. * @returns a string
  81517. */
  81518. static GetDOMTextContent(element: HTMLElement): string;
  81519. }
  81520. }
  81521. declare module BABYLON {
  81522. /**
  81523. * Logger used througouht the application to allow configuration of
  81524. * the log level required for the messages.
  81525. */
  81526. export class Logger {
  81527. /**
  81528. * No log
  81529. */
  81530. static readonly NoneLogLevel: number;
  81531. /**
  81532. * Only message logs
  81533. */
  81534. static readonly MessageLogLevel: number;
  81535. /**
  81536. * Only warning logs
  81537. */
  81538. static readonly WarningLogLevel: number;
  81539. /**
  81540. * Only error logs
  81541. */
  81542. static readonly ErrorLogLevel: number;
  81543. /**
  81544. * All logs
  81545. */
  81546. static readonly AllLogLevel: number;
  81547. private static _LogCache;
  81548. /**
  81549. * Gets a value indicating the number of loading errors
  81550. * @ignorenaming
  81551. */
  81552. static errorsCount: number;
  81553. /**
  81554. * Callback called when a new log is added
  81555. */
  81556. static OnNewCacheEntry: (entry: string) => void;
  81557. private static _AddLogEntry;
  81558. private static _FormatMessage;
  81559. private static _LogDisabled;
  81560. private static _LogEnabled;
  81561. private static _WarnDisabled;
  81562. private static _WarnEnabled;
  81563. private static _ErrorDisabled;
  81564. private static _ErrorEnabled;
  81565. /**
  81566. * Log a message to the console
  81567. */
  81568. static Log: (message: string) => void;
  81569. /**
  81570. * Write a warning message to the console
  81571. */
  81572. static Warn: (message: string) => void;
  81573. /**
  81574. * Write an error message to the console
  81575. */
  81576. static Error: (message: string) => void;
  81577. /**
  81578. * Gets current log cache (list of logs)
  81579. */
  81580. static get LogCache(): string;
  81581. /**
  81582. * Clears the log cache
  81583. */
  81584. static ClearLogCache(): void;
  81585. /**
  81586. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81587. */
  81588. static set LogLevels(level: number);
  81589. }
  81590. }
  81591. declare module BABYLON {
  81592. /** @hidden */
  81593. export class _TypeStore {
  81594. /** @hidden */
  81595. static RegisteredTypes: {
  81596. [key: string]: Object;
  81597. };
  81598. /** @hidden */
  81599. static GetClass(fqdn: string): any;
  81600. }
  81601. }
  81602. declare module BABYLON {
  81603. /**
  81604. * Helper to manipulate strings
  81605. */
  81606. export class StringTools {
  81607. /**
  81608. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81609. * @param str Source string
  81610. * @param suffix Suffix to search for in the source string
  81611. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81612. */
  81613. static EndsWith(str: string, suffix: string): boolean;
  81614. /**
  81615. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81616. * @param str Source string
  81617. * @param suffix Suffix to search for in the source string
  81618. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81619. */
  81620. static StartsWith(str: string, suffix: string): boolean;
  81621. /**
  81622. * Decodes a buffer into a string
  81623. * @param buffer The buffer to decode
  81624. * @returns The decoded string
  81625. */
  81626. static Decode(buffer: Uint8Array | Uint16Array): string;
  81627. /**
  81628. * Encode a buffer to a base64 string
  81629. * @param buffer defines the buffer to encode
  81630. * @returns the encoded string
  81631. */
  81632. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81633. /**
  81634. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81635. * @param num the number to convert and pad
  81636. * @param length the expected length of the string
  81637. * @returns the padded string
  81638. */
  81639. static PadNumber(num: number, length: number): string;
  81640. }
  81641. }
  81642. declare module BABYLON {
  81643. /**
  81644. * Class containing a set of static utilities functions for deep copy.
  81645. */
  81646. export class DeepCopier {
  81647. /**
  81648. * Tries to copy an object by duplicating every property
  81649. * @param source defines the source object
  81650. * @param destination defines the target object
  81651. * @param doNotCopyList defines a list of properties to avoid
  81652. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81653. */
  81654. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81655. }
  81656. }
  81657. declare module BABYLON {
  81658. /**
  81659. * Class containing a set of static utilities functions for precision date
  81660. */
  81661. export class PrecisionDate {
  81662. /**
  81663. * Gets either window.performance.now() if supported or Date.now() else
  81664. */
  81665. static get Now(): number;
  81666. }
  81667. }
  81668. declare module BABYLON {
  81669. /** @hidden */
  81670. export class _DevTools {
  81671. static WarnImport(name: string): string;
  81672. }
  81673. }
  81674. declare module BABYLON {
  81675. /**
  81676. * Interface used to define the mechanism to get data from the network
  81677. */
  81678. export interface IWebRequest {
  81679. /**
  81680. * Returns client's response url
  81681. */
  81682. responseURL: string;
  81683. /**
  81684. * Returns client's status
  81685. */
  81686. status: number;
  81687. /**
  81688. * Returns client's status as a text
  81689. */
  81690. statusText: string;
  81691. }
  81692. }
  81693. declare module BABYLON {
  81694. /**
  81695. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81696. */
  81697. export class WebRequest implements IWebRequest {
  81698. private readonly _xhr;
  81699. /**
  81700. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81701. * i.e. when loading files, where the server/service expects an Authorization header
  81702. */
  81703. static CustomRequestHeaders: {
  81704. [key: string]: string;
  81705. };
  81706. /**
  81707. * Add callback functions in this array to update all the requests before they get sent to the network
  81708. */
  81709. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81710. private _injectCustomRequestHeaders;
  81711. /**
  81712. * Gets or sets a function to be called when loading progress changes
  81713. */
  81714. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81715. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81716. /**
  81717. * Returns client's state
  81718. */
  81719. get readyState(): number;
  81720. /**
  81721. * Returns client's status
  81722. */
  81723. get status(): number;
  81724. /**
  81725. * Returns client's status as a text
  81726. */
  81727. get statusText(): string;
  81728. /**
  81729. * Returns client's response
  81730. */
  81731. get response(): any;
  81732. /**
  81733. * Returns client's response url
  81734. */
  81735. get responseURL(): string;
  81736. /**
  81737. * Returns client's response as text
  81738. */
  81739. get responseText(): string;
  81740. /**
  81741. * Gets or sets the expected response type
  81742. */
  81743. get responseType(): XMLHttpRequestResponseType;
  81744. set responseType(value: XMLHttpRequestResponseType);
  81745. /** @hidden */
  81746. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81747. /** @hidden */
  81748. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81749. /**
  81750. * Cancels any network activity
  81751. */
  81752. abort(): void;
  81753. /**
  81754. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81755. * @param body defines an optional request body
  81756. */
  81757. send(body?: Document | BodyInit | null): void;
  81758. /**
  81759. * Sets the request method, request URL
  81760. * @param method defines the method to use (GET, POST, etc..)
  81761. * @param url defines the url to connect with
  81762. */
  81763. open(method: string, url: string): void;
  81764. /**
  81765. * Sets the value of a request header.
  81766. * @param name The name of the header whose value is to be set
  81767. * @param value The value to set as the body of the header
  81768. */
  81769. setRequestHeader(name: string, value: string): void;
  81770. /**
  81771. * Get the string containing the text of a particular header's value.
  81772. * @param name The name of the header
  81773. * @returns The string containing the text of the given header name
  81774. */
  81775. getResponseHeader(name: string): Nullable<string>;
  81776. }
  81777. }
  81778. declare module BABYLON {
  81779. /**
  81780. * File request interface
  81781. */
  81782. export interface IFileRequest {
  81783. /**
  81784. * Raised when the request is complete (success or error).
  81785. */
  81786. onCompleteObservable: Observable<IFileRequest>;
  81787. /**
  81788. * Aborts the request for a file.
  81789. */
  81790. abort: () => void;
  81791. }
  81792. }
  81793. declare module BABYLON {
  81794. /**
  81795. * Define options used to create a render target texture
  81796. */
  81797. export class RenderTargetCreationOptions {
  81798. /**
  81799. * Specifies is mipmaps must be generated
  81800. */
  81801. generateMipMaps?: boolean;
  81802. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81803. generateDepthBuffer?: boolean;
  81804. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81805. generateStencilBuffer?: boolean;
  81806. /** Defines texture type (int by default) */
  81807. type?: number;
  81808. /** Defines sampling mode (trilinear by default) */
  81809. samplingMode?: number;
  81810. /** Defines format (RGBA by default) */
  81811. format?: number;
  81812. }
  81813. }
  81814. declare module BABYLON {
  81815. /** Defines the cross module used constants to avoid circular dependncies */
  81816. export class Constants {
  81817. /** Defines that alpha blending is disabled */
  81818. static readonly ALPHA_DISABLE: number;
  81819. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81820. static readonly ALPHA_ADD: number;
  81821. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81822. static readonly ALPHA_COMBINE: number;
  81823. /** Defines that alpha blending is DEST - SRC * DEST */
  81824. static readonly ALPHA_SUBTRACT: number;
  81825. /** Defines that alpha blending is SRC * DEST */
  81826. static readonly ALPHA_MULTIPLY: number;
  81827. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81828. static readonly ALPHA_MAXIMIZED: number;
  81829. /** Defines that alpha blending is SRC + DEST */
  81830. static readonly ALPHA_ONEONE: number;
  81831. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81832. static readonly ALPHA_PREMULTIPLIED: number;
  81833. /**
  81834. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81835. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81836. */
  81837. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81838. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81839. static readonly ALPHA_INTERPOLATE: number;
  81840. /**
  81841. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81842. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81843. */
  81844. static readonly ALPHA_SCREENMODE: number;
  81845. /**
  81846. * Defines that alpha blending is SRC + DST
  81847. * Alpha will be set to SRC ALPHA + DST ALPHA
  81848. */
  81849. static readonly ALPHA_ONEONE_ONEONE: number;
  81850. /**
  81851. * Defines that alpha blending is SRC * DST ALPHA + DST
  81852. * Alpha will be set to 0
  81853. */
  81854. static readonly ALPHA_ALPHATOCOLOR: number;
  81855. /**
  81856. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81857. */
  81858. static readonly ALPHA_REVERSEONEMINUS: number;
  81859. /**
  81860. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81861. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81862. */
  81863. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81864. /**
  81865. * Defines that alpha blending is SRC + DST
  81866. * Alpha will be set to SRC ALPHA
  81867. */
  81868. static readonly ALPHA_ONEONE_ONEZERO: number;
  81869. /**
  81870. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81871. * Alpha will be set to DST ALPHA
  81872. */
  81873. static readonly ALPHA_EXCLUSION: number;
  81874. /** Defines that alpha blending equation a SUM */
  81875. static readonly ALPHA_EQUATION_ADD: number;
  81876. /** Defines that alpha blending equation a SUBSTRACTION */
  81877. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81878. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81879. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81880. /** Defines that alpha blending equation a MAX operation */
  81881. static readonly ALPHA_EQUATION_MAX: number;
  81882. /** Defines that alpha blending equation a MIN operation */
  81883. static readonly ALPHA_EQUATION_MIN: number;
  81884. /**
  81885. * Defines that alpha blending equation a DARKEN operation:
  81886. * It takes the min of the src and sums the alpha channels.
  81887. */
  81888. static readonly ALPHA_EQUATION_DARKEN: number;
  81889. /** Defines that the ressource is not delayed*/
  81890. static readonly DELAYLOADSTATE_NONE: number;
  81891. /** Defines that the ressource was successfully delay loaded */
  81892. static readonly DELAYLOADSTATE_LOADED: number;
  81893. /** Defines that the ressource is currently delay loading */
  81894. static readonly DELAYLOADSTATE_LOADING: number;
  81895. /** Defines that the ressource is delayed and has not started loading */
  81896. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81897. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81898. static readonly NEVER: number;
  81899. /** 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 */
  81900. static readonly ALWAYS: number;
  81901. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81902. static readonly LESS: number;
  81903. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81904. static readonly EQUAL: number;
  81905. /** 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 */
  81906. static readonly LEQUAL: number;
  81907. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81908. static readonly GREATER: number;
  81909. /** 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 */
  81910. static readonly GEQUAL: number;
  81911. /** 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 */
  81912. static readonly NOTEQUAL: number;
  81913. /** Passed to stencilOperation to specify that stencil value must be kept */
  81914. static readonly KEEP: number;
  81915. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81916. static readonly REPLACE: number;
  81917. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81918. static readonly INCR: number;
  81919. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81920. static readonly DECR: number;
  81921. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81922. static readonly INVERT: number;
  81923. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81924. static readonly INCR_WRAP: number;
  81925. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81926. static readonly DECR_WRAP: number;
  81927. /** Texture is not repeating outside of 0..1 UVs */
  81928. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81929. /** Texture is repeating outside of 0..1 UVs */
  81930. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81931. /** Texture is repeating and mirrored */
  81932. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81933. /** ALPHA */
  81934. static readonly TEXTUREFORMAT_ALPHA: number;
  81935. /** LUMINANCE */
  81936. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81937. /** LUMINANCE_ALPHA */
  81938. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81939. /** RGB */
  81940. static readonly TEXTUREFORMAT_RGB: number;
  81941. /** RGBA */
  81942. static readonly TEXTUREFORMAT_RGBA: number;
  81943. /** RED */
  81944. static readonly TEXTUREFORMAT_RED: number;
  81945. /** RED (2nd reference) */
  81946. static readonly TEXTUREFORMAT_R: number;
  81947. /** RG */
  81948. static readonly TEXTUREFORMAT_RG: number;
  81949. /** RED_INTEGER */
  81950. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81951. /** RED_INTEGER (2nd reference) */
  81952. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81953. /** RG_INTEGER */
  81954. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81955. /** RGB_INTEGER */
  81956. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81957. /** RGBA_INTEGER */
  81958. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81959. /** UNSIGNED_BYTE */
  81960. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81961. /** UNSIGNED_BYTE (2nd reference) */
  81962. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81963. /** FLOAT */
  81964. static readonly TEXTURETYPE_FLOAT: number;
  81965. /** HALF_FLOAT */
  81966. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81967. /** BYTE */
  81968. static readonly TEXTURETYPE_BYTE: number;
  81969. /** SHORT */
  81970. static readonly TEXTURETYPE_SHORT: number;
  81971. /** UNSIGNED_SHORT */
  81972. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81973. /** INT */
  81974. static readonly TEXTURETYPE_INT: number;
  81975. /** UNSIGNED_INT */
  81976. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81977. /** UNSIGNED_SHORT_4_4_4_4 */
  81978. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81979. /** UNSIGNED_SHORT_5_5_5_1 */
  81980. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81981. /** UNSIGNED_SHORT_5_6_5 */
  81982. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81983. /** UNSIGNED_INT_2_10_10_10_REV */
  81984. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81985. /** UNSIGNED_INT_24_8 */
  81986. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81987. /** UNSIGNED_INT_10F_11F_11F_REV */
  81988. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81989. /** UNSIGNED_INT_5_9_9_9_REV */
  81990. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81991. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81992. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81993. /** nearest is mag = nearest and min = nearest and no mip */
  81994. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81995. /** mag = nearest and min = nearest and mip = none */
  81996. static readonly TEXTURE_NEAREST_NEAREST: number;
  81997. /** Bilinear is mag = linear and min = linear and no mip */
  81998. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81999. /** mag = linear and min = linear and mip = none */
  82000. static readonly TEXTURE_LINEAR_LINEAR: number;
  82001. /** Trilinear is mag = linear and min = linear and mip = linear */
  82002. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82003. /** Trilinear is mag = linear and min = linear and mip = linear */
  82004. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82005. /** mag = nearest and min = nearest and mip = nearest */
  82006. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82007. /** mag = nearest and min = linear and mip = nearest */
  82008. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82009. /** mag = nearest and min = linear and mip = linear */
  82010. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82011. /** mag = nearest and min = linear and mip = none */
  82012. static readonly TEXTURE_NEAREST_LINEAR: number;
  82013. /** nearest is mag = nearest and min = nearest and mip = linear */
  82014. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82015. /** mag = linear and min = nearest and mip = nearest */
  82016. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82017. /** mag = linear and min = nearest and mip = linear */
  82018. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82019. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82020. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82021. /** mag = linear and min = nearest and mip = none */
  82022. static readonly TEXTURE_LINEAR_NEAREST: number;
  82023. /** Explicit coordinates mode */
  82024. static readonly TEXTURE_EXPLICIT_MODE: number;
  82025. /** Spherical coordinates mode */
  82026. static readonly TEXTURE_SPHERICAL_MODE: number;
  82027. /** Planar coordinates mode */
  82028. static readonly TEXTURE_PLANAR_MODE: number;
  82029. /** Cubic coordinates mode */
  82030. static readonly TEXTURE_CUBIC_MODE: number;
  82031. /** Projection coordinates mode */
  82032. static readonly TEXTURE_PROJECTION_MODE: number;
  82033. /** Skybox coordinates mode */
  82034. static readonly TEXTURE_SKYBOX_MODE: number;
  82035. /** Inverse Cubic coordinates mode */
  82036. static readonly TEXTURE_INVCUBIC_MODE: number;
  82037. /** Equirectangular coordinates mode */
  82038. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82039. /** Equirectangular Fixed coordinates mode */
  82040. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82041. /** Equirectangular Fixed Mirrored coordinates mode */
  82042. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82043. /** Offline (baking) quality for texture filtering */
  82044. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  82045. /** High quality for texture filtering */
  82046. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  82047. /** Medium quality for texture filtering */
  82048. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  82049. /** Low quality for texture filtering */
  82050. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  82051. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82052. static readonly SCALEMODE_FLOOR: number;
  82053. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82054. static readonly SCALEMODE_NEAREST: number;
  82055. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82056. static readonly SCALEMODE_CEILING: number;
  82057. /**
  82058. * The dirty texture flag value
  82059. */
  82060. static readonly MATERIAL_TextureDirtyFlag: number;
  82061. /**
  82062. * The dirty light flag value
  82063. */
  82064. static readonly MATERIAL_LightDirtyFlag: number;
  82065. /**
  82066. * The dirty fresnel flag value
  82067. */
  82068. static readonly MATERIAL_FresnelDirtyFlag: number;
  82069. /**
  82070. * The dirty attribute flag value
  82071. */
  82072. static readonly MATERIAL_AttributesDirtyFlag: number;
  82073. /**
  82074. * The dirty misc flag value
  82075. */
  82076. static readonly MATERIAL_MiscDirtyFlag: number;
  82077. /**
  82078. * The dirty prepass flag value
  82079. */
  82080. static readonly MATERIAL_PrePassDirtyFlag: number;
  82081. /**
  82082. * The all dirty flag value
  82083. */
  82084. static readonly MATERIAL_AllDirtyFlag: number;
  82085. /**
  82086. * Returns the triangle fill mode
  82087. */
  82088. static readonly MATERIAL_TriangleFillMode: number;
  82089. /**
  82090. * Returns the wireframe mode
  82091. */
  82092. static readonly MATERIAL_WireFrameFillMode: number;
  82093. /**
  82094. * Returns the point fill mode
  82095. */
  82096. static readonly MATERIAL_PointFillMode: number;
  82097. /**
  82098. * Returns the point list draw mode
  82099. */
  82100. static readonly MATERIAL_PointListDrawMode: number;
  82101. /**
  82102. * Returns the line list draw mode
  82103. */
  82104. static readonly MATERIAL_LineListDrawMode: number;
  82105. /**
  82106. * Returns the line loop draw mode
  82107. */
  82108. static readonly MATERIAL_LineLoopDrawMode: number;
  82109. /**
  82110. * Returns the line strip draw mode
  82111. */
  82112. static readonly MATERIAL_LineStripDrawMode: number;
  82113. /**
  82114. * Returns the triangle strip draw mode
  82115. */
  82116. static readonly MATERIAL_TriangleStripDrawMode: number;
  82117. /**
  82118. * Returns the triangle fan draw mode
  82119. */
  82120. static readonly MATERIAL_TriangleFanDrawMode: number;
  82121. /**
  82122. * Stores the clock-wise side orientation
  82123. */
  82124. static readonly MATERIAL_ClockWiseSideOrientation: number;
  82125. /**
  82126. * Stores the counter clock-wise side orientation
  82127. */
  82128. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  82129. /**
  82130. * Nothing
  82131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82132. */
  82133. static readonly ACTION_NothingTrigger: number;
  82134. /**
  82135. * On pick
  82136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82137. */
  82138. static readonly ACTION_OnPickTrigger: number;
  82139. /**
  82140. * On left pick
  82141. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82142. */
  82143. static readonly ACTION_OnLeftPickTrigger: number;
  82144. /**
  82145. * On right pick
  82146. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82147. */
  82148. static readonly ACTION_OnRightPickTrigger: number;
  82149. /**
  82150. * On center pick
  82151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82152. */
  82153. static readonly ACTION_OnCenterPickTrigger: number;
  82154. /**
  82155. * On pick down
  82156. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82157. */
  82158. static readonly ACTION_OnPickDownTrigger: number;
  82159. /**
  82160. * On double pick
  82161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82162. */
  82163. static readonly ACTION_OnDoublePickTrigger: number;
  82164. /**
  82165. * On pick up
  82166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82167. */
  82168. static readonly ACTION_OnPickUpTrigger: number;
  82169. /**
  82170. * On pick out.
  82171. * This trigger will only be raised if you also declared a OnPickDown
  82172. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82173. */
  82174. static readonly ACTION_OnPickOutTrigger: number;
  82175. /**
  82176. * On long press
  82177. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82178. */
  82179. static readonly ACTION_OnLongPressTrigger: number;
  82180. /**
  82181. * On pointer over
  82182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82183. */
  82184. static readonly ACTION_OnPointerOverTrigger: number;
  82185. /**
  82186. * On pointer out
  82187. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82188. */
  82189. static readonly ACTION_OnPointerOutTrigger: number;
  82190. /**
  82191. * On every frame
  82192. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82193. */
  82194. static readonly ACTION_OnEveryFrameTrigger: number;
  82195. /**
  82196. * On intersection enter
  82197. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82198. */
  82199. static readonly ACTION_OnIntersectionEnterTrigger: number;
  82200. /**
  82201. * On intersection exit
  82202. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82203. */
  82204. static readonly ACTION_OnIntersectionExitTrigger: number;
  82205. /**
  82206. * On key down
  82207. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82208. */
  82209. static readonly ACTION_OnKeyDownTrigger: number;
  82210. /**
  82211. * On key up
  82212. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82213. */
  82214. static readonly ACTION_OnKeyUpTrigger: number;
  82215. /**
  82216. * Billboard mode will only apply to Y axis
  82217. */
  82218. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  82219. /**
  82220. * Billboard mode will apply to all axes
  82221. */
  82222. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  82223. /**
  82224. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82225. */
  82226. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  82227. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82228. * Test order :
  82229. * Is the bounding sphere outside the frustum ?
  82230. * If not, are the bounding box vertices outside the frustum ?
  82231. * It not, then the cullable object is in the frustum.
  82232. */
  82233. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  82234. /** Culling strategy : Bounding Sphere Only.
  82235. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82236. * It's also less accurate than the standard because some not visible objects can still be selected.
  82237. * Test : is the bounding sphere outside the frustum ?
  82238. * If not, then the cullable object is in the frustum.
  82239. */
  82240. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82241. /** Culling strategy : Optimistic Inclusion.
  82242. * This in an inclusion test first, then the standard exclusion test.
  82243. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82244. * 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.
  82245. * Anyway, it's as accurate as the standard strategy.
  82246. * Test :
  82247. * Is the cullable object bounding sphere center in the frustum ?
  82248. * If not, apply the default culling strategy.
  82249. */
  82250. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82251. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82252. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82253. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82254. * 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.
  82255. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82256. * Test :
  82257. * Is the cullable object bounding sphere center in the frustum ?
  82258. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82259. */
  82260. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82261. /**
  82262. * No logging while loading
  82263. */
  82264. static readonly SCENELOADER_NO_LOGGING: number;
  82265. /**
  82266. * Minimal logging while loading
  82267. */
  82268. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  82269. /**
  82270. * Summary logging while loading
  82271. */
  82272. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  82273. /**
  82274. * Detailled logging while loading
  82275. */
  82276. static readonly SCENELOADER_DETAILED_LOGGING: number;
  82277. /**
  82278. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  82279. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  82280. */
  82281. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  82282. /**
  82283. * Constant used to retrieve the position texture index in the textures array in the prepass
  82284. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  82285. */
  82286. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  82287. /**
  82288. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  82289. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  82290. */
  82291. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  82292. /**
  82293. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  82294. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  82295. */
  82296. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  82297. /**
  82298. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  82299. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  82300. */
  82301. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  82302. /**
  82303. * Constant used to retrieve depth + normal index in the textures array in the prepass
  82304. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  82305. */
  82306. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  82307. /**
  82308. * Constant used to retrieve albedo index in the textures array in the prepass
  82309. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  82310. */
  82311. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  82312. }
  82313. }
  82314. declare module BABYLON {
  82315. /**
  82316. * This represents the required contract to create a new type of texture loader.
  82317. */
  82318. export interface IInternalTextureLoader {
  82319. /**
  82320. * Defines wether the loader supports cascade loading the different faces.
  82321. */
  82322. supportCascades: boolean;
  82323. /**
  82324. * This returns if the loader support the current file information.
  82325. * @param extension defines the file extension of the file being loaded
  82326. * @param mimeType defines the optional mime type of the file being loaded
  82327. * @returns true if the loader can load the specified file
  82328. */
  82329. canLoad(extension: string, mimeType?: string): boolean;
  82330. /**
  82331. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  82332. * @param data contains the texture data
  82333. * @param texture defines the BabylonJS internal texture
  82334. * @param createPolynomials will be true if polynomials have been requested
  82335. * @param onLoad defines the callback to trigger once the texture is ready
  82336. * @param onError defines the callback to trigger in case of error
  82337. * @param options options to be passed to the loader
  82338. */
  82339. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  82340. /**
  82341. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  82342. * @param data contains the texture data
  82343. * @param texture defines the BabylonJS internal texture
  82344. * @param callback defines the method to call once ready to upload
  82345. * @param options options to be passed to the loader
  82346. */
  82347. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  82348. }
  82349. }
  82350. declare module BABYLON {
  82351. /**
  82352. * Class used to store and describe the pipeline context associated with an effect
  82353. */
  82354. export interface IPipelineContext {
  82355. /**
  82356. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  82357. */
  82358. isAsync: boolean;
  82359. /**
  82360. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  82361. */
  82362. isReady: boolean;
  82363. /** @hidden */
  82364. _getVertexShaderCode(): string | null;
  82365. /** @hidden */
  82366. _getFragmentShaderCode(): string | null;
  82367. /** @hidden */
  82368. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  82369. }
  82370. }
  82371. declare module BABYLON {
  82372. /**
  82373. * Class used to store gfx data (like WebGLBuffer)
  82374. */
  82375. export class DataBuffer {
  82376. /**
  82377. * Gets or sets the number of objects referencing this buffer
  82378. */
  82379. references: number;
  82380. /** Gets or sets the size of the underlying buffer */
  82381. capacity: number;
  82382. /**
  82383. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  82384. */
  82385. is32Bits: boolean;
  82386. /**
  82387. * Gets the underlying buffer
  82388. */
  82389. get underlyingResource(): any;
  82390. }
  82391. }
  82392. declare module BABYLON {
  82393. /** @hidden */
  82394. export interface IShaderProcessor {
  82395. attributeProcessor?: (attribute: string) => string;
  82396. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  82397. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  82398. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  82399. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  82400. lineProcessor?: (line: string, isFragment: boolean) => string;
  82401. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  82402. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  82403. }
  82404. }
  82405. declare module BABYLON {
  82406. /** @hidden */
  82407. export interface ProcessingOptions {
  82408. defines: string[];
  82409. indexParameters: any;
  82410. isFragment: boolean;
  82411. shouldUseHighPrecisionShader: boolean;
  82412. supportsUniformBuffers: boolean;
  82413. shadersRepository: string;
  82414. includesShadersStore: {
  82415. [key: string]: string;
  82416. };
  82417. processor?: IShaderProcessor;
  82418. version: string;
  82419. platformName: string;
  82420. lookForClosingBracketForUniformBuffer?: boolean;
  82421. }
  82422. }
  82423. declare module BABYLON {
  82424. /** @hidden */
  82425. export class ShaderCodeNode {
  82426. line: string;
  82427. children: ShaderCodeNode[];
  82428. additionalDefineKey?: string;
  82429. additionalDefineValue?: string;
  82430. isValid(preprocessors: {
  82431. [key: string]: string;
  82432. }): boolean;
  82433. process(preprocessors: {
  82434. [key: string]: string;
  82435. }, options: ProcessingOptions): string;
  82436. }
  82437. }
  82438. declare module BABYLON {
  82439. /** @hidden */
  82440. export class ShaderCodeCursor {
  82441. private _lines;
  82442. lineIndex: number;
  82443. get currentLine(): string;
  82444. get canRead(): boolean;
  82445. set lines(value: string[]);
  82446. }
  82447. }
  82448. declare module BABYLON {
  82449. /** @hidden */
  82450. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82451. process(preprocessors: {
  82452. [key: string]: string;
  82453. }, options: ProcessingOptions): string;
  82454. }
  82455. }
  82456. declare module BABYLON {
  82457. /** @hidden */
  82458. export class ShaderDefineExpression {
  82459. isTrue(preprocessors: {
  82460. [key: string]: string;
  82461. }): boolean;
  82462. private static _OperatorPriority;
  82463. private static _Stack;
  82464. static postfixToInfix(postfix: string[]): string;
  82465. static infixToPostfix(infix: string): string[];
  82466. }
  82467. }
  82468. declare module BABYLON {
  82469. /** @hidden */
  82470. export class ShaderCodeTestNode extends ShaderCodeNode {
  82471. testExpression: ShaderDefineExpression;
  82472. isValid(preprocessors: {
  82473. [key: string]: string;
  82474. }): boolean;
  82475. }
  82476. }
  82477. declare module BABYLON {
  82478. /** @hidden */
  82479. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82480. define: string;
  82481. not: boolean;
  82482. constructor(define: string, not?: boolean);
  82483. isTrue(preprocessors: {
  82484. [key: string]: string;
  82485. }): boolean;
  82486. }
  82487. }
  82488. declare module BABYLON {
  82489. /** @hidden */
  82490. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82491. leftOperand: ShaderDefineExpression;
  82492. rightOperand: ShaderDefineExpression;
  82493. isTrue(preprocessors: {
  82494. [key: string]: string;
  82495. }): boolean;
  82496. }
  82497. }
  82498. declare module BABYLON {
  82499. /** @hidden */
  82500. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82501. leftOperand: ShaderDefineExpression;
  82502. rightOperand: ShaderDefineExpression;
  82503. isTrue(preprocessors: {
  82504. [key: string]: string;
  82505. }): boolean;
  82506. }
  82507. }
  82508. declare module BABYLON {
  82509. /** @hidden */
  82510. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82511. define: string;
  82512. operand: string;
  82513. testValue: string;
  82514. constructor(define: string, operand: string, testValue: string);
  82515. isTrue(preprocessors: {
  82516. [key: string]: string;
  82517. }): boolean;
  82518. }
  82519. }
  82520. declare module BABYLON {
  82521. /**
  82522. * Class used to enable access to offline support
  82523. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82524. */
  82525. export interface IOfflineProvider {
  82526. /**
  82527. * Gets a boolean indicating if scene must be saved in the database
  82528. */
  82529. enableSceneOffline: boolean;
  82530. /**
  82531. * Gets a boolean indicating if textures must be saved in the database
  82532. */
  82533. enableTexturesOffline: boolean;
  82534. /**
  82535. * Open the offline support and make it available
  82536. * @param successCallback defines the callback to call on success
  82537. * @param errorCallback defines the callback to call on error
  82538. */
  82539. open(successCallback: () => void, errorCallback: () => void): void;
  82540. /**
  82541. * Loads an image from the offline support
  82542. * @param url defines the url to load from
  82543. * @param image defines the target DOM image
  82544. */
  82545. loadImage(url: string, image: HTMLImageElement): void;
  82546. /**
  82547. * Loads a file from offline support
  82548. * @param url defines the URL to load from
  82549. * @param sceneLoaded defines a callback to call on success
  82550. * @param progressCallBack defines a callback to call when progress changed
  82551. * @param errorCallback defines a callback to call on error
  82552. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82553. */
  82554. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82555. }
  82556. }
  82557. declare module BABYLON {
  82558. /**
  82559. * Class used to help managing file picking and drag'n'drop
  82560. * File Storage
  82561. */
  82562. export class FilesInputStore {
  82563. /**
  82564. * List of files ready to be loaded
  82565. */
  82566. static FilesToLoad: {
  82567. [key: string]: File;
  82568. };
  82569. }
  82570. }
  82571. declare module BABYLON {
  82572. /**
  82573. * Class used to define a retry strategy when error happens while loading assets
  82574. */
  82575. export class RetryStrategy {
  82576. /**
  82577. * Function used to defines an exponential back off strategy
  82578. * @param maxRetries defines the maximum number of retries (3 by default)
  82579. * @param baseInterval defines the interval between retries
  82580. * @returns the strategy function to use
  82581. */
  82582. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82583. }
  82584. }
  82585. declare module BABYLON {
  82586. /**
  82587. * @ignore
  82588. * Application error to support additional information when loading a file
  82589. */
  82590. export abstract class BaseError extends Error {
  82591. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82592. }
  82593. }
  82594. declare module BABYLON {
  82595. /** @ignore */
  82596. export class LoadFileError extends BaseError {
  82597. request?: WebRequest;
  82598. file?: File;
  82599. /**
  82600. * Creates a new LoadFileError
  82601. * @param message defines the message of the error
  82602. * @param request defines the optional web request
  82603. * @param file defines the optional file
  82604. */
  82605. constructor(message: string, object?: WebRequest | File);
  82606. }
  82607. /** @ignore */
  82608. export class RequestFileError extends BaseError {
  82609. request: WebRequest;
  82610. /**
  82611. * Creates a new LoadFileError
  82612. * @param message defines the message of the error
  82613. * @param request defines the optional web request
  82614. */
  82615. constructor(message: string, request: WebRequest);
  82616. }
  82617. /** @ignore */
  82618. export class ReadFileError extends BaseError {
  82619. file: File;
  82620. /**
  82621. * Creates a new ReadFileError
  82622. * @param message defines the message of the error
  82623. * @param file defines the optional file
  82624. */
  82625. constructor(message: string, file: File);
  82626. }
  82627. /**
  82628. * @hidden
  82629. */
  82630. export class FileTools {
  82631. /**
  82632. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82633. */
  82634. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82635. /**
  82636. * Gets or sets the base URL to use to load assets
  82637. */
  82638. static BaseUrl: string;
  82639. /**
  82640. * Default behaviour for cors in the application.
  82641. * It can be a string if the expected behavior is identical in the entire app.
  82642. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82643. */
  82644. static CorsBehavior: string | ((url: string | string[]) => string);
  82645. /**
  82646. * Gets or sets a function used to pre-process url before using them to load assets
  82647. */
  82648. static PreprocessUrl: (url: string) => string;
  82649. /**
  82650. * Removes unwanted characters from an url
  82651. * @param url defines the url to clean
  82652. * @returns the cleaned url
  82653. */
  82654. private static _CleanUrl;
  82655. /**
  82656. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82657. * @param url define the url we are trying
  82658. * @param element define the dom element where to configure the cors policy
  82659. */
  82660. static SetCorsBehavior(url: string | string[], element: {
  82661. crossOrigin: string | null;
  82662. }): void;
  82663. /**
  82664. * Loads an image as an HTMLImageElement.
  82665. * @param input url string, ArrayBuffer, or Blob to load
  82666. * @param onLoad callback called when the image successfully loads
  82667. * @param onError callback called when the image fails to load
  82668. * @param offlineProvider offline provider for caching
  82669. * @param mimeType optional mime type
  82670. * @returns the HTMLImageElement of the loaded image
  82671. */
  82672. 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>;
  82673. /**
  82674. * Reads a file from a File object
  82675. * @param file defines the file to load
  82676. * @param onSuccess defines the callback to call when data is loaded
  82677. * @param onProgress defines the callback to call during loading process
  82678. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82679. * @param onError defines the callback to call when an error occurs
  82680. * @returns a file request object
  82681. */
  82682. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82683. /**
  82684. * Loads a file from a url
  82685. * @param url url to load
  82686. * @param onSuccess callback called when the file successfully loads
  82687. * @param onProgress callback called while file is loading (if the server supports this mode)
  82688. * @param offlineProvider defines the offline provider for caching
  82689. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82690. * @param onError callback called when the file fails to load
  82691. * @returns a file request object
  82692. */
  82693. 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;
  82694. /**
  82695. * Loads a file
  82696. * @param url url to load
  82697. * @param onSuccess callback called when the file successfully loads
  82698. * @param onProgress callback called while file is loading (if the server supports this mode)
  82699. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82700. * @param onError callback called when the file fails to load
  82701. * @param onOpened callback called when the web request is opened
  82702. * @returns a file request object
  82703. */
  82704. 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;
  82705. /**
  82706. * Checks if the loaded document was accessed via `file:`-Protocol.
  82707. * @returns boolean
  82708. */
  82709. static IsFileURL(): boolean;
  82710. }
  82711. }
  82712. declare module BABYLON {
  82713. /** @hidden */
  82714. export class ShaderProcessor {
  82715. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  82716. private static _ProcessPrecision;
  82717. private static _ExtractOperation;
  82718. private static _BuildSubExpression;
  82719. private static _BuildExpression;
  82720. private static _MoveCursorWithinIf;
  82721. private static _MoveCursor;
  82722. private static _EvaluatePreProcessors;
  82723. private static _PreparePreProcessors;
  82724. private static _ProcessShaderConversion;
  82725. private static _ProcessIncludes;
  82726. /**
  82727. * Loads a file from a url
  82728. * @param url url to load
  82729. * @param onSuccess callback called when the file successfully loads
  82730. * @param onProgress callback called while file is loading (if the server supports this mode)
  82731. * @param offlineProvider defines the offline provider for caching
  82732. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82733. * @param onError callback called when the file fails to load
  82734. * @returns a file request object
  82735. * @hidden
  82736. */
  82737. 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;
  82738. }
  82739. }
  82740. declare module BABYLON {
  82741. /**
  82742. * @hidden
  82743. */
  82744. export interface IColor4Like {
  82745. r: float;
  82746. g: float;
  82747. b: float;
  82748. a: float;
  82749. }
  82750. /**
  82751. * @hidden
  82752. */
  82753. export interface IColor3Like {
  82754. r: float;
  82755. g: float;
  82756. b: float;
  82757. }
  82758. /**
  82759. * @hidden
  82760. */
  82761. export interface IVector4Like {
  82762. x: float;
  82763. y: float;
  82764. z: float;
  82765. w: float;
  82766. }
  82767. /**
  82768. * @hidden
  82769. */
  82770. export interface IVector3Like {
  82771. x: float;
  82772. y: float;
  82773. z: float;
  82774. }
  82775. /**
  82776. * @hidden
  82777. */
  82778. export interface IVector2Like {
  82779. x: float;
  82780. y: float;
  82781. }
  82782. /**
  82783. * @hidden
  82784. */
  82785. export interface IMatrixLike {
  82786. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82787. updateFlag: int;
  82788. }
  82789. /**
  82790. * @hidden
  82791. */
  82792. export interface IViewportLike {
  82793. x: float;
  82794. y: float;
  82795. width: float;
  82796. height: float;
  82797. }
  82798. /**
  82799. * @hidden
  82800. */
  82801. export interface IPlaneLike {
  82802. normal: IVector3Like;
  82803. d: float;
  82804. normalize(): void;
  82805. }
  82806. }
  82807. declare module BABYLON {
  82808. /**
  82809. * Interface used to define common properties for effect fallbacks
  82810. */
  82811. export interface IEffectFallbacks {
  82812. /**
  82813. * Removes the defines that should be removed when falling back.
  82814. * @param currentDefines defines the current define statements for the shader.
  82815. * @param effect defines the current effect we try to compile
  82816. * @returns The resulting defines with defines of the current rank removed.
  82817. */
  82818. reduce(currentDefines: string, effect: Effect): string;
  82819. /**
  82820. * Removes the fallback from the bound mesh.
  82821. */
  82822. unBindMesh(): void;
  82823. /**
  82824. * Checks to see if more fallbacks are still availible.
  82825. */
  82826. hasMoreFallbacks: boolean;
  82827. }
  82828. }
  82829. declare module BABYLON {
  82830. /**
  82831. * Class used to evalaute queries containing `and` and `or` operators
  82832. */
  82833. export class AndOrNotEvaluator {
  82834. /**
  82835. * Evaluate a query
  82836. * @param query defines the query to evaluate
  82837. * @param evaluateCallback defines the callback used to filter result
  82838. * @returns true if the query matches
  82839. */
  82840. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82841. private static _HandleParenthesisContent;
  82842. private static _SimplifyNegation;
  82843. }
  82844. }
  82845. declare module BABYLON {
  82846. /**
  82847. * Class used to store custom tags
  82848. */
  82849. export class Tags {
  82850. /**
  82851. * Adds support for tags on the given object
  82852. * @param obj defines the object to use
  82853. */
  82854. static EnableFor(obj: any): void;
  82855. /**
  82856. * Removes tags support
  82857. * @param obj defines the object to use
  82858. */
  82859. static DisableFor(obj: any): void;
  82860. /**
  82861. * Gets a boolean indicating if the given object has tags
  82862. * @param obj defines the object to use
  82863. * @returns a boolean
  82864. */
  82865. static HasTags(obj: any): boolean;
  82866. /**
  82867. * Gets the tags available on a given object
  82868. * @param obj defines the object to use
  82869. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82870. * @returns the tags
  82871. */
  82872. static GetTags(obj: any, asString?: boolean): any;
  82873. /**
  82874. * Adds tags to an object
  82875. * @param obj defines the object to use
  82876. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82877. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82878. */
  82879. static AddTagsTo(obj: any, tagsString: string): void;
  82880. /**
  82881. * @hidden
  82882. */
  82883. static _AddTagTo(obj: any, tag: string): void;
  82884. /**
  82885. * Removes specific tags from a specific object
  82886. * @param obj defines the object to use
  82887. * @param tagsString defines the tags to remove
  82888. */
  82889. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82890. /**
  82891. * @hidden
  82892. */
  82893. static _RemoveTagFrom(obj: any, tag: string): void;
  82894. /**
  82895. * Defines if tags hosted on an object match a given query
  82896. * @param obj defines the object to use
  82897. * @param tagsQuery defines the tag query
  82898. * @returns a boolean
  82899. */
  82900. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82901. }
  82902. }
  82903. declare module BABYLON {
  82904. /**
  82905. * Scalar computation library
  82906. */
  82907. export class Scalar {
  82908. /**
  82909. * Two pi constants convenient for computation.
  82910. */
  82911. static TwoPi: number;
  82912. /**
  82913. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82914. * @param a number
  82915. * @param b number
  82916. * @param epsilon (default = 1.401298E-45)
  82917. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82918. */
  82919. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82920. /**
  82921. * Returns a string : the upper case translation of the number i to hexadecimal.
  82922. * @param i number
  82923. * @returns the upper case translation of the number i to hexadecimal.
  82924. */
  82925. static ToHex(i: number): string;
  82926. /**
  82927. * Returns -1 if value is negative and +1 is value is positive.
  82928. * @param value the value
  82929. * @returns the value itself if it's equal to zero.
  82930. */
  82931. static Sign(value: number): number;
  82932. /**
  82933. * Returns the value itself if it's between min and max.
  82934. * Returns min if the value is lower than min.
  82935. * Returns max if the value is greater than max.
  82936. * @param value the value to clmap
  82937. * @param min the min value to clamp to (default: 0)
  82938. * @param max the max value to clamp to (default: 1)
  82939. * @returns the clamped value
  82940. */
  82941. static Clamp(value: number, min?: number, max?: number): number;
  82942. /**
  82943. * the log2 of value.
  82944. * @param value the value to compute log2 of
  82945. * @returns the log2 of value.
  82946. */
  82947. static Log2(value: number): number;
  82948. /**
  82949. * Loops the value, so that it is never larger than length and never smaller than 0.
  82950. *
  82951. * This is similar to the modulo operator but it works with floating point numbers.
  82952. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82953. * With t = 5 and length = 2.5, the result would be 0.0.
  82954. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82955. * @param value the value
  82956. * @param length the length
  82957. * @returns the looped value
  82958. */
  82959. static Repeat(value: number, length: number): number;
  82960. /**
  82961. * Normalize the value between 0.0 and 1.0 using min and max values
  82962. * @param value value to normalize
  82963. * @param min max to normalize between
  82964. * @param max min to normalize between
  82965. * @returns the normalized value
  82966. */
  82967. static Normalize(value: number, min: number, max: number): number;
  82968. /**
  82969. * Denormalize the value from 0.0 and 1.0 using min and max values
  82970. * @param normalized value to denormalize
  82971. * @param min max to denormalize between
  82972. * @param max min to denormalize between
  82973. * @returns the denormalized value
  82974. */
  82975. static Denormalize(normalized: number, min: number, max: number): number;
  82976. /**
  82977. * Calculates the shortest difference between two given angles given in degrees.
  82978. * @param current current angle in degrees
  82979. * @param target target angle in degrees
  82980. * @returns the delta
  82981. */
  82982. static DeltaAngle(current: number, target: number): number;
  82983. /**
  82984. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82985. * @param tx value
  82986. * @param length length
  82987. * @returns The returned value will move back and forth between 0 and length
  82988. */
  82989. static PingPong(tx: number, length: number): number;
  82990. /**
  82991. * Interpolates between min and max with smoothing at the limits.
  82992. *
  82993. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82994. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82995. * @param from from
  82996. * @param to to
  82997. * @param tx value
  82998. * @returns the smooth stepped value
  82999. */
  83000. static SmoothStep(from: number, to: number, tx: number): number;
  83001. /**
  83002. * Moves a value current towards target.
  83003. *
  83004. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  83005. * Negative values of maxDelta pushes the value away from target.
  83006. * @param current current value
  83007. * @param target target value
  83008. * @param maxDelta max distance to move
  83009. * @returns resulting value
  83010. */
  83011. static MoveTowards(current: number, target: number, maxDelta: number): number;
  83012. /**
  83013. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83014. *
  83015. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  83016. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  83017. * @param current current value
  83018. * @param target target value
  83019. * @param maxDelta max distance to move
  83020. * @returns resulting angle
  83021. */
  83022. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  83023. /**
  83024. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  83025. * @param start start value
  83026. * @param end target value
  83027. * @param amount amount to lerp between
  83028. * @returns the lerped value
  83029. */
  83030. static Lerp(start: number, end: number, amount: number): number;
  83031. /**
  83032. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83033. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  83034. * @param start start value
  83035. * @param end target value
  83036. * @param amount amount to lerp between
  83037. * @returns the lerped value
  83038. */
  83039. static LerpAngle(start: number, end: number, amount: number): number;
  83040. /**
  83041. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  83042. * @param a start value
  83043. * @param b target value
  83044. * @param value value between a and b
  83045. * @returns the inverseLerp value
  83046. */
  83047. static InverseLerp(a: number, b: number, value: number): number;
  83048. /**
  83049. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  83050. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  83051. * @param value1 spline value
  83052. * @param tangent1 spline value
  83053. * @param value2 spline value
  83054. * @param tangent2 spline value
  83055. * @param amount input value
  83056. * @returns hermite result
  83057. */
  83058. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  83059. /**
  83060. * Returns a random float number between and min and max values
  83061. * @param min min value of random
  83062. * @param max max value of random
  83063. * @returns random value
  83064. */
  83065. static RandomRange(min: number, max: number): number;
  83066. /**
  83067. * This function returns percentage of a number in a given range.
  83068. *
  83069. * RangeToPercent(40,20,60) will return 0.5 (50%)
  83070. * RangeToPercent(34,0,100) will return 0.34 (34%)
  83071. * @param number to convert to percentage
  83072. * @param min min range
  83073. * @param max max range
  83074. * @returns the percentage
  83075. */
  83076. static RangeToPercent(number: number, min: number, max: number): number;
  83077. /**
  83078. * This function returns number that corresponds to the percentage in a given range.
  83079. *
  83080. * PercentToRange(0.34,0,100) will return 34.
  83081. * @param percent to convert to number
  83082. * @param min min range
  83083. * @param max max range
  83084. * @returns the number
  83085. */
  83086. static PercentToRange(percent: number, min: number, max: number): number;
  83087. /**
  83088. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  83089. * @param angle The angle to normalize in radian.
  83090. * @return The converted angle.
  83091. */
  83092. static NormalizeRadians(angle: number): number;
  83093. }
  83094. }
  83095. declare module BABYLON {
  83096. /**
  83097. * Constant used to convert a value to gamma space
  83098. * @ignorenaming
  83099. */
  83100. export const ToGammaSpace: number;
  83101. /**
  83102. * Constant used to convert a value to linear space
  83103. * @ignorenaming
  83104. */
  83105. export const ToLinearSpace = 2.2;
  83106. /**
  83107. * Constant used to define the minimal number value in Babylon.js
  83108. * @ignorenaming
  83109. */
  83110. let Epsilon: number;
  83111. }
  83112. declare module BABYLON {
  83113. /**
  83114. * Class used to represent a viewport on screen
  83115. */
  83116. export class Viewport {
  83117. /** viewport left coordinate */
  83118. x: number;
  83119. /** viewport top coordinate */
  83120. y: number;
  83121. /**viewport width */
  83122. width: number;
  83123. /** viewport height */
  83124. height: number;
  83125. /**
  83126. * Creates a Viewport object located at (x, y) and sized (width, height)
  83127. * @param x defines viewport left coordinate
  83128. * @param y defines viewport top coordinate
  83129. * @param width defines the viewport width
  83130. * @param height defines the viewport height
  83131. */
  83132. constructor(
  83133. /** viewport left coordinate */
  83134. x: number,
  83135. /** viewport top coordinate */
  83136. y: number,
  83137. /**viewport width */
  83138. width: number,
  83139. /** viewport height */
  83140. height: number);
  83141. /**
  83142. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  83143. * @param renderWidth defines the rendering width
  83144. * @param renderHeight defines the rendering height
  83145. * @returns a new Viewport
  83146. */
  83147. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  83148. /**
  83149. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  83150. * @param renderWidth defines the rendering width
  83151. * @param renderHeight defines the rendering height
  83152. * @param ref defines the target viewport
  83153. * @returns the current viewport
  83154. */
  83155. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  83156. /**
  83157. * Returns a new Viewport copied from the current one
  83158. * @returns a new Viewport
  83159. */
  83160. clone(): Viewport;
  83161. }
  83162. }
  83163. declare module BABYLON {
  83164. /**
  83165. * Class containing a set of static utilities functions for arrays.
  83166. */
  83167. export class ArrayTools {
  83168. /**
  83169. * Returns an array of the given size filled with element built from the given constructor and the paramters
  83170. * @param size the number of element to construct and put in the array
  83171. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  83172. * @returns a new array filled with new objects
  83173. */
  83174. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  83175. }
  83176. }
  83177. declare module BABYLON {
  83178. /**
  83179. * Represents a plane by the equation ax + by + cz + d = 0
  83180. */
  83181. export class Plane {
  83182. private static _TmpMatrix;
  83183. /**
  83184. * Normal of the plane (a,b,c)
  83185. */
  83186. normal: Vector3;
  83187. /**
  83188. * d component of the plane
  83189. */
  83190. d: number;
  83191. /**
  83192. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  83193. * @param a a component of the plane
  83194. * @param b b component of the plane
  83195. * @param c c component of the plane
  83196. * @param d d component of the plane
  83197. */
  83198. constructor(a: number, b: number, c: number, d: number);
  83199. /**
  83200. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  83201. */
  83202. asArray(): number[];
  83203. /**
  83204. * @returns a new plane copied from the current Plane.
  83205. */
  83206. clone(): Plane;
  83207. /**
  83208. * @returns the string "Plane".
  83209. */
  83210. getClassName(): string;
  83211. /**
  83212. * @returns the Plane hash code.
  83213. */
  83214. getHashCode(): number;
  83215. /**
  83216. * Normalize the current Plane in place.
  83217. * @returns the updated Plane.
  83218. */
  83219. normalize(): Plane;
  83220. /**
  83221. * Applies a transformation the plane and returns the result
  83222. * @param transformation the transformation matrix to be applied to the plane
  83223. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  83224. */
  83225. transform(transformation: DeepImmutable<Matrix>): Plane;
  83226. /**
  83227. * Compute the dot product between the point and the plane normal
  83228. * @param point point to calculate the dot product with
  83229. * @returns the dot product (float) of the point coordinates and the plane normal.
  83230. */
  83231. dotCoordinate(point: DeepImmutable<Vector3>): number;
  83232. /**
  83233. * Updates the current Plane from the plane defined by the three given points.
  83234. * @param point1 one of the points used to contruct the plane
  83235. * @param point2 one of the points used to contruct the plane
  83236. * @param point3 one of the points used to contruct the plane
  83237. * @returns the updated Plane.
  83238. */
  83239. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83240. /**
  83241. * Checks if the plane is facing a given direction
  83242. * @param direction the direction to check if the plane is facing
  83243. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  83244. * @returns True is the vector "direction" is the same side than the plane normal.
  83245. */
  83246. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  83247. /**
  83248. * Calculates the distance to a point
  83249. * @param point point to calculate distance to
  83250. * @returns the signed distance (float) from the given point to the Plane.
  83251. */
  83252. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  83253. /**
  83254. * Creates a plane from an array
  83255. * @param array the array to create a plane from
  83256. * @returns a new Plane from the given array.
  83257. */
  83258. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  83259. /**
  83260. * Creates a plane from three points
  83261. * @param point1 point used to create the plane
  83262. * @param point2 point used to create the plane
  83263. * @param point3 point used to create the plane
  83264. * @returns a new Plane defined by the three given points.
  83265. */
  83266. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83267. /**
  83268. * Creates a plane from an origin point and a normal
  83269. * @param origin origin of the plane to be constructed
  83270. * @param normal normal of the plane to be constructed
  83271. * @returns a new Plane the normal vector to this plane at the given origin point.
  83272. * Note : the vector "normal" is updated because normalized.
  83273. */
  83274. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  83275. /**
  83276. * Calculates the distance from a plane and a point
  83277. * @param origin origin of the plane to be constructed
  83278. * @param normal normal of the plane to be constructed
  83279. * @param point point to calculate distance to
  83280. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  83281. */
  83282. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  83283. }
  83284. }
  83285. declare module BABYLON {
  83286. /** @hidden */
  83287. export class PerformanceConfigurator {
  83288. /** @hidden */
  83289. static MatrixUse64Bits: boolean;
  83290. /** @hidden */
  83291. static MatrixTrackPrecisionChange: boolean;
  83292. /** @hidden */
  83293. static MatrixCurrentType: any;
  83294. /** @hidden */
  83295. static MatrixTrackedMatrices: Array<any> | null;
  83296. /** @hidden */
  83297. static SetMatrixPrecision(use64bits: boolean): void;
  83298. }
  83299. }
  83300. declare module BABYLON {
  83301. /**
  83302. * Class representing a vector containing 2 coordinates
  83303. */
  83304. export class Vector2 {
  83305. /** defines the first coordinate */
  83306. x: number;
  83307. /** defines the second coordinate */
  83308. y: number;
  83309. /**
  83310. * Creates a new Vector2 from the given x and y coordinates
  83311. * @param x defines the first coordinate
  83312. * @param y defines the second coordinate
  83313. */
  83314. constructor(
  83315. /** defines the first coordinate */
  83316. x?: number,
  83317. /** defines the second coordinate */
  83318. y?: number);
  83319. /**
  83320. * Gets a string with the Vector2 coordinates
  83321. * @returns a string with the Vector2 coordinates
  83322. */
  83323. toString(): string;
  83324. /**
  83325. * Gets class name
  83326. * @returns the string "Vector2"
  83327. */
  83328. getClassName(): string;
  83329. /**
  83330. * Gets current vector hash code
  83331. * @returns the Vector2 hash code as a number
  83332. */
  83333. getHashCode(): number;
  83334. /**
  83335. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  83336. * @param array defines the source array
  83337. * @param index defines the offset in source array
  83338. * @returns the current Vector2
  83339. */
  83340. toArray(array: FloatArray, index?: number): Vector2;
  83341. /**
  83342. * Update the current vector from an array
  83343. * @param array defines the destination array
  83344. * @param index defines the offset in the destination array
  83345. * @returns the current Vector3
  83346. */
  83347. fromArray(array: FloatArray, index?: number): Vector2;
  83348. /**
  83349. * Copy the current vector to an array
  83350. * @returns a new array with 2 elements: the Vector2 coordinates.
  83351. */
  83352. asArray(): number[];
  83353. /**
  83354. * Sets the Vector2 coordinates with the given Vector2 coordinates
  83355. * @param source defines the source Vector2
  83356. * @returns the current updated Vector2
  83357. */
  83358. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  83359. /**
  83360. * Sets the Vector2 coordinates with the given floats
  83361. * @param x defines the first coordinate
  83362. * @param y defines the second coordinate
  83363. * @returns the current updated Vector2
  83364. */
  83365. copyFromFloats(x: number, y: number): Vector2;
  83366. /**
  83367. * Sets the Vector2 coordinates with the given floats
  83368. * @param x defines the first coordinate
  83369. * @param y defines the second coordinate
  83370. * @returns the current updated Vector2
  83371. */
  83372. set(x: number, y: number): Vector2;
  83373. /**
  83374. * Add another vector with the current one
  83375. * @param otherVector defines the other vector
  83376. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  83377. */
  83378. add(otherVector: DeepImmutable<Vector2>): Vector2;
  83379. /**
  83380. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  83381. * @param otherVector defines the other vector
  83382. * @param result defines the target vector
  83383. * @returns the unmodified current Vector2
  83384. */
  83385. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83386. /**
  83387. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  83388. * @param otherVector defines the other vector
  83389. * @returns the current updated Vector2
  83390. */
  83391. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83392. /**
  83393. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  83394. * @param otherVector defines the other vector
  83395. * @returns a new Vector2
  83396. */
  83397. addVector3(otherVector: Vector3): Vector2;
  83398. /**
  83399. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  83400. * @param otherVector defines the other vector
  83401. * @returns a new Vector2
  83402. */
  83403. subtract(otherVector: Vector2): Vector2;
  83404. /**
  83405. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  83406. * @param otherVector defines the other vector
  83407. * @param result defines the target vector
  83408. * @returns the unmodified current Vector2
  83409. */
  83410. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83411. /**
  83412. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  83413. * @param otherVector defines the other vector
  83414. * @returns the current updated Vector2
  83415. */
  83416. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83417. /**
  83418. * Multiplies in place the current Vector2 coordinates by the given ones
  83419. * @param otherVector defines the other vector
  83420. * @returns the current updated Vector2
  83421. */
  83422. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83423. /**
  83424. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  83425. * @param otherVector defines the other vector
  83426. * @returns a new Vector2
  83427. */
  83428. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  83429. /**
  83430. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  83431. * @param otherVector defines the other vector
  83432. * @param result defines the target vector
  83433. * @returns the unmodified current Vector2
  83434. */
  83435. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83436. /**
  83437. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  83438. * @param x defines the first coordinate
  83439. * @param y defines the second coordinate
  83440. * @returns a new Vector2
  83441. */
  83442. multiplyByFloats(x: number, y: number): Vector2;
  83443. /**
  83444. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  83445. * @param otherVector defines the other vector
  83446. * @returns a new Vector2
  83447. */
  83448. divide(otherVector: Vector2): Vector2;
  83449. /**
  83450. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  83451. * @param otherVector defines the other vector
  83452. * @param result defines the target vector
  83453. * @returns the unmodified current Vector2
  83454. */
  83455. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83456. /**
  83457. * Divides the current Vector2 coordinates by the given ones
  83458. * @param otherVector defines the other vector
  83459. * @returns the current updated Vector2
  83460. */
  83461. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83462. /**
  83463. * Gets a new Vector2 with current Vector2 negated coordinates
  83464. * @returns a new Vector2
  83465. */
  83466. negate(): Vector2;
  83467. /**
  83468. * Negate this vector in place
  83469. * @returns this
  83470. */
  83471. negateInPlace(): Vector2;
  83472. /**
  83473. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  83474. * @param result defines the Vector3 object where to store the result
  83475. * @returns the current Vector2
  83476. */
  83477. negateToRef(result: Vector2): Vector2;
  83478. /**
  83479. * Multiply the Vector2 coordinates by scale
  83480. * @param scale defines the scaling factor
  83481. * @returns the current updated Vector2
  83482. */
  83483. scaleInPlace(scale: number): Vector2;
  83484. /**
  83485. * Returns a new Vector2 scaled by "scale" from the current Vector2
  83486. * @param scale defines the scaling factor
  83487. * @returns a new Vector2
  83488. */
  83489. scale(scale: number): Vector2;
  83490. /**
  83491. * Scale the current Vector2 values by a factor to a given Vector2
  83492. * @param scale defines the scale factor
  83493. * @param result defines the Vector2 object where to store the result
  83494. * @returns the unmodified current Vector2
  83495. */
  83496. scaleToRef(scale: number, result: Vector2): Vector2;
  83497. /**
  83498. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  83499. * @param scale defines the scale factor
  83500. * @param result defines the Vector2 object where to store the result
  83501. * @returns the unmodified current Vector2
  83502. */
  83503. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  83504. /**
  83505. * Gets a boolean if two vectors are equals
  83506. * @param otherVector defines the other vector
  83507. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  83508. */
  83509. equals(otherVector: DeepImmutable<Vector2>): boolean;
  83510. /**
  83511. * Gets a boolean if two vectors are equals (using an epsilon value)
  83512. * @param otherVector defines the other vector
  83513. * @param epsilon defines the minimal distance to consider equality
  83514. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  83515. */
  83516. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  83517. /**
  83518. * Gets a new Vector2 from current Vector2 floored values
  83519. * @returns a new Vector2
  83520. */
  83521. floor(): Vector2;
  83522. /**
  83523. * Gets a new Vector2 from current Vector2 floored values
  83524. * @returns a new Vector2
  83525. */
  83526. fract(): Vector2;
  83527. /**
  83528. * Gets the length of the vector
  83529. * @returns the vector length (float)
  83530. */
  83531. length(): number;
  83532. /**
  83533. * Gets the vector squared length
  83534. * @returns the vector squared length (float)
  83535. */
  83536. lengthSquared(): number;
  83537. /**
  83538. * Normalize the vector
  83539. * @returns the current updated Vector2
  83540. */
  83541. normalize(): Vector2;
  83542. /**
  83543. * Gets a new Vector2 copied from the Vector2
  83544. * @returns a new Vector2
  83545. */
  83546. clone(): Vector2;
  83547. /**
  83548. * Gets a new Vector2(0, 0)
  83549. * @returns a new Vector2
  83550. */
  83551. static Zero(): Vector2;
  83552. /**
  83553. * Gets a new Vector2(1, 1)
  83554. * @returns a new Vector2
  83555. */
  83556. static One(): Vector2;
  83557. /**
  83558. * Gets a new Vector2 set from the given index element of the given array
  83559. * @param array defines the data source
  83560. * @param offset defines the offset in the data source
  83561. * @returns a new Vector2
  83562. */
  83563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  83564. /**
  83565. * Sets "result" from the given index element of the given array
  83566. * @param array defines the data source
  83567. * @param offset defines the offset in the data source
  83568. * @param result defines the target vector
  83569. */
  83570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  83571. /**
  83572. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  83573. * @param value1 defines 1st point of control
  83574. * @param value2 defines 2nd point of control
  83575. * @param value3 defines 3rd point of control
  83576. * @param value4 defines 4th point of control
  83577. * @param amount defines the interpolation factor
  83578. * @returns a new Vector2
  83579. */
  83580. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  83581. /**
  83582. * 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".
  83583. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  83584. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  83585. * @param value defines the value to clamp
  83586. * @param min defines the lower limit
  83587. * @param max defines the upper limit
  83588. * @returns a new Vector2
  83589. */
  83590. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  83591. /**
  83592. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  83593. * @param value1 defines the 1st control point
  83594. * @param tangent1 defines the outgoing tangent
  83595. * @param value2 defines the 2nd control point
  83596. * @param tangent2 defines the incoming tangent
  83597. * @param amount defines the interpolation factor
  83598. * @returns a new Vector2
  83599. */
  83600. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  83601. /**
  83602. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83603. * @param start defines the start vector
  83604. * @param end defines the end vector
  83605. * @param amount defines the interpolation factor
  83606. * @returns a new Vector2
  83607. */
  83608. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  83609. /**
  83610. * Gets the dot product of the vector "left" and the vector "right"
  83611. * @param left defines first vector
  83612. * @param right defines second vector
  83613. * @returns the dot product (float)
  83614. */
  83615. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  83616. /**
  83617. * Returns a new Vector2 equal to the normalized given vector
  83618. * @param vector defines the vector to normalize
  83619. * @returns a new Vector2
  83620. */
  83621. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  83622. /**
  83623. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83624. * @param left defines 1st vector
  83625. * @param right defines 2nd vector
  83626. * @returns a new Vector2
  83627. */
  83628. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83629. /**
  83630. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83631. * @param left defines 1st vector
  83632. * @param right defines 2nd vector
  83633. * @returns a new Vector2
  83634. */
  83635. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83636. /**
  83637. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83638. * @param vector defines the vector to transform
  83639. * @param transformation defines the matrix to apply
  83640. * @returns a new Vector2
  83641. */
  83642. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  83643. /**
  83644. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83645. * @param vector defines the vector to transform
  83646. * @param transformation defines the matrix to apply
  83647. * @param result defines the target vector
  83648. */
  83649. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  83650. /**
  83651. * Determines if a given vector is included in a triangle
  83652. * @param p defines the vector to test
  83653. * @param p0 defines 1st triangle point
  83654. * @param p1 defines 2nd triangle point
  83655. * @param p2 defines 3rd triangle point
  83656. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83657. */
  83658. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  83659. /**
  83660. * Gets the distance between the vectors "value1" and "value2"
  83661. * @param value1 defines first vector
  83662. * @param value2 defines second vector
  83663. * @returns the distance between vectors
  83664. */
  83665. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83666. /**
  83667. * Returns the squared distance between the vectors "value1" and "value2"
  83668. * @param value1 defines first vector
  83669. * @param value2 defines second vector
  83670. * @returns the squared distance between vectors
  83671. */
  83672. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83673. /**
  83674. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83675. * @param value1 defines first vector
  83676. * @param value2 defines second vector
  83677. * @returns a new Vector2
  83678. */
  83679. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  83680. /**
  83681. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83682. * @param p defines the middle point
  83683. * @param segA defines one point of the segment
  83684. * @param segB defines the other point of the segment
  83685. * @returns the shortest distance
  83686. */
  83687. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  83688. }
  83689. /**
  83690. * Class used to store (x,y,z) vector representation
  83691. * A Vector3 is the main object used in 3D geometry
  83692. * It can represent etiher the coordinates of a point the space, either a direction
  83693. * Reminder: js uses a left handed forward facing system
  83694. */
  83695. export class Vector3 {
  83696. private static _UpReadOnly;
  83697. private static _ZeroReadOnly;
  83698. /** @hidden */
  83699. _x: number;
  83700. /** @hidden */
  83701. _y: number;
  83702. /** @hidden */
  83703. _z: number;
  83704. /** @hidden */
  83705. _isDirty: boolean;
  83706. /** Gets or sets the x coordinate */
  83707. get x(): number;
  83708. set x(value: number);
  83709. /** Gets or sets the y coordinate */
  83710. get y(): number;
  83711. set y(value: number);
  83712. /** Gets or sets the z coordinate */
  83713. get z(): number;
  83714. set z(value: number);
  83715. /**
  83716. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83717. * @param x defines the first coordinates (on X axis)
  83718. * @param y defines the second coordinates (on Y axis)
  83719. * @param z defines the third coordinates (on Z axis)
  83720. */
  83721. constructor(x?: number, y?: number, z?: number);
  83722. /**
  83723. * Creates a string representation of the Vector3
  83724. * @returns a string with the Vector3 coordinates.
  83725. */
  83726. toString(): string;
  83727. /**
  83728. * Gets the class name
  83729. * @returns the string "Vector3"
  83730. */
  83731. getClassName(): string;
  83732. /**
  83733. * Creates the Vector3 hash code
  83734. * @returns a number which tends to be unique between Vector3 instances
  83735. */
  83736. getHashCode(): number;
  83737. /**
  83738. * Creates an array containing three elements : the coordinates of the Vector3
  83739. * @returns a new array of numbers
  83740. */
  83741. asArray(): number[];
  83742. /**
  83743. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83744. * @param array defines the destination array
  83745. * @param index defines the offset in the destination array
  83746. * @returns the current Vector3
  83747. */
  83748. toArray(array: FloatArray, index?: number): Vector3;
  83749. /**
  83750. * Update the current vector from an array
  83751. * @param array defines the destination array
  83752. * @param index defines the offset in the destination array
  83753. * @returns the current Vector3
  83754. */
  83755. fromArray(array: FloatArray, index?: number): Vector3;
  83756. /**
  83757. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83758. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83759. */
  83760. toQuaternion(): Quaternion;
  83761. /**
  83762. * Adds the given vector to the current Vector3
  83763. * @param otherVector defines the second operand
  83764. * @returns the current updated Vector3
  83765. */
  83766. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83767. /**
  83768. * Adds the given coordinates to the current Vector3
  83769. * @param x defines the x coordinate of the operand
  83770. * @param y defines the y coordinate of the operand
  83771. * @param z defines the z coordinate of the operand
  83772. * @returns the current updated Vector3
  83773. */
  83774. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83775. /**
  83776. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83777. * @param otherVector defines the second operand
  83778. * @returns the resulting Vector3
  83779. */
  83780. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83781. /**
  83782. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83783. * @param otherVector defines the second operand
  83784. * @param result defines the Vector3 object where to store the result
  83785. * @returns the current Vector3
  83786. */
  83787. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83788. /**
  83789. * Subtract the given vector from the current Vector3
  83790. * @param otherVector defines the second operand
  83791. * @returns the current updated Vector3
  83792. */
  83793. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83794. /**
  83795. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83796. * @param otherVector defines the second operand
  83797. * @returns the resulting Vector3
  83798. */
  83799. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83800. /**
  83801. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83802. * @param otherVector defines the second operand
  83803. * @param result defines the Vector3 object where to store the result
  83804. * @returns the current Vector3
  83805. */
  83806. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83807. /**
  83808. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83809. * @param x defines the x coordinate of the operand
  83810. * @param y defines the y coordinate of the operand
  83811. * @param z defines the z coordinate of the operand
  83812. * @returns the resulting Vector3
  83813. */
  83814. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83815. /**
  83816. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83817. * @param x defines the x coordinate of the operand
  83818. * @param y defines the y coordinate of the operand
  83819. * @param z defines the z coordinate of the operand
  83820. * @param result defines the Vector3 object where to store the result
  83821. * @returns the current Vector3
  83822. */
  83823. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83824. /**
  83825. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83826. * @returns a new Vector3
  83827. */
  83828. negate(): Vector3;
  83829. /**
  83830. * Negate this vector in place
  83831. * @returns this
  83832. */
  83833. negateInPlace(): Vector3;
  83834. /**
  83835. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83836. * @param result defines the Vector3 object where to store the result
  83837. * @returns the current Vector3
  83838. */
  83839. negateToRef(result: Vector3): Vector3;
  83840. /**
  83841. * Multiplies the Vector3 coordinates by the float "scale"
  83842. * @param scale defines the multiplier factor
  83843. * @returns the current updated Vector3
  83844. */
  83845. scaleInPlace(scale: number): Vector3;
  83846. /**
  83847. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83848. * @param scale defines the multiplier factor
  83849. * @returns a new Vector3
  83850. */
  83851. scale(scale: number): Vector3;
  83852. /**
  83853. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83854. * @param scale defines the multiplier factor
  83855. * @param result defines the Vector3 object where to store the result
  83856. * @returns the current Vector3
  83857. */
  83858. scaleToRef(scale: number, result: Vector3): Vector3;
  83859. /**
  83860. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83861. * @param scale defines the scale factor
  83862. * @param result defines the Vector3 object where to store the result
  83863. * @returns the unmodified current Vector3
  83864. */
  83865. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83866. /**
  83867. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83868. * @param origin defines the origin of the projection ray
  83869. * @param plane defines the plane to project to
  83870. * @returns the projected vector3
  83871. */
  83872. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83873. /**
  83874. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83875. * @param origin defines the origin of the projection ray
  83876. * @param plane defines the plane to project to
  83877. * @param result defines the Vector3 where to store the result
  83878. */
  83879. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83880. /**
  83881. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83882. * @param otherVector defines the second operand
  83883. * @returns true if both vectors are equals
  83884. */
  83885. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83886. /**
  83887. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83888. * @param otherVector defines the second operand
  83889. * @param epsilon defines the minimal distance to define values as equals
  83890. * @returns true if both vectors are distant less than epsilon
  83891. */
  83892. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83893. /**
  83894. * Returns true if the current Vector3 coordinates equals the given floats
  83895. * @param x defines the x coordinate of the operand
  83896. * @param y defines the y coordinate of the operand
  83897. * @param z defines the z coordinate of the operand
  83898. * @returns true if both vectors are equals
  83899. */
  83900. equalsToFloats(x: number, y: number, z: number): boolean;
  83901. /**
  83902. * Multiplies the current Vector3 coordinates by the given ones
  83903. * @param otherVector defines the second operand
  83904. * @returns the current updated Vector3
  83905. */
  83906. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83907. /**
  83908. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83909. * @param otherVector defines the second operand
  83910. * @returns the new Vector3
  83911. */
  83912. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83913. /**
  83914. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83915. * @param otherVector defines the second operand
  83916. * @param result defines the Vector3 object where to store the result
  83917. * @returns the current Vector3
  83918. */
  83919. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83920. /**
  83921. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83922. * @param x defines the x coordinate of the operand
  83923. * @param y defines the y coordinate of the operand
  83924. * @param z defines the z coordinate of the operand
  83925. * @returns the new Vector3
  83926. */
  83927. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83928. /**
  83929. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83930. * @param otherVector defines the second operand
  83931. * @returns the new Vector3
  83932. */
  83933. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83934. /**
  83935. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83936. * @param otherVector defines the second operand
  83937. * @param result defines the Vector3 object where to store the result
  83938. * @returns the current Vector3
  83939. */
  83940. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83941. /**
  83942. * Divides the current Vector3 coordinates by the given ones.
  83943. * @param otherVector defines the second operand
  83944. * @returns the current updated Vector3
  83945. */
  83946. divideInPlace(otherVector: Vector3): Vector3;
  83947. /**
  83948. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83949. * @param other defines the second operand
  83950. * @returns the current updated Vector3
  83951. */
  83952. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83953. /**
  83954. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83955. * @param other defines the second operand
  83956. * @returns the current updated Vector3
  83957. */
  83958. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83959. /**
  83960. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83961. * @param x defines the x coordinate of the operand
  83962. * @param y defines the y coordinate of the operand
  83963. * @param z defines the z coordinate of the operand
  83964. * @returns the current updated Vector3
  83965. */
  83966. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83967. /**
  83968. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83969. * @param x defines the x coordinate of the operand
  83970. * @param y defines the y coordinate of the operand
  83971. * @param z defines the z coordinate of the operand
  83972. * @returns the current updated Vector3
  83973. */
  83974. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83975. /**
  83976. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83977. * Check if is non uniform within a certain amount of decimal places to account for this
  83978. * @param epsilon the amount the values can differ
  83979. * @returns if the the vector is non uniform to a certain number of decimal places
  83980. */
  83981. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83982. /**
  83983. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83984. */
  83985. get isNonUniform(): boolean;
  83986. /**
  83987. * Gets a new Vector3 from current Vector3 floored values
  83988. * @returns a new Vector3
  83989. */
  83990. floor(): Vector3;
  83991. /**
  83992. * Gets a new Vector3 from current Vector3 floored values
  83993. * @returns a new Vector3
  83994. */
  83995. fract(): Vector3;
  83996. /**
  83997. * Gets the length of the Vector3
  83998. * @returns the length of the Vector3
  83999. */
  84000. length(): number;
  84001. /**
  84002. * Gets the squared length of the Vector3
  84003. * @returns squared length of the Vector3
  84004. */
  84005. lengthSquared(): number;
  84006. /**
  84007. * Normalize the current Vector3.
  84008. * Please note that this is an in place operation.
  84009. * @returns the current updated Vector3
  84010. */
  84011. normalize(): Vector3;
  84012. /**
  84013. * Reorders the x y z properties of the vector in place
  84014. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  84015. * @returns the current updated vector
  84016. */
  84017. reorderInPlace(order: string): this;
  84018. /**
  84019. * Rotates the vector around 0,0,0 by a quaternion
  84020. * @param quaternion the rotation quaternion
  84021. * @param result vector to store the result
  84022. * @returns the resulting vector
  84023. */
  84024. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  84025. /**
  84026. * Rotates a vector around a given point
  84027. * @param quaternion the rotation quaternion
  84028. * @param point the point to rotate around
  84029. * @param result vector to store the result
  84030. * @returns the resulting vector
  84031. */
  84032. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  84033. /**
  84034. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  84035. * The cross product is then orthogonal to both current and "other"
  84036. * @param other defines the right operand
  84037. * @returns the cross product
  84038. */
  84039. cross(other: Vector3): Vector3;
  84040. /**
  84041. * Normalize the current Vector3 with the given input length.
  84042. * Please note that this is an in place operation.
  84043. * @param len the length of the vector
  84044. * @returns the current updated Vector3
  84045. */
  84046. normalizeFromLength(len: number): Vector3;
  84047. /**
  84048. * Normalize the current Vector3 to a new vector
  84049. * @returns the new Vector3
  84050. */
  84051. normalizeToNew(): Vector3;
  84052. /**
  84053. * Normalize the current Vector3 to the reference
  84054. * @param reference define the Vector3 to update
  84055. * @returns the updated Vector3
  84056. */
  84057. normalizeToRef(reference: Vector3): Vector3;
  84058. /**
  84059. * Creates a new Vector3 copied from the current Vector3
  84060. * @returns the new Vector3
  84061. */
  84062. clone(): Vector3;
  84063. /**
  84064. * Copies the given vector coordinates to the current Vector3 ones
  84065. * @param source defines the source Vector3
  84066. * @returns the current updated Vector3
  84067. */
  84068. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  84069. /**
  84070. * Copies the given floats to the current Vector3 coordinates
  84071. * @param x defines the x coordinate of the operand
  84072. * @param y defines the y coordinate of the operand
  84073. * @param z defines the z coordinate of the operand
  84074. * @returns the current updated Vector3
  84075. */
  84076. copyFromFloats(x: number, y: number, z: number): Vector3;
  84077. /**
  84078. * Copies the given floats to the current Vector3 coordinates
  84079. * @param x defines the x coordinate of the operand
  84080. * @param y defines the y coordinate of the operand
  84081. * @param z defines the z coordinate of the operand
  84082. * @returns the current updated Vector3
  84083. */
  84084. set(x: number, y: number, z: number): Vector3;
  84085. /**
  84086. * Copies the given float to the current Vector3 coordinates
  84087. * @param v defines the x, y and z coordinates of the operand
  84088. * @returns the current updated Vector3
  84089. */
  84090. setAll(v: number): Vector3;
  84091. /**
  84092. * Get the clip factor between two vectors
  84093. * @param vector0 defines the first operand
  84094. * @param vector1 defines the second operand
  84095. * @param axis defines the axis to use
  84096. * @param size defines the size along the axis
  84097. * @returns the clip factor
  84098. */
  84099. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  84100. /**
  84101. * Get angle between two vectors
  84102. * @param vector0 angle between vector0 and vector1
  84103. * @param vector1 angle between vector0 and vector1
  84104. * @param normal direction of the normal
  84105. * @return the angle between vector0 and vector1
  84106. */
  84107. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  84108. /**
  84109. * Returns a new Vector3 set from the index "offset" of the given array
  84110. * @param array defines the source array
  84111. * @param offset defines the offset in the source array
  84112. * @returns the new Vector3
  84113. */
  84114. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  84115. /**
  84116. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  84117. * @param array defines the source array
  84118. * @param offset defines the offset in the source array
  84119. * @returns the new Vector3
  84120. * @deprecated Please use FromArray instead.
  84121. */
  84122. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  84123. /**
  84124. * Sets the given vector "result" with the element values from the index "offset" of the given array
  84125. * @param array defines the source array
  84126. * @param offset defines the offset in the source array
  84127. * @param result defines the Vector3 where to store the result
  84128. */
  84129. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  84130. /**
  84131. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  84132. * @param array defines the source array
  84133. * @param offset defines the offset in the source array
  84134. * @param result defines the Vector3 where to store the result
  84135. * @deprecated Please use FromArrayToRef instead.
  84136. */
  84137. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  84138. /**
  84139. * Sets the given vector "result" with the given floats.
  84140. * @param x defines the x coordinate of the source
  84141. * @param y defines the y coordinate of the source
  84142. * @param z defines the z coordinate of the source
  84143. * @param result defines the Vector3 where to store the result
  84144. */
  84145. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  84146. /**
  84147. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  84148. * @returns a new empty Vector3
  84149. */
  84150. static Zero(): Vector3;
  84151. /**
  84152. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  84153. * @returns a new unit Vector3
  84154. */
  84155. static One(): Vector3;
  84156. /**
  84157. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  84158. * @returns a new up Vector3
  84159. */
  84160. static Up(): Vector3;
  84161. /**
  84162. * Gets a up Vector3 that must not be updated
  84163. */
  84164. static get UpReadOnly(): DeepImmutable<Vector3>;
  84165. /**
  84166. * Gets a zero Vector3 that must not be updated
  84167. */
  84168. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  84169. /**
  84170. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  84171. * @returns a new down Vector3
  84172. */
  84173. static Down(): Vector3;
  84174. /**
  84175. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  84176. * @param rightHandedSystem is the scene right-handed (negative z)
  84177. * @returns a new forward Vector3
  84178. */
  84179. static Forward(rightHandedSystem?: boolean): Vector3;
  84180. /**
  84181. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  84182. * @param rightHandedSystem is the scene right-handed (negative-z)
  84183. * @returns a new forward Vector3
  84184. */
  84185. static Backward(rightHandedSystem?: boolean): Vector3;
  84186. /**
  84187. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  84188. * @returns a new right Vector3
  84189. */
  84190. static Right(): Vector3;
  84191. /**
  84192. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  84193. * @returns a new left Vector3
  84194. */
  84195. static Left(): Vector3;
  84196. /**
  84197. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  84198. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84199. * @param vector defines the Vector3 to transform
  84200. * @param transformation defines the transformation matrix
  84201. * @returns the transformed Vector3
  84202. */
  84203. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84204. /**
  84205. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  84206. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84207. * @param vector defines the Vector3 to transform
  84208. * @param transformation defines the transformation matrix
  84209. * @param result defines the Vector3 where to store the result
  84210. */
  84211. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84212. /**
  84213. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  84214. * This method computes tranformed coordinates only, not transformed direction vectors
  84215. * @param x define the x coordinate of the source vector
  84216. * @param y define the y coordinate of the source vector
  84217. * @param z define the z coordinate of the source vector
  84218. * @param transformation defines the transformation matrix
  84219. * @param result defines the Vector3 where to store the result
  84220. */
  84221. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84222. /**
  84223. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  84224. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84225. * @param vector defines the Vector3 to transform
  84226. * @param transformation defines the transformation matrix
  84227. * @returns the new Vector3
  84228. */
  84229. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84230. /**
  84231. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  84232. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84233. * @param vector defines the Vector3 to transform
  84234. * @param transformation defines the transformation matrix
  84235. * @param result defines the Vector3 where to store the result
  84236. */
  84237. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84238. /**
  84239. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  84240. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84241. * @param x define the x coordinate of the source vector
  84242. * @param y define the y coordinate of the source vector
  84243. * @param z define the z coordinate of the source vector
  84244. * @param transformation defines the transformation matrix
  84245. * @param result defines the Vector3 where to store the result
  84246. */
  84247. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84248. /**
  84249. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  84250. * @param value1 defines the first control point
  84251. * @param value2 defines the second control point
  84252. * @param value3 defines the third control point
  84253. * @param value4 defines the fourth control point
  84254. * @param amount defines the amount on the spline to use
  84255. * @returns the new Vector3
  84256. */
  84257. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  84258. /**
  84259. * 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"
  84260. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84261. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84262. * @param value defines the current value
  84263. * @param min defines the lower range value
  84264. * @param max defines the upper range value
  84265. * @returns the new Vector3
  84266. */
  84267. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  84268. /**
  84269. * 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"
  84270. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84271. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84272. * @param value defines the current value
  84273. * @param min defines the lower range value
  84274. * @param max defines the upper range value
  84275. * @param result defines the Vector3 where to store the result
  84276. */
  84277. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  84278. /**
  84279. * Checks if a given vector is inside a specific range
  84280. * @param v defines the vector to test
  84281. * @param min defines the minimum range
  84282. * @param max defines the maximum range
  84283. */
  84284. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  84285. /**
  84286. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  84287. * @param value1 defines the first control point
  84288. * @param tangent1 defines the first tangent vector
  84289. * @param value2 defines the second control point
  84290. * @param tangent2 defines the second tangent vector
  84291. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  84292. * @returns the new Vector3
  84293. */
  84294. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  84295. /**
  84296. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  84297. * @param start defines the start value
  84298. * @param end defines the end value
  84299. * @param amount max defines amount between both (between 0 and 1)
  84300. * @returns the new Vector3
  84301. */
  84302. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  84303. /**
  84304. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  84305. * @param start defines the start value
  84306. * @param end defines the end value
  84307. * @param amount max defines amount between both (between 0 and 1)
  84308. * @param result defines the Vector3 where to store the result
  84309. */
  84310. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  84311. /**
  84312. * Returns the dot product (float) between the vectors "left" and "right"
  84313. * @param left defines the left operand
  84314. * @param right defines the right operand
  84315. * @returns the dot product
  84316. */
  84317. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  84318. /**
  84319. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  84320. * The cross product is then orthogonal to both "left" and "right"
  84321. * @param left defines the left operand
  84322. * @param right defines the right operand
  84323. * @returns the cross product
  84324. */
  84325. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84326. /**
  84327. * Sets the given vector "result" with the cross product of "left" and "right"
  84328. * The cross product is then orthogonal to both "left" and "right"
  84329. * @param left defines the left operand
  84330. * @param right defines the right operand
  84331. * @param result defines the Vector3 where to store the result
  84332. */
  84333. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  84334. /**
  84335. * Returns a new Vector3 as the normalization of the given vector
  84336. * @param vector defines the Vector3 to normalize
  84337. * @returns the new Vector3
  84338. */
  84339. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  84340. /**
  84341. * Sets the given vector "result" with the normalization of the given first vector
  84342. * @param vector defines the Vector3 to normalize
  84343. * @param result defines the Vector3 where to store the result
  84344. */
  84345. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  84346. /**
  84347. * Project a Vector3 onto screen space
  84348. * @param vector defines the Vector3 to project
  84349. * @param world defines the world matrix to use
  84350. * @param transform defines the transform (view x projection) matrix to use
  84351. * @param viewport defines the screen viewport to use
  84352. * @returns the new Vector3
  84353. */
  84354. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  84355. /**
  84356. * Project a Vector3 onto screen space to reference
  84357. * @param vector defines the Vector3 to project
  84358. * @param world defines the world matrix to use
  84359. * @param transform defines the transform (view x projection) matrix to use
  84360. * @param viewport defines the screen viewport to use
  84361. * @param result the vector in which the screen space will be stored
  84362. * @returns the new Vector3
  84363. */
  84364. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  84365. /** @hidden */
  84366. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  84367. /**
  84368. * Unproject from screen space to object space
  84369. * @param source defines the screen space Vector3 to use
  84370. * @param viewportWidth defines the current width of the viewport
  84371. * @param viewportHeight defines the current height of the viewport
  84372. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84373. * @param transform defines the transform (view x projection) matrix to use
  84374. * @returns the new Vector3
  84375. */
  84376. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  84377. /**
  84378. * Unproject from screen space to object space
  84379. * @param source defines the screen space Vector3 to use
  84380. * @param viewportWidth defines the current width of the viewport
  84381. * @param viewportHeight defines the current height of the viewport
  84382. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84383. * @param view defines the view matrix to use
  84384. * @param projection defines the projection matrix to use
  84385. * @returns the new Vector3
  84386. */
  84387. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  84388. /**
  84389. * Unproject from screen space to object space
  84390. * @param source defines the screen space Vector3 to use
  84391. * @param viewportWidth defines the current width of the viewport
  84392. * @param viewportHeight defines the current height of the viewport
  84393. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84394. * @param view defines the view matrix to use
  84395. * @param projection defines the projection matrix to use
  84396. * @param result defines the Vector3 where to store the result
  84397. */
  84398. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  84399. /**
  84400. * Unproject from screen space to object space
  84401. * @param sourceX defines the screen space x coordinate to use
  84402. * @param sourceY defines the screen space y coordinate to use
  84403. * @param sourceZ defines the screen space z coordinate to use
  84404. * @param viewportWidth defines the current width of the viewport
  84405. * @param viewportHeight defines the current height of the viewport
  84406. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84407. * @param view defines the view matrix to use
  84408. * @param projection defines the projection matrix to use
  84409. * @param result defines the Vector3 where to store the result
  84410. */
  84411. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  84412. /**
  84413. * Gets the minimal coordinate values between two Vector3
  84414. * @param left defines the first operand
  84415. * @param right defines the second operand
  84416. * @returns the new Vector3
  84417. */
  84418. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84419. /**
  84420. * Gets the maximal coordinate values between two Vector3
  84421. * @param left defines the first operand
  84422. * @param right defines the second operand
  84423. * @returns the new Vector3
  84424. */
  84425. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84426. /**
  84427. * Returns the distance between the vectors "value1" and "value2"
  84428. * @param value1 defines the first operand
  84429. * @param value2 defines the second operand
  84430. * @returns the distance
  84431. */
  84432. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84433. /**
  84434. * Returns the squared distance between the vectors "value1" and "value2"
  84435. * @param value1 defines the first operand
  84436. * @param value2 defines the second operand
  84437. * @returns the squared distance
  84438. */
  84439. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84440. /**
  84441. * Returns a new Vector3 located at the center between "value1" and "value2"
  84442. * @param value1 defines the first operand
  84443. * @param value2 defines the second operand
  84444. * @returns the new Vector3
  84445. */
  84446. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  84447. /**
  84448. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  84449. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  84450. * to something in order to rotate it from its local system to the given target system
  84451. * Note: axis1, axis2 and axis3 are normalized during this operation
  84452. * @param axis1 defines the first axis
  84453. * @param axis2 defines the second axis
  84454. * @param axis3 defines the third axis
  84455. * @returns a new Vector3
  84456. */
  84457. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  84458. /**
  84459. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  84460. * @param axis1 defines the first axis
  84461. * @param axis2 defines the second axis
  84462. * @param axis3 defines the third axis
  84463. * @param ref defines the Vector3 where to store the result
  84464. */
  84465. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  84466. }
  84467. /**
  84468. * Vector4 class created for EulerAngle class conversion to Quaternion
  84469. */
  84470. export class Vector4 {
  84471. /** x value of the vector */
  84472. x: number;
  84473. /** y value of the vector */
  84474. y: number;
  84475. /** z value of the vector */
  84476. z: number;
  84477. /** w value of the vector */
  84478. w: number;
  84479. /**
  84480. * Creates a Vector4 object from the given floats.
  84481. * @param x x value of the vector
  84482. * @param y y value of the vector
  84483. * @param z z value of the vector
  84484. * @param w w value of the vector
  84485. */
  84486. constructor(
  84487. /** x value of the vector */
  84488. x: number,
  84489. /** y value of the vector */
  84490. y: number,
  84491. /** z value of the vector */
  84492. z: number,
  84493. /** w value of the vector */
  84494. w: number);
  84495. /**
  84496. * Returns the string with the Vector4 coordinates.
  84497. * @returns a string containing all the vector values
  84498. */
  84499. toString(): string;
  84500. /**
  84501. * Returns the string "Vector4".
  84502. * @returns "Vector4"
  84503. */
  84504. getClassName(): string;
  84505. /**
  84506. * Returns the Vector4 hash code.
  84507. * @returns a unique hash code
  84508. */
  84509. getHashCode(): number;
  84510. /**
  84511. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  84512. * @returns the resulting array
  84513. */
  84514. asArray(): number[];
  84515. /**
  84516. * Populates the given array from the given index with the Vector4 coordinates.
  84517. * @param array array to populate
  84518. * @param index index of the array to start at (default: 0)
  84519. * @returns the Vector4.
  84520. */
  84521. toArray(array: FloatArray, index?: number): Vector4;
  84522. /**
  84523. * Update the current vector from an array
  84524. * @param array defines the destination array
  84525. * @param index defines the offset in the destination array
  84526. * @returns the current Vector3
  84527. */
  84528. fromArray(array: FloatArray, index?: number): Vector4;
  84529. /**
  84530. * Adds the given vector to the current Vector4.
  84531. * @param otherVector the vector to add
  84532. * @returns the updated Vector4.
  84533. */
  84534. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84535. /**
  84536. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  84537. * @param otherVector the vector to add
  84538. * @returns the resulting vector
  84539. */
  84540. add(otherVector: DeepImmutable<Vector4>): Vector4;
  84541. /**
  84542. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  84543. * @param otherVector the vector to add
  84544. * @param result the vector to store the result
  84545. * @returns the current Vector4.
  84546. */
  84547. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84548. /**
  84549. * Subtract in place the given vector from the current Vector4.
  84550. * @param otherVector the vector to subtract
  84551. * @returns the updated Vector4.
  84552. */
  84553. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84554. /**
  84555. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  84556. * @param otherVector the vector to add
  84557. * @returns the new vector with the result
  84558. */
  84559. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  84560. /**
  84561. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  84562. * @param otherVector the vector to subtract
  84563. * @param result the vector to store the result
  84564. * @returns the current Vector4.
  84565. */
  84566. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84567. /**
  84568. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84569. */
  84570. /**
  84571. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84572. * @param x value to subtract
  84573. * @param y value to subtract
  84574. * @param z value to subtract
  84575. * @param w value to subtract
  84576. * @returns new vector containing the result
  84577. */
  84578. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84579. /**
  84580. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84581. * @param x value to subtract
  84582. * @param y value to subtract
  84583. * @param z value to subtract
  84584. * @param w value to subtract
  84585. * @param result the vector to store the result in
  84586. * @returns the current Vector4.
  84587. */
  84588. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  84589. /**
  84590. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  84591. * @returns a new vector with the negated values
  84592. */
  84593. negate(): Vector4;
  84594. /**
  84595. * Negate this vector in place
  84596. * @returns this
  84597. */
  84598. negateInPlace(): Vector4;
  84599. /**
  84600. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  84601. * @param result defines the Vector3 object where to store the result
  84602. * @returns the current Vector4
  84603. */
  84604. negateToRef(result: Vector4): Vector4;
  84605. /**
  84606. * Multiplies the current Vector4 coordinates by scale (float).
  84607. * @param scale the number to scale with
  84608. * @returns the updated Vector4.
  84609. */
  84610. scaleInPlace(scale: number): Vector4;
  84611. /**
  84612. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84613. * @param scale the number to scale with
  84614. * @returns a new vector with the result
  84615. */
  84616. scale(scale: number): Vector4;
  84617. /**
  84618. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84619. * @param scale the number to scale with
  84620. * @param result a vector to store the result in
  84621. * @returns the current Vector4.
  84622. */
  84623. scaleToRef(scale: number, result: Vector4): Vector4;
  84624. /**
  84625. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84626. * @param scale defines the scale factor
  84627. * @param result defines the Vector4 object where to store the result
  84628. * @returns the unmodified current Vector4
  84629. */
  84630. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  84631. /**
  84632. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84633. * @param otherVector the vector to compare against
  84634. * @returns true if they are equal
  84635. */
  84636. equals(otherVector: DeepImmutable<Vector4>): boolean;
  84637. /**
  84638. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84639. * @param otherVector vector to compare against
  84640. * @param epsilon (Default: very small number)
  84641. * @returns true if they are equal
  84642. */
  84643. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  84644. /**
  84645. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84646. * @param x x value to compare against
  84647. * @param y y value to compare against
  84648. * @param z z value to compare against
  84649. * @param w w value to compare against
  84650. * @returns true if equal
  84651. */
  84652. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  84653. /**
  84654. * Multiplies in place the current Vector4 by the given one.
  84655. * @param otherVector vector to multiple with
  84656. * @returns the updated Vector4.
  84657. */
  84658. multiplyInPlace(otherVector: Vector4): Vector4;
  84659. /**
  84660. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84661. * @param otherVector vector to multiple with
  84662. * @returns resulting new vector
  84663. */
  84664. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  84665. /**
  84666. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84667. * @param otherVector vector to multiple with
  84668. * @param result vector to store the result
  84669. * @returns the current Vector4.
  84670. */
  84671. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84672. /**
  84673. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84674. * @param x x value multiply with
  84675. * @param y y value multiply with
  84676. * @param z z value multiply with
  84677. * @param w w value multiply with
  84678. * @returns resulting new vector
  84679. */
  84680. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  84681. /**
  84682. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84683. * @param otherVector vector to devide with
  84684. * @returns resulting new vector
  84685. */
  84686. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  84687. /**
  84688. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84689. * @param otherVector vector to devide with
  84690. * @param result vector to store the result
  84691. * @returns the current Vector4.
  84692. */
  84693. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84694. /**
  84695. * Divides the current Vector3 coordinates by the given ones.
  84696. * @param otherVector vector to devide with
  84697. * @returns the updated Vector3.
  84698. */
  84699. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84700. /**
  84701. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84702. * @param other defines the second operand
  84703. * @returns the current updated Vector4
  84704. */
  84705. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84706. /**
  84707. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84708. * @param other defines the second operand
  84709. * @returns the current updated Vector4
  84710. */
  84711. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84712. /**
  84713. * Gets a new Vector4 from current Vector4 floored values
  84714. * @returns a new Vector4
  84715. */
  84716. floor(): Vector4;
  84717. /**
  84718. * Gets a new Vector4 from current Vector3 floored values
  84719. * @returns a new Vector4
  84720. */
  84721. fract(): Vector4;
  84722. /**
  84723. * Returns the Vector4 length (float).
  84724. * @returns the length
  84725. */
  84726. length(): number;
  84727. /**
  84728. * Returns the Vector4 squared length (float).
  84729. * @returns the length squared
  84730. */
  84731. lengthSquared(): number;
  84732. /**
  84733. * Normalizes in place the Vector4.
  84734. * @returns the updated Vector4.
  84735. */
  84736. normalize(): Vector4;
  84737. /**
  84738. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84739. * @returns this converted to a new vector3
  84740. */
  84741. toVector3(): Vector3;
  84742. /**
  84743. * Returns a new Vector4 copied from the current one.
  84744. * @returns the new cloned vector
  84745. */
  84746. clone(): Vector4;
  84747. /**
  84748. * Updates the current Vector4 with the given one coordinates.
  84749. * @param source the source vector to copy from
  84750. * @returns the updated Vector4.
  84751. */
  84752. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84753. /**
  84754. * Updates the current Vector4 coordinates with the given floats.
  84755. * @param x float to copy from
  84756. * @param y float to copy from
  84757. * @param z float to copy from
  84758. * @param w float to copy from
  84759. * @returns the updated Vector4.
  84760. */
  84761. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84762. /**
  84763. * Updates the current Vector4 coordinates with the given floats.
  84764. * @param x float to set from
  84765. * @param y float to set from
  84766. * @param z float to set from
  84767. * @param w float to set from
  84768. * @returns the updated Vector4.
  84769. */
  84770. set(x: number, y: number, z: number, w: number): Vector4;
  84771. /**
  84772. * Copies the given float to the current Vector3 coordinates
  84773. * @param v defines the x, y, z and w coordinates of the operand
  84774. * @returns the current updated Vector3
  84775. */
  84776. setAll(v: number): Vector4;
  84777. /**
  84778. * Returns a new Vector4 set from the starting index of the given array.
  84779. * @param array the array to pull values from
  84780. * @param offset the offset into the array to start at
  84781. * @returns the new vector
  84782. */
  84783. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84784. /**
  84785. * Updates the given vector "result" from the starting index of the given array.
  84786. * @param array the array to pull values from
  84787. * @param offset the offset into the array to start at
  84788. * @param result the vector to store the result in
  84789. */
  84790. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84791. /**
  84792. * Updates the given vector "result" from the starting index of the given Float32Array.
  84793. * @param array the array to pull values from
  84794. * @param offset the offset into the array to start at
  84795. * @param result the vector to store the result in
  84796. */
  84797. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84798. /**
  84799. * Updates the given vector "result" coordinates from the given floats.
  84800. * @param x float to set from
  84801. * @param y float to set from
  84802. * @param z float to set from
  84803. * @param w float to set from
  84804. * @param result the vector to the floats in
  84805. */
  84806. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84807. /**
  84808. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84809. * @returns the new vector
  84810. */
  84811. static Zero(): Vector4;
  84812. /**
  84813. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84814. * @returns the new vector
  84815. */
  84816. static One(): Vector4;
  84817. /**
  84818. * Returns a new normalized Vector4 from the given one.
  84819. * @param vector the vector to normalize
  84820. * @returns the vector
  84821. */
  84822. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84823. /**
  84824. * Updates the given vector "result" from the normalization of the given one.
  84825. * @param vector the vector to normalize
  84826. * @param result the vector to store the result in
  84827. */
  84828. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84829. /**
  84830. * Returns a vector with the minimum values from the left and right vectors
  84831. * @param left left vector to minimize
  84832. * @param right right vector to minimize
  84833. * @returns a new vector with the minimum of the left and right vector values
  84834. */
  84835. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84836. /**
  84837. * Returns a vector with the maximum values from the left and right vectors
  84838. * @param left left vector to maximize
  84839. * @param right right vector to maximize
  84840. * @returns a new vector with the maximum of the left and right vector values
  84841. */
  84842. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84843. /**
  84844. * Returns the distance (float) between the vectors "value1" and "value2".
  84845. * @param value1 value to calulate the distance between
  84846. * @param value2 value to calulate the distance between
  84847. * @return the distance between the two vectors
  84848. */
  84849. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84850. /**
  84851. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84852. * @param value1 value to calulate the distance between
  84853. * @param value2 value to calulate the distance between
  84854. * @return the distance between the two vectors squared
  84855. */
  84856. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84857. /**
  84858. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84859. * @param value1 value to calulate the center between
  84860. * @param value2 value to calulate the center between
  84861. * @return the center between the two vectors
  84862. */
  84863. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84864. /**
  84865. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84866. * This methods computes transformed normalized direction vectors only.
  84867. * @param vector the vector to transform
  84868. * @param transformation the transformation matrix to apply
  84869. * @returns the new vector
  84870. */
  84871. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84872. /**
  84873. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84874. * This methods computes transformed normalized direction vectors only.
  84875. * @param vector the vector to transform
  84876. * @param transformation the transformation matrix to apply
  84877. * @param result the vector to store the result in
  84878. */
  84879. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84880. /**
  84881. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84882. * This methods computes transformed normalized direction vectors only.
  84883. * @param x value to transform
  84884. * @param y value to transform
  84885. * @param z value to transform
  84886. * @param w value to transform
  84887. * @param transformation the transformation matrix to apply
  84888. * @param result the vector to store the results in
  84889. */
  84890. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84891. /**
  84892. * Creates a new Vector4 from a Vector3
  84893. * @param source defines the source data
  84894. * @param w defines the 4th component (default is 0)
  84895. * @returns a new Vector4
  84896. */
  84897. static FromVector3(source: Vector3, w?: number): Vector4;
  84898. }
  84899. /**
  84900. * Class used to store quaternion data
  84901. * @see https://en.wikipedia.org/wiki/Quaternion
  84902. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84903. */
  84904. export class Quaternion {
  84905. /** @hidden */
  84906. _x: number;
  84907. /** @hidden */
  84908. _y: number;
  84909. /** @hidden */
  84910. _z: number;
  84911. /** @hidden */
  84912. _w: number;
  84913. /** @hidden */
  84914. _isDirty: boolean;
  84915. /** Gets or sets the x coordinate */
  84916. get x(): number;
  84917. set x(value: number);
  84918. /** Gets or sets the y coordinate */
  84919. get y(): number;
  84920. set y(value: number);
  84921. /** Gets or sets the z coordinate */
  84922. get z(): number;
  84923. set z(value: number);
  84924. /** Gets or sets the w coordinate */
  84925. get w(): number;
  84926. set w(value: number);
  84927. /**
  84928. * Creates a new Quaternion from the given floats
  84929. * @param x defines the first component (0 by default)
  84930. * @param y defines the second component (0 by default)
  84931. * @param z defines the third component (0 by default)
  84932. * @param w defines the fourth component (1.0 by default)
  84933. */
  84934. constructor(x?: number, y?: number, z?: number, w?: number);
  84935. /**
  84936. * Gets a string representation for the current quaternion
  84937. * @returns a string with the Quaternion coordinates
  84938. */
  84939. toString(): string;
  84940. /**
  84941. * Gets the class name of the quaternion
  84942. * @returns the string "Quaternion"
  84943. */
  84944. getClassName(): string;
  84945. /**
  84946. * Gets a hash code for this quaternion
  84947. * @returns the quaternion hash code
  84948. */
  84949. getHashCode(): number;
  84950. /**
  84951. * Copy the quaternion to an array
  84952. * @returns a new array populated with 4 elements from the quaternion coordinates
  84953. */
  84954. asArray(): number[];
  84955. /**
  84956. * Check if two quaternions are equals
  84957. * @param otherQuaternion defines the second operand
  84958. * @return true if the current quaternion and the given one coordinates are strictly equals
  84959. */
  84960. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84961. /**
  84962. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84963. * @param otherQuaternion defines the other quaternion
  84964. * @param epsilon defines the minimal distance to consider equality
  84965. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84966. */
  84967. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84968. /**
  84969. * Clone the current quaternion
  84970. * @returns a new quaternion copied from the current one
  84971. */
  84972. clone(): Quaternion;
  84973. /**
  84974. * Copy a quaternion to the current one
  84975. * @param other defines the other quaternion
  84976. * @returns the updated current quaternion
  84977. */
  84978. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84979. /**
  84980. * Updates the current quaternion with the given float coordinates
  84981. * @param x defines the x coordinate
  84982. * @param y defines the y coordinate
  84983. * @param z defines the z coordinate
  84984. * @param w defines the w coordinate
  84985. * @returns the updated current quaternion
  84986. */
  84987. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84988. /**
  84989. * Updates the current quaternion from the given float coordinates
  84990. * @param x defines the x coordinate
  84991. * @param y defines the y coordinate
  84992. * @param z defines the z coordinate
  84993. * @param w defines the w coordinate
  84994. * @returns the updated current quaternion
  84995. */
  84996. set(x: number, y: number, z: number, w: number): Quaternion;
  84997. /**
  84998. * Adds two quaternions
  84999. * @param other defines the second operand
  85000. * @returns a new quaternion as the addition result of the given one and the current quaternion
  85001. */
  85002. add(other: DeepImmutable<Quaternion>): Quaternion;
  85003. /**
  85004. * Add a quaternion to the current one
  85005. * @param other defines the quaternion to add
  85006. * @returns the current quaternion
  85007. */
  85008. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  85009. /**
  85010. * Subtract two quaternions
  85011. * @param other defines the second operand
  85012. * @returns a new quaternion as the subtraction result of the given one from the current one
  85013. */
  85014. subtract(other: Quaternion): Quaternion;
  85015. /**
  85016. * Multiplies the current quaternion by a scale factor
  85017. * @param value defines the scale factor
  85018. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  85019. */
  85020. scale(value: number): Quaternion;
  85021. /**
  85022. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  85023. * @param scale defines the scale factor
  85024. * @param result defines the Quaternion object where to store the result
  85025. * @returns the unmodified current quaternion
  85026. */
  85027. scaleToRef(scale: number, result: Quaternion): Quaternion;
  85028. /**
  85029. * Multiplies in place the current quaternion by a scale factor
  85030. * @param value defines the scale factor
  85031. * @returns the current modified quaternion
  85032. */
  85033. scaleInPlace(value: number): Quaternion;
  85034. /**
  85035. * Scale the current quaternion values by a factor and add the result to a given quaternion
  85036. * @param scale defines the scale factor
  85037. * @param result defines the Quaternion object where to store the result
  85038. * @returns the unmodified current quaternion
  85039. */
  85040. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  85041. /**
  85042. * Multiplies two quaternions
  85043. * @param q1 defines the second operand
  85044. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  85045. */
  85046. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  85047. /**
  85048. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  85049. * @param q1 defines the second operand
  85050. * @param result defines the target quaternion
  85051. * @returns the current quaternion
  85052. */
  85053. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  85054. /**
  85055. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  85056. * @param q1 defines the second operand
  85057. * @returns the currentupdated quaternion
  85058. */
  85059. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  85060. /**
  85061. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  85062. * @param ref defines the target quaternion
  85063. * @returns the current quaternion
  85064. */
  85065. conjugateToRef(ref: Quaternion): Quaternion;
  85066. /**
  85067. * Conjugates in place (1-q) the current quaternion
  85068. * @returns the current updated quaternion
  85069. */
  85070. conjugateInPlace(): Quaternion;
  85071. /**
  85072. * Conjugates in place (1-q) the current quaternion
  85073. * @returns a new quaternion
  85074. */
  85075. conjugate(): Quaternion;
  85076. /**
  85077. * Gets length of current quaternion
  85078. * @returns the quaternion length (float)
  85079. */
  85080. length(): number;
  85081. /**
  85082. * Normalize in place the current quaternion
  85083. * @returns the current updated quaternion
  85084. */
  85085. normalize(): Quaternion;
  85086. /**
  85087. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  85088. * @param order is a reserved parameter and is ignored for now
  85089. * @returns a new Vector3 containing the Euler angles
  85090. */
  85091. toEulerAngles(order?: string): Vector3;
  85092. /**
  85093. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  85094. * @param result defines the vector which will be filled with the Euler angles
  85095. * @returns the current unchanged quaternion
  85096. */
  85097. toEulerAnglesToRef(result: Vector3): Quaternion;
  85098. /**
  85099. * Updates the given rotation matrix with the current quaternion values
  85100. * @param result defines the target matrix
  85101. * @returns the current unchanged quaternion
  85102. */
  85103. toRotationMatrix(result: Matrix): Quaternion;
  85104. /**
  85105. * Updates the current quaternion from the given rotation matrix values
  85106. * @param matrix defines the source matrix
  85107. * @returns the current updated quaternion
  85108. */
  85109. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85110. /**
  85111. * Creates a new quaternion from a rotation matrix
  85112. * @param matrix defines the source matrix
  85113. * @returns a new quaternion created from the given rotation matrix values
  85114. */
  85115. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85116. /**
  85117. * Updates the given quaternion with the given rotation matrix values
  85118. * @param matrix defines the source matrix
  85119. * @param result defines the target quaternion
  85120. */
  85121. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  85122. /**
  85123. * Returns the dot product (float) between the quaternions "left" and "right"
  85124. * @param left defines the left operand
  85125. * @param right defines the right operand
  85126. * @returns the dot product
  85127. */
  85128. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  85129. /**
  85130. * Checks if the two quaternions are close to each other
  85131. * @param quat0 defines the first quaternion to check
  85132. * @param quat1 defines the second quaternion to check
  85133. * @returns true if the two quaternions are close to each other
  85134. */
  85135. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  85136. /**
  85137. * Creates an empty quaternion
  85138. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  85139. */
  85140. static Zero(): Quaternion;
  85141. /**
  85142. * Inverse a given quaternion
  85143. * @param q defines the source quaternion
  85144. * @returns a new quaternion as the inverted current quaternion
  85145. */
  85146. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  85147. /**
  85148. * Inverse a given quaternion
  85149. * @param q defines the source quaternion
  85150. * @param result the quaternion the result will be stored in
  85151. * @returns the result quaternion
  85152. */
  85153. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  85154. /**
  85155. * Creates an identity quaternion
  85156. * @returns the identity quaternion
  85157. */
  85158. static Identity(): Quaternion;
  85159. /**
  85160. * Gets a boolean indicating if the given quaternion is identity
  85161. * @param quaternion defines the quaternion to check
  85162. * @returns true if the quaternion is identity
  85163. */
  85164. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  85165. /**
  85166. * Creates a quaternion from a rotation around an axis
  85167. * @param axis defines the axis to use
  85168. * @param angle defines the angle to use
  85169. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  85170. */
  85171. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  85172. /**
  85173. * Creates a rotation around an axis and stores it into the given quaternion
  85174. * @param axis defines the axis to use
  85175. * @param angle defines the angle to use
  85176. * @param result defines the target quaternion
  85177. * @returns the target quaternion
  85178. */
  85179. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  85180. /**
  85181. * Creates a new quaternion from data stored into an array
  85182. * @param array defines the data source
  85183. * @param offset defines the offset in the source array where the data starts
  85184. * @returns a new quaternion
  85185. */
  85186. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  85187. /**
  85188. * Updates the given quaternion "result" from the starting index of the given array.
  85189. * @param array the array to pull values from
  85190. * @param offset the offset into the array to start at
  85191. * @param result the quaternion to store the result in
  85192. */
  85193. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  85194. /**
  85195. * Create a quaternion from Euler rotation angles
  85196. * @param x Pitch
  85197. * @param y Yaw
  85198. * @param z Roll
  85199. * @returns the new Quaternion
  85200. */
  85201. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  85202. /**
  85203. * Updates a quaternion from Euler rotation angles
  85204. * @param x Pitch
  85205. * @param y Yaw
  85206. * @param z Roll
  85207. * @param result the quaternion to store the result
  85208. * @returns the updated quaternion
  85209. */
  85210. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  85211. /**
  85212. * Create a quaternion from Euler rotation vector
  85213. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85214. * @returns the new Quaternion
  85215. */
  85216. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  85217. /**
  85218. * Updates a quaternion from Euler rotation vector
  85219. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85220. * @param result the quaternion to store the result
  85221. * @returns the updated quaternion
  85222. */
  85223. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  85224. /**
  85225. * Creates a new quaternion from the given Euler float angles (y, x, z)
  85226. * @param yaw defines the rotation around Y axis
  85227. * @param pitch defines the rotation around X axis
  85228. * @param roll defines the rotation around Z axis
  85229. * @returns the new quaternion
  85230. */
  85231. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  85232. /**
  85233. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  85234. * @param yaw defines the rotation around Y axis
  85235. * @param pitch defines the rotation around X axis
  85236. * @param roll defines the rotation around Z axis
  85237. * @param result defines the target quaternion
  85238. */
  85239. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  85240. /**
  85241. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  85242. * @param alpha defines the rotation around first axis
  85243. * @param beta defines the rotation around second axis
  85244. * @param gamma defines the rotation around third axis
  85245. * @returns the new quaternion
  85246. */
  85247. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  85248. /**
  85249. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  85250. * @param alpha defines the rotation around first axis
  85251. * @param beta defines the rotation around second axis
  85252. * @param gamma defines the rotation around third axis
  85253. * @param result defines the target quaternion
  85254. */
  85255. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  85256. /**
  85257. * 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)
  85258. * @param axis1 defines the first axis
  85259. * @param axis2 defines the second axis
  85260. * @param axis3 defines the third axis
  85261. * @returns the new quaternion
  85262. */
  85263. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  85264. /**
  85265. * 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
  85266. * @param axis1 defines the first axis
  85267. * @param axis2 defines the second axis
  85268. * @param axis3 defines the third axis
  85269. * @param ref defines the target quaternion
  85270. */
  85271. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  85272. /**
  85273. * Interpolates between two quaternions
  85274. * @param left defines first quaternion
  85275. * @param right defines second quaternion
  85276. * @param amount defines the gradient to use
  85277. * @returns the new interpolated quaternion
  85278. */
  85279. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85280. /**
  85281. * Interpolates between two quaternions and stores it into a target quaternion
  85282. * @param left defines first quaternion
  85283. * @param right defines second quaternion
  85284. * @param amount defines the gradient to use
  85285. * @param result defines the target quaternion
  85286. */
  85287. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  85288. /**
  85289. * Interpolate between two quaternions using Hermite interpolation
  85290. * @param value1 defines first quaternion
  85291. * @param tangent1 defines the incoming tangent
  85292. * @param value2 defines second quaternion
  85293. * @param tangent2 defines the outgoing tangent
  85294. * @param amount defines the target quaternion
  85295. * @returns the new interpolated quaternion
  85296. */
  85297. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85298. }
  85299. /**
  85300. * Class used to store matrix data (4x4)
  85301. */
  85302. export class Matrix {
  85303. /**
  85304. * Gets the precision of matrix computations
  85305. */
  85306. static get Use64Bits(): boolean;
  85307. private static _updateFlagSeed;
  85308. private static _identityReadOnly;
  85309. private _isIdentity;
  85310. private _isIdentityDirty;
  85311. private _isIdentity3x2;
  85312. private _isIdentity3x2Dirty;
  85313. /**
  85314. * Gets the update flag of the matrix which is an unique number for the matrix.
  85315. * It will be incremented every time the matrix data change.
  85316. * You can use it to speed the comparison between two versions of the same matrix.
  85317. */
  85318. updateFlag: number;
  85319. private readonly _m;
  85320. /**
  85321. * Gets the internal data of the matrix
  85322. */
  85323. get m(): DeepImmutable<Float32Array | Array<number>>;
  85324. /** @hidden */
  85325. _markAsUpdated(): void;
  85326. /** @hidden */
  85327. private _updateIdentityStatus;
  85328. /**
  85329. * Creates an empty matrix (filled with zeros)
  85330. */
  85331. constructor();
  85332. /**
  85333. * Check if the current matrix is identity
  85334. * @returns true is the matrix is the identity matrix
  85335. */
  85336. isIdentity(): boolean;
  85337. /**
  85338. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  85339. * @returns true is the matrix is the identity matrix
  85340. */
  85341. isIdentityAs3x2(): boolean;
  85342. /**
  85343. * Gets the determinant of the matrix
  85344. * @returns the matrix determinant
  85345. */
  85346. determinant(): number;
  85347. /**
  85348. * Returns the matrix as a Float32Array or Array<number>
  85349. * @returns the matrix underlying array
  85350. */
  85351. toArray(): DeepImmutable<Float32Array | Array<number>>;
  85352. /**
  85353. * Returns the matrix as a Float32Array or Array<number>
  85354. * @returns the matrix underlying array.
  85355. */
  85356. asArray(): DeepImmutable<Float32Array | Array<number>>;
  85357. /**
  85358. * Inverts the current matrix in place
  85359. * @returns the current inverted matrix
  85360. */
  85361. invert(): Matrix;
  85362. /**
  85363. * Sets all the matrix elements to zero
  85364. * @returns the current matrix
  85365. */
  85366. reset(): Matrix;
  85367. /**
  85368. * Adds the current matrix with a second one
  85369. * @param other defines the matrix to add
  85370. * @returns a new matrix as the addition of the current matrix and the given one
  85371. */
  85372. add(other: DeepImmutable<Matrix>): Matrix;
  85373. /**
  85374. * Sets the given matrix "result" to the addition of the current matrix and the given one
  85375. * @param other defines the matrix to add
  85376. * @param result defines the target matrix
  85377. * @returns the current matrix
  85378. */
  85379. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85380. /**
  85381. * Adds in place the given matrix to the current matrix
  85382. * @param other defines the second operand
  85383. * @returns the current updated matrix
  85384. */
  85385. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  85386. /**
  85387. * Sets the given matrix to the current inverted Matrix
  85388. * @param other defines the target matrix
  85389. * @returns the unmodified current matrix
  85390. */
  85391. invertToRef(other: Matrix): Matrix;
  85392. /**
  85393. * add a value at the specified position in the current Matrix
  85394. * @param index the index of the value within the matrix. between 0 and 15.
  85395. * @param value the value to be added
  85396. * @returns the current updated matrix
  85397. */
  85398. addAtIndex(index: number, value: number): Matrix;
  85399. /**
  85400. * mutiply the specified position in the current Matrix by a value
  85401. * @param index the index of the value within the matrix. between 0 and 15.
  85402. * @param value the value to be added
  85403. * @returns the current updated matrix
  85404. */
  85405. multiplyAtIndex(index: number, value: number): Matrix;
  85406. /**
  85407. * Inserts the translation vector (using 3 floats) in the current matrix
  85408. * @param x defines the 1st component of the translation
  85409. * @param y defines the 2nd component of the translation
  85410. * @param z defines the 3rd component of the translation
  85411. * @returns the current updated matrix
  85412. */
  85413. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85414. /**
  85415. * Adds the translation vector (using 3 floats) in the current matrix
  85416. * @param x defines the 1st component of the translation
  85417. * @param y defines the 2nd component of the translation
  85418. * @param z defines the 3rd component of the translation
  85419. * @returns the current updated matrix
  85420. */
  85421. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85422. /**
  85423. * Inserts the translation vector in the current matrix
  85424. * @param vector3 defines the translation to insert
  85425. * @returns the current updated matrix
  85426. */
  85427. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  85428. /**
  85429. * Gets the translation value of the current matrix
  85430. * @returns a new Vector3 as the extracted translation from the matrix
  85431. */
  85432. getTranslation(): Vector3;
  85433. /**
  85434. * Fill a Vector3 with the extracted translation from the matrix
  85435. * @param result defines the Vector3 where to store the translation
  85436. * @returns the current matrix
  85437. */
  85438. getTranslationToRef(result: Vector3): Matrix;
  85439. /**
  85440. * Remove rotation and scaling part from the matrix
  85441. * @returns the updated matrix
  85442. */
  85443. removeRotationAndScaling(): Matrix;
  85444. /**
  85445. * Multiply two matrices
  85446. * @param other defines the second operand
  85447. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  85448. */
  85449. multiply(other: DeepImmutable<Matrix>): Matrix;
  85450. /**
  85451. * Copy the current matrix from the given one
  85452. * @param other defines the source matrix
  85453. * @returns the current updated matrix
  85454. */
  85455. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  85456. /**
  85457. * Populates the given array from the starting index with the current matrix values
  85458. * @param array defines the target array
  85459. * @param offset defines the offset in the target array where to start storing values
  85460. * @returns the current matrix
  85461. */
  85462. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  85463. /**
  85464. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  85465. * @param other defines the second operand
  85466. * @param result defines the matrix where to store the multiplication
  85467. * @returns the current matrix
  85468. */
  85469. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85470. /**
  85471. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  85472. * @param other defines the second operand
  85473. * @param result defines the array where to store the multiplication
  85474. * @param offset defines the offset in the target array where to start storing values
  85475. * @returns the current matrix
  85476. */
  85477. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  85478. /**
  85479. * Check equality between this matrix and a second one
  85480. * @param value defines the second matrix to compare
  85481. * @returns true is the current matrix and the given one values are strictly equal
  85482. */
  85483. equals(value: DeepImmutable<Matrix>): boolean;
  85484. /**
  85485. * Clone the current matrix
  85486. * @returns a new matrix from the current matrix
  85487. */
  85488. clone(): Matrix;
  85489. /**
  85490. * Returns the name of the current matrix class
  85491. * @returns the string "Matrix"
  85492. */
  85493. getClassName(): string;
  85494. /**
  85495. * Gets the hash code of the current matrix
  85496. * @returns the hash code
  85497. */
  85498. getHashCode(): number;
  85499. /**
  85500. * Decomposes the current Matrix into a translation, rotation and scaling components
  85501. * @param scale defines the scale vector3 given as a reference to update
  85502. * @param rotation defines the rotation quaternion given as a reference to update
  85503. * @param translation defines the translation vector3 given as a reference to update
  85504. * @returns true if operation was successful
  85505. */
  85506. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  85507. /**
  85508. * Gets specific row of the matrix
  85509. * @param index defines the number of the row to get
  85510. * @returns the index-th row of the current matrix as a new Vector4
  85511. */
  85512. getRow(index: number): Nullable<Vector4>;
  85513. /**
  85514. * Sets the index-th row of the current matrix to the vector4 values
  85515. * @param index defines the number of the row to set
  85516. * @param row defines the target vector4
  85517. * @returns the updated current matrix
  85518. */
  85519. setRow(index: number, row: Vector4): Matrix;
  85520. /**
  85521. * Compute the transpose of the matrix
  85522. * @returns the new transposed matrix
  85523. */
  85524. transpose(): Matrix;
  85525. /**
  85526. * Compute the transpose of the matrix and store it in a given matrix
  85527. * @param result defines the target matrix
  85528. * @returns the current matrix
  85529. */
  85530. transposeToRef(result: Matrix): Matrix;
  85531. /**
  85532. * Sets the index-th row of the current matrix with the given 4 x float values
  85533. * @param index defines the row index
  85534. * @param x defines the x component to set
  85535. * @param y defines the y component to set
  85536. * @param z defines the z component to set
  85537. * @param w defines the w component to set
  85538. * @returns the updated current matrix
  85539. */
  85540. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  85541. /**
  85542. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  85543. * @param scale defines the scale factor
  85544. * @returns a new matrix
  85545. */
  85546. scale(scale: number): Matrix;
  85547. /**
  85548. * Scale the current matrix values by a factor to a given result matrix
  85549. * @param scale defines the scale factor
  85550. * @param result defines the matrix to store the result
  85551. * @returns the current matrix
  85552. */
  85553. scaleToRef(scale: number, result: Matrix): Matrix;
  85554. /**
  85555. * Scale the current matrix values by a factor and add the result to a given matrix
  85556. * @param scale defines the scale factor
  85557. * @param result defines the Matrix to store the result
  85558. * @returns the current matrix
  85559. */
  85560. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  85561. /**
  85562. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  85563. * @param ref matrix to store the result
  85564. */
  85565. toNormalMatrix(ref: Matrix): void;
  85566. /**
  85567. * Gets only rotation part of the current matrix
  85568. * @returns a new matrix sets to the extracted rotation matrix from the current one
  85569. */
  85570. getRotationMatrix(): Matrix;
  85571. /**
  85572. * Extracts the rotation matrix from the current one and sets it as the given "result"
  85573. * @param result defines the target matrix to store data to
  85574. * @returns the current matrix
  85575. */
  85576. getRotationMatrixToRef(result: Matrix): Matrix;
  85577. /**
  85578. * Toggles model matrix from being right handed to left handed in place and vice versa
  85579. */
  85580. toggleModelMatrixHandInPlace(): void;
  85581. /**
  85582. * Toggles projection matrix from being right handed to left handed in place and vice versa
  85583. */
  85584. toggleProjectionMatrixHandInPlace(): void;
  85585. /**
  85586. * Creates a matrix from an array
  85587. * @param array defines the source array
  85588. * @param offset defines an offset in the source array
  85589. * @returns a new Matrix set from the starting index of the given array
  85590. */
  85591. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  85592. /**
  85593. * Copy the content of an array into a given matrix
  85594. * @param array defines the source array
  85595. * @param offset defines an offset in the source array
  85596. * @param result defines the target matrix
  85597. */
  85598. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  85599. /**
  85600. * Stores an array into a matrix after having multiplied each component by a given factor
  85601. * @param array defines the source array
  85602. * @param offset defines the offset in the source array
  85603. * @param scale defines the scaling factor
  85604. * @param result defines the target matrix
  85605. */
  85606. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  85607. /**
  85608. * Gets an identity matrix that must not be updated
  85609. */
  85610. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  85611. /**
  85612. * Stores a list of values (16) inside a given matrix
  85613. * @param initialM11 defines 1st value of 1st row
  85614. * @param initialM12 defines 2nd value of 1st row
  85615. * @param initialM13 defines 3rd value of 1st row
  85616. * @param initialM14 defines 4th value of 1st row
  85617. * @param initialM21 defines 1st value of 2nd row
  85618. * @param initialM22 defines 2nd value of 2nd row
  85619. * @param initialM23 defines 3rd value of 2nd row
  85620. * @param initialM24 defines 4th value of 2nd row
  85621. * @param initialM31 defines 1st value of 3rd row
  85622. * @param initialM32 defines 2nd value of 3rd row
  85623. * @param initialM33 defines 3rd value of 3rd row
  85624. * @param initialM34 defines 4th value of 3rd row
  85625. * @param initialM41 defines 1st value of 4th row
  85626. * @param initialM42 defines 2nd value of 4th row
  85627. * @param initialM43 defines 3rd value of 4th row
  85628. * @param initialM44 defines 4th value of 4th row
  85629. * @param result defines the target matrix
  85630. */
  85631. 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;
  85632. /**
  85633. * Creates new matrix from a list of values (16)
  85634. * @param initialM11 defines 1st value of 1st row
  85635. * @param initialM12 defines 2nd value of 1st row
  85636. * @param initialM13 defines 3rd value of 1st row
  85637. * @param initialM14 defines 4th value of 1st row
  85638. * @param initialM21 defines 1st value of 2nd row
  85639. * @param initialM22 defines 2nd value of 2nd row
  85640. * @param initialM23 defines 3rd value of 2nd row
  85641. * @param initialM24 defines 4th value of 2nd row
  85642. * @param initialM31 defines 1st value of 3rd row
  85643. * @param initialM32 defines 2nd value of 3rd row
  85644. * @param initialM33 defines 3rd value of 3rd row
  85645. * @param initialM34 defines 4th value of 3rd row
  85646. * @param initialM41 defines 1st value of 4th row
  85647. * @param initialM42 defines 2nd value of 4th row
  85648. * @param initialM43 defines 3rd value of 4th row
  85649. * @param initialM44 defines 4th value of 4th row
  85650. * @returns the new matrix
  85651. */
  85652. 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;
  85653. /**
  85654. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85655. * @param scale defines the scale vector3
  85656. * @param rotation defines the rotation quaternion
  85657. * @param translation defines the translation vector3
  85658. * @returns a new matrix
  85659. */
  85660. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  85661. /**
  85662. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85663. * @param scale defines the scale vector3
  85664. * @param rotation defines the rotation quaternion
  85665. * @param translation defines the translation vector3
  85666. * @param result defines the target matrix
  85667. */
  85668. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  85669. /**
  85670. * Creates a new identity matrix
  85671. * @returns a new identity matrix
  85672. */
  85673. static Identity(): Matrix;
  85674. /**
  85675. * Creates a new identity matrix and stores the result in a given matrix
  85676. * @param result defines the target matrix
  85677. */
  85678. static IdentityToRef(result: Matrix): void;
  85679. /**
  85680. * Creates a new zero matrix
  85681. * @returns a new zero matrix
  85682. */
  85683. static Zero(): Matrix;
  85684. /**
  85685. * Creates a new rotation matrix for "angle" radians around the X axis
  85686. * @param angle defines the angle (in radians) to use
  85687. * @return the new matrix
  85688. */
  85689. static RotationX(angle: number): Matrix;
  85690. /**
  85691. * Creates a new matrix as the invert of a given matrix
  85692. * @param source defines the source matrix
  85693. * @returns the new matrix
  85694. */
  85695. static Invert(source: DeepImmutable<Matrix>): Matrix;
  85696. /**
  85697. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  85698. * @param angle defines the angle (in radians) to use
  85699. * @param result defines the target matrix
  85700. */
  85701. static RotationXToRef(angle: number, result: Matrix): void;
  85702. /**
  85703. * Creates a new rotation matrix for "angle" radians around the Y axis
  85704. * @param angle defines the angle (in radians) to use
  85705. * @return the new matrix
  85706. */
  85707. static RotationY(angle: number): Matrix;
  85708. /**
  85709. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  85710. * @param angle defines the angle (in radians) to use
  85711. * @param result defines the target matrix
  85712. */
  85713. static RotationYToRef(angle: number, result: Matrix): void;
  85714. /**
  85715. * Creates a new rotation matrix for "angle" radians around the Z axis
  85716. * @param angle defines the angle (in radians) to use
  85717. * @return the new matrix
  85718. */
  85719. static RotationZ(angle: number): Matrix;
  85720. /**
  85721. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  85722. * @param angle defines the angle (in radians) to use
  85723. * @param result defines the target matrix
  85724. */
  85725. static RotationZToRef(angle: number, result: Matrix): void;
  85726. /**
  85727. * Creates a new rotation matrix for "angle" radians around the given axis
  85728. * @param axis defines the axis to use
  85729. * @param angle defines the angle (in radians) to use
  85730. * @return the new matrix
  85731. */
  85732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85733. /**
  85734. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85735. * @param axis defines the axis to use
  85736. * @param angle defines the angle (in radians) to use
  85737. * @param result defines the target matrix
  85738. */
  85739. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85740. /**
  85741. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85742. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85743. * @param from defines the vector to align
  85744. * @param to defines the vector to align to
  85745. * @param result defines the target matrix
  85746. */
  85747. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85748. /**
  85749. * Creates a rotation matrix
  85750. * @param yaw defines the yaw angle in radians (Y axis)
  85751. * @param pitch defines the pitch angle in radians (X axis)
  85752. * @param roll defines the roll angle in radians (Z axis)
  85753. * @returns the new rotation matrix
  85754. */
  85755. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85756. /**
  85757. * Creates a rotation matrix and stores it in a given matrix
  85758. * @param yaw defines the yaw angle in radians (Y axis)
  85759. * @param pitch defines the pitch angle in radians (X axis)
  85760. * @param roll defines the roll angle in radians (Z axis)
  85761. * @param result defines the target matrix
  85762. */
  85763. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85764. /**
  85765. * Creates a scaling matrix
  85766. * @param x defines the scale factor on X axis
  85767. * @param y defines the scale factor on Y axis
  85768. * @param z defines the scale factor on Z axis
  85769. * @returns the new matrix
  85770. */
  85771. static Scaling(x: number, y: number, z: number): Matrix;
  85772. /**
  85773. * Creates a scaling matrix and stores it in a given matrix
  85774. * @param x defines the scale factor on X axis
  85775. * @param y defines the scale factor on Y axis
  85776. * @param z defines the scale factor on Z axis
  85777. * @param result defines the target matrix
  85778. */
  85779. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85780. /**
  85781. * Creates a translation matrix
  85782. * @param x defines the translation on X axis
  85783. * @param y defines the translation on Y axis
  85784. * @param z defines the translationon Z axis
  85785. * @returns the new matrix
  85786. */
  85787. static Translation(x: number, y: number, z: number): Matrix;
  85788. /**
  85789. * Creates a translation matrix and stores it in a given matrix
  85790. * @param x defines the translation on X axis
  85791. * @param y defines the translation on Y axis
  85792. * @param z defines the translationon Z axis
  85793. * @param result defines the target matrix
  85794. */
  85795. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85796. /**
  85797. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85798. * @param startValue defines the start value
  85799. * @param endValue defines the end value
  85800. * @param gradient defines the gradient factor
  85801. * @returns the new matrix
  85802. */
  85803. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85804. /**
  85805. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85806. * @param startValue defines the start value
  85807. * @param endValue defines the end value
  85808. * @param gradient defines the gradient factor
  85809. * @param result defines the Matrix object where to store data
  85810. */
  85811. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85812. /**
  85813. * Builds a new matrix whose values are computed by:
  85814. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85815. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85816. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85817. * @param startValue defines the first matrix
  85818. * @param endValue defines the second matrix
  85819. * @param gradient defines the gradient between the two matrices
  85820. * @returns the new matrix
  85821. */
  85822. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85823. /**
  85824. * Update a matrix to values which are computed by:
  85825. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85826. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85827. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85828. * @param startValue defines the first matrix
  85829. * @param endValue defines the second matrix
  85830. * @param gradient defines the gradient between the two matrices
  85831. * @param result defines the target matrix
  85832. */
  85833. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85834. /**
  85835. * 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"
  85836. * This function works in left handed mode
  85837. * @param eye defines the final position of the entity
  85838. * @param target defines where the entity should look at
  85839. * @param up defines the up vector for the entity
  85840. * @returns the new matrix
  85841. */
  85842. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85843. /**
  85844. * 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".
  85845. * This function works in left handed mode
  85846. * @param eye defines the final position of the entity
  85847. * @param target defines where the entity should look at
  85848. * @param up defines the up vector for the entity
  85849. * @param result defines the target matrix
  85850. */
  85851. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85852. /**
  85853. * 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"
  85854. * This function works in right handed mode
  85855. * @param eye defines the final position of the entity
  85856. * @param target defines where the entity should look at
  85857. * @param up defines the up vector for the entity
  85858. * @returns the new matrix
  85859. */
  85860. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85861. /**
  85862. * 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".
  85863. * This function works in right handed mode
  85864. * @param eye defines the final position of the entity
  85865. * @param target defines where the entity should look at
  85866. * @param up defines the up vector for the entity
  85867. * @param result defines the target matrix
  85868. */
  85869. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85870. /**
  85871. * Create a left-handed orthographic projection matrix
  85872. * @param width defines the viewport width
  85873. * @param height defines the viewport height
  85874. * @param znear defines the near clip plane
  85875. * @param zfar defines the far clip plane
  85876. * @returns a new matrix as a left-handed orthographic projection matrix
  85877. */
  85878. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85879. /**
  85880. * Store a left-handed orthographic projection to a given matrix
  85881. * @param width defines the viewport width
  85882. * @param height defines the viewport height
  85883. * @param znear defines the near clip plane
  85884. * @param zfar defines the far clip plane
  85885. * @param result defines the target matrix
  85886. */
  85887. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85888. /**
  85889. * Create a left-handed orthographic projection matrix
  85890. * @param left defines the viewport left coordinate
  85891. * @param right defines the viewport right coordinate
  85892. * @param bottom defines the viewport bottom coordinate
  85893. * @param top defines the viewport top coordinate
  85894. * @param znear defines the near clip plane
  85895. * @param zfar defines the far clip plane
  85896. * @returns a new matrix as a left-handed orthographic projection matrix
  85897. */
  85898. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85899. /**
  85900. * Stores a left-handed orthographic projection into a given matrix
  85901. * @param left defines the viewport left coordinate
  85902. * @param right defines the viewport right coordinate
  85903. * @param bottom defines the viewport bottom coordinate
  85904. * @param top defines the viewport top coordinate
  85905. * @param znear defines the near clip plane
  85906. * @param zfar defines the far clip plane
  85907. * @param result defines the target matrix
  85908. */
  85909. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85910. /**
  85911. * Creates a right-handed orthographic projection matrix
  85912. * @param left defines the viewport left coordinate
  85913. * @param right defines the viewport right coordinate
  85914. * @param bottom defines the viewport bottom coordinate
  85915. * @param top defines the viewport top coordinate
  85916. * @param znear defines the near clip plane
  85917. * @param zfar defines the far clip plane
  85918. * @returns a new matrix as a right-handed orthographic projection matrix
  85919. */
  85920. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85921. /**
  85922. * Stores a right-handed orthographic projection into a given matrix
  85923. * @param left defines the viewport left coordinate
  85924. * @param right defines the viewport right coordinate
  85925. * @param bottom defines the viewport bottom coordinate
  85926. * @param top defines the viewport top coordinate
  85927. * @param znear defines the near clip plane
  85928. * @param zfar defines the far clip plane
  85929. * @param result defines the target matrix
  85930. */
  85931. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85932. /**
  85933. * Creates a left-handed perspective projection matrix
  85934. * @param width defines the viewport width
  85935. * @param height defines the viewport height
  85936. * @param znear defines the near clip plane
  85937. * @param zfar defines the far clip plane
  85938. * @returns a new matrix as a left-handed perspective projection matrix
  85939. */
  85940. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85941. /**
  85942. * Creates a left-handed perspective projection matrix
  85943. * @param fov defines the horizontal field of view
  85944. * @param aspect defines the aspect ratio
  85945. * @param znear defines the near clip plane
  85946. * @param zfar defines the far clip plane
  85947. * @returns a new matrix as a left-handed perspective projection matrix
  85948. */
  85949. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85950. /**
  85951. * Stores a left-handed perspective projection into a given matrix
  85952. * @param fov defines the horizontal field of view
  85953. * @param aspect defines the aspect ratio
  85954. * @param znear defines the near clip plane
  85955. * @param zfar defines the far clip plane
  85956. * @param result defines the target matrix
  85957. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85958. */
  85959. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85960. /**
  85961. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85962. * @param fov defines the horizontal field of view
  85963. * @param aspect defines the aspect ratio
  85964. * @param znear defines the near clip plane
  85965. * @param zfar not used as infinity is used as far clip
  85966. * @param result defines the target matrix
  85967. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85968. */
  85969. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85970. /**
  85971. * Creates a right-handed perspective projection matrix
  85972. * @param fov defines the horizontal field of view
  85973. * @param aspect defines the aspect ratio
  85974. * @param znear defines the near clip plane
  85975. * @param zfar defines the far clip plane
  85976. * @returns a new matrix as a right-handed perspective projection matrix
  85977. */
  85978. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85979. /**
  85980. * Stores a right-handed perspective projection into a given matrix
  85981. * @param fov defines the horizontal field of view
  85982. * @param aspect defines the aspect ratio
  85983. * @param znear defines the near clip plane
  85984. * @param zfar defines the far clip plane
  85985. * @param result defines the target matrix
  85986. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85987. */
  85988. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85989. /**
  85990. * Stores a right-handed perspective projection into a given matrix
  85991. * @param fov defines the horizontal field of view
  85992. * @param aspect defines the aspect ratio
  85993. * @param znear defines the near clip plane
  85994. * @param zfar not used as infinity is used as far clip
  85995. * @param result defines the target matrix
  85996. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85997. */
  85998. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85999. /**
  86000. * Stores a perspective projection for WebVR info a given matrix
  86001. * @param fov defines the field of view
  86002. * @param znear defines the near clip plane
  86003. * @param zfar defines the far clip plane
  86004. * @param result defines the target matrix
  86005. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  86006. */
  86007. static PerspectiveFovWebVRToRef(fov: {
  86008. upDegrees: number;
  86009. downDegrees: number;
  86010. leftDegrees: number;
  86011. rightDegrees: number;
  86012. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  86013. /**
  86014. * Computes a complete transformation matrix
  86015. * @param viewport defines the viewport to use
  86016. * @param world defines the world matrix
  86017. * @param view defines the view matrix
  86018. * @param projection defines the projection matrix
  86019. * @param zmin defines the near clip plane
  86020. * @param zmax defines the far clip plane
  86021. * @returns the transformation matrix
  86022. */
  86023. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  86024. /**
  86025. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  86026. * @param matrix defines the matrix to use
  86027. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  86028. */
  86029. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86030. /**
  86031. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  86032. * @param matrix defines the matrix to use
  86033. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  86034. */
  86035. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86036. /**
  86037. * Compute the transpose of a given matrix
  86038. * @param matrix defines the matrix to transpose
  86039. * @returns the new matrix
  86040. */
  86041. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  86042. /**
  86043. * Compute the transpose of a matrix and store it in a target matrix
  86044. * @param matrix defines the matrix to transpose
  86045. * @param result defines the target matrix
  86046. */
  86047. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  86048. /**
  86049. * Computes a reflection matrix from a plane
  86050. * @param plane defines the reflection plane
  86051. * @returns a new matrix
  86052. */
  86053. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  86054. /**
  86055. * Computes a reflection matrix from a plane
  86056. * @param plane defines the reflection plane
  86057. * @param result defines the target matrix
  86058. */
  86059. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  86060. /**
  86061. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  86062. * @param xaxis defines the value of the 1st axis
  86063. * @param yaxis defines the value of the 2nd axis
  86064. * @param zaxis defines the value of the 3rd axis
  86065. * @param result defines the target matrix
  86066. */
  86067. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  86068. /**
  86069. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  86070. * @param quat defines the quaternion to use
  86071. * @param result defines the target matrix
  86072. */
  86073. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  86074. }
  86075. /**
  86076. * @hidden
  86077. */
  86078. export class TmpVectors {
  86079. static Vector2: Vector2[];
  86080. static Vector3: Vector3[];
  86081. static Vector4: Vector4[];
  86082. static Quaternion: Quaternion[];
  86083. static Matrix: Matrix[];
  86084. }
  86085. }
  86086. declare module BABYLON {
  86087. /**
  86088. * Defines potential orientation for back face culling
  86089. */
  86090. export enum Orientation {
  86091. /**
  86092. * Clockwise
  86093. */
  86094. CW = 0,
  86095. /** Counter clockwise */
  86096. CCW = 1
  86097. }
  86098. /** Class used to represent a Bezier curve */
  86099. export class BezierCurve {
  86100. /**
  86101. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  86102. * @param t defines the time
  86103. * @param x1 defines the left coordinate on X axis
  86104. * @param y1 defines the left coordinate on Y axis
  86105. * @param x2 defines the right coordinate on X axis
  86106. * @param y2 defines the right coordinate on Y axis
  86107. * @returns the interpolated value
  86108. */
  86109. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  86110. }
  86111. /**
  86112. * Defines angle representation
  86113. */
  86114. export class Angle {
  86115. private _radians;
  86116. /**
  86117. * Creates an Angle object of "radians" radians (float).
  86118. * @param radians the angle in radians
  86119. */
  86120. constructor(radians: number);
  86121. /**
  86122. * Get value in degrees
  86123. * @returns the Angle value in degrees (float)
  86124. */
  86125. degrees(): number;
  86126. /**
  86127. * Get value in radians
  86128. * @returns the Angle value in radians (float)
  86129. */
  86130. radians(): number;
  86131. /**
  86132. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  86133. * @param a defines first point as the origin
  86134. * @param b defines point
  86135. * @returns a new Angle
  86136. */
  86137. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  86138. /**
  86139. * Gets a new Angle object from the given float in radians
  86140. * @param radians defines the angle value in radians
  86141. * @returns a new Angle
  86142. */
  86143. static FromRadians(radians: number): Angle;
  86144. /**
  86145. * Gets a new Angle object from the given float in degrees
  86146. * @param degrees defines the angle value in degrees
  86147. * @returns a new Angle
  86148. */
  86149. static FromDegrees(degrees: number): Angle;
  86150. }
  86151. /**
  86152. * This represents an arc in a 2d space.
  86153. */
  86154. export class Arc2 {
  86155. /** Defines the start point of the arc */
  86156. startPoint: Vector2;
  86157. /** Defines the mid point of the arc */
  86158. midPoint: Vector2;
  86159. /** Defines the end point of the arc */
  86160. endPoint: Vector2;
  86161. /**
  86162. * Defines the center point of the arc.
  86163. */
  86164. centerPoint: Vector2;
  86165. /**
  86166. * Defines the radius of the arc.
  86167. */
  86168. radius: number;
  86169. /**
  86170. * Defines the angle of the arc (from mid point to end point).
  86171. */
  86172. angle: Angle;
  86173. /**
  86174. * Defines the start angle of the arc (from start point to middle point).
  86175. */
  86176. startAngle: Angle;
  86177. /**
  86178. * Defines the orientation of the arc (clock wise/counter clock wise).
  86179. */
  86180. orientation: Orientation;
  86181. /**
  86182. * Creates an Arc object from the three given points : start, middle and end.
  86183. * @param startPoint Defines the start point of the arc
  86184. * @param midPoint Defines the midlle point of the arc
  86185. * @param endPoint Defines the end point of the arc
  86186. */
  86187. constructor(
  86188. /** Defines the start point of the arc */
  86189. startPoint: Vector2,
  86190. /** Defines the mid point of the arc */
  86191. midPoint: Vector2,
  86192. /** Defines the end point of the arc */
  86193. endPoint: Vector2);
  86194. }
  86195. /**
  86196. * Represents a 2D path made up of multiple 2D points
  86197. */
  86198. export class Path2 {
  86199. private _points;
  86200. private _length;
  86201. /**
  86202. * If the path start and end point are the same
  86203. */
  86204. closed: boolean;
  86205. /**
  86206. * Creates a Path2 object from the starting 2D coordinates x and y.
  86207. * @param x the starting points x value
  86208. * @param y the starting points y value
  86209. */
  86210. constructor(x: number, y: number);
  86211. /**
  86212. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  86213. * @param x the added points x value
  86214. * @param y the added points y value
  86215. * @returns the updated Path2.
  86216. */
  86217. addLineTo(x: number, y: number): Path2;
  86218. /**
  86219. * 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.
  86220. * @param midX middle point x value
  86221. * @param midY middle point y value
  86222. * @param endX end point x value
  86223. * @param endY end point y value
  86224. * @param numberOfSegments (default: 36)
  86225. * @returns the updated Path2.
  86226. */
  86227. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  86228. /**
  86229. * Closes the Path2.
  86230. * @returns the Path2.
  86231. */
  86232. close(): Path2;
  86233. /**
  86234. * Gets the sum of the distance between each sequential point in the path
  86235. * @returns the Path2 total length (float).
  86236. */
  86237. length(): number;
  86238. /**
  86239. * Gets the points which construct the path
  86240. * @returns the Path2 internal array of points.
  86241. */
  86242. getPoints(): Vector2[];
  86243. /**
  86244. * Retreives the point at the distance aways from the starting point
  86245. * @param normalizedLengthPosition the length along the path to retreive the point from
  86246. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  86247. */
  86248. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  86249. /**
  86250. * Creates a new path starting from an x and y position
  86251. * @param x starting x value
  86252. * @param y starting y value
  86253. * @returns a new Path2 starting at the coordinates (x, y).
  86254. */
  86255. static StartingAt(x: number, y: number): Path2;
  86256. }
  86257. /**
  86258. * Represents a 3D path made up of multiple 3D points
  86259. */
  86260. export class Path3D {
  86261. /**
  86262. * an array of Vector3, the curve axis of the Path3D
  86263. */
  86264. path: Vector3[];
  86265. private _curve;
  86266. private _distances;
  86267. private _tangents;
  86268. private _normals;
  86269. private _binormals;
  86270. private _raw;
  86271. private _alignTangentsWithPath;
  86272. private readonly _pointAtData;
  86273. /**
  86274. * new Path3D(path, normal, raw)
  86275. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  86276. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  86277. * @param path an array of Vector3, the curve axis of the Path3D
  86278. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  86279. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  86280. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  86281. */
  86282. constructor(
  86283. /**
  86284. * an array of Vector3, the curve axis of the Path3D
  86285. */
  86286. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  86287. /**
  86288. * Returns the Path3D array of successive Vector3 designing its curve.
  86289. * @returns the Path3D array of successive Vector3 designing its curve.
  86290. */
  86291. getCurve(): Vector3[];
  86292. /**
  86293. * Returns the Path3D array of successive Vector3 designing its curve.
  86294. * @returns the Path3D array of successive Vector3 designing its curve.
  86295. */
  86296. getPoints(): Vector3[];
  86297. /**
  86298. * @returns the computed length (float) of the path.
  86299. */
  86300. length(): number;
  86301. /**
  86302. * Returns an array populated with tangent vectors on each Path3D curve point.
  86303. * @returns an array populated with tangent vectors on each Path3D curve point.
  86304. */
  86305. getTangents(): Vector3[];
  86306. /**
  86307. * Returns an array populated with normal vectors on each Path3D curve point.
  86308. * @returns an array populated with normal vectors on each Path3D curve point.
  86309. */
  86310. getNormals(): Vector3[];
  86311. /**
  86312. * Returns an array populated with binormal vectors on each Path3D curve point.
  86313. * @returns an array populated with binormal vectors on each Path3D curve point.
  86314. */
  86315. getBinormals(): Vector3[];
  86316. /**
  86317. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  86318. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  86319. */
  86320. getDistances(): number[];
  86321. /**
  86322. * Returns an interpolated point along this path
  86323. * @param position the position of the point along this path, from 0.0 to 1.0
  86324. * @returns a new Vector3 as the point
  86325. */
  86326. getPointAt(position: number): Vector3;
  86327. /**
  86328. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  86329. * @param position the position of the point along this path, from 0.0 to 1.0
  86330. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  86331. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  86332. */
  86333. getTangentAt(position: number, interpolated?: boolean): Vector3;
  86334. /**
  86335. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  86336. * @param position the position of the point along this path, from 0.0 to 1.0
  86337. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  86338. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  86339. */
  86340. getNormalAt(position: number, interpolated?: boolean): Vector3;
  86341. /**
  86342. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  86343. * @param position the position of the point along this path, from 0.0 to 1.0
  86344. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  86345. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  86346. */
  86347. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  86348. /**
  86349. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  86350. * @param position the position of the point along this path, from 0.0 to 1.0
  86351. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  86352. */
  86353. getDistanceAt(position: number): number;
  86354. /**
  86355. * Returns the array index of the previous point of an interpolated point along this path
  86356. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  86357. * @returns the array index
  86358. */
  86359. getPreviousPointIndexAt(position: number): number;
  86360. /**
  86361. * 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)
  86362. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  86363. * @returns the sub position
  86364. */
  86365. getSubPositionAt(position: number): number;
  86366. /**
  86367. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  86368. * @param target the vector of which to get the closest position to
  86369. * @returns the position of the closest virtual point on this path to the target vector
  86370. */
  86371. getClosestPositionTo(target: Vector3): number;
  86372. /**
  86373. * Returns a sub path (slice) of this path
  86374. * @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
  86375. * @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
  86376. * @returns a sub path (slice) of this path
  86377. */
  86378. slice(start?: number, end?: number): Path3D;
  86379. /**
  86380. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  86381. * @param path path which all values are copied into the curves points
  86382. * @param firstNormal which should be projected onto the curve
  86383. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  86384. * @returns the same object updated.
  86385. */
  86386. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  86387. private _compute;
  86388. private _getFirstNonNullVector;
  86389. private _getLastNonNullVector;
  86390. private _normalVector;
  86391. /**
  86392. * Updates the point at data for an interpolated point along this curve
  86393. * @param position the position of the point along this curve, from 0.0 to 1.0
  86394. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  86395. * @returns the (updated) point at data
  86396. */
  86397. private _updatePointAtData;
  86398. /**
  86399. * Updates the point at data from the specified parameters
  86400. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  86401. * @param point the interpolated point
  86402. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  86403. */
  86404. private _setPointAtData;
  86405. /**
  86406. * Updates the point at interpolation matrix for the tangents, normals and binormals
  86407. */
  86408. private _updateInterpolationMatrix;
  86409. }
  86410. /**
  86411. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86412. * A Curve3 is designed from a series of successive Vector3.
  86413. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  86414. */
  86415. export class Curve3 {
  86416. private _points;
  86417. private _length;
  86418. /**
  86419. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  86420. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  86421. * @param v1 (Vector3) the control point
  86422. * @param v2 (Vector3) the end point of the Quadratic Bezier
  86423. * @param nbPoints (integer) the wanted number of points in the curve
  86424. * @returns the created Curve3
  86425. */
  86426. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86427. /**
  86428. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  86429. * @param v0 (Vector3) the origin point of the Cubic Bezier
  86430. * @param v1 (Vector3) the first control point
  86431. * @param v2 (Vector3) the second control point
  86432. * @param v3 (Vector3) the end point of the Cubic Bezier
  86433. * @param nbPoints (integer) the wanted number of points in the curve
  86434. * @returns the created Curve3
  86435. */
  86436. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86437. /**
  86438. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  86439. * @param p1 (Vector3) the origin point of the Hermite Spline
  86440. * @param t1 (Vector3) the tangent vector at the origin point
  86441. * @param p2 (Vector3) the end point of the Hermite Spline
  86442. * @param t2 (Vector3) the tangent vector at the end point
  86443. * @param nbPoints (integer) the wanted number of points in the curve
  86444. * @returns the created Curve3
  86445. */
  86446. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86447. /**
  86448. * Returns a Curve3 object along a CatmullRom Spline curve :
  86449. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  86450. * @param nbPoints (integer) the wanted number of points between each curve control points
  86451. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  86452. * @returns the created Curve3
  86453. */
  86454. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  86455. /**
  86456. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86457. * A Curve3 is designed from a series of successive Vector3.
  86458. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  86459. * @param points points which make up the curve
  86460. */
  86461. constructor(points: Vector3[]);
  86462. /**
  86463. * @returns the Curve3 stored array of successive Vector3
  86464. */
  86465. getPoints(): Vector3[];
  86466. /**
  86467. * @returns the computed length (float) of the curve.
  86468. */
  86469. length(): number;
  86470. /**
  86471. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  86472. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  86473. * curveA and curveB keep unchanged.
  86474. * @param curve the curve to continue from this curve
  86475. * @returns the newly constructed curve
  86476. */
  86477. continue(curve: DeepImmutable<Curve3>): Curve3;
  86478. private _computeLength;
  86479. }
  86480. }
  86481. declare module BABYLON {
  86482. /**
  86483. * This represents the main contract an easing function should follow.
  86484. * Easing functions are used throughout the animation system.
  86485. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86486. */
  86487. export interface IEasingFunction {
  86488. /**
  86489. * Given an input gradient between 0 and 1, this returns the corrseponding value
  86490. * of the easing function.
  86491. * The link below provides some of the most common examples of easing functions.
  86492. * @see https://easings.net/
  86493. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86494. * @returns the corresponding value on the curve defined by the easing function
  86495. */
  86496. ease(gradient: number): number;
  86497. }
  86498. /**
  86499. * Base class used for every default easing function.
  86500. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86501. */
  86502. export class EasingFunction implements IEasingFunction {
  86503. /**
  86504. * Interpolation follows the mathematical formula associated with the easing function.
  86505. */
  86506. static readonly EASINGMODE_EASEIN: number;
  86507. /**
  86508. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  86509. */
  86510. static readonly EASINGMODE_EASEOUT: number;
  86511. /**
  86512. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  86513. */
  86514. static readonly EASINGMODE_EASEINOUT: number;
  86515. private _easingMode;
  86516. /**
  86517. * Sets the easing mode of the current function.
  86518. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  86519. */
  86520. setEasingMode(easingMode: number): void;
  86521. /**
  86522. * Gets the current easing mode.
  86523. * @returns the easing mode
  86524. */
  86525. getEasingMode(): number;
  86526. /**
  86527. * @hidden
  86528. */
  86529. easeInCore(gradient: number): number;
  86530. /**
  86531. * Given an input gradient between 0 and 1, this returns the corresponding value
  86532. * of the easing function.
  86533. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86534. * @returns the corresponding value on the curve defined by the easing function
  86535. */
  86536. ease(gradient: number): number;
  86537. }
  86538. /**
  86539. * Easing function with a circle shape (see link below).
  86540. * @see https://easings.net/#easeInCirc
  86541. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86542. */
  86543. export class CircleEase extends EasingFunction implements IEasingFunction {
  86544. /** @hidden */
  86545. easeInCore(gradient: number): number;
  86546. }
  86547. /**
  86548. * Easing function with a ease back shape (see link below).
  86549. * @see https://easings.net/#easeInBack
  86550. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86551. */
  86552. export class BackEase extends EasingFunction implements IEasingFunction {
  86553. /** Defines the amplitude of the function */
  86554. amplitude: number;
  86555. /**
  86556. * Instantiates a back ease easing
  86557. * @see https://easings.net/#easeInBack
  86558. * @param amplitude Defines the amplitude of the function
  86559. */
  86560. constructor(
  86561. /** Defines the amplitude of the function */
  86562. amplitude?: number);
  86563. /** @hidden */
  86564. easeInCore(gradient: number): number;
  86565. }
  86566. /**
  86567. * Easing function with a bouncing shape (see link below).
  86568. * @see https://easings.net/#easeInBounce
  86569. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86570. */
  86571. export class BounceEase extends EasingFunction implements IEasingFunction {
  86572. /** Defines the number of bounces */
  86573. bounces: number;
  86574. /** Defines the amplitude of the bounce */
  86575. bounciness: number;
  86576. /**
  86577. * Instantiates a bounce easing
  86578. * @see https://easings.net/#easeInBounce
  86579. * @param bounces Defines the number of bounces
  86580. * @param bounciness Defines the amplitude of the bounce
  86581. */
  86582. constructor(
  86583. /** Defines the number of bounces */
  86584. bounces?: number,
  86585. /** Defines the amplitude of the bounce */
  86586. bounciness?: number);
  86587. /** @hidden */
  86588. easeInCore(gradient: number): number;
  86589. }
  86590. /**
  86591. * Easing function with a power of 3 shape (see link below).
  86592. * @see https://easings.net/#easeInCubic
  86593. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86594. */
  86595. export class CubicEase extends EasingFunction implements IEasingFunction {
  86596. /** @hidden */
  86597. easeInCore(gradient: number): number;
  86598. }
  86599. /**
  86600. * Easing function with an elastic shape (see link below).
  86601. * @see https://easings.net/#easeInElastic
  86602. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86603. */
  86604. export class ElasticEase extends EasingFunction implements IEasingFunction {
  86605. /** Defines the number of oscillations*/
  86606. oscillations: number;
  86607. /** Defines the amplitude of the oscillations*/
  86608. springiness: number;
  86609. /**
  86610. * Instantiates an elastic easing function
  86611. * @see https://easings.net/#easeInElastic
  86612. * @param oscillations Defines the number of oscillations
  86613. * @param springiness Defines the amplitude of the oscillations
  86614. */
  86615. constructor(
  86616. /** Defines the number of oscillations*/
  86617. oscillations?: number,
  86618. /** Defines the amplitude of the oscillations*/
  86619. springiness?: number);
  86620. /** @hidden */
  86621. easeInCore(gradient: number): number;
  86622. }
  86623. /**
  86624. * Easing function with an exponential shape (see link below).
  86625. * @see https://easings.net/#easeInExpo
  86626. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86627. */
  86628. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  86629. /** Defines the exponent of the function */
  86630. exponent: number;
  86631. /**
  86632. * Instantiates an exponential easing function
  86633. * @see https://easings.net/#easeInExpo
  86634. * @param exponent Defines the exponent of the function
  86635. */
  86636. constructor(
  86637. /** Defines the exponent of the function */
  86638. exponent?: number);
  86639. /** @hidden */
  86640. easeInCore(gradient: number): number;
  86641. }
  86642. /**
  86643. * Easing function with a power shape (see link below).
  86644. * @see https://easings.net/#easeInQuad
  86645. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86646. */
  86647. export class PowerEase extends EasingFunction implements IEasingFunction {
  86648. /** Defines the power of the function */
  86649. power: number;
  86650. /**
  86651. * Instantiates an power base easing function
  86652. * @see https://easings.net/#easeInQuad
  86653. * @param power Defines the power of the function
  86654. */
  86655. constructor(
  86656. /** Defines the power of the function */
  86657. power?: number);
  86658. /** @hidden */
  86659. easeInCore(gradient: number): number;
  86660. }
  86661. /**
  86662. * Easing function with a power of 2 shape (see link below).
  86663. * @see https://easings.net/#easeInQuad
  86664. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86665. */
  86666. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  86667. /** @hidden */
  86668. easeInCore(gradient: number): number;
  86669. }
  86670. /**
  86671. * Easing function with a power of 4 shape (see link below).
  86672. * @see https://easings.net/#easeInQuart
  86673. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86674. */
  86675. export class QuarticEase extends EasingFunction implements IEasingFunction {
  86676. /** @hidden */
  86677. easeInCore(gradient: number): number;
  86678. }
  86679. /**
  86680. * Easing function with a power of 5 shape (see link below).
  86681. * @see https://easings.net/#easeInQuint
  86682. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86683. */
  86684. export class QuinticEase extends EasingFunction implements IEasingFunction {
  86685. /** @hidden */
  86686. easeInCore(gradient: number): number;
  86687. }
  86688. /**
  86689. * Easing function with a sin shape (see link below).
  86690. * @see https://easings.net/#easeInSine
  86691. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86692. */
  86693. export class SineEase extends EasingFunction implements IEasingFunction {
  86694. /** @hidden */
  86695. easeInCore(gradient: number): number;
  86696. }
  86697. /**
  86698. * Easing function with a bezier shape (see link below).
  86699. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86700. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86701. */
  86702. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  86703. /** Defines the x component of the start tangent in the bezier curve */
  86704. x1: number;
  86705. /** Defines the y component of the start tangent in the bezier curve */
  86706. y1: number;
  86707. /** Defines the x component of the end tangent in the bezier curve */
  86708. x2: number;
  86709. /** Defines the y component of the end tangent in the bezier curve */
  86710. y2: number;
  86711. /**
  86712. * Instantiates a bezier function
  86713. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86714. * @param x1 Defines the x component of the start tangent in the bezier curve
  86715. * @param y1 Defines the y component of the start tangent in the bezier curve
  86716. * @param x2 Defines the x component of the end tangent in the bezier curve
  86717. * @param y2 Defines the y component of the end tangent in the bezier curve
  86718. */
  86719. constructor(
  86720. /** Defines the x component of the start tangent in the bezier curve */
  86721. x1?: number,
  86722. /** Defines the y component of the start tangent in the bezier curve */
  86723. y1?: number,
  86724. /** Defines the x component of the end tangent in the bezier curve */
  86725. x2?: number,
  86726. /** Defines the y component of the end tangent in the bezier curve */
  86727. y2?: number);
  86728. /** @hidden */
  86729. easeInCore(gradient: number): number;
  86730. }
  86731. }
  86732. declare module BABYLON {
  86733. /**
  86734. * Class used to hold a RBG color
  86735. */
  86736. export class Color3 {
  86737. /**
  86738. * Defines the red component (between 0 and 1, default is 0)
  86739. */
  86740. r: number;
  86741. /**
  86742. * Defines the green component (between 0 and 1, default is 0)
  86743. */
  86744. g: number;
  86745. /**
  86746. * Defines the blue component (between 0 and 1, default is 0)
  86747. */
  86748. b: number;
  86749. /**
  86750. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86751. * @param r defines the red component (between 0 and 1, default is 0)
  86752. * @param g defines the green component (between 0 and 1, default is 0)
  86753. * @param b defines the blue component (between 0 and 1, default is 0)
  86754. */
  86755. constructor(
  86756. /**
  86757. * Defines the red component (between 0 and 1, default is 0)
  86758. */
  86759. r?: number,
  86760. /**
  86761. * Defines the green component (between 0 and 1, default is 0)
  86762. */
  86763. g?: number,
  86764. /**
  86765. * Defines the blue component (between 0 and 1, default is 0)
  86766. */
  86767. b?: number);
  86768. /**
  86769. * Creates a string with the Color3 current values
  86770. * @returns the string representation of the Color3 object
  86771. */
  86772. toString(): string;
  86773. /**
  86774. * Returns the string "Color3"
  86775. * @returns "Color3"
  86776. */
  86777. getClassName(): string;
  86778. /**
  86779. * Compute the Color3 hash code
  86780. * @returns an unique number that can be used to hash Color3 objects
  86781. */
  86782. getHashCode(): number;
  86783. /**
  86784. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86785. * @param array defines the array where to store the r,g,b components
  86786. * @param index defines an optional index in the target array to define where to start storing values
  86787. * @returns the current Color3 object
  86788. */
  86789. toArray(array: FloatArray, index?: number): Color3;
  86790. /**
  86791. * Update the current color with values stored in an array from the starting index of the given array
  86792. * @param array defines the source array
  86793. * @param offset defines an offset in the source array
  86794. * @returns the current Color3 object
  86795. */
  86796. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86797. /**
  86798. * Returns a new Color4 object from the current Color3 and the given alpha
  86799. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86800. * @returns a new Color4 object
  86801. */
  86802. toColor4(alpha?: number): Color4;
  86803. /**
  86804. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86805. * @returns the new array
  86806. */
  86807. asArray(): number[];
  86808. /**
  86809. * Returns the luminance value
  86810. * @returns a float value
  86811. */
  86812. toLuminance(): number;
  86813. /**
  86814. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86815. * @param otherColor defines the second operand
  86816. * @returns the new Color3 object
  86817. */
  86818. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86819. /**
  86820. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86821. * @param otherColor defines the second operand
  86822. * @param result defines the Color3 object where to store the result
  86823. * @returns the current Color3
  86824. */
  86825. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86826. /**
  86827. * Determines equality between Color3 objects
  86828. * @param otherColor defines the second operand
  86829. * @returns true if the rgb values are equal to the given ones
  86830. */
  86831. equals(otherColor: DeepImmutable<Color3>): boolean;
  86832. /**
  86833. * Determines equality between the current Color3 object and a set of r,b,g values
  86834. * @param r defines the red component to check
  86835. * @param g defines the green component to check
  86836. * @param b defines the blue component to check
  86837. * @returns true if the rgb values are equal to the given ones
  86838. */
  86839. equalsFloats(r: number, g: number, b: number): boolean;
  86840. /**
  86841. * Multiplies in place each rgb value by scale
  86842. * @param scale defines the scaling factor
  86843. * @returns the updated Color3
  86844. */
  86845. scale(scale: number): Color3;
  86846. /**
  86847. * Multiplies the rgb values by scale and stores the result into "result"
  86848. * @param scale defines the scaling factor
  86849. * @param result defines the Color3 object where to store the result
  86850. * @returns the unmodified current Color3
  86851. */
  86852. scaleToRef(scale: number, result: Color3): Color3;
  86853. /**
  86854. * Scale the current Color3 values by a factor and add the result to a given Color3
  86855. * @param scale defines the scale factor
  86856. * @param result defines color to store the result into
  86857. * @returns the unmodified current Color3
  86858. */
  86859. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86860. /**
  86861. * Clamps the rgb values by the min and max values and stores the result into "result"
  86862. * @param min defines minimum clamping value (default is 0)
  86863. * @param max defines maximum clamping value (default is 1)
  86864. * @param result defines color to store the result into
  86865. * @returns the original Color3
  86866. */
  86867. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86868. /**
  86869. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86870. * @param otherColor defines the second operand
  86871. * @returns the new Color3
  86872. */
  86873. add(otherColor: DeepImmutable<Color3>): Color3;
  86874. /**
  86875. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86876. * @param otherColor defines the second operand
  86877. * @param result defines Color3 object to store the result into
  86878. * @returns the unmodified current Color3
  86879. */
  86880. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86881. /**
  86882. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86883. * @param otherColor defines the second operand
  86884. * @returns the new Color3
  86885. */
  86886. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86887. /**
  86888. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86889. * @param otherColor defines the second operand
  86890. * @param result defines Color3 object to store the result into
  86891. * @returns the unmodified current Color3
  86892. */
  86893. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86894. /**
  86895. * Copy the current object
  86896. * @returns a new Color3 copied the current one
  86897. */
  86898. clone(): Color3;
  86899. /**
  86900. * Copies the rgb values from the source in the current Color3
  86901. * @param source defines the source Color3 object
  86902. * @returns the updated Color3 object
  86903. */
  86904. copyFrom(source: DeepImmutable<Color3>): Color3;
  86905. /**
  86906. * Updates the Color3 rgb values from the given floats
  86907. * @param r defines the red component to read from
  86908. * @param g defines the green component to read from
  86909. * @param b defines the blue component to read from
  86910. * @returns the current Color3 object
  86911. */
  86912. copyFromFloats(r: number, g: number, b: number): Color3;
  86913. /**
  86914. * Updates the Color3 rgb values from the given floats
  86915. * @param r defines the red component to read from
  86916. * @param g defines the green component to read from
  86917. * @param b defines the blue component to read from
  86918. * @returns the current Color3 object
  86919. */
  86920. set(r: number, g: number, b: number): Color3;
  86921. /**
  86922. * Compute the Color3 hexadecimal code as a string
  86923. * @returns a string containing the hexadecimal representation of the Color3 object
  86924. */
  86925. toHexString(): string;
  86926. /**
  86927. * Computes a new Color3 converted from the current one to linear space
  86928. * @returns a new Color3 object
  86929. */
  86930. toLinearSpace(): Color3;
  86931. /**
  86932. * Converts current color in rgb space to HSV values
  86933. * @returns a new color3 representing the HSV values
  86934. */
  86935. toHSV(): Color3;
  86936. /**
  86937. * Converts current color in rgb space to HSV values
  86938. * @param result defines the Color3 where to store the HSV values
  86939. */
  86940. toHSVToRef(result: Color3): void;
  86941. /**
  86942. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86943. * @param convertedColor defines the Color3 object where to store the linear space version
  86944. * @returns the unmodified Color3
  86945. */
  86946. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86947. /**
  86948. * Computes a new Color3 converted from the current one to gamma space
  86949. * @returns a new Color3 object
  86950. */
  86951. toGammaSpace(): Color3;
  86952. /**
  86953. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86954. * @param convertedColor defines the Color3 object where to store the gamma space version
  86955. * @returns the unmodified Color3
  86956. */
  86957. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86958. private static _BlackReadOnly;
  86959. /**
  86960. * Convert Hue, saturation and value to a Color3 (RGB)
  86961. * @param hue defines the hue
  86962. * @param saturation defines the saturation
  86963. * @param value defines the value
  86964. * @param result defines the Color3 where to store the RGB values
  86965. */
  86966. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86967. /**
  86968. * Creates a new Color3 from the string containing valid hexadecimal values
  86969. * @param hex defines a string containing valid hexadecimal values
  86970. * @returns a new Color3 object
  86971. */
  86972. static FromHexString(hex: string): Color3;
  86973. /**
  86974. * Creates a new Color3 from the starting index of the given array
  86975. * @param array defines the source array
  86976. * @param offset defines an offset in the source array
  86977. * @returns a new Color3 object
  86978. */
  86979. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86980. /**
  86981. * Creates a new Color3 from the starting index element of the given array
  86982. * @param array defines the source array to read from
  86983. * @param offset defines the offset in the source array
  86984. * @param result defines the target Color3 object
  86985. */
  86986. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86987. /**
  86988. * Creates a new Color3 from integer values (< 256)
  86989. * @param r defines the red component to read from (value between 0 and 255)
  86990. * @param g defines the green component to read from (value between 0 and 255)
  86991. * @param b defines the blue component to read from (value between 0 and 255)
  86992. * @returns a new Color3 object
  86993. */
  86994. static FromInts(r: number, g: number, b: number): Color3;
  86995. /**
  86996. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86997. * @param start defines the start Color3 value
  86998. * @param end defines the end Color3 value
  86999. * @param amount defines the gradient value between start and end
  87000. * @returns a new Color3 object
  87001. */
  87002. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  87003. /**
  87004. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87005. * @param left defines the start value
  87006. * @param right defines the end value
  87007. * @param amount defines the gradient factor
  87008. * @param result defines the Color3 object where to store the result
  87009. */
  87010. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  87011. /**
  87012. * Returns a Color3 value containing a red color
  87013. * @returns a new Color3 object
  87014. */
  87015. static Red(): Color3;
  87016. /**
  87017. * Returns a Color3 value containing a green color
  87018. * @returns a new Color3 object
  87019. */
  87020. static Green(): Color3;
  87021. /**
  87022. * Returns a Color3 value containing a blue color
  87023. * @returns a new Color3 object
  87024. */
  87025. static Blue(): Color3;
  87026. /**
  87027. * Returns a Color3 value containing a black color
  87028. * @returns a new Color3 object
  87029. */
  87030. static Black(): Color3;
  87031. /**
  87032. * Gets a Color3 value containing a black color that must not be updated
  87033. */
  87034. static get BlackReadOnly(): DeepImmutable<Color3>;
  87035. /**
  87036. * Returns a Color3 value containing a white color
  87037. * @returns a new Color3 object
  87038. */
  87039. static White(): Color3;
  87040. /**
  87041. * Returns a Color3 value containing a purple color
  87042. * @returns a new Color3 object
  87043. */
  87044. static Purple(): Color3;
  87045. /**
  87046. * Returns a Color3 value containing a magenta color
  87047. * @returns a new Color3 object
  87048. */
  87049. static Magenta(): Color3;
  87050. /**
  87051. * Returns a Color3 value containing a yellow color
  87052. * @returns a new Color3 object
  87053. */
  87054. static Yellow(): Color3;
  87055. /**
  87056. * Returns a Color3 value containing a gray color
  87057. * @returns a new Color3 object
  87058. */
  87059. static Gray(): Color3;
  87060. /**
  87061. * Returns a Color3 value containing a teal color
  87062. * @returns a new Color3 object
  87063. */
  87064. static Teal(): Color3;
  87065. /**
  87066. * Returns a Color3 value containing a random color
  87067. * @returns a new Color3 object
  87068. */
  87069. static Random(): Color3;
  87070. }
  87071. /**
  87072. * Class used to hold a RBGA color
  87073. */
  87074. export class Color4 {
  87075. /**
  87076. * Defines the red component (between 0 and 1, default is 0)
  87077. */
  87078. r: number;
  87079. /**
  87080. * Defines the green component (between 0 and 1, default is 0)
  87081. */
  87082. g: number;
  87083. /**
  87084. * Defines the blue component (between 0 and 1, default is 0)
  87085. */
  87086. b: number;
  87087. /**
  87088. * Defines the alpha component (between 0 and 1, default is 1)
  87089. */
  87090. a: number;
  87091. /**
  87092. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  87093. * @param r defines the red component (between 0 and 1, default is 0)
  87094. * @param g defines the green component (between 0 and 1, default is 0)
  87095. * @param b defines the blue component (between 0 and 1, default is 0)
  87096. * @param a defines the alpha component (between 0 and 1, default is 1)
  87097. */
  87098. constructor(
  87099. /**
  87100. * Defines the red component (between 0 and 1, default is 0)
  87101. */
  87102. r?: number,
  87103. /**
  87104. * Defines the green component (between 0 and 1, default is 0)
  87105. */
  87106. g?: number,
  87107. /**
  87108. * Defines the blue component (between 0 and 1, default is 0)
  87109. */
  87110. b?: number,
  87111. /**
  87112. * Defines the alpha component (between 0 and 1, default is 1)
  87113. */
  87114. a?: number);
  87115. /**
  87116. * Adds in place the given Color4 values to the current Color4 object
  87117. * @param right defines the second operand
  87118. * @returns the current updated Color4 object
  87119. */
  87120. addInPlace(right: DeepImmutable<Color4>): Color4;
  87121. /**
  87122. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  87123. * @returns the new array
  87124. */
  87125. asArray(): number[];
  87126. /**
  87127. * Stores from the starting index in the given array the Color4 successive values
  87128. * @param array defines the array where to store the r,g,b components
  87129. * @param index defines an optional index in the target array to define where to start storing values
  87130. * @returns the current Color4 object
  87131. */
  87132. toArray(array: number[], index?: number): Color4;
  87133. /**
  87134. * Update the current color with values stored in an array from the starting index of the given array
  87135. * @param array defines the source array
  87136. * @param offset defines an offset in the source array
  87137. * @returns the current Color4 object
  87138. */
  87139. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87140. /**
  87141. * Determines equality between Color4 objects
  87142. * @param otherColor defines the second operand
  87143. * @returns true if the rgba values are equal to the given ones
  87144. */
  87145. equals(otherColor: DeepImmutable<Color4>): boolean;
  87146. /**
  87147. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  87148. * @param right defines the second operand
  87149. * @returns a new Color4 object
  87150. */
  87151. add(right: DeepImmutable<Color4>): Color4;
  87152. /**
  87153. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  87154. * @param right defines the second operand
  87155. * @returns a new Color4 object
  87156. */
  87157. subtract(right: DeepImmutable<Color4>): Color4;
  87158. /**
  87159. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  87160. * @param right defines the second operand
  87161. * @param result defines the Color4 object where to store the result
  87162. * @returns the current Color4 object
  87163. */
  87164. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  87165. /**
  87166. * Creates a new Color4 with the current Color4 values multiplied by scale
  87167. * @param scale defines the scaling factor to apply
  87168. * @returns a new Color4 object
  87169. */
  87170. scale(scale: number): Color4;
  87171. /**
  87172. * Multiplies the current Color4 values by scale and stores the result in "result"
  87173. * @param scale defines the scaling factor to apply
  87174. * @param result defines the Color4 object where to store the result
  87175. * @returns the current unmodified Color4
  87176. */
  87177. scaleToRef(scale: number, result: Color4): Color4;
  87178. /**
  87179. * Scale the current Color4 values by a factor and add the result to a given Color4
  87180. * @param scale defines the scale factor
  87181. * @param result defines the Color4 object where to store the result
  87182. * @returns the unmodified current Color4
  87183. */
  87184. scaleAndAddToRef(scale: number, result: Color4): Color4;
  87185. /**
  87186. * Clamps the rgb values by the min and max values and stores the result into "result"
  87187. * @param min defines minimum clamping value (default is 0)
  87188. * @param max defines maximum clamping value (default is 1)
  87189. * @param result defines color to store the result into.
  87190. * @returns the cuurent Color4
  87191. */
  87192. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  87193. /**
  87194. * Multipy an Color4 value by another and return a new Color4 object
  87195. * @param color defines the Color4 value to multiply by
  87196. * @returns a new Color4 object
  87197. */
  87198. multiply(color: Color4): Color4;
  87199. /**
  87200. * Multipy a Color4 value by another and push the result in a reference value
  87201. * @param color defines the Color4 value to multiply by
  87202. * @param result defines the Color4 to fill the result in
  87203. * @returns the result Color4
  87204. */
  87205. multiplyToRef(color: Color4, result: Color4): Color4;
  87206. /**
  87207. * Creates a string with the Color4 current values
  87208. * @returns the string representation of the Color4 object
  87209. */
  87210. toString(): string;
  87211. /**
  87212. * Returns the string "Color4"
  87213. * @returns "Color4"
  87214. */
  87215. getClassName(): string;
  87216. /**
  87217. * Compute the Color4 hash code
  87218. * @returns an unique number that can be used to hash Color4 objects
  87219. */
  87220. getHashCode(): number;
  87221. /**
  87222. * Creates a new Color4 copied from the current one
  87223. * @returns a new Color4 object
  87224. */
  87225. clone(): Color4;
  87226. /**
  87227. * Copies the given Color4 values into the current one
  87228. * @param source defines the source Color4 object
  87229. * @returns the current updated Color4 object
  87230. */
  87231. copyFrom(source: Color4): Color4;
  87232. /**
  87233. * Copies the given float values into the current one
  87234. * @param r defines the red component to read from
  87235. * @param g defines the green component to read from
  87236. * @param b defines the blue component to read from
  87237. * @param a defines the alpha component to read from
  87238. * @returns the current updated Color4 object
  87239. */
  87240. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  87241. /**
  87242. * Copies the given float values into the current one
  87243. * @param r defines the red component to read from
  87244. * @param g defines the green component to read from
  87245. * @param b defines the blue component to read from
  87246. * @param a defines the alpha component to read from
  87247. * @returns the current updated Color4 object
  87248. */
  87249. set(r: number, g: number, b: number, a: number): Color4;
  87250. /**
  87251. * Compute the Color4 hexadecimal code as a string
  87252. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  87253. * @returns a string containing the hexadecimal representation of the Color4 object
  87254. */
  87255. toHexString(returnAsColor3?: boolean): string;
  87256. /**
  87257. * Computes a new Color4 converted from the current one to linear space
  87258. * @returns a new Color4 object
  87259. */
  87260. toLinearSpace(): Color4;
  87261. /**
  87262. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  87263. * @param convertedColor defines the Color4 object where to store the linear space version
  87264. * @returns the unmodified Color4
  87265. */
  87266. toLinearSpaceToRef(convertedColor: Color4): Color4;
  87267. /**
  87268. * Computes a new Color4 converted from the current one to gamma space
  87269. * @returns a new Color4 object
  87270. */
  87271. toGammaSpace(): Color4;
  87272. /**
  87273. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  87274. * @param convertedColor defines the Color4 object where to store the gamma space version
  87275. * @returns the unmodified Color4
  87276. */
  87277. toGammaSpaceToRef(convertedColor: Color4): Color4;
  87278. /**
  87279. * Creates a new Color4 from the string containing valid hexadecimal values
  87280. * @param hex defines a string containing valid hexadecimal values
  87281. * @returns a new Color4 object
  87282. */
  87283. static FromHexString(hex: string): Color4;
  87284. /**
  87285. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87286. * @param left defines the start value
  87287. * @param right defines the end value
  87288. * @param amount defines the gradient factor
  87289. * @returns a new Color4 object
  87290. */
  87291. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  87292. /**
  87293. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87294. * @param left defines the start value
  87295. * @param right defines the end value
  87296. * @param amount defines the gradient factor
  87297. * @param result defines the Color4 object where to store data
  87298. */
  87299. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  87300. /**
  87301. * Creates a new Color4 from a Color3 and an alpha value
  87302. * @param color3 defines the source Color3 to read from
  87303. * @param alpha defines the alpha component (1.0 by default)
  87304. * @returns a new Color4 object
  87305. */
  87306. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  87307. /**
  87308. * Creates a new Color4 from the starting index element of the given array
  87309. * @param array defines the source array to read from
  87310. * @param offset defines the offset in the source array
  87311. * @returns a new Color4 object
  87312. */
  87313. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87314. /**
  87315. * Creates a new Color4 from the starting index element of the given array
  87316. * @param array defines the source array to read from
  87317. * @param offset defines the offset in the source array
  87318. * @param result defines the target Color4 object
  87319. */
  87320. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  87321. /**
  87322. * Creates a new Color3 from integer values (< 256)
  87323. * @param r defines the red component to read from (value between 0 and 255)
  87324. * @param g defines the green component to read from (value between 0 and 255)
  87325. * @param b defines the blue component to read from (value between 0 and 255)
  87326. * @param a defines the alpha component to read from (value between 0 and 255)
  87327. * @returns a new Color3 object
  87328. */
  87329. static FromInts(r: number, g: number, b: number, a: number): Color4;
  87330. /**
  87331. * Check the content of a given array and convert it to an array containing RGBA data
  87332. * If the original array was already containing count * 4 values then it is returned directly
  87333. * @param colors defines the array to check
  87334. * @param count defines the number of RGBA data to expect
  87335. * @returns an array containing count * 4 values (RGBA)
  87336. */
  87337. static CheckColors4(colors: number[], count: number): number[];
  87338. }
  87339. /**
  87340. * @hidden
  87341. */
  87342. export class TmpColors {
  87343. static Color3: Color3[];
  87344. static Color4: Color4[];
  87345. }
  87346. }
  87347. declare module BABYLON {
  87348. /**
  87349. * Defines an interface which represents an animation key frame
  87350. */
  87351. export interface IAnimationKey {
  87352. /**
  87353. * Frame of the key frame
  87354. */
  87355. frame: number;
  87356. /**
  87357. * Value at the specifies key frame
  87358. */
  87359. value: any;
  87360. /**
  87361. * The input tangent for the cubic hermite spline
  87362. */
  87363. inTangent?: any;
  87364. /**
  87365. * The output tangent for the cubic hermite spline
  87366. */
  87367. outTangent?: any;
  87368. /**
  87369. * The animation interpolation type
  87370. */
  87371. interpolation?: AnimationKeyInterpolation;
  87372. }
  87373. /**
  87374. * Enum for the animation key frame interpolation type
  87375. */
  87376. export enum AnimationKeyInterpolation {
  87377. /**
  87378. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  87379. */
  87380. STEP = 1
  87381. }
  87382. }
  87383. declare module BABYLON {
  87384. /**
  87385. * Represents the range of an animation
  87386. */
  87387. export class AnimationRange {
  87388. /**The name of the animation range**/
  87389. name: string;
  87390. /**The starting frame of the animation */
  87391. from: number;
  87392. /**The ending frame of the animation*/
  87393. to: number;
  87394. /**
  87395. * Initializes the range of an animation
  87396. * @param name The name of the animation range
  87397. * @param from The starting frame of the animation
  87398. * @param to The ending frame of the animation
  87399. */
  87400. constructor(
  87401. /**The name of the animation range**/
  87402. name: string,
  87403. /**The starting frame of the animation */
  87404. from: number,
  87405. /**The ending frame of the animation*/
  87406. to: number);
  87407. /**
  87408. * Makes a copy of the animation range
  87409. * @returns A copy of the animation range
  87410. */
  87411. clone(): AnimationRange;
  87412. }
  87413. }
  87414. declare module BABYLON {
  87415. /**
  87416. * Composed of a frame, and an action function
  87417. */
  87418. export class AnimationEvent {
  87419. /** The frame for which the event is triggered **/
  87420. frame: number;
  87421. /** The event to perform when triggered **/
  87422. action: (currentFrame: number) => void;
  87423. /** Specifies if the event should be triggered only once**/
  87424. onlyOnce?: boolean | undefined;
  87425. /**
  87426. * Specifies if the animation event is done
  87427. */
  87428. isDone: boolean;
  87429. /**
  87430. * Initializes the animation event
  87431. * @param frame The frame for which the event is triggered
  87432. * @param action The event to perform when triggered
  87433. * @param onlyOnce Specifies if the event should be triggered only once
  87434. */
  87435. constructor(
  87436. /** The frame for which the event is triggered **/
  87437. frame: number,
  87438. /** The event to perform when triggered **/
  87439. action: (currentFrame: number) => void,
  87440. /** Specifies if the event should be triggered only once**/
  87441. onlyOnce?: boolean | undefined);
  87442. /** @hidden */
  87443. _clone(): AnimationEvent;
  87444. }
  87445. }
  87446. declare module BABYLON {
  87447. /**
  87448. * Interface used to define a behavior
  87449. */
  87450. export interface Behavior<T> {
  87451. /** gets or sets behavior's name */
  87452. name: string;
  87453. /**
  87454. * Function called when the behavior needs to be initialized (after attaching it to a target)
  87455. */
  87456. init(): void;
  87457. /**
  87458. * Called when the behavior is attached to a target
  87459. * @param target defines the target where the behavior is attached to
  87460. */
  87461. attach(target: T): void;
  87462. /**
  87463. * Called when the behavior is detached from its target
  87464. */
  87465. detach(): void;
  87466. }
  87467. /**
  87468. * Interface implemented by classes supporting behaviors
  87469. */
  87470. export interface IBehaviorAware<T> {
  87471. /**
  87472. * Attach a behavior
  87473. * @param behavior defines the behavior to attach
  87474. * @returns the current host
  87475. */
  87476. addBehavior(behavior: Behavior<T>): T;
  87477. /**
  87478. * Remove a behavior from the current object
  87479. * @param behavior defines the behavior to detach
  87480. * @returns the current host
  87481. */
  87482. removeBehavior(behavior: Behavior<T>): T;
  87483. /**
  87484. * Gets a behavior using its name to search
  87485. * @param name defines the name to search
  87486. * @returns the behavior or null if not found
  87487. */
  87488. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  87489. }
  87490. }
  87491. declare module BABYLON {
  87492. /**
  87493. * Defines an array and its length.
  87494. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  87495. */
  87496. export interface ISmartArrayLike<T> {
  87497. /**
  87498. * The data of the array.
  87499. */
  87500. data: Array<T>;
  87501. /**
  87502. * The active length of the array.
  87503. */
  87504. length: number;
  87505. }
  87506. /**
  87507. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87508. */
  87509. export class SmartArray<T> implements ISmartArrayLike<T> {
  87510. /**
  87511. * The full set of data from the array.
  87512. */
  87513. data: Array<T>;
  87514. /**
  87515. * The active length of the array.
  87516. */
  87517. length: number;
  87518. protected _id: number;
  87519. /**
  87520. * Instantiates a Smart Array.
  87521. * @param capacity defines the default capacity of the array.
  87522. */
  87523. constructor(capacity: number);
  87524. /**
  87525. * Pushes a value at the end of the active data.
  87526. * @param value defines the object to push in the array.
  87527. */
  87528. push(value: T): void;
  87529. /**
  87530. * Iterates over the active data and apply the lambda to them.
  87531. * @param func defines the action to apply on each value.
  87532. */
  87533. forEach(func: (content: T) => void): void;
  87534. /**
  87535. * Sorts the full sets of data.
  87536. * @param compareFn defines the comparison function to apply.
  87537. */
  87538. sort(compareFn: (a: T, b: T) => number): void;
  87539. /**
  87540. * Resets the active data to an empty array.
  87541. */
  87542. reset(): void;
  87543. /**
  87544. * Releases all the data from the array as well as the array.
  87545. */
  87546. dispose(): void;
  87547. /**
  87548. * Concats the active data with a given array.
  87549. * @param array defines the data to concatenate with.
  87550. */
  87551. concat(array: any): void;
  87552. /**
  87553. * Returns the position of a value in the active data.
  87554. * @param value defines the value to find the index for
  87555. * @returns the index if found in the active data otherwise -1
  87556. */
  87557. indexOf(value: T): number;
  87558. /**
  87559. * Returns whether an element is part of the active data.
  87560. * @param value defines the value to look for
  87561. * @returns true if found in the active data otherwise false
  87562. */
  87563. contains(value: T): boolean;
  87564. private static _GlobalId;
  87565. }
  87566. /**
  87567. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87568. * The data in this array can only be present once
  87569. */
  87570. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  87571. private _duplicateId;
  87572. /**
  87573. * Pushes a value at the end of the active data.
  87574. * THIS DOES NOT PREVENT DUPPLICATE DATA
  87575. * @param value defines the object to push in the array.
  87576. */
  87577. push(value: T): void;
  87578. /**
  87579. * Pushes a value at the end of the active data.
  87580. * If the data is already present, it won t be added again
  87581. * @param value defines the object to push in the array.
  87582. * @returns true if added false if it was already present
  87583. */
  87584. pushNoDuplicate(value: T): boolean;
  87585. /**
  87586. * Resets the active data to an empty array.
  87587. */
  87588. reset(): void;
  87589. /**
  87590. * Concats the active data with a given array.
  87591. * This ensures no dupplicate will be present in the result.
  87592. * @param array defines the data to concatenate with.
  87593. */
  87594. concatWithNoDuplicate(array: any): void;
  87595. }
  87596. }
  87597. declare module BABYLON {
  87598. /**
  87599. * @ignore
  87600. * This is a list of all the different input types that are available in the application.
  87601. * Fo instance: ArcRotateCameraGamepadInput...
  87602. */
  87603. export var CameraInputTypes: {};
  87604. /**
  87605. * This is the contract to implement in order to create a new input class.
  87606. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  87607. */
  87608. export interface ICameraInput<TCamera extends Camera> {
  87609. /**
  87610. * Defines the camera the input is attached to.
  87611. */
  87612. camera: Nullable<TCamera>;
  87613. /**
  87614. * Gets the class name of the current intput.
  87615. * @returns the class name
  87616. */
  87617. getClassName(): string;
  87618. /**
  87619. * Get the friendly name associated with the input class.
  87620. * @returns the input friendly name
  87621. */
  87622. getSimpleName(): string;
  87623. /**
  87624. * Attach the input controls to a specific dom element to get the input from.
  87625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87626. */
  87627. attachControl(noPreventDefault?: boolean): void;
  87628. /**
  87629. * Detach the current controls from the specified dom element.
  87630. */
  87631. detachControl(): void;
  87632. /**
  87633. * Update the current camera state depending on the inputs that have been used this frame.
  87634. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87635. */
  87636. checkInputs?: () => void;
  87637. }
  87638. /**
  87639. * Represents a map of input types to input instance or input index to input instance.
  87640. */
  87641. export interface CameraInputsMap<TCamera extends Camera> {
  87642. /**
  87643. * Accessor to the input by input type.
  87644. */
  87645. [name: string]: ICameraInput<TCamera>;
  87646. /**
  87647. * Accessor to the input by input index.
  87648. */
  87649. [idx: number]: ICameraInput<TCamera>;
  87650. }
  87651. /**
  87652. * This represents the input manager used within a camera.
  87653. * It helps dealing with all the different kind of input attached to a camera.
  87654. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87655. */
  87656. export class CameraInputsManager<TCamera extends Camera> {
  87657. /**
  87658. * Defines the list of inputs attahed to the camera.
  87659. */
  87660. attached: CameraInputsMap<TCamera>;
  87661. /**
  87662. * Defines the dom element the camera is collecting inputs from.
  87663. * This is null if the controls have not been attached.
  87664. */
  87665. attachedToElement: boolean;
  87666. /**
  87667. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87668. */
  87669. noPreventDefault: boolean;
  87670. /**
  87671. * Defined the camera the input manager belongs to.
  87672. */
  87673. camera: TCamera;
  87674. /**
  87675. * Update the current camera state depending on the inputs that have been used this frame.
  87676. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87677. */
  87678. checkInputs: () => void;
  87679. /**
  87680. * Instantiate a new Camera Input Manager.
  87681. * @param camera Defines the camera the input manager blongs to
  87682. */
  87683. constructor(camera: TCamera);
  87684. /**
  87685. * Add an input method to a camera
  87686. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87687. * @param input camera input method
  87688. */
  87689. add(input: ICameraInput<TCamera>): void;
  87690. /**
  87691. * Remove a specific input method from a camera
  87692. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  87693. * @param inputToRemove camera input method
  87694. */
  87695. remove(inputToRemove: ICameraInput<TCamera>): void;
  87696. /**
  87697. * Remove a specific input type from a camera
  87698. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  87699. * @param inputType the type of the input to remove
  87700. */
  87701. removeByType(inputType: string): void;
  87702. private _addCheckInputs;
  87703. /**
  87704. * Attach the input controls to the currently attached dom element to listen the events from.
  87705. * @param input Defines the input to attach
  87706. */
  87707. attachInput(input: ICameraInput<TCamera>): void;
  87708. /**
  87709. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  87710. * @param element Defines the dom element to collect the events from
  87711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87712. */
  87713. attachElement(noPreventDefault?: boolean): void;
  87714. /**
  87715. * Detach the current manager inputs controls from a specific dom element.
  87716. * @param element Defines the dom element to collect the events from
  87717. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  87718. */
  87719. detachElement(disconnect?: boolean): void;
  87720. /**
  87721. * Rebuild the dynamic inputCheck function from the current list of
  87722. * defined inputs in the manager.
  87723. */
  87724. rebuildInputCheck(): void;
  87725. /**
  87726. * Remove all attached input methods from a camera
  87727. */
  87728. clear(): void;
  87729. /**
  87730. * Serialize the current input manager attached to a camera.
  87731. * This ensures than once parsed,
  87732. * the input associated to the camera will be identical to the current ones
  87733. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87734. */
  87735. serialize(serializedCamera: any): void;
  87736. /**
  87737. * Parses an input manager serialized JSON to restore the previous list of inputs
  87738. * and states associated to a camera.
  87739. * @param parsedCamera Defines the JSON to parse
  87740. */
  87741. parse(parsedCamera: any): void;
  87742. }
  87743. }
  87744. declare module BABYLON {
  87745. /**
  87746. * Class used to store data that will be store in GPU memory
  87747. */
  87748. export class Buffer {
  87749. private _engine;
  87750. private _buffer;
  87751. /** @hidden */
  87752. _data: Nullable<DataArray>;
  87753. private _updatable;
  87754. private _instanced;
  87755. private _divisor;
  87756. /**
  87757. * Gets the byte stride.
  87758. */
  87759. readonly byteStride: number;
  87760. /**
  87761. * Constructor
  87762. * @param engine the engine
  87763. * @param data the data to use for this buffer
  87764. * @param updatable whether the data is updatable
  87765. * @param stride the stride (optional)
  87766. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87767. * @param instanced whether the buffer is instanced (optional)
  87768. * @param useBytes set to true if the stride in in bytes (optional)
  87769. * @param divisor sets an optional divisor for instances (1 by default)
  87770. */
  87771. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87772. /**
  87773. * Create a new VertexBuffer based on the current buffer
  87774. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87775. * @param offset defines offset in the buffer (0 by default)
  87776. * @param size defines the size in floats of attributes (position is 3 for instance)
  87777. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87778. * @param instanced defines if the vertex buffer contains indexed data
  87779. * @param useBytes defines if the offset and stride are in bytes *
  87780. * @param divisor sets an optional divisor for instances (1 by default)
  87781. * @returns the new vertex buffer
  87782. */
  87783. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87784. /**
  87785. * Gets a boolean indicating if the Buffer is updatable?
  87786. * @returns true if the buffer is updatable
  87787. */
  87788. isUpdatable(): boolean;
  87789. /**
  87790. * Gets current buffer's data
  87791. * @returns a DataArray or null
  87792. */
  87793. getData(): Nullable<DataArray>;
  87794. /**
  87795. * Gets underlying native buffer
  87796. * @returns underlying native buffer
  87797. */
  87798. getBuffer(): Nullable<DataBuffer>;
  87799. /**
  87800. * Gets the stride in float32 units (i.e. byte stride / 4).
  87801. * May not be an integer if the byte stride is not divisible by 4.
  87802. * @returns the stride in float32 units
  87803. * @deprecated Please use byteStride instead.
  87804. */
  87805. getStrideSize(): number;
  87806. /**
  87807. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87808. * @param data defines the data to store
  87809. */
  87810. create(data?: Nullable<DataArray>): void;
  87811. /** @hidden */
  87812. _rebuild(): void;
  87813. /**
  87814. * Update current buffer data
  87815. * @param data defines the data to store
  87816. */
  87817. update(data: DataArray): void;
  87818. /**
  87819. * Updates the data directly.
  87820. * @param data the new data
  87821. * @param offset the new offset
  87822. * @param vertexCount the vertex count (optional)
  87823. * @param useBytes set to true if the offset is in bytes
  87824. */
  87825. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87826. /**
  87827. * Release all resources
  87828. */
  87829. dispose(): void;
  87830. }
  87831. /**
  87832. * Specialized buffer used to store vertex data
  87833. */
  87834. export class VertexBuffer {
  87835. /** @hidden */
  87836. _buffer: Buffer;
  87837. private _kind;
  87838. private _size;
  87839. private _ownsBuffer;
  87840. private _instanced;
  87841. private _instanceDivisor;
  87842. /**
  87843. * The byte type.
  87844. */
  87845. static readonly BYTE: number;
  87846. /**
  87847. * The unsigned byte type.
  87848. */
  87849. static readonly UNSIGNED_BYTE: number;
  87850. /**
  87851. * The short type.
  87852. */
  87853. static readonly SHORT: number;
  87854. /**
  87855. * The unsigned short type.
  87856. */
  87857. static readonly UNSIGNED_SHORT: number;
  87858. /**
  87859. * The integer type.
  87860. */
  87861. static readonly INT: number;
  87862. /**
  87863. * The unsigned integer type.
  87864. */
  87865. static readonly UNSIGNED_INT: number;
  87866. /**
  87867. * The float type.
  87868. */
  87869. static readonly FLOAT: number;
  87870. /**
  87871. * Gets or sets the instance divisor when in instanced mode
  87872. */
  87873. get instanceDivisor(): number;
  87874. set instanceDivisor(value: number);
  87875. /**
  87876. * Gets the byte stride.
  87877. */
  87878. readonly byteStride: number;
  87879. /**
  87880. * Gets the byte offset.
  87881. */
  87882. readonly byteOffset: number;
  87883. /**
  87884. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87885. */
  87886. readonly normalized: boolean;
  87887. /**
  87888. * Gets the data type of each component in the array.
  87889. */
  87890. readonly type: number;
  87891. /**
  87892. * Constructor
  87893. * @param engine the engine
  87894. * @param data the data to use for this vertex buffer
  87895. * @param kind the vertex buffer kind
  87896. * @param updatable whether the data is updatable
  87897. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87898. * @param stride the stride (optional)
  87899. * @param instanced whether the buffer is instanced (optional)
  87900. * @param offset the offset of the data (optional)
  87901. * @param size the number of components (optional)
  87902. * @param type the type of the component (optional)
  87903. * @param normalized whether the data contains normalized data (optional)
  87904. * @param useBytes set to true if stride and offset are in bytes (optional)
  87905. * @param divisor defines the instance divisor to use (1 by default)
  87906. */
  87907. 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);
  87908. /** @hidden */
  87909. _rebuild(): void;
  87910. /**
  87911. * Returns the kind of the VertexBuffer (string)
  87912. * @returns a string
  87913. */
  87914. getKind(): string;
  87915. /**
  87916. * Gets a boolean indicating if the VertexBuffer is updatable?
  87917. * @returns true if the buffer is updatable
  87918. */
  87919. isUpdatable(): boolean;
  87920. /**
  87921. * Gets current buffer's data
  87922. * @returns a DataArray or null
  87923. */
  87924. getData(): Nullable<DataArray>;
  87925. /**
  87926. * Gets underlying native buffer
  87927. * @returns underlying native buffer
  87928. */
  87929. getBuffer(): Nullable<DataBuffer>;
  87930. /**
  87931. * Gets the stride in float32 units (i.e. byte stride / 4).
  87932. * May not be an integer if the byte stride is not divisible by 4.
  87933. * @returns the stride in float32 units
  87934. * @deprecated Please use byteStride instead.
  87935. */
  87936. getStrideSize(): number;
  87937. /**
  87938. * Returns the offset as a multiple of the type byte length.
  87939. * @returns the offset in bytes
  87940. * @deprecated Please use byteOffset instead.
  87941. */
  87942. getOffset(): number;
  87943. /**
  87944. * Returns the number of components per vertex attribute (integer)
  87945. * @returns the size in float
  87946. */
  87947. getSize(): number;
  87948. /**
  87949. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87950. * @returns true if this buffer is instanced
  87951. */
  87952. getIsInstanced(): boolean;
  87953. /**
  87954. * Returns the instancing divisor, zero for non-instanced (integer).
  87955. * @returns a number
  87956. */
  87957. getInstanceDivisor(): number;
  87958. /**
  87959. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87960. * @param data defines the data to store
  87961. */
  87962. create(data?: DataArray): void;
  87963. /**
  87964. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87965. * This function will create a new buffer if the current one is not updatable
  87966. * @param data defines the data to store
  87967. */
  87968. update(data: DataArray): void;
  87969. /**
  87970. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87971. * Returns the directly updated WebGLBuffer.
  87972. * @param data the new data
  87973. * @param offset the new offset
  87974. * @param useBytes set to true if the offset is in bytes
  87975. */
  87976. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87977. /**
  87978. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87979. */
  87980. dispose(): void;
  87981. /**
  87982. * Enumerates each value of this vertex buffer as numbers.
  87983. * @param count the number of values to enumerate
  87984. * @param callback the callback function called for each value
  87985. */
  87986. forEach(count: number, callback: (value: number, index: number) => void): void;
  87987. /**
  87988. * Positions
  87989. */
  87990. static readonly PositionKind: string;
  87991. /**
  87992. * Normals
  87993. */
  87994. static readonly NormalKind: string;
  87995. /**
  87996. * Tangents
  87997. */
  87998. static readonly TangentKind: string;
  87999. /**
  88000. * Texture coordinates
  88001. */
  88002. static readonly UVKind: string;
  88003. /**
  88004. * Texture coordinates 2
  88005. */
  88006. static readonly UV2Kind: string;
  88007. /**
  88008. * Texture coordinates 3
  88009. */
  88010. static readonly UV3Kind: string;
  88011. /**
  88012. * Texture coordinates 4
  88013. */
  88014. static readonly UV4Kind: string;
  88015. /**
  88016. * Texture coordinates 5
  88017. */
  88018. static readonly UV5Kind: string;
  88019. /**
  88020. * Texture coordinates 6
  88021. */
  88022. static readonly UV6Kind: string;
  88023. /**
  88024. * Colors
  88025. */
  88026. static readonly ColorKind: string;
  88027. /**
  88028. * Matrix indices (for bones)
  88029. */
  88030. static readonly MatricesIndicesKind: string;
  88031. /**
  88032. * Matrix weights (for bones)
  88033. */
  88034. static readonly MatricesWeightsKind: string;
  88035. /**
  88036. * Additional matrix indices (for bones)
  88037. */
  88038. static readonly MatricesIndicesExtraKind: string;
  88039. /**
  88040. * Additional matrix weights (for bones)
  88041. */
  88042. static readonly MatricesWeightsExtraKind: string;
  88043. /**
  88044. * Deduces the stride given a kind.
  88045. * @param kind The kind string to deduce
  88046. * @returns The deduced stride
  88047. */
  88048. static DeduceStride(kind: string): number;
  88049. /**
  88050. * Gets the byte length of the given type.
  88051. * @param type the type
  88052. * @returns the number of bytes
  88053. */
  88054. static GetTypeByteLength(type: number): number;
  88055. /**
  88056. * Enumerates each value of the given parameters as numbers.
  88057. * @param data the data to enumerate
  88058. * @param byteOffset the byte offset of the data
  88059. * @param byteStride the byte stride of the data
  88060. * @param componentCount the number of components per element
  88061. * @param componentType the type of the component
  88062. * @param count the number of values to enumerate
  88063. * @param normalized whether the data is normalized
  88064. * @param callback the callback function called for each value
  88065. */
  88066. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  88067. private static _GetFloatValue;
  88068. }
  88069. }
  88070. declare module BABYLON {
  88071. /**
  88072. * The options Interface for creating a Capsule Mesh
  88073. */
  88074. export interface ICreateCapsuleOptions {
  88075. /** The Orientation of the capsule. Default : Vector3.Up() */
  88076. orientation?: Vector3;
  88077. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  88078. subdivisions: number;
  88079. /** Number of cylindrical segments on the capsule. */
  88080. tessellation: number;
  88081. /** Height or Length of the capsule. */
  88082. height: number;
  88083. /** Radius of the capsule. */
  88084. radius: number;
  88085. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  88086. capSubdivisions: number;
  88087. /** Overwrite for the top radius. */
  88088. radiusTop?: number;
  88089. /** Overwrite for the bottom radius. */
  88090. radiusBottom?: number;
  88091. /** Overwrite for the top capSubdivisions. */
  88092. topCapSubdivisions?: number;
  88093. /** Overwrite for the bottom capSubdivisions. */
  88094. bottomCapSubdivisions?: number;
  88095. }
  88096. /**
  88097. * Class containing static functions to help procedurally build meshes
  88098. */
  88099. export class CapsuleBuilder {
  88100. /**
  88101. * Creates a capsule or a pill mesh
  88102. * @param name defines the name of the mesh
  88103. * @param options The constructors options.
  88104. * @param scene The scene the mesh is scoped to.
  88105. * @returns Capsule Mesh
  88106. */
  88107. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  88108. }
  88109. }
  88110. declare module BABYLON {
  88111. /**
  88112. * @hidden
  88113. */
  88114. export class IntersectionInfo {
  88115. bu: Nullable<number>;
  88116. bv: Nullable<number>;
  88117. distance: number;
  88118. faceId: number;
  88119. subMeshId: number;
  88120. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  88121. }
  88122. }
  88123. declare module BABYLON {
  88124. /**
  88125. * Class used to store bounding sphere information
  88126. */
  88127. export class BoundingSphere {
  88128. /**
  88129. * Gets the center of the bounding sphere in local space
  88130. */
  88131. readonly center: Vector3;
  88132. /**
  88133. * Radius of the bounding sphere in local space
  88134. */
  88135. radius: number;
  88136. /**
  88137. * Gets the center of the bounding sphere in world space
  88138. */
  88139. readonly centerWorld: Vector3;
  88140. /**
  88141. * Radius of the bounding sphere in world space
  88142. */
  88143. radiusWorld: number;
  88144. /**
  88145. * Gets the minimum vector in local space
  88146. */
  88147. readonly minimum: Vector3;
  88148. /**
  88149. * Gets the maximum vector in local space
  88150. */
  88151. readonly maximum: Vector3;
  88152. private _worldMatrix;
  88153. private static readonly TmpVector3;
  88154. /**
  88155. * Creates a new bounding sphere
  88156. * @param min defines the minimum vector (in local space)
  88157. * @param max defines the maximum vector (in local space)
  88158. * @param worldMatrix defines the new world matrix
  88159. */
  88160. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88161. /**
  88162. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  88163. * @param min defines the new minimum vector (in local space)
  88164. * @param max defines the new maximum vector (in local space)
  88165. * @param worldMatrix defines the new world matrix
  88166. */
  88167. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88168. /**
  88169. * Scale the current bounding sphere by applying a scale factor
  88170. * @param factor defines the scale factor to apply
  88171. * @returns the current bounding box
  88172. */
  88173. scale(factor: number): BoundingSphere;
  88174. /**
  88175. * Gets the world matrix of the bounding box
  88176. * @returns a matrix
  88177. */
  88178. getWorldMatrix(): DeepImmutable<Matrix>;
  88179. /** @hidden */
  88180. _update(worldMatrix: DeepImmutable<Matrix>): void;
  88181. /**
  88182. * Tests if the bounding sphere is intersecting the frustum planes
  88183. * @param frustumPlanes defines the frustum planes to test
  88184. * @returns true if there is an intersection
  88185. */
  88186. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88187. /**
  88188. * Tests if the bounding sphere center is in between the frustum planes.
  88189. * Used for optimistic fast inclusion.
  88190. * @param frustumPlanes defines the frustum planes to test
  88191. * @returns true if the sphere center is in between the frustum planes
  88192. */
  88193. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88194. /**
  88195. * Tests if a point is inside the bounding sphere
  88196. * @param point defines the point to test
  88197. * @returns true if the point is inside the bounding sphere
  88198. */
  88199. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88200. /**
  88201. * Checks if two sphere intersct
  88202. * @param sphere0 sphere 0
  88203. * @param sphere1 sphere 1
  88204. * @returns true if the speres intersect
  88205. */
  88206. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  88207. }
  88208. }
  88209. declare module BABYLON {
  88210. /**
  88211. * Class used to store bounding box information
  88212. */
  88213. export class BoundingBox implements ICullable {
  88214. /**
  88215. * Gets the 8 vectors representing the bounding box in local space
  88216. */
  88217. readonly vectors: Vector3[];
  88218. /**
  88219. * Gets the center of the bounding box in local space
  88220. */
  88221. readonly center: Vector3;
  88222. /**
  88223. * Gets the center of the bounding box in world space
  88224. */
  88225. readonly centerWorld: Vector3;
  88226. /**
  88227. * Gets the extend size in local space
  88228. */
  88229. readonly extendSize: Vector3;
  88230. /**
  88231. * Gets the extend size in world space
  88232. */
  88233. readonly extendSizeWorld: Vector3;
  88234. /**
  88235. * Gets the OBB (object bounding box) directions
  88236. */
  88237. readonly directions: Vector3[];
  88238. /**
  88239. * Gets the 8 vectors representing the bounding box in world space
  88240. */
  88241. readonly vectorsWorld: Vector3[];
  88242. /**
  88243. * Gets the minimum vector in world space
  88244. */
  88245. readonly minimumWorld: Vector3;
  88246. /**
  88247. * Gets the maximum vector in world space
  88248. */
  88249. readonly maximumWorld: Vector3;
  88250. /**
  88251. * Gets the minimum vector in local space
  88252. */
  88253. readonly minimum: Vector3;
  88254. /**
  88255. * Gets the maximum vector in local space
  88256. */
  88257. readonly maximum: Vector3;
  88258. private _worldMatrix;
  88259. private static readonly TmpVector3;
  88260. /**
  88261. * @hidden
  88262. */
  88263. _tag: number;
  88264. /**
  88265. * Creates a new bounding box
  88266. * @param min defines the minimum vector (in local space)
  88267. * @param max defines the maximum vector (in local space)
  88268. * @param worldMatrix defines the new world matrix
  88269. */
  88270. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88271. /**
  88272. * Recreates the entire bounding box from scratch as if we call the constructor in place
  88273. * @param min defines the new minimum vector (in local space)
  88274. * @param max defines the new maximum vector (in local space)
  88275. * @param worldMatrix defines the new world matrix
  88276. */
  88277. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88278. /**
  88279. * Scale the current bounding box by applying a scale factor
  88280. * @param factor defines the scale factor to apply
  88281. * @returns the current bounding box
  88282. */
  88283. scale(factor: number): BoundingBox;
  88284. /**
  88285. * Gets the world matrix of the bounding box
  88286. * @returns a matrix
  88287. */
  88288. getWorldMatrix(): DeepImmutable<Matrix>;
  88289. /** @hidden */
  88290. _update(world: DeepImmutable<Matrix>): void;
  88291. /**
  88292. * Tests if the bounding box is intersecting the frustum planes
  88293. * @param frustumPlanes defines the frustum planes to test
  88294. * @returns true if there is an intersection
  88295. */
  88296. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88297. /**
  88298. * Tests if the bounding box is entirely inside the frustum planes
  88299. * @param frustumPlanes defines the frustum planes to test
  88300. * @returns true if there is an inclusion
  88301. */
  88302. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88303. /**
  88304. * Tests if a point is inside the bounding box
  88305. * @param point defines the point to test
  88306. * @returns true if the point is inside the bounding box
  88307. */
  88308. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88309. /**
  88310. * Tests if the bounding box intersects with a bounding sphere
  88311. * @param sphere defines the sphere to test
  88312. * @returns true if there is an intersection
  88313. */
  88314. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  88315. /**
  88316. * Tests if the bounding box intersects with a box defined by a min and max vectors
  88317. * @param min defines the min vector to use
  88318. * @param max defines the max vector to use
  88319. * @returns true if there is an intersection
  88320. */
  88321. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  88322. /**
  88323. * Tests if two bounding boxes are intersections
  88324. * @param box0 defines the first box to test
  88325. * @param box1 defines the second box to test
  88326. * @returns true if there is an intersection
  88327. */
  88328. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  88329. /**
  88330. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  88331. * @param minPoint defines the minimum vector of the bounding box
  88332. * @param maxPoint defines the maximum vector of the bounding box
  88333. * @param sphereCenter defines the sphere center
  88334. * @param sphereRadius defines the sphere radius
  88335. * @returns true if there is an intersection
  88336. */
  88337. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  88338. /**
  88339. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  88340. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88341. * @param frustumPlanes defines the frustum planes to test
  88342. * @return true if there is an inclusion
  88343. */
  88344. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88345. /**
  88346. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  88347. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88348. * @param frustumPlanes defines the frustum planes to test
  88349. * @return true if there is an intersection
  88350. */
  88351. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88352. }
  88353. }
  88354. declare module BABYLON {
  88355. /** @hidden */
  88356. export class Collider {
  88357. /** Define if a collision was found */
  88358. collisionFound: boolean;
  88359. /**
  88360. * Define last intersection point in local space
  88361. */
  88362. intersectionPoint: Vector3;
  88363. /**
  88364. * Define last collided mesh
  88365. */
  88366. collidedMesh: Nullable<AbstractMesh>;
  88367. private _collisionPoint;
  88368. private _planeIntersectionPoint;
  88369. private _tempVector;
  88370. private _tempVector2;
  88371. private _tempVector3;
  88372. private _tempVector4;
  88373. private _edge;
  88374. private _baseToVertex;
  88375. private _destinationPoint;
  88376. private _slidePlaneNormal;
  88377. private _displacementVector;
  88378. /** @hidden */
  88379. _radius: Vector3;
  88380. /** @hidden */
  88381. _retry: number;
  88382. private _velocity;
  88383. private _basePoint;
  88384. private _epsilon;
  88385. /** @hidden */
  88386. _velocityWorldLength: number;
  88387. /** @hidden */
  88388. _basePointWorld: Vector3;
  88389. private _velocityWorld;
  88390. private _normalizedVelocity;
  88391. /** @hidden */
  88392. _initialVelocity: Vector3;
  88393. /** @hidden */
  88394. _initialPosition: Vector3;
  88395. private _nearestDistance;
  88396. private _collisionMask;
  88397. get collisionMask(): number;
  88398. set collisionMask(mask: number);
  88399. /**
  88400. * Gets the plane normal used to compute the sliding response (in local space)
  88401. */
  88402. get slidePlaneNormal(): Vector3;
  88403. /** @hidden */
  88404. _initialize(source: Vector3, dir: Vector3, e: number): void;
  88405. /** @hidden */
  88406. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  88407. /** @hidden */
  88408. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  88409. /** @hidden */
  88410. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88411. /** @hidden */
  88412. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88413. /** @hidden */
  88414. _getResponse(pos: Vector3, vel: Vector3): void;
  88415. }
  88416. }
  88417. declare module BABYLON {
  88418. /**
  88419. * Interface for cullable objects
  88420. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  88421. */
  88422. export interface ICullable {
  88423. /**
  88424. * Checks if the object or part of the object is in the frustum
  88425. * @param frustumPlanes Camera near/planes
  88426. * @returns true if the object is in frustum otherwise false
  88427. */
  88428. isInFrustum(frustumPlanes: Plane[]): boolean;
  88429. /**
  88430. * Checks if a cullable object (mesh...) is in the camera frustum
  88431. * Unlike isInFrustum this cheks the full bounding box
  88432. * @param frustumPlanes Camera near/planes
  88433. * @returns true if the object is in frustum otherwise false
  88434. */
  88435. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88436. }
  88437. /**
  88438. * Info for a bounding data of a mesh
  88439. */
  88440. export class BoundingInfo implements ICullable {
  88441. /**
  88442. * Bounding box for the mesh
  88443. */
  88444. readonly boundingBox: BoundingBox;
  88445. /**
  88446. * Bounding sphere for the mesh
  88447. */
  88448. readonly boundingSphere: BoundingSphere;
  88449. private _isLocked;
  88450. private static readonly TmpVector3;
  88451. /**
  88452. * Constructs bounding info
  88453. * @param minimum min vector of the bounding box/sphere
  88454. * @param maximum max vector of the bounding box/sphere
  88455. * @param worldMatrix defines the new world matrix
  88456. */
  88457. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88458. /**
  88459. * Recreates the entire bounding info from scratch as if we call the constructor in place
  88460. * @param min defines the new minimum vector (in local space)
  88461. * @param max defines the new maximum vector (in local space)
  88462. * @param worldMatrix defines the new world matrix
  88463. */
  88464. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88465. /**
  88466. * min vector of the bounding box/sphere
  88467. */
  88468. get minimum(): Vector3;
  88469. /**
  88470. * max vector of the bounding box/sphere
  88471. */
  88472. get maximum(): Vector3;
  88473. /**
  88474. * If the info is locked and won't be updated to avoid perf overhead
  88475. */
  88476. get isLocked(): boolean;
  88477. set isLocked(value: boolean);
  88478. /**
  88479. * Updates the bounding sphere and box
  88480. * @param world world matrix to be used to update
  88481. */
  88482. update(world: DeepImmutable<Matrix>): void;
  88483. /**
  88484. * Recreate the bounding info to be centered around a specific point given a specific extend.
  88485. * @param center New center of the bounding info
  88486. * @param extend New extend of the bounding info
  88487. * @returns the current bounding info
  88488. */
  88489. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  88490. /**
  88491. * Scale the current bounding info by applying a scale factor
  88492. * @param factor defines the scale factor to apply
  88493. * @returns the current bounding info
  88494. */
  88495. scale(factor: number): BoundingInfo;
  88496. /**
  88497. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  88498. * @param frustumPlanes defines the frustum to test
  88499. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  88500. * @returns true if the bounding info is in the frustum planes
  88501. */
  88502. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  88503. /**
  88504. * Gets the world distance between the min and max points of the bounding box
  88505. */
  88506. get diagonalLength(): number;
  88507. /**
  88508. * Checks if a cullable object (mesh...) is in the camera frustum
  88509. * Unlike isInFrustum this cheks the full bounding box
  88510. * @param frustumPlanes Camera near/planes
  88511. * @returns true if the object is in frustum otherwise false
  88512. */
  88513. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88514. /** @hidden */
  88515. _checkCollision(collider: Collider): boolean;
  88516. /**
  88517. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  88518. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88519. * @param point the point to check intersection with
  88520. * @returns if the point intersects
  88521. */
  88522. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88523. /**
  88524. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  88525. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88526. * @param boundingInfo the bounding info to check intersection with
  88527. * @param precise if the intersection should be done using OBB
  88528. * @returns if the bounding info intersects
  88529. */
  88530. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  88531. }
  88532. }
  88533. declare module BABYLON {
  88534. /**
  88535. * Extracts minimum and maximum values from a list of indexed positions
  88536. * @param positions defines the positions to use
  88537. * @param indices defines the indices to the positions
  88538. * @param indexStart defines the start index
  88539. * @param indexCount defines the end index
  88540. * @param bias defines bias value to add to the result
  88541. * @return minimum and maximum values
  88542. */
  88543. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88544. minimum: Vector3;
  88545. maximum: Vector3;
  88546. };
  88547. /**
  88548. * Extracts minimum and maximum values from a list of positions
  88549. * @param positions defines the positions to use
  88550. * @param start defines the start index in the positions array
  88551. * @param count defines the number of positions to handle
  88552. * @param bias defines bias value to add to the result
  88553. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88554. * @return minimum and maximum values
  88555. */
  88556. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88557. minimum: Vector3;
  88558. maximum: Vector3;
  88559. };
  88560. }
  88561. declare module BABYLON {
  88562. /** @hidden */
  88563. export class WebGLDataBuffer extends DataBuffer {
  88564. private _buffer;
  88565. constructor(resource: WebGLBuffer);
  88566. get underlyingResource(): any;
  88567. }
  88568. }
  88569. declare module BABYLON {
  88570. /** @hidden */
  88571. export class WebGLPipelineContext implements IPipelineContext {
  88572. engine: ThinEngine;
  88573. program: Nullable<WebGLProgram>;
  88574. context?: WebGLRenderingContext;
  88575. vertexShader?: WebGLShader;
  88576. fragmentShader?: WebGLShader;
  88577. isParallelCompiled: boolean;
  88578. onCompiled?: () => void;
  88579. transformFeedback?: WebGLTransformFeedback | null;
  88580. vertexCompilationError: Nullable<string>;
  88581. fragmentCompilationError: Nullable<string>;
  88582. programLinkError: Nullable<string>;
  88583. programValidationError: Nullable<string>;
  88584. get isAsync(): boolean;
  88585. get isReady(): boolean;
  88586. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  88587. _getVertexShaderCode(): string | null;
  88588. _getFragmentShaderCode(): string | null;
  88589. }
  88590. }
  88591. declare module BABYLON {
  88592. interface ThinEngine {
  88593. /**
  88594. * Create an uniform buffer
  88595. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88596. * @param elements defines the content of the uniform buffer
  88597. * @returns the webGL uniform buffer
  88598. */
  88599. createUniformBuffer(elements: FloatArray): DataBuffer;
  88600. /**
  88601. * Create a dynamic uniform buffer
  88602. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88603. * @param elements defines the content of the uniform buffer
  88604. * @returns the webGL uniform buffer
  88605. */
  88606. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88607. /**
  88608. * Update an existing uniform buffer
  88609. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88610. * @param uniformBuffer defines the target uniform buffer
  88611. * @param elements defines the content to update
  88612. * @param offset defines the offset in the uniform buffer where update should start
  88613. * @param count defines the size of the data to update
  88614. */
  88615. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88616. /**
  88617. * Bind an uniform buffer to the current webGL context
  88618. * @param buffer defines the buffer to bind
  88619. */
  88620. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88621. /**
  88622. * Bind a buffer to the current webGL context at a given location
  88623. * @param buffer defines the buffer to bind
  88624. * @param location defines the index where to bind the buffer
  88625. */
  88626. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88627. /**
  88628. * Bind a specific block at a given index in a specific shader program
  88629. * @param pipelineContext defines the pipeline context to use
  88630. * @param blockName defines the block name
  88631. * @param index defines the index where to bind the block
  88632. */
  88633. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88634. }
  88635. }
  88636. declare module BABYLON {
  88637. /**
  88638. * Uniform buffer objects.
  88639. *
  88640. * Handles blocks of uniform on the GPU.
  88641. *
  88642. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88643. *
  88644. * For more information, please refer to :
  88645. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88646. */
  88647. export class UniformBuffer {
  88648. private _engine;
  88649. private _buffer;
  88650. private _data;
  88651. private _bufferData;
  88652. private _dynamic?;
  88653. private _uniformLocations;
  88654. private _uniformSizes;
  88655. private _uniformLocationPointer;
  88656. private _needSync;
  88657. private _noUBO;
  88658. private _currentEffect;
  88659. /** @hidden */
  88660. _alreadyBound: boolean;
  88661. private static _MAX_UNIFORM_SIZE;
  88662. private static _tempBuffer;
  88663. /**
  88664. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88665. * This is dynamic to allow compat with webgl 1 and 2.
  88666. * You will need to pass the name of the uniform as well as the value.
  88667. */
  88668. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88669. /**
  88670. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88671. * This is dynamic to allow compat with webgl 1 and 2.
  88672. * You will need to pass the name of the uniform as well as the value.
  88673. */
  88674. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88675. /**
  88676. * Lambda to Update a single float in a uniform buffer.
  88677. * This is dynamic to allow compat with webgl 1 and 2.
  88678. * You will need to pass the name of the uniform as well as the value.
  88679. */
  88680. updateFloat: (name: string, x: number) => void;
  88681. /**
  88682. * Lambda to Update a vec2 of float in a uniform buffer.
  88683. * This is dynamic to allow compat with webgl 1 and 2.
  88684. * You will need to pass the name of the uniform as well as the value.
  88685. */
  88686. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88687. /**
  88688. * Lambda to Update a vec3 of float in a uniform buffer.
  88689. * This is dynamic to allow compat with webgl 1 and 2.
  88690. * You will need to pass the name of the uniform as well as the value.
  88691. */
  88692. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88693. /**
  88694. * Lambda to Update a vec4 of float in a uniform buffer.
  88695. * This is dynamic to allow compat with webgl 1 and 2.
  88696. * You will need to pass the name of the uniform as well as the value.
  88697. */
  88698. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88699. /**
  88700. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88701. * This is dynamic to allow compat with webgl 1 and 2.
  88702. * You will need to pass the name of the uniform as well as the value.
  88703. */
  88704. updateMatrix: (name: string, mat: Matrix) => void;
  88705. /**
  88706. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88707. * This is dynamic to allow compat with webgl 1 and 2.
  88708. * You will need to pass the name of the uniform as well as the value.
  88709. */
  88710. updateVector3: (name: string, vector: Vector3) => void;
  88711. /**
  88712. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88713. * This is dynamic to allow compat with webgl 1 and 2.
  88714. * You will need to pass the name of the uniform as well as the value.
  88715. */
  88716. updateVector4: (name: string, vector: Vector4) => void;
  88717. /**
  88718. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88719. * This is dynamic to allow compat with webgl 1 and 2.
  88720. * You will need to pass the name of the uniform as well as the value.
  88721. */
  88722. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88723. /**
  88724. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88725. * This is dynamic to allow compat with webgl 1 and 2.
  88726. * You will need to pass the name of the uniform as well as the value.
  88727. */
  88728. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88729. /**
  88730. * Instantiates a new Uniform buffer objects.
  88731. *
  88732. * Handles blocks of uniform on the GPU.
  88733. *
  88734. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88735. *
  88736. * For more information, please refer to :
  88737. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88738. * @param engine Define the engine the buffer is associated with
  88739. * @param data Define the data contained in the buffer
  88740. * @param dynamic Define if the buffer is updatable
  88741. */
  88742. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88743. /**
  88744. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88745. * or just falling back on setUniformXXX calls.
  88746. */
  88747. get useUbo(): boolean;
  88748. /**
  88749. * Indicates if the WebGL underlying uniform buffer is in sync
  88750. * with the javascript cache data.
  88751. */
  88752. get isSync(): boolean;
  88753. /**
  88754. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88755. * Also, a dynamic UniformBuffer will disable cache verification and always
  88756. * update the underlying WebGL uniform buffer to the GPU.
  88757. * @returns if Dynamic, otherwise false
  88758. */
  88759. isDynamic(): boolean;
  88760. /**
  88761. * The data cache on JS side.
  88762. * @returns the underlying data as a float array
  88763. */
  88764. getData(): Float32Array;
  88765. /**
  88766. * The underlying WebGL Uniform buffer.
  88767. * @returns the webgl buffer
  88768. */
  88769. getBuffer(): Nullable<DataBuffer>;
  88770. /**
  88771. * std140 layout specifies how to align data within an UBO structure.
  88772. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88773. * for specs.
  88774. */
  88775. private _fillAlignment;
  88776. /**
  88777. * Adds an uniform in the buffer.
  88778. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88779. * for the layout to be correct !
  88780. * @param name Name of the uniform, as used in the uniform block in the shader.
  88781. * @param size Data size, or data directly.
  88782. */
  88783. addUniform(name: string, size: number | number[]): void;
  88784. /**
  88785. * Adds a Matrix 4x4 to the uniform buffer.
  88786. * @param name Name of the uniform, as used in the uniform block in the shader.
  88787. * @param mat A 4x4 matrix.
  88788. */
  88789. addMatrix(name: string, mat: Matrix): void;
  88790. /**
  88791. * Adds a vec2 to the uniform buffer.
  88792. * @param name Name of the uniform, as used in the uniform block in the shader.
  88793. * @param x Define the x component value of the vec2
  88794. * @param y Define the y component value of the vec2
  88795. */
  88796. addFloat2(name: string, x: number, y: number): void;
  88797. /**
  88798. * Adds a vec3 to the uniform buffer.
  88799. * @param name Name of the uniform, as used in the uniform block in the shader.
  88800. * @param x Define the x component value of the vec3
  88801. * @param y Define the y component value of the vec3
  88802. * @param z Define the z component value of the vec3
  88803. */
  88804. addFloat3(name: string, x: number, y: number, z: number): void;
  88805. /**
  88806. * Adds a vec3 to the uniform buffer.
  88807. * @param name Name of the uniform, as used in the uniform block in the shader.
  88808. * @param color Define the vec3 from a Color
  88809. */
  88810. addColor3(name: string, color: Color3): void;
  88811. /**
  88812. * Adds a vec4 to the uniform buffer.
  88813. * @param name Name of the uniform, as used in the uniform block in the shader.
  88814. * @param color Define the rgb components from a Color
  88815. * @param alpha Define the a component of the vec4
  88816. */
  88817. addColor4(name: string, color: Color3, alpha: number): void;
  88818. /**
  88819. * Adds a vec3 to the uniform buffer.
  88820. * @param name Name of the uniform, as used in the uniform block in the shader.
  88821. * @param vector Define the vec3 components from a Vector
  88822. */
  88823. addVector3(name: string, vector: Vector3): void;
  88824. /**
  88825. * Adds a Matrix 3x3 to the uniform buffer.
  88826. * @param name Name of the uniform, as used in the uniform block in the shader.
  88827. */
  88828. addMatrix3x3(name: string): void;
  88829. /**
  88830. * Adds a Matrix 2x2 to the uniform buffer.
  88831. * @param name Name of the uniform, as used in the uniform block in the shader.
  88832. */
  88833. addMatrix2x2(name: string): void;
  88834. /**
  88835. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88836. */
  88837. create(): void;
  88838. /** @hidden */
  88839. _rebuild(): void;
  88840. /**
  88841. * Updates the WebGL Uniform Buffer on the GPU.
  88842. * If the `dynamic` flag is set to true, no cache comparison is done.
  88843. * Otherwise, the buffer will be updated only if the cache differs.
  88844. */
  88845. update(): void;
  88846. /**
  88847. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88848. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88849. * @param data Define the flattened data
  88850. * @param size Define the size of the data.
  88851. */
  88852. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88853. private _valueCache;
  88854. private _cacheMatrix;
  88855. private _updateMatrix3x3ForUniform;
  88856. private _updateMatrix3x3ForEffect;
  88857. private _updateMatrix2x2ForEffect;
  88858. private _updateMatrix2x2ForUniform;
  88859. private _updateFloatForEffect;
  88860. private _updateFloatForUniform;
  88861. private _updateFloat2ForEffect;
  88862. private _updateFloat2ForUniform;
  88863. private _updateFloat3ForEffect;
  88864. private _updateFloat3ForUniform;
  88865. private _updateFloat4ForEffect;
  88866. private _updateFloat4ForUniform;
  88867. private _updateMatrixForEffect;
  88868. private _updateMatrixForUniform;
  88869. private _updateVector3ForEffect;
  88870. private _updateVector3ForUniform;
  88871. private _updateVector4ForEffect;
  88872. private _updateVector4ForUniform;
  88873. private _updateColor3ForEffect;
  88874. private _updateColor3ForUniform;
  88875. private _updateColor4ForEffect;
  88876. private _updateColor4ForUniform;
  88877. /**
  88878. * Sets a sampler uniform on the effect.
  88879. * @param name Define the name of the sampler.
  88880. * @param texture Define the texture to set in the sampler
  88881. */
  88882. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88883. /**
  88884. * Directly updates the value of the uniform in the cache AND on the GPU.
  88885. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88886. * @param data Define the flattened data
  88887. */
  88888. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88889. /**
  88890. * Binds this uniform buffer to an effect.
  88891. * @param effect Define the effect to bind the buffer to
  88892. * @param name Name of the uniform block in the shader.
  88893. */
  88894. bindToEffect(effect: Effect, name: string): void;
  88895. /**
  88896. * Disposes the uniform buffer.
  88897. */
  88898. dispose(): void;
  88899. }
  88900. }
  88901. declare module BABYLON {
  88902. /**
  88903. * Enum that determines the text-wrapping mode to use.
  88904. */
  88905. export enum InspectableType {
  88906. /**
  88907. * Checkbox for booleans
  88908. */
  88909. Checkbox = 0,
  88910. /**
  88911. * Sliders for numbers
  88912. */
  88913. Slider = 1,
  88914. /**
  88915. * Vector3
  88916. */
  88917. Vector3 = 2,
  88918. /**
  88919. * Quaternions
  88920. */
  88921. Quaternion = 3,
  88922. /**
  88923. * Color3
  88924. */
  88925. Color3 = 4,
  88926. /**
  88927. * String
  88928. */
  88929. String = 5
  88930. }
  88931. /**
  88932. * Interface used to define custom inspectable properties.
  88933. * This interface is used by the inspector to display custom property grids
  88934. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88935. */
  88936. export interface IInspectable {
  88937. /**
  88938. * Gets the label to display
  88939. */
  88940. label: string;
  88941. /**
  88942. * Gets the name of the property to edit
  88943. */
  88944. propertyName: string;
  88945. /**
  88946. * Gets the type of the editor to use
  88947. */
  88948. type: InspectableType;
  88949. /**
  88950. * Gets the minimum value of the property when using in "slider" mode
  88951. */
  88952. min?: number;
  88953. /**
  88954. * Gets the maximum value of the property when using in "slider" mode
  88955. */
  88956. max?: number;
  88957. /**
  88958. * Gets the setp to use when using in "slider" mode
  88959. */
  88960. step?: number;
  88961. }
  88962. }
  88963. declare module BABYLON {
  88964. /**
  88965. * Class used to provide helper for timing
  88966. */
  88967. export class TimingTools {
  88968. /**
  88969. * Polyfill for setImmediate
  88970. * @param action defines the action to execute after the current execution block
  88971. */
  88972. static SetImmediate(action: () => void): void;
  88973. }
  88974. }
  88975. declare module BABYLON {
  88976. /**
  88977. * Class used to enable instatition of objects by class name
  88978. */
  88979. export class InstantiationTools {
  88980. /**
  88981. * Use this object to register external classes like custom textures or material
  88982. * to allow the laoders to instantiate them
  88983. */
  88984. static RegisteredExternalClasses: {
  88985. [key: string]: Object;
  88986. };
  88987. /**
  88988. * Tries to instantiate a new object from a given class name
  88989. * @param className defines the class name to instantiate
  88990. * @returns the new object or null if the system was not able to do the instantiation
  88991. */
  88992. static Instantiate(className: string): any;
  88993. }
  88994. }
  88995. declare module BABYLON {
  88996. /**
  88997. * Class used to host copy specific utilities
  88998. */
  88999. export class CopyTools {
  89000. /**
  89001. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  89002. * @param texture defines the texture to read pixels from
  89003. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89004. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89005. * @returns The base64 encoded string or null
  89006. */
  89007. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  89008. }
  89009. }
  89010. declare module BABYLON {
  89011. /**
  89012. * Define options used to create a depth texture
  89013. */
  89014. export class DepthTextureCreationOptions {
  89015. /** Specifies whether or not a stencil should be allocated in the texture */
  89016. generateStencil?: boolean;
  89017. /** Specifies whether or not bilinear filtering is enable on the texture */
  89018. bilinearFiltering?: boolean;
  89019. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89020. comparisonFunction?: number;
  89021. /** Specifies if the created texture is a cube texture */
  89022. isCube?: boolean;
  89023. }
  89024. }
  89025. declare module BABYLON {
  89026. interface ThinEngine {
  89027. /**
  89028. * Creates a depth stencil cube texture.
  89029. * This is only available in WebGL 2.
  89030. * @param size The size of face edge in the cube texture.
  89031. * @param options The options defining the cube texture.
  89032. * @returns The cube texture
  89033. */
  89034. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  89035. /**
  89036. * Creates a cube texture
  89037. * @param rootUrl defines the url where the files to load is located
  89038. * @param scene defines the current scene
  89039. * @param files defines the list of files to load (1 per face)
  89040. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  89041. * @param onLoad defines an optional callback raised when the texture is loaded
  89042. * @param onError defines an optional callback raised if there is an issue to load the texture
  89043. * @param format defines the format of the data
  89044. * @param forcedExtension defines the extension to use to pick the right loader
  89045. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  89046. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  89047. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  89048. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  89049. * @param loaderOptions options to be passed to the loader
  89050. * @returns the cube texture as an InternalTexture
  89051. */
  89052. 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;
  89053. /**
  89054. * Creates a cube texture
  89055. * @param rootUrl defines the url where the files to load is located
  89056. * @param scene defines the current scene
  89057. * @param files defines the list of files to load (1 per face)
  89058. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  89059. * @param onLoad defines an optional callback raised when the texture is loaded
  89060. * @param onError defines an optional callback raised if there is an issue to load the texture
  89061. * @param format defines the format of the data
  89062. * @param forcedExtension defines the extension to use to pick the right loader
  89063. * @returns the cube texture as an InternalTexture
  89064. */
  89065. 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;
  89066. /**
  89067. * Creates a cube texture
  89068. * @param rootUrl defines the url where the files to load is located
  89069. * @param scene defines the current scene
  89070. * @param files defines the list of files to load (1 per face)
  89071. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  89072. * @param onLoad defines an optional callback raised when the texture is loaded
  89073. * @param onError defines an optional callback raised if there is an issue to load the texture
  89074. * @param format defines the format of the data
  89075. * @param forcedExtension defines the extension to use to pick the right loader
  89076. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  89077. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  89078. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  89079. * @returns the cube texture as an InternalTexture
  89080. */
  89081. 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;
  89082. /** @hidden */
  89083. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  89084. /** @hidden */
  89085. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  89086. /** @hidden */
  89087. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  89088. /** @hidden */
  89089. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  89090. /**
  89091. * @hidden
  89092. */
  89093. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  89094. }
  89095. }
  89096. declare module BABYLON {
  89097. /**
  89098. * Class for creating a cube texture
  89099. */
  89100. export class CubeTexture extends BaseTexture {
  89101. private _delayedOnLoad;
  89102. /**
  89103. * Observable triggered once the texture has been loaded.
  89104. */
  89105. onLoadObservable: Observable<CubeTexture>;
  89106. /**
  89107. * The url of the texture
  89108. */
  89109. url: string;
  89110. /**
  89111. * Gets or sets the center of the bounding box associated with the cube texture.
  89112. * It must define where the camera used to render the texture was set
  89113. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  89114. */
  89115. boundingBoxPosition: Vector3;
  89116. private _boundingBoxSize;
  89117. /**
  89118. * Gets or sets the size of the bounding box associated with the cube texture
  89119. * When defined, the cubemap will switch to local mode
  89120. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  89121. * @example https://www.babylonjs-playground.com/#RNASML
  89122. */
  89123. set boundingBoxSize(value: Vector3);
  89124. /**
  89125. * Returns the bounding box size
  89126. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  89127. */
  89128. get boundingBoxSize(): Vector3;
  89129. protected _rotationY: number;
  89130. /**
  89131. * Sets texture matrix rotation angle around Y axis in radians.
  89132. */
  89133. set rotationY(value: number);
  89134. /**
  89135. * Gets texture matrix rotation angle around Y axis radians.
  89136. */
  89137. get rotationY(): number;
  89138. /**
  89139. * Are mip maps generated for this texture or not.
  89140. */
  89141. get noMipmap(): boolean;
  89142. private _noMipmap;
  89143. private _files;
  89144. protected _forcedExtension: Nullable<string>;
  89145. private _extensions;
  89146. private _textureMatrix;
  89147. private _format;
  89148. private _createPolynomials;
  89149. private _loaderOptions;
  89150. /**
  89151. * Creates a cube texture from an array of image urls
  89152. * @param files defines an array of image urls
  89153. * @param scene defines the hosting scene
  89154. * @param noMipmap specifies if mip maps are not used
  89155. * @returns a cube texture
  89156. */
  89157. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  89158. /**
  89159. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  89160. * @param url defines the url of the prefiltered texture
  89161. * @param scene defines the scene the texture is attached to
  89162. * @param forcedExtension defines the extension of the file if different from the url
  89163. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  89164. * @return the prefiltered texture
  89165. */
  89166. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  89167. /**
  89168. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  89169. * as prefiltered data.
  89170. * @param rootUrl defines the url of the texture or the root name of the six images
  89171. * @param null defines the scene or engine the texture is attached to
  89172. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  89173. * @param noMipmap defines if mipmaps should be created or not
  89174. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  89175. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  89176. * @param onError defines a callback triggered in case of error during load
  89177. * @param format defines the internal format to use for the texture once loaded
  89178. * @param prefiltered defines whether or not the texture is created from prefiltered data
  89179. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  89180. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  89181. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  89182. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  89183. * @param loaderOptions options to be passed to the loader
  89184. * @return the cube texture
  89185. */
  89186. 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);
  89187. /**
  89188. * Get the current class name of the texture useful for serialization or dynamic coding.
  89189. * @returns "CubeTexture"
  89190. */
  89191. getClassName(): string;
  89192. /**
  89193. * Update the url (and optional buffer) of this texture if url was null during construction.
  89194. * @param url the url of the texture
  89195. * @param forcedExtension defines the extension to use
  89196. * @param onLoad callback called when the texture is loaded (defaults to null)
  89197. * @param prefiltered Defines whether the updated texture is prefiltered or not
  89198. */
  89199. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  89200. /**
  89201. * Delays loading of the cube texture
  89202. * @param forcedExtension defines the extension to use
  89203. */
  89204. delayLoad(forcedExtension?: string): void;
  89205. /**
  89206. * Returns the reflection texture matrix
  89207. * @returns the reflection texture matrix
  89208. */
  89209. getReflectionTextureMatrix(): Matrix;
  89210. /**
  89211. * Sets the reflection texture matrix
  89212. * @param value Reflection texture matrix
  89213. */
  89214. setReflectionTextureMatrix(value: Matrix): void;
  89215. /**
  89216. * Parses text to create a cube texture
  89217. * @param parsedTexture define the serialized text to read from
  89218. * @param scene defines the hosting scene
  89219. * @param rootUrl defines the root url of the cube texture
  89220. * @returns a cube texture
  89221. */
  89222. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  89223. /**
  89224. * Makes a clone, or deep copy, of the cube texture
  89225. * @returns a new cube texture
  89226. */
  89227. clone(): CubeTexture;
  89228. }
  89229. }
  89230. declare module BABYLON {
  89231. /**
  89232. * Manages the defines for the Material
  89233. */
  89234. export class MaterialDefines {
  89235. /** @hidden */
  89236. protected _keys: string[];
  89237. private _isDirty;
  89238. /** @hidden */
  89239. _renderId: number;
  89240. /** @hidden */
  89241. _areLightsDirty: boolean;
  89242. /** @hidden */
  89243. _areLightsDisposed: boolean;
  89244. /** @hidden */
  89245. _areAttributesDirty: boolean;
  89246. /** @hidden */
  89247. _areTexturesDirty: boolean;
  89248. /** @hidden */
  89249. _areFresnelDirty: boolean;
  89250. /** @hidden */
  89251. _areMiscDirty: boolean;
  89252. /** @hidden */
  89253. _arePrePassDirty: boolean;
  89254. /** @hidden */
  89255. _areImageProcessingDirty: boolean;
  89256. /** @hidden */
  89257. _normals: boolean;
  89258. /** @hidden */
  89259. _uvs: boolean;
  89260. /** @hidden */
  89261. _needNormals: boolean;
  89262. /** @hidden */
  89263. _needUVs: boolean;
  89264. [id: string]: any;
  89265. /**
  89266. * Specifies if the material needs to be re-calculated
  89267. */
  89268. get isDirty(): boolean;
  89269. /**
  89270. * Marks the material to indicate that it has been re-calculated
  89271. */
  89272. markAsProcessed(): void;
  89273. /**
  89274. * Marks the material to indicate that it needs to be re-calculated
  89275. */
  89276. markAsUnprocessed(): void;
  89277. /**
  89278. * Marks the material to indicate all of its defines need to be re-calculated
  89279. */
  89280. markAllAsDirty(): void;
  89281. /**
  89282. * Marks the material to indicate that image processing needs to be re-calculated
  89283. */
  89284. markAsImageProcessingDirty(): void;
  89285. /**
  89286. * Marks the material to indicate the lights need to be re-calculated
  89287. * @param disposed Defines whether the light is dirty due to dispose or not
  89288. */
  89289. markAsLightDirty(disposed?: boolean): void;
  89290. /**
  89291. * Marks the attribute state as changed
  89292. */
  89293. markAsAttributesDirty(): void;
  89294. /**
  89295. * Marks the texture state as changed
  89296. */
  89297. markAsTexturesDirty(): void;
  89298. /**
  89299. * Marks the fresnel state as changed
  89300. */
  89301. markAsFresnelDirty(): void;
  89302. /**
  89303. * Marks the misc state as changed
  89304. */
  89305. markAsMiscDirty(): void;
  89306. /**
  89307. * Marks the prepass state as changed
  89308. */
  89309. markAsPrePassDirty(): void;
  89310. /**
  89311. * Rebuilds the material defines
  89312. */
  89313. rebuild(): void;
  89314. /**
  89315. * Specifies if two material defines are equal
  89316. * @param other - A material define instance to compare to
  89317. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  89318. */
  89319. isEqual(other: MaterialDefines): boolean;
  89320. /**
  89321. * Clones this instance's defines to another instance
  89322. * @param other - material defines to clone values to
  89323. */
  89324. cloneTo(other: MaterialDefines): void;
  89325. /**
  89326. * Resets the material define values
  89327. */
  89328. reset(): void;
  89329. /**
  89330. * Converts the material define values to a string
  89331. * @returns - String of material define information
  89332. */
  89333. toString(): string;
  89334. }
  89335. }
  89336. declare module BABYLON {
  89337. /**
  89338. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89339. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89340. * 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;
  89341. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89342. */
  89343. export class ColorCurves {
  89344. private _dirty;
  89345. private _tempColor;
  89346. private _globalCurve;
  89347. private _highlightsCurve;
  89348. private _midtonesCurve;
  89349. private _shadowsCurve;
  89350. private _positiveCurve;
  89351. private _negativeCurve;
  89352. private _globalHue;
  89353. private _globalDensity;
  89354. private _globalSaturation;
  89355. private _globalExposure;
  89356. /**
  89357. * Gets the global Hue value.
  89358. * 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).
  89359. */
  89360. get globalHue(): number;
  89361. /**
  89362. * Sets the global Hue value.
  89363. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  89364. */
  89365. set globalHue(value: number);
  89366. /**
  89367. * Gets the global Density value.
  89368. * 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.
  89369. * Values less than zero provide a filter of opposite hue.
  89370. */
  89371. get globalDensity(): number;
  89372. /**
  89373. * Sets the global Density value.
  89374. * 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.
  89375. * Values less than zero provide a filter of opposite hue.
  89376. */
  89377. set globalDensity(value: number);
  89378. /**
  89379. * Gets the global Saturation value.
  89380. * 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.
  89381. */
  89382. get globalSaturation(): number;
  89383. /**
  89384. * Sets the global Saturation value.
  89385. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  89386. */
  89387. set globalSaturation(value: number);
  89388. /**
  89389. * Gets the global Exposure value.
  89390. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  89391. */
  89392. get globalExposure(): number;
  89393. /**
  89394. * Sets the global Exposure value.
  89395. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  89396. */
  89397. set globalExposure(value: number);
  89398. private _highlightsHue;
  89399. private _highlightsDensity;
  89400. private _highlightsSaturation;
  89401. private _highlightsExposure;
  89402. /**
  89403. * Gets the highlights Hue value.
  89404. * 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).
  89405. */
  89406. get highlightsHue(): number;
  89407. /**
  89408. * Sets the highlights Hue value.
  89409. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  89410. */
  89411. set highlightsHue(value: number);
  89412. /**
  89413. * Gets the highlights Density value.
  89414. * 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.
  89415. * Values less than zero provide a filter of opposite hue.
  89416. */
  89417. get highlightsDensity(): number;
  89418. /**
  89419. * Sets the highlights Density value.
  89420. * 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.
  89421. * Values less than zero provide a filter of opposite hue.
  89422. */
  89423. set highlightsDensity(value: number);
  89424. /**
  89425. * Gets the highlights Saturation value.
  89426. * 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.
  89427. */
  89428. get highlightsSaturation(): number;
  89429. /**
  89430. * Sets the highlights Saturation value.
  89431. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  89432. */
  89433. set highlightsSaturation(value: number);
  89434. /**
  89435. * Gets the highlights Exposure value.
  89436. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  89437. */
  89438. get highlightsExposure(): number;
  89439. /**
  89440. * Sets the highlights Exposure value.
  89441. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  89442. */
  89443. set highlightsExposure(value: number);
  89444. private _midtonesHue;
  89445. private _midtonesDensity;
  89446. private _midtonesSaturation;
  89447. private _midtonesExposure;
  89448. /**
  89449. * Gets the midtones Hue value.
  89450. * 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).
  89451. */
  89452. get midtonesHue(): number;
  89453. /**
  89454. * Sets the midtones Hue value.
  89455. * 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).
  89456. */
  89457. set midtonesHue(value: number);
  89458. /**
  89459. * Gets the midtones Density value.
  89460. * 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.
  89461. * Values less than zero provide a filter of opposite hue.
  89462. */
  89463. get midtonesDensity(): number;
  89464. /**
  89465. * Sets the midtones Density value.
  89466. * 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.
  89467. * Values less than zero provide a filter of opposite hue.
  89468. */
  89469. set midtonesDensity(value: number);
  89470. /**
  89471. * Gets the midtones Saturation value.
  89472. * 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.
  89473. */
  89474. get midtonesSaturation(): number;
  89475. /**
  89476. * Sets the midtones Saturation value.
  89477. * 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.
  89478. */
  89479. set midtonesSaturation(value: number);
  89480. /**
  89481. * Gets the midtones Exposure value.
  89482. * 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.
  89483. */
  89484. get midtonesExposure(): number;
  89485. /**
  89486. * Sets the midtones Exposure value.
  89487. * 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.
  89488. */
  89489. set midtonesExposure(value: number);
  89490. private _shadowsHue;
  89491. private _shadowsDensity;
  89492. private _shadowsSaturation;
  89493. private _shadowsExposure;
  89494. /**
  89495. * Gets the shadows Hue value.
  89496. * 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).
  89497. */
  89498. get shadowsHue(): number;
  89499. /**
  89500. * Sets the shadows Hue value.
  89501. * 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).
  89502. */
  89503. set shadowsHue(value: number);
  89504. /**
  89505. * Gets the shadows Density value.
  89506. * 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.
  89507. * Values less than zero provide a filter of opposite hue.
  89508. */
  89509. get shadowsDensity(): number;
  89510. /**
  89511. * Sets the shadows Density value.
  89512. * 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.
  89513. * Values less than zero provide a filter of opposite hue.
  89514. */
  89515. set shadowsDensity(value: number);
  89516. /**
  89517. * Gets the shadows Saturation value.
  89518. * 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.
  89519. */
  89520. get shadowsSaturation(): number;
  89521. /**
  89522. * Sets the shadows Saturation value.
  89523. * 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.
  89524. */
  89525. set shadowsSaturation(value: number);
  89526. /**
  89527. * Gets the shadows Exposure value.
  89528. * 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.
  89529. */
  89530. get shadowsExposure(): number;
  89531. /**
  89532. * Sets the shadows Exposure value.
  89533. * 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.
  89534. */
  89535. set shadowsExposure(value: number);
  89536. /**
  89537. * Returns the class name
  89538. * @returns The class name
  89539. */
  89540. getClassName(): string;
  89541. /**
  89542. * Binds the color curves to the shader.
  89543. * @param colorCurves The color curve to bind
  89544. * @param effect The effect to bind to
  89545. * @param positiveUniform The positive uniform shader parameter
  89546. * @param neutralUniform The neutral uniform shader parameter
  89547. * @param negativeUniform The negative uniform shader parameter
  89548. */
  89549. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89550. /**
  89551. * Prepare the list of uniforms associated with the ColorCurves effects.
  89552. * @param uniformsList The list of uniforms used in the effect
  89553. */
  89554. static PrepareUniforms(uniformsList: string[]): void;
  89555. /**
  89556. * Returns color grading data based on a hue, density, saturation and exposure value.
  89557. * @param filterHue The hue of the color filter.
  89558. * @param filterDensity The density of the color filter.
  89559. * @param saturation The saturation.
  89560. * @param exposure The exposure.
  89561. * @param result The result data container.
  89562. */
  89563. private getColorGradingDataToRef;
  89564. /**
  89565. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89566. * @param value The input slider value in range [-100,100].
  89567. * @returns Adjusted value.
  89568. */
  89569. private static applyColorGradingSliderNonlinear;
  89570. /**
  89571. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89572. * @param hue The hue (H) input.
  89573. * @param saturation The saturation (S) input.
  89574. * @param brightness The brightness (B) input.
  89575. * @result An RGBA color represented as Vector4.
  89576. */
  89577. private static fromHSBToRef;
  89578. /**
  89579. * Returns a value clamped between min and max
  89580. * @param value The value to clamp
  89581. * @param min The minimum of value
  89582. * @param max The maximum of value
  89583. * @returns The clamped value.
  89584. */
  89585. private static clamp;
  89586. /**
  89587. * Clones the current color curve instance.
  89588. * @return The cloned curves
  89589. */
  89590. clone(): ColorCurves;
  89591. /**
  89592. * Serializes the current color curve instance to a json representation.
  89593. * @return a JSON representation
  89594. */
  89595. serialize(): any;
  89596. /**
  89597. * Parses the color curve from a json representation.
  89598. * @param source the JSON source to parse
  89599. * @return The parsed curves
  89600. */
  89601. static Parse(source: any): ColorCurves;
  89602. }
  89603. }
  89604. declare module BABYLON {
  89605. /**
  89606. * Interface to follow in your material defines to integrate easily the
  89607. * Image proccessing functions.
  89608. * @hidden
  89609. */
  89610. export interface IImageProcessingConfigurationDefines {
  89611. IMAGEPROCESSING: boolean;
  89612. VIGNETTE: boolean;
  89613. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89614. VIGNETTEBLENDMODEOPAQUE: boolean;
  89615. TONEMAPPING: boolean;
  89616. TONEMAPPING_ACES: boolean;
  89617. CONTRAST: boolean;
  89618. EXPOSURE: boolean;
  89619. COLORCURVES: boolean;
  89620. COLORGRADING: boolean;
  89621. COLORGRADING3D: boolean;
  89622. SAMPLER3DGREENDEPTH: boolean;
  89623. SAMPLER3DBGRMAP: boolean;
  89624. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89625. }
  89626. /**
  89627. * @hidden
  89628. */
  89629. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89630. IMAGEPROCESSING: boolean;
  89631. VIGNETTE: boolean;
  89632. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89633. VIGNETTEBLENDMODEOPAQUE: boolean;
  89634. TONEMAPPING: boolean;
  89635. TONEMAPPING_ACES: boolean;
  89636. CONTRAST: boolean;
  89637. COLORCURVES: boolean;
  89638. COLORGRADING: boolean;
  89639. COLORGRADING3D: boolean;
  89640. SAMPLER3DGREENDEPTH: boolean;
  89641. SAMPLER3DBGRMAP: boolean;
  89642. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89643. EXPOSURE: boolean;
  89644. constructor();
  89645. }
  89646. /**
  89647. * This groups together the common properties used for image processing either in direct forward pass
  89648. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89649. * or not.
  89650. */
  89651. export class ImageProcessingConfiguration {
  89652. /**
  89653. * Default tone mapping applied in BabylonJS.
  89654. */
  89655. static readonly TONEMAPPING_STANDARD: number;
  89656. /**
  89657. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89658. * to other engines rendering to increase portability.
  89659. */
  89660. static readonly TONEMAPPING_ACES: number;
  89661. /**
  89662. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89663. */
  89664. colorCurves: Nullable<ColorCurves>;
  89665. private _colorCurvesEnabled;
  89666. /**
  89667. * Gets wether the color curves effect is enabled.
  89668. */
  89669. get colorCurvesEnabled(): boolean;
  89670. /**
  89671. * Sets wether the color curves effect is enabled.
  89672. */
  89673. set colorCurvesEnabled(value: boolean);
  89674. private _colorGradingTexture;
  89675. /**
  89676. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89677. */
  89678. get colorGradingTexture(): Nullable<BaseTexture>;
  89679. /**
  89680. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89681. */
  89682. set colorGradingTexture(value: Nullable<BaseTexture>);
  89683. private _colorGradingEnabled;
  89684. /**
  89685. * Gets wether the color grading effect is enabled.
  89686. */
  89687. get colorGradingEnabled(): boolean;
  89688. /**
  89689. * Sets wether the color grading effect is enabled.
  89690. */
  89691. set colorGradingEnabled(value: boolean);
  89692. private _colorGradingWithGreenDepth;
  89693. /**
  89694. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89695. */
  89696. get colorGradingWithGreenDepth(): boolean;
  89697. /**
  89698. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89699. */
  89700. set colorGradingWithGreenDepth(value: boolean);
  89701. private _colorGradingBGR;
  89702. /**
  89703. * Gets wether the color grading texture contains BGR values.
  89704. */
  89705. get colorGradingBGR(): boolean;
  89706. /**
  89707. * Sets wether the color grading texture contains BGR values.
  89708. */
  89709. set colorGradingBGR(value: boolean);
  89710. /** @hidden */
  89711. _exposure: number;
  89712. /**
  89713. * Gets the Exposure used in the effect.
  89714. */
  89715. get exposure(): number;
  89716. /**
  89717. * Sets the Exposure used in the effect.
  89718. */
  89719. set exposure(value: number);
  89720. private _toneMappingEnabled;
  89721. /**
  89722. * Gets wether the tone mapping effect is enabled.
  89723. */
  89724. get toneMappingEnabled(): boolean;
  89725. /**
  89726. * Sets wether the tone mapping effect is enabled.
  89727. */
  89728. set toneMappingEnabled(value: boolean);
  89729. private _toneMappingType;
  89730. /**
  89731. * Gets the type of tone mapping effect.
  89732. */
  89733. get toneMappingType(): number;
  89734. /**
  89735. * Sets the type of tone mapping effect used in BabylonJS.
  89736. */
  89737. set toneMappingType(value: number);
  89738. protected _contrast: number;
  89739. /**
  89740. * Gets the contrast used in the effect.
  89741. */
  89742. get contrast(): number;
  89743. /**
  89744. * Sets the contrast used in the effect.
  89745. */
  89746. set contrast(value: number);
  89747. /**
  89748. * Vignette stretch size.
  89749. */
  89750. vignetteStretch: number;
  89751. /**
  89752. * Vignette centre X Offset.
  89753. */
  89754. vignetteCentreX: number;
  89755. /**
  89756. * Vignette centre Y Offset.
  89757. */
  89758. vignetteCentreY: number;
  89759. /**
  89760. * Vignette weight or intensity of the vignette effect.
  89761. */
  89762. vignetteWeight: number;
  89763. /**
  89764. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89765. * if vignetteEnabled is set to true.
  89766. */
  89767. vignetteColor: Color4;
  89768. /**
  89769. * Camera field of view used by the Vignette effect.
  89770. */
  89771. vignetteCameraFov: number;
  89772. private _vignetteBlendMode;
  89773. /**
  89774. * Gets the vignette blend mode allowing different kind of effect.
  89775. */
  89776. get vignetteBlendMode(): number;
  89777. /**
  89778. * Sets the vignette blend mode allowing different kind of effect.
  89779. */
  89780. set vignetteBlendMode(value: number);
  89781. private _vignetteEnabled;
  89782. /**
  89783. * Gets wether the vignette effect is enabled.
  89784. */
  89785. get vignetteEnabled(): boolean;
  89786. /**
  89787. * Sets wether the vignette effect is enabled.
  89788. */
  89789. set vignetteEnabled(value: boolean);
  89790. private _applyByPostProcess;
  89791. /**
  89792. * Gets wether the image processing is applied through a post process or not.
  89793. */
  89794. get applyByPostProcess(): boolean;
  89795. /**
  89796. * Sets wether the image processing is applied through a post process or not.
  89797. */
  89798. set applyByPostProcess(value: boolean);
  89799. private _isEnabled;
  89800. /**
  89801. * Gets wether the image processing is enabled or not.
  89802. */
  89803. get isEnabled(): boolean;
  89804. /**
  89805. * Sets wether the image processing is enabled or not.
  89806. */
  89807. set isEnabled(value: boolean);
  89808. /**
  89809. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89810. */
  89811. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89812. /**
  89813. * Method called each time the image processing information changes requires to recompile the effect.
  89814. */
  89815. protected _updateParameters(): void;
  89816. /**
  89817. * Gets the current class name.
  89818. * @return "ImageProcessingConfiguration"
  89819. */
  89820. getClassName(): string;
  89821. /**
  89822. * Prepare the list of uniforms associated with the Image Processing effects.
  89823. * @param uniforms The list of uniforms used in the effect
  89824. * @param defines the list of defines currently in use
  89825. */
  89826. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89827. /**
  89828. * Prepare the list of samplers associated with the Image Processing effects.
  89829. * @param samplersList The list of uniforms used in the effect
  89830. * @param defines the list of defines currently in use
  89831. */
  89832. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89833. /**
  89834. * Prepare the list of defines associated to the shader.
  89835. * @param defines the list of defines to complete
  89836. * @param forPostProcess Define if we are currently in post process mode or not
  89837. */
  89838. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89839. /**
  89840. * Returns true if all the image processing information are ready.
  89841. * @returns True if ready, otherwise, false
  89842. */
  89843. isReady(): boolean;
  89844. /**
  89845. * Binds the image processing to the shader.
  89846. * @param effect The effect to bind to
  89847. * @param overrideAspectRatio Override the aspect ratio of the effect
  89848. */
  89849. bind(effect: Effect, overrideAspectRatio?: number): void;
  89850. /**
  89851. * Clones the current image processing instance.
  89852. * @return The cloned image processing
  89853. */
  89854. clone(): ImageProcessingConfiguration;
  89855. /**
  89856. * Serializes the current image processing instance to a json representation.
  89857. * @return a JSON representation
  89858. */
  89859. serialize(): any;
  89860. /**
  89861. * Parses the image processing from a json representation.
  89862. * @param source the JSON source to parse
  89863. * @return The parsed image processing
  89864. */
  89865. static Parse(source: any): ImageProcessingConfiguration;
  89866. private static _VIGNETTEMODE_MULTIPLY;
  89867. private static _VIGNETTEMODE_OPAQUE;
  89868. /**
  89869. * Used to apply the vignette as a mix with the pixel color.
  89870. */
  89871. static get VIGNETTEMODE_MULTIPLY(): number;
  89872. /**
  89873. * Used to apply the vignette as a replacement of the pixel color.
  89874. */
  89875. static get VIGNETTEMODE_OPAQUE(): number;
  89876. }
  89877. }
  89878. declare module BABYLON {
  89879. /** @hidden */
  89880. export var postprocessVertexShader: {
  89881. name: string;
  89882. shader: string;
  89883. };
  89884. }
  89885. declare module BABYLON {
  89886. /**
  89887. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89888. */
  89889. export type RenderTargetTextureSize = number | {
  89890. width: number;
  89891. height: number;
  89892. layers?: number;
  89893. };
  89894. interface ThinEngine {
  89895. /**
  89896. * Creates a new render target texture
  89897. * @param size defines the size of the texture
  89898. * @param options defines the options used to create the texture
  89899. * @returns a new render target texture stored in an InternalTexture
  89900. */
  89901. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89902. /**
  89903. * Creates a depth stencil texture.
  89904. * This is only available in WebGL 2 or with the depth texture extension available.
  89905. * @param size The size of face edge in the texture.
  89906. * @param options The options defining the texture.
  89907. * @returns The texture
  89908. */
  89909. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89910. /** @hidden */
  89911. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89912. }
  89913. }
  89914. declare module BABYLON {
  89915. /**
  89916. * Defines the kind of connection point for node based material
  89917. */
  89918. export enum NodeMaterialBlockConnectionPointTypes {
  89919. /** Float */
  89920. Float = 1,
  89921. /** Int */
  89922. Int = 2,
  89923. /** Vector2 */
  89924. Vector2 = 4,
  89925. /** Vector3 */
  89926. Vector3 = 8,
  89927. /** Vector4 */
  89928. Vector4 = 16,
  89929. /** Color3 */
  89930. Color3 = 32,
  89931. /** Color4 */
  89932. Color4 = 64,
  89933. /** Matrix */
  89934. Matrix = 128,
  89935. /** Custom object */
  89936. Object = 256,
  89937. /** Detect type based on connection */
  89938. AutoDetect = 1024,
  89939. /** Output type that will be defined by input type */
  89940. BasedOnInput = 2048
  89941. }
  89942. }
  89943. declare module BABYLON {
  89944. /**
  89945. * Enum used to define the target of a block
  89946. */
  89947. export enum NodeMaterialBlockTargets {
  89948. /** Vertex shader */
  89949. Vertex = 1,
  89950. /** Fragment shader */
  89951. Fragment = 2,
  89952. /** Neutral */
  89953. Neutral = 4,
  89954. /** Vertex and Fragment */
  89955. VertexAndFragment = 3
  89956. }
  89957. }
  89958. declare module BABYLON {
  89959. /**
  89960. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89961. */
  89962. export enum NodeMaterialBlockConnectionPointMode {
  89963. /** Value is an uniform */
  89964. Uniform = 0,
  89965. /** Value is a mesh attribute */
  89966. Attribute = 1,
  89967. /** Value is a varying between vertex and fragment shaders */
  89968. Varying = 2,
  89969. /** Mode is undefined */
  89970. Undefined = 3
  89971. }
  89972. }
  89973. declare module BABYLON {
  89974. /**
  89975. * Enum used to define system values e.g. values automatically provided by the system
  89976. */
  89977. export enum NodeMaterialSystemValues {
  89978. /** World */
  89979. World = 1,
  89980. /** View */
  89981. View = 2,
  89982. /** Projection */
  89983. Projection = 3,
  89984. /** ViewProjection */
  89985. ViewProjection = 4,
  89986. /** WorldView */
  89987. WorldView = 5,
  89988. /** WorldViewProjection */
  89989. WorldViewProjection = 6,
  89990. /** CameraPosition */
  89991. CameraPosition = 7,
  89992. /** Fog Color */
  89993. FogColor = 8,
  89994. /** Delta time */
  89995. DeltaTime = 9
  89996. }
  89997. }
  89998. declare module BABYLON {
  89999. /** Defines supported spaces */
  90000. export enum Space {
  90001. /** Local (object) space */
  90002. LOCAL = 0,
  90003. /** World space */
  90004. WORLD = 1,
  90005. /** Bone space */
  90006. BONE = 2
  90007. }
  90008. /** Defines the 3 main axes */
  90009. export class Axis {
  90010. /** X axis */
  90011. static X: Vector3;
  90012. /** Y axis */
  90013. static Y: Vector3;
  90014. /** Z axis */
  90015. static Z: Vector3;
  90016. }
  90017. /**
  90018. * Defines cartesian components.
  90019. */
  90020. export enum Coordinate {
  90021. /** X axis */
  90022. X = 0,
  90023. /** Y axis */
  90024. Y = 1,
  90025. /** Z axis */
  90026. Z = 2
  90027. }
  90028. }
  90029. declare module BABYLON {
  90030. /**
  90031. * Represents a camera frustum
  90032. */
  90033. export class Frustum {
  90034. /**
  90035. * Gets the planes representing the frustum
  90036. * @param transform matrix to be applied to the returned planes
  90037. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  90038. */
  90039. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  90040. /**
  90041. * Gets the near frustum plane transformed by the transform matrix
  90042. * @param transform transformation matrix to be applied to the resulting frustum plane
  90043. * @param frustumPlane the resuling frustum plane
  90044. */
  90045. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  90046. /**
  90047. * Gets the far frustum plane transformed by the transform matrix
  90048. * @param transform transformation matrix to be applied to the resulting frustum plane
  90049. * @param frustumPlane the resuling frustum plane
  90050. */
  90051. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  90052. /**
  90053. * Gets the left frustum plane transformed by the transform matrix
  90054. * @param transform transformation matrix to be applied to the resulting frustum plane
  90055. * @param frustumPlane the resuling frustum plane
  90056. */
  90057. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  90058. /**
  90059. * Gets the right frustum plane transformed by the transform matrix
  90060. * @param transform transformation matrix to be applied to the resulting frustum plane
  90061. * @param frustumPlane the resuling frustum plane
  90062. */
  90063. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  90064. /**
  90065. * Gets the top frustum plane transformed by the transform matrix
  90066. * @param transform transformation matrix to be applied to the resulting frustum plane
  90067. * @param frustumPlane the resuling frustum plane
  90068. */
  90069. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  90070. /**
  90071. * Gets the bottom frustum plane transformed by the transform matrix
  90072. * @param transform transformation matrix to be applied to the resulting frustum plane
  90073. * @param frustumPlane the resuling frustum plane
  90074. */
  90075. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  90076. /**
  90077. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  90078. * @param transform transformation matrix to be applied to the resulting frustum planes
  90079. * @param frustumPlanes the resuling frustum planes
  90080. */
  90081. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  90082. }
  90083. }
  90084. declare module BABYLON {
  90085. /**
  90086. * Interface for the size containing width and height
  90087. */
  90088. export interface ISize {
  90089. /**
  90090. * Width
  90091. */
  90092. width: number;
  90093. /**
  90094. * Heighht
  90095. */
  90096. height: number;
  90097. }
  90098. /**
  90099. * Size containing widht and height
  90100. */
  90101. export class Size implements ISize {
  90102. /**
  90103. * Width
  90104. */
  90105. width: number;
  90106. /**
  90107. * Height
  90108. */
  90109. height: number;
  90110. /**
  90111. * Creates a Size object from the given width and height (floats).
  90112. * @param width width of the new size
  90113. * @param height height of the new size
  90114. */
  90115. constructor(width: number, height: number);
  90116. /**
  90117. * Returns a string with the Size width and height
  90118. * @returns a string with the Size width and height
  90119. */
  90120. toString(): string;
  90121. /**
  90122. * "Size"
  90123. * @returns the string "Size"
  90124. */
  90125. getClassName(): string;
  90126. /**
  90127. * Returns the Size hash code.
  90128. * @returns a hash code for a unique width and height
  90129. */
  90130. getHashCode(): number;
  90131. /**
  90132. * Updates the current size from the given one.
  90133. * @param src the given size
  90134. */
  90135. copyFrom(src: Size): void;
  90136. /**
  90137. * Updates in place the current Size from the given floats.
  90138. * @param width width of the new size
  90139. * @param height height of the new size
  90140. * @returns the updated Size.
  90141. */
  90142. copyFromFloats(width: number, height: number): Size;
  90143. /**
  90144. * Updates in place the current Size from the given floats.
  90145. * @param width width to set
  90146. * @param height height to set
  90147. * @returns the updated Size.
  90148. */
  90149. set(width: number, height: number): Size;
  90150. /**
  90151. * Multiplies the width and height by numbers
  90152. * @param w factor to multiple the width by
  90153. * @param h factor to multiple the height by
  90154. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  90155. */
  90156. multiplyByFloats(w: number, h: number): Size;
  90157. /**
  90158. * Clones the size
  90159. * @returns a new Size copied from the given one.
  90160. */
  90161. clone(): Size;
  90162. /**
  90163. * True if the current Size and the given one width and height are strictly equal.
  90164. * @param other the other size to compare against
  90165. * @returns True if the current Size and the given one width and height are strictly equal.
  90166. */
  90167. equals(other: Size): boolean;
  90168. /**
  90169. * The surface of the Size : width * height (float).
  90170. */
  90171. get surface(): number;
  90172. /**
  90173. * Create a new size of zero
  90174. * @returns a new Size set to (0.0, 0.0)
  90175. */
  90176. static Zero(): Size;
  90177. /**
  90178. * Sums the width and height of two sizes
  90179. * @param otherSize size to add to this size
  90180. * @returns a new Size set as the addition result of the current Size and the given one.
  90181. */
  90182. add(otherSize: Size): Size;
  90183. /**
  90184. * Subtracts the width and height of two
  90185. * @param otherSize size to subtract to this size
  90186. * @returns a new Size set as the subtraction result of the given one from the current Size.
  90187. */
  90188. subtract(otherSize: Size): Size;
  90189. /**
  90190. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  90191. * @param start starting size to lerp between
  90192. * @param end end size to lerp between
  90193. * @param amount amount to lerp between the start and end values
  90194. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  90195. */
  90196. static Lerp(start: Size, end: Size, amount: number): Size;
  90197. }
  90198. }
  90199. declare module BABYLON {
  90200. /**
  90201. * Contains position and normal vectors for a vertex
  90202. */
  90203. export class PositionNormalVertex {
  90204. /** the position of the vertex (defaut: 0,0,0) */
  90205. position: Vector3;
  90206. /** the normal of the vertex (defaut: 0,1,0) */
  90207. normal: Vector3;
  90208. /**
  90209. * Creates a PositionNormalVertex
  90210. * @param position the position of the vertex (defaut: 0,0,0)
  90211. * @param normal the normal of the vertex (defaut: 0,1,0)
  90212. */
  90213. constructor(
  90214. /** the position of the vertex (defaut: 0,0,0) */
  90215. position?: Vector3,
  90216. /** the normal of the vertex (defaut: 0,1,0) */
  90217. normal?: Vector3);
  90218. /**
  90219. * Clones the PositionNormalVertex
  90220. * @returns the cloned PositionNormalVertex
  90221. */
  90222. clone(): PositionNormalVertex;
  90223. }
  90224. /**
  90225. * Contains position, normal and uv vectors for a vertex
  90226. */
  90227. export class PositionNormalTextureVertex {
  90228. /** the position of the vertex (defaut: 0,0,0) */
  90229. position: Vector3;
  90230. /** the normal of the vertex (defaut: 0,1,0) */
  90231. normal: Vector3;
  90232. /** the uv of the vertex (default: 0,0) */
  90233. uv: Vector2;
  90234. /**
  90235. * Creates a PositionNormalTextureVertex
  90236. * @param position the position of the vertex (defaut: 0,0,0)
  90237. * @param normal the normal of the vertex (defaut: 0,1,0)
  90238. * @param uv the uv of the vertex (default: 0,0)
  90239. */
  90240. constructor(
  90241. /** the position of the vertex (defaut: 0,0,0) */
  90242. position?: Vector3,
  90243. /** the normal of the vertex (defaut: 0,1,0) */
  90244. normal?: Vector3,
  90245. /** the uv of the vertex (default: 0,0) */
  90246. uv?: Vector2);
  90247. /**
  90248. * Clones the PositionNormalTextureVertex
  90249. * @returns the cloned PositionNormalTextureVertex
  90250. */
  90251. clone(): PositionNormalTextureVertex;
  90252. }
  90253. }
  90254. declare module BABYLON {
  90255. /**
  90256. * Enum defining the type of animations supported by InputBlock
  90257. */
  90258. export enum AnimatedInputBlockTypes {
  90259. /** No animation */
  90260. None = 0,
  90261. /** Time based animation. Will only work for floats */
  90262. Time = 1
  90263. }
  90264. }
  90265. declare module BABYLON {
  90266. /**
  90267. * Interface describing all the common properties and methods a shadow light needs to implement.
  90268. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  90269. * as well as binding the different shadow properties to the effects.
  90270. */
  90271. export interface IShadowLight extends Light {
  90272. /**
  90273. * The light id in the scene (used in scene.findLighById for instance)
  90274. */
  90275. id: string;
  90276. /**
  90277. * The position the shdow will be casted from.
  90278. */
  90279. position: Vector3;
  90280. /**
  90281. * In 2d mode (needCube being false), the direction used to cast the shadow.
  90282. */
  90283. direction: Vector3;
  90284. /**
  90285. * The transformed position. Position of the light in world space taking parenting in account.
  90286. */
  90287. transformedPosition: Vector3;
  90288. /**
  90289. * The transformed direction. Direction of the light in world space taking parenting in account.
  90290. */
  90291. transformedDirection: Vector3;
  90292. /**
  90293. * The friendly name of the light in the scene.
  90294. */
  90295. name: string;
  90296. /**
  90297. * Defines the shadow projection clipping minimum z value.
  90298. */
  90299. shadowMinZ: number;
  90300. /**
  90301. * Defines the shadow projection clipping maximum z value.
  90302. */
  90303. shadowMaxZ: number;
  90304. /**
  90305. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90306. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90307. */
  90308. computeTransformedInformation(): boolean;
  90309. /**
  90310. * Gets the scene the light belongs to.
  90311. * @returns The scene
  90312. */
  90313. getScene(): Scene;
  90314. /**
  90315. * Callback defining a custom Projection Matrix Builder.
  90316. * This can be used to override the default projection matrix computation.
  90317. */
  90318. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90319. /**
  90320. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90321. * @param matrix The materix to updated with the projection information
  90322. * @param viewMatrix The transform matrix of the light
  90323. * @param renderList The list of mesh to render in the map
  90324. * @returns The current light
  90325. */
  90326. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90327. /**
  90328. * Gets the current depth scale used in ESM.
  90329. * @returns The scale
  90330. */
  90331. getDepthScale(): number;
  90332. /**
  90333. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90334. * @returns true if a cube texture needs to be use
  90335. */
  90336. needCube(): boolean;
  90337. /**
  90338. * Detects if the projection matrix requires to be recomputed this frame.
  90339. * @returns true if it requires to be recomputed otherwise, false.
  90340. */
  90341. needProjectionMatrixCompute(): boolean;
  90342. /**
  90343. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90344. */
  90345. forceProjectionMatrixCompute(): void;
  90346. /**
  90347. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90348. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90349. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90350. */
  90351. getShadowDirection(faceIndex?: number): Vector3;
  90352. /**
  90353. * Gets the minZ used for shadow according to both the scene and the light.
  90354. * @param activeCamera The camera we are returning the min for
  90355. * @returns the depth min z
  90356. */
  90357. getDepthMinZ(activeCamera: Camera): number;
  90358. /**
  90359. * Gets the maxZ used for shadow according to both the scene and the light.
  90360. * @param activeCamera The camera we are returning the max for
  90361. * @returns the depth max z
  90362. */
  90363. getDepthMaxZ(activeCamera: Camera): number;
  90364. }
  90365. /**
  90366. * Base implementation IShadowLight
  90367. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  90368. */
  90369. export abstract class ShadowLight extends Light implements IShadowLight {
  90370. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  90371. protected _position: Vector3;
  90372. protected _setPosition(value: Vector3): void;
  90373. /**
  90374. * Sets the position the shadow will be casted from. Also use as the light position for both
  90375. * point and spot lights.
  90376. */
  90377. get position(): Vector3;
  90378. /**
  90379. * Sets the position the shadow will be casted from. Also use as the light position for both
  90380. * point and spot lights.
  90381. */
  90382. set position(value: Vector3);
  90383. protected _direction: Vector3;
  90384. protected _setDirection(value: Vector3): void;
  90385. /**
  90386. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  90387. * Also use as the light direction on spot and directional lights.
  90388. */
  90389. get direction(): Vector3;
  90390. /**
  90391. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  90392. * Also use as the light direction on spot and directional lights.
  90393. */
  90394. set direction(value: Vector3);
  90395. protected _shadowMinZ: number;
  90396. /**
  90397. * Gets the shadow projection clipping minimum z value.
  90398. */
  90399. get shadowMinZ(): number;
  90400. /**
  90401. * Sets the shadow projection clipping minimum z value.
  90402. */
  90403. set shadowMinZ(value: number);
  90404. protected _shadowMaxZ: number;
  90405. /**
  90406. * Sets the shadow projection clipping maximum z value.
  90407. */
  90408. get shadowMaxZ(): number;
  90409. /**
  90410. * Gets the shadow projection clipping maximum z value.
  90411. */
  90412. set shadowMaxZ(value: number);
  90413. /**
  90414. * Callback defining a custom Projection Matrix Builder.
  90415. * This can be used to override the default projection matrix computation.
  90416. */
  90417. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90418. /**
  90419. * The transformed position. Position of the light in world space taking parenting in account.
  90420. */
  90421. transformedPosition: Vector3;
  90422. /**
  90423. * The transformed direction. Direction of the light in world space taking parenting in account.
  90424. */
  90425. transformedDirection: Vector3;
  90426. private _needProjectionMatrixCompute;
  90427. /**
  90428. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90429. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90430. */
  90431. computeTransformedInformation(): boolean;
  90432. /**
  90433. * Return the depth scale used for the shadow map.
  90434. * @returns the depth scale.
  90435. */
  90436. getDepthScale(): number;
  90437. /**
  90438. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90439. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90440. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90441. */
  90442. getShadowDirection(faceIndex?: number): Vector3;
  90443. /**
  90444. * Returns the ShadowLight absolute position in the World.
  90445. * @returns the position vector in world space
  90446. */
  90447. getAbsolutePosition(): Vector3;
  90448. /**
  90449. * Sets the ShadowLight direction toward the passed target.
  90450. * @param target The point to target in local space
  90451. * @returns the updated ShadowLight direction
  90452. */
  90453. setDirectionToTarget(target: Vector3): Vector3;
  90454. /**
  90455. * Returns the light rotation in euler definition.
  90456. * @returns the x y z rotation in local space.
  90457. */
  90458. getRotation(): Vector3;
  90459. /**
  90460. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90461. * @returns true if a cube texture needs to be use
  90462. */
  90463. needCube(): boolean;
  90464. /**
  90465. * Detects if the projection matrix requires to be recomputed this frame.
  90466. * @returns true if it requires to be recomputed otherwise, false.
  90467. */
  90468. needProjectionMatrixCompute(): boolean;
  90469. /**
  90470. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90471. */
  90472. forceProjectionMatrixCompute(): void;
  90473. /** @hidden */
  90474. _initCache(): void;
  90475. /** @hidden */
  90476. _isSynchronized(): boolean;
  90477. /**
  90478. * Computes the world matrix of the node
  90479. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90480. * @returns the world matrix
  90481. */
  90482. computeWorldMatrix(force?: boolean): Matrix;
  90483. /**
  90484. * Gets the minZ used for shadow according to both the scene and the light.
  90485. * @param activeCamera The camera we are returning the min for
  90486. * @returns the depth min z
  90487. */
  90488. getDepthMinZ(activeCamera: Camera): number;
  90489. /**
  90490. * Gets the maxZ used for shadow according to both the scene and the light.
  90491. * @param activeCamera The camera we are returning the max for
  90492. * @returns the depth max z
  90493. */
  90494. getDepthMaxZ(activeCamera: Camera): number;
  90495. /**
  90496. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90497. * @param matrix The materix to updated with the projection information
  90498. * @param viewMatrix The transform matrix of the light
  90499. * @param renderList The list of mesh to render in the map
  90500. * @returns The current light
  90501. */
  90502. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90503. }
  90504. }
  90505. declare module BABYLON {
  90506. /** @hidden */
  90507. export var packingFunctions: {
  90508. name: string;
  90509. shader: string;
  90510. };
  90511. }
  90512. declare module BABYLON {
  90513. /** @hidden */
  90514. export var bayerDitherFunctions: {
  90515. name: string;
  90516. shader: string;
  90517. };
  90518. }
  90519. declare module BABYLON {
  90520. /** @hidden */
  90521. export var shadowMapFragmentDeclaration: {
  90522. name: string;
  90523. shader: string;
  90524. };
  90525. }
  90526. declare module BABYLON {
  90527. /** @hidden */
  90528. export var clipPlaneFragmentDeclaration: {
  90529. name: string;
  90530. shader: string;
  90531. };
  90532. }
  90533. declare module BABYLON {
  90534. /** @hidden */
  90535. export var clipPlaneFragment: {
  90536. name: string;
  90537. shader: string;
  90538. };
  90539. }
  90540. declare module BABYLON {
  90541. /** @hidden */
  90542. export var shadowMapFragment: {
  90543. name: string;
  90544. shader: string;
  90545. };
  90546. }
  90547. declare module BABYLON {
  90548. /** @hidden */
  90549. export var shadowMapPixelShader: {
  90550. name: string;
  90551. shader: string;
  90552. };
  90553. }
  90554. declare module BABYLON {
  90555. /** @hidden */
  90556. export var bonesDeclaration: {
  90557. name: string;
  90558. shader: string;
  90559. };
  90560. }
  90561. declare module BABYLON {
  90562. /** @hidden */
  90563. export var morphTargetsVertexGlobalDeclaration: {
  90564. name: string;
  90565. shader: string;
  90566. };
  90567. }
  90568. declare module BABYLON {
  90569. /** @hidden */
  90570. export var morphTargetsVertexDeclaration: {
  90571. name: string;
  90572. shader: string;
  90573. };
  90574. }
  90575. declare module BABYLON {
  90576. /** @hidden */
  90577. export var instancesDeclaration: {
  90578. name: string;
  90579. shader: string;
  90580. };
  90581. }
  90582. declare module BABYLON {
  90583. /** @hidden */
  90584. export var helperFunctions: {
  90585. name: string;
  90586. shader: string;
  90587. };
  90588. }
  90589. declare module BABYLON {
  90590. /** @hidden */
  90591. export var shadowMapVertexDeclaration: {
  90592. name: string;
  90593. shader: string;
  90594. };
  90595. }
  90596. declare module BABYLON {
  90597. /** @hidden */
  90598. export var clipPlaneVertexDeclaration: {
  90599. name: string;
  90600. shader: string;
  90601. };
  90602. }
  90603. declare module BABYLON {
  90604. /** @hidden */
  90605. export var morphTargetsVertex: {
  90606. name: string;
  90607. shader: string;
  90608. };
  90609. }
  90610. declare module BABYLON {
  90611. /** @hidden */
  90612. export var instancesVertex: {
  90613. name: string;
  90614. shader: string;
  90615. };
  90616. }
  90617. declare module BABYLON {
  90618. /** @hidden */
  90619. export var bonesVertex: {
  90620. name: string;
  90621. shader: string;
  90622. };
  90623. }
  90624. declare module BABYLON {
  90625. /** @hidden */
  90626. export var shadowMapVertexNormalBias: {
  90627. name: string;
  90628. shader: string;
  90629. };
  90630. }
  90631. declare module BABYLON {
  90632. /** @hidden */
  90633. export var shadowMapVertexMetric: {
  90634. name: string;
  90635. shader: string;
  90636. };
  90637. }
  90638. declare module BABYLON {
  90639. /** @hidden */
  90640. export var clipPlaneVertex: {
  90641. name: string;
  90642. shader: string;
  90643. };
  90644. }
  90645. declare module BABYLON {
  90646. /** @hidden */
  90647. export var shadowMapVertexShader: {
  90648. name: string;
  90649. shader: string;
  90650. };
  90651. }
  90652. declare module BABYLON {
  90653. /** @hidden */
  90654. export var depthBoxBlurPixelShader: {
  90655. name: string;
  90656. shader: string;
  90657. };
  90658. }
  90659. declare module BABYLON {
  90660. /** @hidden */
  90661. export var shadowMapFragmentSoftTransparentShadow: {
  90662. name: string;
  90663. shader: string;
  90664. };
  90665. }
  90666. declare module BABYLON {
  90667. /**
  90668. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  90669. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  90670. */
  90671. export class EffectFallbacks implements IEffectFallbacks {
  90672. private _defines;
  90673. private _currentRank;
  90674. private _maxRank;
  90675. private _mesh;
  90676. /**
  90677. * Removes the fallback from the bound mesh.
  90678. */
  90679. unBindMesh(): void;
  90680. /**
  90681. * Adds a fallback on the specified property.
  90682. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90683. * @param define The name of the define in the shader
  90684. */
  90685. addFallback(rank: number, define: string): void;
  90686. /**
  90687. * Sets the mesh to use CPU skinning when needing to fallback.
  90688. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90689. * @param mesh The mesh to use the fallbacks.
  90690. */
  90691. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  90692. /**
  90693. * Checks to see if more fallbacks are still availible.
  90694. */
  90695. get hasMoreFallbacks(): boolean;
  90696. /**
  90697. * Removes the defines that should be removed when falling back.
  90698. * @param currentDefines defines the current define statements for the shader.
  90699. * @param effect defines the current effect we try to compile
  90700. * @returns The resulting defines with defines of the current rank removed.
  90701. */
  90702. reduce(currentDefines: string, effect: Effect): string;
  90703. }
  90704. }
  90705. declare module BABYLON {
  90706. /**
  90707. * Interface used to define Action
  90708. */
  90709. export interface IAction {
  90710. /**
  90711. * Trigger for the action
  90712. */
  90713. trigger: number;
  90714. /** Options of the trigger */
  90715. triggerOptions: any;
  90716. /**
  90717. * Gets the trigger parameters
  90718. * @returns the trigger parameters
  90719. */
  90720. getTriggerParameter(): any;
  90721. /**
  90722. * Internal only - executes current action event
  90723. * @hidden
  90724. */
  90725. _executeCurrent(evt?: ActionEvent): void;
  90726. /**
  90727. * Serialize placeholder for child classes
  90728. * @param parent of child
  90729. * @returns the serialized object
  90730. */
  90731. serialize(parent: any): any;
  90732. /**
  90733. * Internal only
  90734. * @hidden
  90735. */
  90736. _prepare(): void;
  90737. /**
  90738. * Internal only - manager for action
  90739. * @hidden
  90740. */
  90741. _actionManager: Nullable<AbstractActionManager>;
  90742. /**
  90743. * Adds action to chain of actions, may be a DoNothingAction
  90744. * @param action defines the next action to execute
  90745. * @returns The action passed in
  90746. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90747. */
  90748. then(action: IAction): IAction;
  90749. }
  90750. /**
  90751. * The action to be carried out following a trigger
  90752. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90753. */
  90754. export class Action implements IAction {
  90755. /** the trigger, with or without parameters, for the action */
  90756. triggerOptions: any;
  90757. /**
  90758. * Trigger for the action
  90759. */
  90760. trigger: number;
  90761. /**
  90762. * Internal only - manager for action
  90763. * @hidden
  90764. */
  90765. _actionManager: ActionManager;
  90766. private _nextActiveAction;
  90767. private _child;
  90768. private _condition?;
  90769. private _triggerParameter;
  90770. /**
  90771. * An event triggered prior to action being executed.
  90772. */
  90773. onBeforeExecuteObservable: Observable<Action>;
  90774. /**
  90775. * Creates a new Action
  90776. * @param triggerOptions the trigger, with or without parameters, for the action
  90777. * @param condition an optional determinant of action
  90778. */
  90779. constructor(
  90780. /** the trigger, with or without parameters, for the action */
  90781. triggerOptions: any, condition?: Condition);
  90782. /**
  90783. * Internal only
  90784. * @hidden
  90785. */
  90786. _prepare(): void;
  90787. /**
  90788. * Gets the trigger parameters
  90789. * @returns the trigger parameters
  90790. */
  90791. getTriggerParameter(): any;
  90792. /**
  90793. * Internal only - executes current action event
  90794. * @hidden
  90795. */
  90796. _executeCurrent(evt?: ActionEvent): void;
  90797. /**
  90798. * Execute placeholder for child classes
  90799. * @param evt optional action event
  90800. */
  90801. execute(evt?: ActionEvent): void;
  90802. /**
  90803. * Skips to next active action
  90804. */
  90805. skipToNextActiveAction(): void;
  90806. /**
  90807. * Adds action to chain of actions, may be a DoNothingAction
  90808. * @param action defines the next action to execute
  90809. * @returns The action passed in
  90810. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90811. */
  90812. then(action: Action): Action;
  90813. /**
  90814. * Internal only
  90815. * @hidden
  90816. */
  90817. _getProperty(propertyPath: string): string;
  90818. /**
  90819. * Internal only
  90820. * @hidden
  90821. */
  90822. _getEffectiveTarget(target: any, propertyPath: string): any;
  90823. /**
  90824. * Serialize placeholder for child classes
  90825. * @param parent of child
  90826. * @returns the serialized object
  90827. */
  90828. serialize(parent: any): any;
  90829. /**
  90830. * Internal only called by serialize
  90831. * @hidden
  90832. */
  90833. protected _serialize(serializedAction: any, parent?: any): any;
  90834. /**
  90835. * Internal only
  90836. * @hidden
  90837. */
  90838. static _SerializeValueAsString: (value: any) => string;
  90839. /**
  90840. * Internal only
  90841. * @hidden
  90842. */
  90843. static _GetTargetProperty: (target: Scene | Node) => {
  90844. name: string;
  90845. targetType: string;
  90846. value: string;
  90847. };
  90848. }
  90849. }
  90850. declare module BABYLON {
  90851. /**
  90852. * A Condition applied to an Action
  90853. */
  90854. export class Condition {
  90855. /**
  90856. * Internal only - manager for action
  90857. * @hidden
  90858. */
  90859. _actionManager: ActionManager;
  90860. /**
  90861. * Internal only
  90862. * @hidden
  90863. */
  90864. _evaluationId: number;
  90865. /**
  90866. * Internal only
  90867. * @hidden
  90868. */
  90869. _currentResult: boolean;
  90870. /**
  90871. * Creates a new Condition
  90872. * @param actionManager the manager of the action the condition is applied to
  90873. */
  90874. constructor(actionManager: ActionManager);
  90875. /**
  90876. * Check if the current condition is valid
  90877. * @returns a boolean
  90878. */
  90879. isValid(): boolean;
  90880. /**
  90881. * Internal only
  90882. * @hidden
  90883. */
  90884. _getProperty(propertyPath: string): string;
  90885. /**
  90886. * Internal only
  90887. * @hidden
  90888. */
  90889. _getEffectiveTarget(target: any, propertyPath: string): any;
  90890. /**
  90891. * Serialize placeholder for child classes
  90892. * @returns the serialized object
  90893. */
  90894. serialize(): any;
  90895. /**
  90896. * Internal only
  90897. * @hidden
  90898. */
  90899. protected _serialize(serializedCondition: any): any;
  90900. }
  90901. /**
  90902. * Defines specific conditional operators as extensions of Condition
  90903. */
  90904. export class ValueCondition extends Condition {
  90905. /** path to specify the property of the target the conditional operator uses */
  90906. propertyPath: string;
  90907. /** the value compared by the conditional operator against the current value of the property */
  90908. value: any;
  90909. /** the conditional operator, default ValueCondition.IsEqual */
  90910. operator: number;
  90911. /**
  90912. * Internal only
  90913. * @hidden
  90914. */
  90915. private static _IsEqual;
  90916. /**
  90917. * Internal only
  90918. * @hidden
  90919. */
  90920. private static _IsDifferent;
  90921. /**
  90922. * Internal only
  90923. * @hidden
  90924. */
  90925. private static _IsGreater;
  90926. /**
  90927. * Internal only
  90928. * @hidden
  90929. */
  90930. private static _IsLesser;
  90931. /**
  90932. * returns the number for IsEqual
  90933. */
  90934. static get IsEqual(): number;
  90935. /**
  90936. * Returns the number for IsDifferent
  90937. */
  90938. static get IsDifferent(): number;
  90939. /**
  90940. * Returns the number for IsGreater
  90941. */
  90942. static get IsGreater(): number;
  90943. /**
  90944. * Returns the number for IsLesser
  90945. */
  90946. static get IsLesser(): number;
  90947. /**
  90948. * Internal only The action manager for the condition
  90949. * @hidden
  90950. */
  90951. _actionManager: ActionManager;
  90952. /**
  90953. * Internal only
  90954. * @hidden
  90955. */
  90956. private _target;
  90957. /**
  90958. * Internal only
  90959. * @hidden
  90960. */
  90961. private _effectiveTarget;
  90962. /**
  90963. * Internal only
  90964. * @hidden
  90965. */
  90966. private _property;
  90967. /**
  90968. * Creates a new ValueCondition
  90969. * @param actionManager manager for the action the condition applies to
  90970. * @param target for the action
  90971. * @param propertyPath path to specify the property of the target the conditional operator uses
  90972. * @param value the value compared by the conditional operator against the current value of the property
  90973. * @param operator the conditional operator, default ValueCondition.IsEqual
  90974. */
  90975. constructor(actionManager: ActionManager, target: any,
  90976. /** path to specify the property of the target the conditional operator uses */
  90977. propertyPath: string,
  90978. /** the value compared by the conditional operator against the current value of the property */
  90979. value: any,
  90980. /** the conditional operator, default ValueCondition.IsEqual */
  90981. operator?: number);
  90982. /**
  90983. * Compares the given value with the property value for the specified conditional operator
  90984. * @returns the result of the comparison
  90985. */
  90986. isValid(): boolean;
  90987. /**
  90988. * Serialize the ValueCondition into a JSON compatible object
  90989. * @returns serialization object
  90990. */
  90991. serialize(): any;
  90992. /**
  90993. * Gets the name of the conditional operator for the ValueCondition
  90994. * @param operator the conditional operator
  90995. * @returns the name
  90996. */
  90997. static GetOperatorName(operator: number): string;
  90998. }
  90999. /**
  91000. * Defines a predicate condition as an extension of Condition
  91001. */
  91002. export class PredicateCondition extends Condition {
  91003. /** defines the predicate function used to validate the condition */
  91004. predicate: () => boolean;
  91005. /**
  91006. * Internal only - manager for action
  91007. * @hidden
  91008. */
  91009. _actionManager: ActionManager;
  91010. /**
  91011. * Creates a new PredicateCondition
  91012. * @param actionManager manager for the action the condition applies to
  91013. * @param predicate defines the predicate function used to validate the condition
  91014. */
  91015. constructor(actionManager: ActionManager,
  91016. /** defines the predicate function used to validate the condition */
  91017. predicate: () => boolean);
  91018. /**
  91019. * @returns the validity of the predicate condition
  91020. */
  91021. isValid(): boolean;
  91022. }
  91023. /**
  91024. * Defines a state condition as an extension of Condition
  91025. */
  91026. export class StateCondition extends Condition {
  91027. /** Value to compare with target state */
  91028. value: string;
  91029. /**
  91030. * Internal only - manager for action
  91031. * @hidden
  91032. */
  91033. _actionManager: ActionManager;
  91034. /**
  91035. * Internal only
  91036. * @hidden
  91037. */
  91038. private _target;
  91039. /**
  91040. * Creates a new StateCondition
  91041. * @param actionManager manager for the action the condition applies to
  91042. * @param target of the condition
  91043. * @param value to compare with target state
  91044. */
  91045. constructor(actionManager: ActionManager, target: any,
  91046. /** Value to compare with target state */
  91047. value: string);
  91048. /**
  91049. * Gets a boolean indicating if the current condition is met
  91050. * @returns the validity of the state
  91051. */
  91052. isValid(): boolean;
  91053. /**
  91054. * Serialize the StateCondition into a JSON compatible object
  91055. * @returns serialization object
  91056. */
  91057. serialize(): any;
  91058. }
  91059. }
  91060. declare module BABYLON {
  91061. /**
  91062. * This defines an action responsible to toggle a boolean once triggered.
  91063. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91064. */
  91065. export class SwitchBooleanAction extends Action {
  91066. /**
  91067. * The path to the boolean property in the target object
  91068. */
  91069. propertyPath: string;
  91070. private _target;
  91071. private _effectiveTarget;
  91072. private _property;
  91073. /**
  91074. * Instantiate the action
  91075. * @param triggerOptions defines the trigger options
  91076. * @param target defines the object containing the boolean
  91077. * @param propertyPath defines the path to the boolean property in the target object
  91078. * @param condition defines the trigger related conditions
  91079. */
  91080. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91081. /** @hidden */
  91082. _prepare(): void;
  91083. /**
  91084. * Execute the action toggle the boolean value.
  91085. */
  91086. execute(): void;
  91087. /**
  91088. * Serializes the actions and its related information.
  91089. * @param parent defines the object to serialize in
  91090. * @returns the serialized object
  91091. */
  91092. serialize(parent: any): any;
  91093. }
  91094. /**
  91095. * This defines an action responsible to set a the state field of the target
  91096. * to a desired value once triggered.
  91097. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91098. */
  91099. export class SetStateAction extends Action {
  91100. /**
  91101. * The value to store in the state field.
  91102. */
  91103. value: string;
  91104. private _target;
  91105. /**
  91106. * Instantiate the action
  91107. * @param triggerOptions defines the trigger options
  91108. * @param target defines the object containing the state property
  91109. * @param value defines the value to store in the state field
  91110. * @param condition defines the trigger related conditions
  91111. */
  91112. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91113. /**
  91114. * Execute the action and store the value on the target state property.
  91115. */
  91116. execute(): void;
  91117. /**
  91118. * Serializes the actions and its related information.
  91119. * @param parent defines the object to serialize in
  91120. * @returns the serialized object
  91121. */
  91122. serialize(parent: any): any;
  91123. }
  91124. /**
  91125. * This defines an action responsible to set a property of the target
  91126. * to a desired value once triggered.
  91127. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91128. */
  91129. export class SetValueAction extends Action {
  91130. /**
  91131. * The path of the property to set in the target.
  91132. */
  91133. propertyPath: string;
  91134. /**
  91135. * The value to set in the property
  91136. */
  91137. value: any;
  91138. private _target;
  91139. private _effectiveTarget;
  91140. private _property;
  91141. /**
  91142. * Instantiate the action
  91143. * @param triggerOptions defines the trigger options
  91144. * @param target defines the object containing the property
  91145. * @param propertyPath defines the path of the property to set in the target
  91146. * @param value defines the value to set in the property
  91147. * @param condition defines the trigger related conditions
  91148. */
  91149. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91150. /** @hidden */
  91151. _prepare(): void;
  91152. /**
  91153. * Execute the action and set the targetted property to the desired value.
  91154. */
  91155. execute(): void;
  91156. /**
  91157. * Serializes the actions and its related information.
  91158. * @param parent defines the object to serialize in
  91159. * @returns the serialized object
  91160. */
  91161. serialize(parent: any): any;
  91162. }
  91163. /**
  91164. * This defines an action responsible to increment the target value
  91165. * to a desired value once triggered.
  91166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91167. */
  91168. export class IncrementValueAction extends Action {
  91169. /**
  91170. * The path of the property to increment in the target.
  91171. */
  91172. propertyPath: string;
  91173. /**
  91174. * The value we should increment the property by.
  91175. */
  91176. value: any;
  91177. private _target;
  91178. private _effectiveTarget;
  91179. private _property;
  91180. /**
  91181. * Instantiate the action
  91182. * @param triggerOptions defines the trigger options
  91183. * @param target defines the object containing the property
  91184. * @param propertyPath defines the path of the property to increment in the target
  91185. * @param value defines the value value we should increment the property by
  91186. * @param condition defines the trigger related conditions
  91187. */
  91188. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91189. /** @hidden */
  91190. _prepare(): void;
  91191. /**
  91192. * Execute the action and increment the target of the value amount.
  91193. */
  91194. execute(): void;
  91195. /**
  91196. * Serializes the actions and its related information.
  91197. * @param parent defines the object to serialize in
  91198. * @returns the serialized object
  91199. */
  91200. serialize(parent: any): any;
  91201. }
  91202. /**
  91203. * This defines an action responsible to start an animation once triggered.
  91204. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91205. */
  91206. export class PlayAnimationAction extends Action {
  91207. /**
  91208. * Where the animation should start (animation frame)
  91209. */
  91210. from: number;
  91211. /**
  91212. * Where the animation should stop (animation frame)
  91213. */
  91214. to: number;
  91215. /**
  91216. * Define if the animation should loop or stop after the first play.
  91217. */
  91218. loop?: boolean;
  91219. private _target;
  91220. /**
  91221. * Instantiate the action
  91222. * @param triggerOptions defines the trigger options
  91223. * @param target defines the target animation or animation name
  91224. * @param from defines from where the animation should start (animation frame)
  91225. * @param end defines where the animation should stop (animation frame)
  91226. * @param loop defines if the animation should loop or stop after the first play
  91227. * @param condition defines the trigger related conditions
  91228. */
  91229. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91230. /** @hidden */
  91231. _prepare(): void;
  91232. /**
  91233. * Execute the action and play the animation.
  91234. */
  91235. execute(): void;
  91236. /**
  91237. * Serializes the actions and its related information.
  91238. * @param parent defines the object to serialize in
  91239. * @returns the serialized object
  91240. */
  91241. serialize(parent: any): any;
  91242. }
  91243. /**
  91244. * This defines an action responsible to stop an animation once triggered.
  91245. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91246. */
  91247. export class StopAnimationAction extends Action {
  91248. private _target;
  91249. /**
  91250. * Instantiate the action
  91251. * @param triggerOptions defines the trigger options
  91252. * @param target defines the target animation or animation name
  91253. * @param condition defines the trigger related conditions
  91254. */
  91255. constructor(triggerOptions: any, target: any, condition?: Condition);
  91256. /** @hidden */
  91257. _prepare(): void;
  91258. /**
  91259. * Execute the action and stop the animation.
  91260. */
  91261. execute(): void;
  91262. /**
  91263. * Serializes the actions and its related information.
  91264. * @param parent defines the object to serialize in
  91265. * @returns the serialized object
  91266. */
  91267. serialize(parent: any): any;
  91268. }
  91269. /**
  91270. * This defines an action responsible that does nothing once triggered.
  91271. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91272. */
  91273. export class DoNothingAction extends Action {
  91274. /**
  91275. * Instantiate the action
  91276. * @param triggerOptions defines the trigger options
  91277. * @param condition defines the trigger related conditions
  91278. */
  91279. constructor(triggerOptions?: any, condition?: Condition);
  91280. /**
  91281. * Execute the action and do nothing.
  91282. */
  91283. execute(): void;
  91284. /**
  91285. * Serializes the actions and its related information.
  91286. * @param parent defines the object to serialize in
  91287. * @returns the serialized object
  91288. */
  91289. serialize(parent: any): any;
  91290. }
  91291. /**
  91292. * This defines an action responsible to trigger several actions once triggered.
  91293. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91294. */
  91295. export class CombineAction extends Action {
  91296. /**
  91297. * The list of aggregated animations to run.
  91298. */
  91299. children: Action[];
  91300. /**
  91301. * Instantiate the action
  91302. * @param triggerOptions defines the trigger options
  91303. * @param children defines the list of aggregated animations to run
  91304. * @param condition defines the trigger related conditions
  91305. */
  91306. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91307. /** @hidden */
  91308. _prepare(): void;
  91309. /**
  91310. * Execute the action and executes all the aggregated actions.
  91311. */
  91312. execute(evt: ActionEvent): void;
  91313. /**
  91314. * Serializes the actions and its related information.
  91315. * @param parent defines the object to serialize in
  91316. * @returns the serialized object
  91317. */
  91318. serialize(parent: any): any;
  91319. }
  91320. /**
  91321. * This defines an action responsible to run code (external event) once triggered.
  91322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91323. */
  91324. export class ExecuteCodeAction extends Action {
  91325. /**
  91326. * The callback function to run.
  91327. */
  91328. func: (evt: ActionEvent) => void;
  91329. /**
  91330. * Instantiate the action
  91331. * @param triggerOptions defines the trigger options
  91332. * @param func defines the callback function to run
  91333. * @param condition defines the trigger related conditions
  91334. */
  91335. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91336. /**
  91337. * Execute the action and run the attached code.
  91338. */
  91339. execute(evt: ActionEvent): void;
  91340. }
  91341. /**
  91342. * This defines an action responsible to set the parent property of the target once triggered.
  91343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91344. */
  91345. export class SetParentAction extends Action {
  91346. private _parent;
  91347. private _target;
  91348. /**
  91349. * Instantiate the action
  91350. * @param triggerOptions defines the trigger options
  91351. * @param target defines the target containing the parent property
  91352. * @param parent defines from where the animation should start (animation frame)
  91353. * @param condition defines the trigger related conditions
  91354. */
  91355. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91356. /** @hidden */
  91357. _prepare(): void;
  91358. /**
  91359. * Execute the action and set the parent property.
  91360. */
  91361. execute(): void;
  91362. /**
  91363. * Serializes the actions and its related information.
  91364. * @param parent defines the object to serialize in
  91365. * @returns the serialized object
  91366. */
  91367. serialize(parent: any): any;
  91368. }
  91369. }
  91370. declare module BABYLON {
  91371. /**
  91372. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91373. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91374. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91375. */
  91376. export class ActionManager extends AbstractActionManager {
  91377. /**
  91378. * Nothing
  91379. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91380. */
  91381. static readonly NothingTrigger: number;
  91382. /**
  91383. * On pick
  91384. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91385. */
  91386. static readonly OnPickTrigger: number;
  91387. /**
  91388. * On left pick
  91389. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91390. */
  91391. static readonly OnLeftPickTrigger: number;
  91392. /**
  91393. * On right pick
  91394. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91395. */
  91396. static readonly OnRightPickTrigger: number;
  91397. /**
  91398. * On center pick
  91399. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91400. */
  91401. static readonly OnCenterPickTrigger: number;
  91402. /**
  91403. * On pick down
  91404. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91405. */
  91406. static readonly OnPickDownTrigger: number;
  91407. /**
  91408. * On double pick
  91409. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91410. */
  91411. static readonly OnDoublePickTrigger: number;
  91412. /**
  91413. * On pick up
  91414. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91415. */
  91416. static readonly OnPickUpTrigger: number;
  91417. /**
  91418. * On pick out.
  91419. * This trigger will only be raised if you also declared a OnPickDown
  91420. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91421. */
  91422. static readonly OnPickOutTrigger: number;
  91423. /**
  91424. * On long press
  91425. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91426. */
  91427. static readonly OnLongPressTrigger: number;
  91428. /**
  91429. * On pointer over
  91430. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91431. */
  91432. static readonly OnPointerOverTrigger: number;
  91433. /**
  91434. * On pointer out
  91435. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91436. */
  91437. static readonly OnPointerOutTrigger: number;
  91438. /**
  91439. * On every frame
  91440. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91441. */
  91442. static readonly OnEveryFrameTrigger: number;
  91443. /**
  91444. * On intersection enter
  91445. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91446. */
  91447. static readonly OnIntersectionEnterTrigger: number;
  91448. /**
  91449. * On intersection exit
  91450. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91451. */
  91452. static readonly OnIntersectionExitTrigger: number;
  91453. /**
  91454. * On key down
  91455. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91456. */
  91457. static readonly OnKeyDownTrigger: number;
  91458. /**
  91459. * On key up
  91460. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91461. */
  91462. static readonly OnKeyUpTrigger: number;
  91463. private _scene;
  91464. /**
  91465. * Creates a new action manager
  91466. * @param scene defines the hosting scene
  91467. */
  91468. constructor(scene: Scene);
  91469. /**
  91470. * Releases all associated resources
  91471. */
  91472. dispose(): void;
  91473. /**
  91474. * Gets hosting scene
  91475. * @returns the hosting scene
  91476. */
  91477. getScene(): Scene;
  91478. /**
  91479. * Does this action manager handles actions of any of the given triggers
  91480. * @param triggers defines the triggers to be tested
  91481. * @return a boolean indicating whether one (or more) of the triggers is handled
  91482. */
  91483. hasSpecificTriggers(triggers: number[]): boolean;
  91484. /**
  91485. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91486. * speed.
  91487. * @param triggerA defines the trigger to be tested
  91488. * @param triggerB defines the trigger to be tested
  91489. * @return a boolean indicating whether one (or more) of the triggers is handled
  91490. */
  91491. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91492. /**
  91493. * Does this action manager handles actions of a given trigger
  91494. * @param trigger defines the trigger to be tested
  91495. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91496. * @return whether the trigger is handled
  91497. */
  91498. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91499. /**
  91500. * Does this action manager has pointer triggers
  91501. */
  91502. get hasPointerTriggers(): boolean;
  91503. /**
  91504. * Does this action manager has pick triggers
  91505. */
  91506. get hasPickTriggers(): boolean;
  91507. /**
  91508. * Registers an action to this action manager
  91509. * @param action defines the action to be registered
  91510. * @return the action amended (prepared) after registration
  91511. */
  91512. registerAction(action: IAction): Nullable<IAction>;
  91513. /**
  91514. * Unregisters an action to this action manager
  91515. * @param action defines the action to be unregistered
  91516. * @return a boolean indicating whether the action has been unregistered
  91517. */
  91518. unregisterAction(action: IAction): Boolean;
  91519. /**
  91520. * Process a specific trigger
  91521. * @param trigger defines the trigger to process
  91522. * @param evt defines the event details to be processed
  91523. */
  91524. processTrigger(trigger: number, evt?: IActionEvent): void;
  91525. /** @hidden */
  91526. _getEffectiveTarget(target: any, propertyPath: string): any;
  91527. /** @hidden */
  91528. _getProperty(propertyPath: string): string;
  91529. /**
  91530. * Serialize this manager to a JSON object
  91531. * @param name defines the property name to store this manager
  91532. * @returns a JSON representation of this manager
  91533. */
  91534. serialize(name: string): any;
  91535. /**
  91536. * Creates a new ActionManager from a JSON data
  91537. * @param parsedActions defines the JSON data to read from
  91538. * @param object defines the hosting mesh
  91539. * @param scene defines the hosting scene
  91540. */
  91541. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91542. /**
  91543. * Get a trigger name by index
  91544. * @param trigger defines the trigger index
  91545. * @returns a trigger name
  91546. */
  91547. static GetTriggerName(trigger: number): string;
  91548. }
  91549. }
  91550. declare module BABYLON {
  91551. /**
  91552. * Class used to represent a sprite
  91553. * @see https://doc.babylonjs.com/babylon101/sprites
  91554. */
  91555. export class Sprite implements IAnimatable {
  91556. /** defines the name */
  91557. name: string;
  91558. /** Gets or sets the current world position */
  91559. position: Vector3;
  91560. /** Gets or sets the main color */
  91561. color: Color4;
  91562. /** Gets or sets the width */
  91563. width: number;
  91564. /** Gets or sets the height */
  91565. height: number;
  91566. /** Gets or sets rotation angle */
  91567. angle: number;
  91568. /** Gets or sets the cell index in the sprite sheet */
  91569. cellIndex: number;
  91570. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91571. cellRef: string;
  91572. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91573. invertU: boolean;
  91574. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91575. invertV: boolean;
  91576. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91577. disposeWhenFinishedAnimating: boolean;
  91578. /** Gets the list of attached animations */
  91579. animations: Nullable<Array<Animation>>;
  91580. /** Gets or sets a boolean indicating if the sprite can be picked */
  91581. isPickable: boolean;
  91582. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  91583. useAlphaForPicking: boolean;
  91584. /** @hidden */
  91585. _xOffset: number;
  91586. /** @hidden */
  91587. _yOffset: number;
  91588. /** @hidden */
  91589. _xSize: number;
  91590. /** @hidden */
  91591. _ySize: number;
  91592. /**
  91593. * Gets or sets the associated action manager
  91594. */
  91595. actionManager: Nullable<ActionManager>;
  91596. /**
  91597. * An event triggered when the control has been disposed
  91598. */
  91599. onDisposeObservable: Observable<Sprite>;
  91600. private _animationStarted;
  91601. private _loopAnimation;
  91602. private _fromIndex;
  91603. private _toIndex;
  91604. private _delay;
  91605. private _direction;
  91606. private _manager;
  91607. private _time;
  91608. private _onAnimationEnd;
  91609. /**
  91610. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91611. */
  91612. isVisible: boolean;
  91613. /**
  91614. * Gets or sets the sprite size
  91615. */
  91616. get size(): number;
  91617. set size(value: number);
  91618. /**
  91619. * Returns a boolean indicating if the animation is started
  91620. */
  91621. get animationStarted(): boolean;
  91622. /**
  91623. * Gets or sets the unique id of the sprite
  91624. */
  91625. uniqueId: number;
  91626. /**
  91627. * Gets the manager of this sprite
  91628. */
  91629. get manager(): ISpriteManager;
  91630. /**
  91631. * Creates a new Sprite
  91632. * @param name defines the name
  91633. * @param manager defines the manager
  91634. */
  91635. constructor(
  91636. /** defines the name */
  91637. name: string, manager: ISpriteManager);
  91638. /**
  91639. * Returns the string "Sprite"
  91640. * @returns "Sprite"
  91641. */
  91642. getClassName(): string;
  91643. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  91644. get fromIndex(): number;
  91645. set fromIndex(value: number);
  91646. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  91647. get toIndex(): number;
  91648. set toIndex(value: number);
  91649. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  91650. get loopAnimation(): boolean;
  91651. set loopAnimation(value: boolean);
  91652. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  91653. get delay(): number;
  91654. set delay(value: number);
  91655. /**
  91656. * Starts an animation
  91657. * @param from defines the initial key
  91658. * @param to defines the end key
  91659. * @param loop defines if the animation must loop
  91660. * @param delay defines the start delay (in ms)
  91661. * @param onAnimationEnd defines a callback to call when animation ends
  91662. */
  91663. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  91664. /** Stops current animation (if any) */
  91665. stopAnimation(): void;
  91666. /** @hidden */
  91667. _animate(deltaTime: number): void;
  91668. /** Release associated resources */
  91669. dispose(): void;
  91670. /**
  91671. * Serializes the sprite to a JSON object
  91672. * @returns the JSON object
  91673. */
  91674. serialize(): any;
  91675. /**
  91676. * Parses a JSON object to create a new sprite
  91677. * @param parsedSprite The JSON object to parse
  91678. * @param manager defines the hosting manager
  91679. * @returns the new sprite
  91680. */
  91681. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  91682. }
  91683. }
  91684. declare module BABYLON {
  91685. /**
  91686. * Information about the result of picking within a scene
  91687. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91688. */
  91689. export class PickingInfo {
  91690. /** @hidden */
  91691. _pickingUnavailable: boolean;
  91692. /**
  91693. * If the pick collided with an object
  91694. */
  91695. hit: boolean;
  91696. /**
  91697. * Distance away where the pick collided
  91698. */
  91699. distance: number;
  91700. /**
  91701. * The location of pick collision
  91702. */
  91703. pickedPoint: Nullable<Vector3>;
  91704. /**
  91705. * The mesh corresponding the the pick collision
  91706. */
  91707. pickedMesh: Nullable<AbstractMesh>;
  91708. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91709. bu: number;
  91710. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91711. bv: number;
  91712. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91713. faceId: number;
  91714. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91715. subMeshFaceId: number;
  91716. /** Id of the the submesh that was picked */
  91717. subMeshId: number;
  91718. /** If a sprite was picked, this will be the sprite the pick collided with */
  91719. pickedSprite: Nullable<Sprite>;
  91720. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  91721. thinInstanceIndex: number;
  91722. /**
  91723. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91724. */
  91725. originMesh: Nullable<AbstractMesh>;
  91726. /**
  91727. * The ray that was used to perform the picking.
  91728. */
  91729. ray: Nullable<Ray>;
  91730. /**
  91731. * Gets the normal correspodning to the face the pick collided with
  91732. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91733. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91734. * @returns The normal correspodning to the face the pick collided with
  91735. */
  91736. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91737. /**
  91738. * Gets the texture coordinates of where the pick occured
  91739. * @returns the vector containing the coordnates of the texture
  91740. */
  91741. getTextureCoordinates(): Nullable<Vector2>;
  91742. }
  91743. }
  91744. declare module BABYLON {
  91745. /**
  91746. * Class representing a ray with position and direction
  91747. */
  91748. export class Ray {
  91749. /** origin point */
  91750. origin: Vector3;
  91751. /** direction */
  91752. direction: Vector3;
  91753. /** length of the ray */
  91754. length: number;
  91755. private static readonly _TmpVector3;
  91756. private _tmpRay;
  91757. /**
  91758. * Creates a new ray
  91759. * @param origin origin point
  91760. * @param direction direction
  91761. * @param length length of the ray
  91762. */
  91763. constructor(
  91764. /** origin point */
  91765. origin: Vector3,
  91766. /** direction */
  91767. direction: Vector3,
  91768. /** length of the ray */
  91769. length?: number);
  91770. /**
  91771. * Checks if the ray intersects a box
  91772. * This does not account for the ray lenght by design to improve perfs.
  91773. * @param minimum bound of the box
  91774. * @param maximum bound of the box
  91775. * @param intersectionTreshold extra extend to be added to the box in all direction
  91776. * @returns if the box was hit
  91777. */
  91778. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91779. /**
  91780. * Checks if the ray intersects a box
  91781. * This does not account for the ray lenght by design to improve perfs.
  91782. * @param box the bounding box to check
  91783. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91784. * @returns if the box was hit
  91785. */
  91786. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91787. /**
  91788. * If the ray hits a sphere
  91789. * @param sphere the bounding sphere to check
  91790. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91791. * @returns true if it hits the sphere
  91792. */
  91793. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91794. /**
  91795. * If the ray hits a triange
  91796. * @param vertex0 triangle vertex
  91797. * @param vertex1 triangle vertex
  91798. * @param vertex2 triangle vertex
  91799. * @returns intersection information if hit
  91800. */
  91801. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91802. /**
  91803. * Checks if ray intersects a plane
  91804. * @param plane the plane to check
  91805. * @returns the distance away it was hit
  91806. */
  91807. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91808. /**
  91809. * Calculate the intercept of a ray on a given axis
  91810. * @param axis to check 'x' | 'y' | 'z'
  91811. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91812. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91813. */
  91814. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91815. /**
  91816. * Checks if ray intersects a mesh
  91817. * @param mesh the mesh to check
  91818. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91819. * @returns picking info of the intersecton
  91820. */
  91821. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91822. /**
  91823. * Checks if ray intersects a mesh
  91824. * @param meshes the meshes to check
  91825. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91826. * @param results array to store result in
  91827. * @returns Array of picking infos
  91828. */
  91829. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91830. private _comparePickingInfo;
  91831. private static smallnum;
  91832. private static rayl;
  91833. /**
  91834. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91835. * @param sega the first point of the segment to test the intersection against
  91836. * @param segb the second point of the segment to test the intersection against
  91837. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91838. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91839. */
  91840. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91841. /**
  91842. * Update the ray from viewport position
  91843. * @param x position
  91844. * @param y y position
  91845. * @param viewportWidth viewport width
  91846. * @param viewportHeight viewport height
  91847. * @param world world matrix
  91848. * @param view view matrix
  91849. * @param projection projection matrix
  91850. * @returns this ray updated
  91851. */
  91852. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91853. /**
  91854. * Creates a ray with origin and direction of 0,0,0
  91855. * @returns the new ray
  91856. */
  91857. static Zero(): Ray;
  91858. /**
  91859. * Creates a new ray from screen space and viewport
  91860. * @param x position
  91861. * @param y y position
  91862. * @param viewportWidth viewport width
  91863. * @param viewportHeight viewport height
  91864. * @param world world matrix
  91865. * @param view view matrix
  91866. * @param projection projection matrix
  91867. * @returns new ray
  91868. */
  91869. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91870. /**
  91871. * 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
  91872. * transformed to the given world matrix.
  91873. * @param origin The origin point
  91874. * @param end The end point
  91875. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91876. * @returns the new ray
  91877. */
  91878. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91879. /**
  91880. * Transforms a ray by a matrix
  91881. * @param ray ray to transform
  91882. * @param matrix matrix to apply
  91883. * @returns the resulting new ray
  91884. */
  91885. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91886. /**
  91887. * Transforms a ray by a matrix
  91888. * @param ray ray to transform
  91889. * @param matrix matrix to apply
  91890. * @param result ray to store result in
  91891. */
  91892. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91893. /**
  91894. * Unproject a ray from screen space to object space
  91895. * @param sourceX defines the screen space x coordinate to use
  91896. * @param sourceY defines the screen space y coordinate to use
  91897. * @param viewportWidth defines the current width of the viewport
  91898. * @param viewportHeight defines the current height of the viewport
  91899. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91900. * @param view defines the view matrix to use
  91901. * @param projection defines the projection matrix to use
  91902. */
  91903. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91904. }
  91905. /**
  91906. * Type used to define predicate used to select faces when a mesh intersection is detected
  91907. */
  91908. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91909. interface Scene {
  91910. /** @hidden */
  91911. _tempPickingRay: Nullable<Ray>;
  91912. /** @hidden */
  91913. _cachedRayForTransform: Ray;
  91914. /** @hidden */
  91915. _pickWithRayInverseMatrix: Matrix;
  91916. /** @hidden */
  91917. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91918. /** @hidden */
  91919. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91920. /** @hidden */
  91921. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  91922. }
  91923. }
  91924. declare module BABYLON {
  91925. /**
  91926. * Groups all the scene component constants in one place to ease maintenance.
  91927. * @hidden
  91928. */
  91929. export class SceneComponentConstants {
  91930. static readonly NAME_EFFECTLAYER: string;
  91931. static readonly NAME_LAYER: string;
  91932. static readonly NAME_LENSFLARESYSTEM: string;
  91933. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91934. static readonly NAME_PARTICLESYSTEM: string;
  91935. static readonly NAME_GAMEPAD: string;
  91936. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91937. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91938. static readonly NAME_PREPASSRENDERER: string;
  91939. static readonly NAME_DEPTHRENDERER: string;
  91940. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91941. static readonly NAME_SPRITE: string;
  91942. static readonly NAME_SUBSURFACE: string;
  91943. static readonly NAME_OUTLINERENDERER: string;
  91944. static readonly NAME_PROCEDURALTEXTURE: string;
  91945. static readonly NAME_SHADOWGENERATOR: string;
  91946. static readonly NAME_OCTREE: string;
  91947. static readonly NAME_PHYSICSENGINE: string;
  91948. static readonly NAME_AUDIO: string;
  91949. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91950. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91951. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91952. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91953. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91954. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91955. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91956. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91957. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91958. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91959. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91960. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91961. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91962. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91963. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91964. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91965. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91966. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91967. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91968. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91969. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91970. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91971. static readonly STEP_AFTERRENDER_AUDIO: number;
  91972. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91973. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91974. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91975. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91976. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91977. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91978. static readonly STEP_POINTERMOVE_SPRITE: number;
  91979. static readonly STEP_POINTERDOWN_SPRITE: number;
  91980. static readonly STEP_POINTERUP_SPRITE: number;
  91981. }
  91982. /**
  91983. * This represents a scene component.
  91984. *
  91985. * This is used to decouple the dependency the scene is having on the different workloads like
  91986. * layers, post processes...
  91987. */
  91988. export interface ISceneComponent {
  91989. /**
  91990. * The name of the component. Each component must have a unique name.
  91991. */
  91992. name: string;
  91993. /**
  91994. * The scene the component belongs to.
  91995. */
  91996. scene: Scene;
  91997. /**
  91998. * Register the component to one instance of a scene.
  91999. */
  92000. register(): void;
  92001. /**
  92002. * Rebuilds the elements related to this component in case of
  92003. * context lost for instance.
  92004. */
  92005. rebuild(): void;
  92006. /**
  92007. * Disposes the component and the associated ressources.
  92008. */
  92009. dispose(): void;
  92010. }
  92011. /**
  92012. * This represents a SERIALIZABLE scene component.
  92013. *
  92014. * This extends Scene Component to add Serialization methods on top.
  92015. */
  92016. export interface ISceneSerializableComponent extends ISceneComponent {
  92017. /**
  92018. * Adds all the elements from the container to the scene
  92019. * @param container the container holding the elements
  92020. */
  92021. addFromContainer(container: AbstractScene): void;
  92022. /**
  92023. * Removes all the elements in the container from the scene
  92024. * @param container contains the elements to remove
  92025. * @param dispose if the removed element should be disposed (default: false)
  92026. */
  92027. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  92028. /**
  92029. * Serializes the component data to the specified json object
  92030. * @param serializationObject The object to serialize to
  92031. */
  92032. serialize(serializationObject: any): void;
  92033. }
  92034. /**
  92035. * Strong typing of a Mesh related stage step action
  92036. */
  92037. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  92038. /**
  92039. * Strong typing of a Evaluate Sub Mesh related stage step action
  92040. */
  92041. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  92042. /**
  92043. * Strong typing of a pre active Mesh related stage step action
  92044. */
  92045. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  92046. /**
  92047. * Strong typing of a Camera related stage step action
  92048. */
  92049. export type CameraStageAction = (camera: Camera) => void;
  92050. /**
  92051. * Strong typing of a Camera Frame buffer related stage step action
  92052. */
  92053. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  92054. /**
  92055. * Strong typing of a Render Target related stage step action
  92056. */
  92057. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  92058. /**
  92059. * Strong typing of a RenderingGroup related stage step action
  92060. */
  92061. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  92062. /**
  92063. * Strong typing of a Mesh Render related stage step action
  92064. */
  92065. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  92066. /**
  92067. * Strong typing of a simple stage step action
  92068. */
  92069. export type SimpleStageAction = () => void;
  92070. /**
  92071. * Strong typing of a render target action.
  92072. */
  92073. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  92074. /**
  92075. * Strong typing of a pointer move action.
  92076. */
  92077. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  92078. /**
  92079. * Strong typing of a pointer up/down action.
  92080. */
  92081. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  92082. /**
  92083. * Representation of a stage in the scene (Basically a list of ordered steps)
  92084. * @hidden
  92085. */
  92086. export class Stage<T extends Function> extends Array<{
  92087. index: number;
  92088. component: ISceneComponent;
  92089. action: T;
  92090. }> {
  92091. /**
  92092. * Hide ctor from the rest of the world.
  92093. * @param items The items to add.
  92094. */
  92095. private constructor();
  92096. /**
  92097. * Creates a new Stage.
  92098. * @returns A new instance of a Stage
  92099. */
  92100. static Create<T extends Function>(): Stage<T>;
  92101. /**
  92102. * Registers a step in an ordered way in the targeted stage.
  92103. * @param index Defines the position to register the step in
  92104. * @param component Defines the component attached to the step
  92105. * @param action Defines the action to launch during the step
  92106. */
  92107. registerStep(index: number, component: ISceneComponent, action: T): void;
  92108. /**
  92109. * Clears all the steps from the stage.
  92110. */
  92111. clear(): void;
  92112. }
  92113. }
  92114. declare module BABYLON {
  92115. interface Scene {
  92116. /** @hidden */
  92117. _pointerOverSprite: Nullable<Sprite>;
  92118. /** @hidden */
  92119. _pickedDownSprite: Nullable<Sprite>;
  92120. /** @hidden */
  92121. _tempSpritePickingRay: Nullable<Ray>;
  92122. /**
  92123. * All of the sprite managers added to this scene
  92124. * @see https://doc.babylonjs.com/babylon101/sprites
  92125. */
  92126. spriteManagers: Array<ISpriteManager>;
  92127. /**
  92128. * An event triggered when sprites rendering is about to start
  92129. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92130. */
  92131. onBeforeSpritesRenderingObservable: Observable<Scene>;
  92132. /**
  92133. * An event triggered when sprites rendering is done
  92134. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92135. */
  92136. onAfterSpritesRenderingObservable: Observable<Scene>;
  92137. /** @hidden */
  92138. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92139. /** Launch a ray to try to pick a sprite in the scene
  92140. * @param x position on screen
  92141. * @param y position on screen
  92142. * @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
  92143. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92144. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92145. * @returns a PickingInfo
  92146. */
  92147. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92148. /** Use the given ray to pick a sprite in the scene
  92149. * @param ray The ray (in world space) to use to pick meshes
  92150. * @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
  92151. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92152. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92153. * @returns a PickingInfo
  92154. */
  92155. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92156. /** @hidden */
  92157. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92158. /** Launch a ray to try to pick sprites in the scene
  92159. * @param x position on screen
  92160. * @param y position on screen
  92161. * @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
  92162. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92163. * @returns a PickingInfo array
  92164. */
  92165. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92166. /** Use the given ray to pick sprites in the scene
  92167. * @param ray The ray (in world space) to use to pick meshes
  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 camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92170. * @returns a PickingInfo array
  92171. */
  92172. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92173. /**
  92174. * Force the sprite under the pointer
  92175. * @param sprite defines the sprite to use
  92176. */
  92177. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  92178. /**
  92179. * Gets the sprite under the pointer
  92180. * @returns a Sprite or null if no sprite is under the pointer
  92181. */
  92182. getPointerOverSprite(): Nullable<Sprite>;
  92183. }
  92184. /**
  92185. * Defines the sprite scene component responsible to manage sprites
  92186. * in a given scene.
  92187. */
  92188. export class SpriteSceneComponent implements ISceneComponent {
  92189. /**
  92190. * The component name helpfull to identify the component in the list of scene components.
  92191. */
  92192. readonly name: string;
  92193. /**
  92194. * The scene the component belongs to.
  92195. */
  92196. scene: Scene;
  92197. /** @hidden */
  92198. private _spritePredicate;
  92199. /**
  92200. * Creates a new instance of the component for the given scene
  92201. * @param scene Defines the scene to register the component in
  92202. */
  92203. constructor(scene: Scene);
  92204. /**
  92205. * Registers the component in a given scene
  92206. */
  92207. register(): void;
  92208. /**
  92209. * Rebuilds the elements related to this component in case of
  92210. * context lost for instance.
  92211. */
  92212. rebuild(): void;
  92213. /**
  92214. * Disposes the component and the associated ressources.
  92215. */
  92216. dispose(): void;
  92217. private _pickSpriteButKeepRay;
  92218. private _pointerMove;
  92219. private _pointerDown;
  92220. private _pointerUp;
  92221. }
  92222. }
  92223. declare module BABYLON {
  92224. /** @hidden */
  92225. export var fogFragmentDeclaration: {
  92226. name: string;
  92227. shader: string;
  92228. };
  92229. }
  92230. declare module BABYLON {
  92231. /** @hidden */
  92232. export var fogFragment: {
  92233. name: string;
  92234. shader: string;
  92235. };
  92236. }
  92237. declare module BABYLON {
  92238. /** @hidden */
  92239. export var imageProcessingCompatibility: {
  92240. name: string;
  92241. shader: string;
  92242. };
  92243. }
  92244. declare module BABYLON {
  92245. /** @hidden */
  92246. export var spritesPixelShader: {
  92247. name: string;
  92248. shader: string;
  92249. };
  92250. }
  92251. declare module BABYLON {
  92252. /** @hidden */
  92253. export var fogVertexDeclaration: {
  92254. name: string;
  92255. shader: string;
  92256. };
  92257. }
  92258. declare module BABYLON {
  92259. /** @hidden */
  92260. export var spritesVertexShader: {
  92261. name: string;
  92262. shader: string;
  92263. };
  92264. }
  92265. declare module BABYLON {
  92266. /**
  92267. * Defines the minimum interface to fullfil in order to be a sprite manager.
  92268. */
  92269. export interface ISpriteManager extends IDisposable {
  92270. /**
  92271. * Gets manager's name
  92272. */
  92273. name: string;
  92274. /**
  92275. * Restricts the camera to viewing objects with the same layerMask.
  92276. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  92277. */
  92278. layerMask: number;
  92279. /**
  92280. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92281. */
  92282. isPickable: boolean;
  92283. /**
  92284. * Gets the hosting scene
  92285. */
  92286. scene: Scene;
  92287. /**
  92288. * Specifies the rendering group id for this mesh (0 by default)
  92289. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92290. */
  92291. renderingGroupId: number;
  92292. /**
  92293. * Defines the list of sprites managed by the manager.
  92294. */
  92295. sprites: Array<Sprite>;
  92296. /**
  92297. * Gets or sets the spritesheet texture
  92298. */
  92299. texture: Texture;
  92300. /** Defines the default width of a cell in the spritesheet */
  92301. cellWidth: number;
  92302. /** Defines the default height of a cell in the spritesheet */
  92303. cellHeight: number;
  92304. /**
  92305. * Tests the intersection of a sprite with a specific ray.
  92306. * @param ray The ray we are sending to test the collision
  92307. * @param camera The camera space we are sending rays in
  92308. * @param predicate A predicate allowing excluding sprites from the list of object to test
  92309. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92310. * @returns picking info or null.
  92311. */
  92312. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  92313. /**
  92314. * Intersects the sprites with a ray
  92315. * @param ray defines the ray to intersect with
  92316. * @param camera defines the current active camera
  92317. * @param predicate defines a predicate used to select candidate sprites
  92318. * @returns null if no hit or a PickingInfo array
  92319. */
  92320. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  92321. /**
  92322. * Renders the list of sprites on screen.
  92323. */
  92324. render(): void;
  92325. }
  92326. /**
  92327. * Class used to manage multiple sprites on the same spritesheet
  92328. * @see https://doc.babylonjs.com/babylon101/sprites
  92329. */
  92330. export class SpriteManager implements ISpriteManager {
  92331. /** defines the manager's name */
  92332. name: string;
  92333. /** Define the Url to load snippets */
  92334. static SnippetUrl: string;
  92335. /** Snippet ID if the manager was created from the snippet server */
  92336. snippetId: string;
  92337. /** Gets the list of sprites */
  92338. sprites: Sprite[];
  92339. /** Gets or sets the rendering group id (0 by default) */
  92340. renderingGroupId: number;
  92341. /** Gets or sets camera layer mask */
  92342. layerMask: number;
  92343. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  92344. fogEnabled: boolean;
  92345. /** Gets or sets a boolean indicating if the sprites are pickable */
  92346. isPickable: boolean;
  92347. /** Defines the default width of a cell in the spritesheet */
  92348. cellWidth: number;
  92349. /** Defines the default height of a cell in the spritesheet */
  92350. cellHeight: number;
  92351. /** Associative array from JSON sprite data file */
  92352. private _cellData;
  92353. /** Array of sprite names from JSON sprite data file */
  92354. private _spriteMap;
  92355. /** True when packed cell data from JSON file is ready*/
  92356. private _packedAndReady;
  92357. private _textureContent;
  92358. private _useInstancing;
  92359. /**
  92360. * An event triggered when the manager is disposed.
  92361. */
  92362. onDisposeObservable: Observable<SpriteManager>;
  92363. private _onDisposeObserver;
  92364. /**
  92365. * Callback called when the manager is disposed
  92366. */
  92367. set onDispose(callback: () => void);
  92368. private _capacity;
  92369. private _fromPacked;
  92370. private _spriteTexture;
  92371. private _epsilon;
  92372. private _scene;
  92373. private _vertexData;
  92374. private _buffer;
  92375. private _vertexBuffers;
  92376. private _spriteBuffer;
  92377. private _indexBuffer;
  92378. private _effectBase;
  92379. private _effectFog;
  92380. private _vertexBufferSize;
  92381. /**
  92382. * Gets or sets the unique id of the sprite
  92383. */
  92384. uniqueId: number;
  92385. /**
  92386. * Gets the array of sprites
  92387. */
  92388. get children(): Sprite[];
  92389. /**
  92390. * Gets the hosting scene
  92391. */
  92392. get scene(): Scene;
  92393. /**
  92394. * Gets the capacity of the manager
  92395. */
  92396. get capacity(): number;
  92397. /**
  92398. * Gets or sets the spritesheet texture
  92399. */
  92400. get texture(): Texture;
  92401. set texture(value: Texture);
  92402. private _blendMode;
  92403. /**
  92404. * Blend mode use to render the particle, it can be any of
  92405. * the static Constants.ALPHA_x properties provided in this class.
  92406. * Default value is Constants.ALPHA_COMBINE
  92407. */
  92408. get blendMode(): number;
  92409. set blendMode(blendMode: number);
  92410. /** Disables writing to the depth buffer when rendering the sprites.
  92411. * It can be handy to disable depth writing when using textures without alpha channel
  92412. * and setting some specific blend modes.
  92413. */
  92414. disableDepthWrite: boolean;
  92415. /**
  92416. * Creates a new sprite manager
  92417. * @param name defines the manager's name
  92418. * @param imgUrl defines the sprite sheet url
  92419. * @param capacity defines the maximum allowed number of sprites
  92420. * @param cellSize defines the size of a sprite cell
  92421. * @param scene defines the hosting scene
  92422. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  92423. * @param samplingMode defines the smapling mode to use with spritesheet
  92424. * @param fromPacked set to false; do not alter
  92425. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  92426. */
  92427. constructor(
  92428. /** defines the manager's name */
  92429. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  92430. /**
  92431. * Returns the string "SpriteManager"
  92432. * @returns "SpriteManager"
  92433. */
  92434. getClassName(): string;
  92435. private _makePacked;
  92436. private _appendSpriteVertex;
  92437. private _checkTextureAlpha;
  92438. /**
  92439. * Intersects the sprites with a ray
  92440. * @param ray defines the ray to intersect with
  92441. * @param camera defines the current active camera
  92442. * @param predicate defines a predicate used to select candidate sprites
  92443. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  92444. * @returns null if no hit or a PickingInfo
  92445. */
  92446. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  92447. /**
  92448. * Intersects the sprites with a ray
  92449. * @param ray defines the ray to intersect with
  92450. * @param camera defines the current active camera
  92451. * @param predicate defines a predicate used to select candidate sprites
  92452. * @returns null if no hit or a PickingInfo array
  92453. */
  92454. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  92455. /**
  92456. * Render all child sprites
  92457. */
  92458. render(): void;
  92459. /**
  92460. * Release associated resources
  92461. */
  92462. dispose(): void;
  92463. /**
  92464. * Serializes the sprite manager to a JSON object
  92465. * @param serializeTexture defines if the texture must be serialized as well
  92466. * @returns the JSON object
  92467. */
  92468. serialize(serializeTexture?: boolean): any;
  92469. /**
  92470. * Parses a JSON object to create a new sprite manager.
  92471. * @param parsedManager The JSON object to parse
  92472. * @param scene The scene to create the sprite managerin
  92473. * @param rootUrl The root url to use to load external dependencies like texture
  92474. * @returns the new sprite manager
  92475. */
  92476. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  92477. /**
  92478. * Creates a sprite manager from a snippet saved in a remote file
  92479. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  92480. * @param url defines the url to load from
  92481. * @param scene defines the hosting scene
  92482. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92483. * @returns a promise that will resolve to the new sprite manager
  92484. */
  92485. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92486. /**
  92487. * Creates a sprite manager from a snippet saved by the sprite editor
  92488. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  92489. * @param scene defines the hosting scene
  92490. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92491. * @returns a promise that will resolve to the new sprite manager
  92492. */
  92493. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92494. }
  92495. }
  92496. declare module BABYLON {
  92497. /** Interface used by value gradients (color, factor, ...) */
  92498. export interface IValueGradient {
  92499. /**
  92500. * Gets or sets the gradient value (between 0 and 1)
  92501. */
  92502. gradient: number;
  92503. }
  92504. /** Class used to store color4 gradient */
  92505. export class ColorGradient implements IValueGradient {
  92506. /**
  92507. * Gets or sets the gradient value (between 0 and 1)
  92508. */
  92509. gradient: number;
  92510. /**
  92511. * Gets or sets first associated color
  92512. */
  92513. color1: Color4;
  92514. /**
  92515. * Gets or sets second associated color
  92516. */
  92517. color2?: Color4 | undefined;
  92518. /**
  92519. * Creates a new color4 gradient
  92520. * @param gradient gets or sets the gradient value (between 0 and 1)
  92521. * @param color1 gets or sets first associated color
  92522. * @param color2 gets or sets first second color
  92523. */
  92524. constructor(
  92525. /**
  92526. * Gets or sets the gradient value (between 0 and 1)
  92527. */
  92528. gradient: number,
  92529. /**
  92530. * Gets or sets first associated color
  92531. */
  92532. color1: Color4,
  92533. /**
  92534. * Gets or sets second associated color
  92535. */
  92536. color2?: Color4 | undefined);
  92537. /**
  92538. * Will get a color picked randomly between color1 and color2.
  92539. * If color2 is undefined then color1 will be used
  92540. * @param result defines the target Color4 to store the result in
  92541. */
  92542. getColorToRef(result: Color4): void;
  92543. }
  92544. /** Class used to store color 3 gradient */
  92545. export class Color3Gradient implements IValueGradient {
  92546. /**
  92547. * Gets or sets the gradient value (between 0 and 1)
  92548. */
  92549. gradient: number;
  92550. /**
  92551. * Gets or sets the associated color
  92552. */
  92553. color: Color3;
  92554. /**
  92555. * Creates a new color3 gradient
  92556. * @param gradient gets or sets the gradient value (between 0 and 1)
  92557. * @param color gets or sets associated color
  92558. */
  92559. constructor(
  92560. /**
  92561. * Gets or sets the gradient value (between 0 and 1)
  92562. */
  92563. gradient: number,
  92564. /**
  92565. * Gets or sets the associated color
  92566. */
  92567. color: Color3);
  92568. }
  92569. /** Class used to store factor gradient */
  92570. export class FactorGradient implements IValueGradient {
  92571. /**
  92572. * Gets or sets the gradient value (between 0 and 1)
  92573. */
  92574. gradient: number;
  92575. /**
  92576. * Gets or sets first associated factor
  92577. */
  92578. factor1: number;
  92579. /**
  92580. * Gets or sets second associated factor
  92581. */
  92582. factor2?: number | undefined;
  92583. /**
  92584. * Creates a new factor gradient
  92585. * @param gradient gets or sets the gradient value (between 0 and 1)
  92586. * @param factor1 gets or sets first associated factor
  92587. * @param factor2 gets or sets second associated factor
  92588. */
  92589. constructor(
  92590. /**
  92591. * Gets or sets the gradient value (between 0 and 1)
  92592. */
  92593. gradient: number,
  92594. /**
  92595. * Gets or sets first associated factor
  92596. */
  92597. factor1: number,
  92598. /**
  92599. * Gets or sets second associated factor
  92600. */
  92601. factor2?: number | undefined);
  92602. /**
  92603. * Will get a number picked randomly between factor1 and factor2.
  92604. * If factor2 is undefined then factor1 will be used
  92605. * @returns the picked number
  92606. */
  92607. getFactor(): number;
  92608. }
  92609. /**
  92610. * Helper used to simplify some generic gradient tasks
  92611. */
  92612. export class GradientHelper {
  92613. /**
  92614. * Gets the current gradient from an array of IValueGradient
  92615. * @param ratio defines the current ratio to get
  92616. * @param gradients defines the array of IValueGradient
  92617. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  92618. */
  92619. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  92620. }
  92621. }
  92622. declare module BABYLON {
  92623. interface ThinEngine {
  92624. /**
  92625. * Creates a raw texture
  92626. * @param data defines the data to store in the texture
  92627. * @param width defines the width of the texture
  92628. * @param height defines the height of the texture
  92629. * @param format defines the format of the data
  92630. * @param generateMipMaps defines if the engine should generate the mip levels
  92631. * @param invertY defines if data must be stored with Y axis inverted
  92632. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92633. * @param compression defines the compression used (null by default)
  92634. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92635. * @returns the raw texture inside an InternalTexture
  92636. */
  92637. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  92638. /**
  92639. * Update a raw texture
  92640. * @param texture defines the texture to update
  92641. * @param data defines the data to store in the texture
  92642. * @param format defines the format of the data
  92643. * @param invertY defines if data must be stored with Y axis inverted
  92644. */
  92645. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92646. /**
  92647. * Update a raw texture
  92648. * @param texture defines the texture to update
  92649. * @param data defines the data to store in the texture
  92650. * @param format defines the format of the data
  92651. * @param invertY defines if data must be stored with Y axis inverted
  92652. * @param compression defines the compression used (null by default)
  92653. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92654. */
  92655. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  92656. /**
  92657. * Creates a new raw cube texture
  92658. * @param data defines the array of data to use to create each face
  92659. * @param size defines the size of the textures
  92660. * @param format defines the format of the data
  92661. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92662. * @param generateMipMaps defines if the engine should generate the mip levels
  92663. * @param invertY defines if data must be stored with Y axis inverted
  92664. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92665. * @param compression defines the compression used (null by default)
  92666. * @returns the cube texture as an InternalTexture
  92667. */
  92668. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  92669. /**
  92670. * Update a raw cube texture
  92671. * @param texture defines the texture to udpdate
  92672. * @param data defines the data to store
  92673. * @param format defines the data format
  92674. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92675. * @param invertY defines if data must be stored with Y axis inverted
  92676. */
  92677. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  92678. /**
  92679. * Update a raw cube texture
  92680. * @param texture defines the texture to udpdate
  92681. * @param data defines the data to store
  92682. * @param format defines the data format
  92683. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92684. * @param invertY defines if data must be stored with Y axis inverted
  92685. * @param compression defines the compression used (null by default)
  92686. */
  92687. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  92688. /**
  92689. * Update a raw cube texture
  92690. * @param texture defines the texture to udpdate
  92691. * @param data defines the data to store
  92692. * @param format defines the data format
  92693. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92694. * @param invertY defines if data must be stored with Y axis inverted
  92695. * @param compression defines the compression used (null by default)
  92696. * @param level defines which level of the texture to update
  92697. */
  92698. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  92699. /**
  92700. * Creates a new raw cube texture from a specified url
  92701. * @param url defines the url where the data is located
  92702. * @param scene defines the current scene
  92703. * @param size defines the size of the textures
  92704. * @param format defines the format of the data
  92705. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92706. * @param noMipmap defines if the engine should avoid generating the mip levels
  92707. * @param callback defines a callback used to extract texture data from loaded data
  92708. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92709. * @param onLoad defines a callback called when texture is loaded
  92710. * @param onError defines a callback called if there is an error
  92711. * @returns the cube texture as an InternalTexture
  92712. */
  92713. 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;
  92714. /**
  92715. * Creates a new raw cube texture from a specified url
  92716. * @param url defines the url where the data is located
  92717. * @param scene defines the current scene
  92718. * @param size defines the size of the textures
  92719. * @param format defines the format of the data
  92720. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92721. * @param noMipmap defines if the engine should avoid generating the mip levels
  92722. * @param callback defines a callback used to extract texture data from loaded data
  92723. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92724. * @param onLoad defines a callback called when texture is loaded
  92725. * @param onError defines a callback called if there is an error
  92726. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92727. * @param invertY defines if data must be stored with Y axis inverted
  92728. * @returns the cube texture as an InternalTexture
  92729. */
  92730. 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;
  92731. /**
  92732. * Creates a new raw 3D texture
  92733. * @param data defines the data used to create the texture
  92734. * @param width defines the width of the texture
  92735. * @param height defines the height of the texture
  92736. * @param depth defines the depth of the texture
  92737. * @param format defines the format of the texture
  92738. * @param generateMipMaps defines if the engine must generate mip levels
  92739. * @param invertY defines if data must be stored with Y axis inverted
  92740. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92741. * @param compression defines the compressed used (can be null)
  92742. * @param textureType defines the compressed used (can be null)
  92743. * @returns a new raw 3D texture (stored in an InternalTexture)
  92744. */
  92745. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92746. /**
  92747. * Update a raw 3D texture
  92748. * @param texture defines the texture to update
  92749. * @param data defines the data to store
  92750. * @param format defines the data format
  92751. * @param invertY defines if data must be stored with Y axis inverted
  92752. */
  92753. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92754. /**
  92755. * Update a raw 3D texture
  92756. * @param texture defines the texture to update
  92757. * @param data defines the data to store
  92758. * @param format defines the data format
  92759. * @param invertY defines if data must be stored with Y axis inverted
  92760. * @param compression defines the used compression (can be null)
  92761. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92762. */
  92763. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92764. /**
  92765. * Creates a new raw 2D array texture
  92766. * @param data defines the data used to create the texture
  92767. * @param width defines the width of the texture
  92768. * @param height defines the height of the texture
  92769. * @param depth defines the number of layers of the texture
  92770. * @param format defines the format of the texture
  92771. * @param generateMipMaps defines if the engine must generate mip levels
  92772. * @param invertY defines if data must be stored with Y axis inverted
  92773. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92774. * @param compression defines the compressed used (can be null)
  92775. * @param textureType defines the compressed used (can be null)
  92776. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92777. */
  92778. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92779. /**
  92780. * Update a raw 2D array texture
  92781. * @param texture defines the texture to update
  92782. * @param data defines the data to store
  92783. * @param format defines the data format
  92784. * @param invertY defines if data must be stored with Y axis inverted
  92785. */
  92786. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92787. /**
  92788. * Update a raw 2D array texture
  92789. * @param texture defines the texture to update
  92790. * @param data defines the data to store
  92791. * @param format defines the data format
  92792. * @param invertY defines if data must be stored with Y axis inverted
  92793. * @param compression defines the used compression (can be null)
  92794. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92795. */
  92796. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92797. }
  92798. }
  92799. declare module BABYLON {
  92800. /**
  92801. * Raw texture can help creating a texture directly from an array of data.
  92802. * This can be super useful if you either get the data from an uncompressed source or
  92803. * if you wish to create your texture pixel by pixel.
  92804. */
  92805. export class RawTexture extends Texture {
  92806. /**
  92807. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92808. */
  92809. format: number;
  92810. /**
  92811. * Instantiates a new RawTexture.
  92812. * Raw texture can help creating a texture directly from an array of data.
  92813. * This can be super useful if you either get the data from an uncompressed source or
  92814. * if you wish to create your texture pixel by pixel.
  92815. * @param data define the array of data to use to create the texture
  92816. * @param width define the width of the texture
  92817. * @param height define the height of the texture
  92818. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92819. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92820. * @param generateMipMaps define whether mip maps should be generated or not
  92821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92823. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92824. */
  92825. constructor(data: ArrayBufferView, width: number, height: number,
  92826. /**
  92827. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92828. */
  92829. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92830. /**
  92831. * Updates the texture underlying data.
  92832. * @param data Define the new data of the texture
  92833. */
  92834. update(data: ArrayBufferView): void;
  92835. /**
  92836. * Creates a luminance texture from some data.
  92837. * @param data Define the texture data
  92838. * @param width Define the width of the texture
  92839. * @param height Define the height of the texture
  92840. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92841. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92842. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92843. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92844. * @returns the luminance texture
  92845. */
  92846. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92847. /**
  92848. * Creates a luminance alpha texture from some data.
  92849. * @param data Define the texture data
  92850. * @param width Define the width of the texture
  92851. * @param height Define the height of the texture
  92852. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92853. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92854. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92855. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92856. * @returns the luminance alpha texture
  92857. */
  92858. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92859. /**
  92860. * Creates an alpha texture from some data.
  92861. * @param data Define the texture data
  92862. * @param width Define the width of the texture
  92863. * @param height Define the height of the texture
  92864. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92865. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92866. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92867. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92868. * @returns the alpha texture
  92869. */
  92870. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92871. /**
  92872. * Creates a RGB texture from some data.
  92873. * @param data Define the texture data
  92874. * @param width Define the width of the texture
  92875. * @param height Define the height of the texture
  92876. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92877. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92878. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92879. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92880. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92881. * @returns the RGB alpha texture
  92882. */
  92883. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92884. /**
  92885. * Creates a RGBA texture from some data.
  92886. * @param data Define the texture data
  92887. * @param width Define the width of the texture
  92888. * @param height Define the height of the texture
  92889. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92890. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92891. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92892. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92893. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92894. * @returns the RGBA texture
  92895. */
  92896. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92897. /**
  92898. * Creates a R texture from some data.
  92899. * @param data Define the texture data
  92900. * @param width Define the width of the texture
  92901. * @param height Define the height of the texture
  92902. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92903. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92904. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92905. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92906. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92907. * @returns the R texture
  92908. */
  92909. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92910. }
  92911. }
  92912. declare module BABYLON {
  92913. interface ThinEngine {
  92914. /**
  92915. * Update a dynamic index buffer
  92916. * @param indexBuffer defines the target index buffer
  92917. * @param indices defines the data to update
  92918. * @param offset defines the offset in the target index buffer where update should start
  92919. */
  92920. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92921. /**
  92922. * Updates a dynamic vertex buffer.
  92923. * @param vertexBuffer the vertex buffer to update
  92924. * @param data the data used to update the vertex buffer
  92925. * @param byteOffset the byte offset of the data
  92926. * @param byteLength the byte length of the data
  92927. */
  92928. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92929. }
  92930. }
  92931. declare module BABYLON {
  92932. interface AbstractScene {
  92933. /**
  92934. * The list of procedural textures added to the scene
  92935. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92936. */
  92937. proceduralTextures: Array<ProceduralTexture>;
  92938. }
  92939. /**
  92940. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92941. * in a given scene.
  92942. */
  92943. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92944. /**
  92945. * The component name helpfull to identify the component in the list of scene components.
  92946. */
  92947. readonly name: string;
  92948. /**
  92949. * The scene the component belongs to.
  92950. */
  92951. scene: Scene;
  92952. /**
  92953. * Creates a new instance of the component for the given scene
  92954. * @param scene Defines the scene to register the component in
  92955. */
  92956. constructor(scene: Scene);
  92957. /**
  92958. * Registers the component in a given scene
  92959. */
  92960. register(): void;
  92961. /**
  92962. * Rebuilds the elements related to this component in case of
  92963. * context lost for instance.
  92964. */
  92965. rebuild(): void;
  92966. /**
  92967. * Disposes the component and the associated ressources.
  92968. */
  92969. dispose(): void;
  92970. private _beforeClear;
  92971. }
  92972. }
  92973. declare module BABYLON {
  92974. interface ThinEngine {
  92975. /**
  92976. * Creates a new render target cube texture
  92977. * @param size defines the size of the texture
  92978. * @param options defines the options used to create the texture
  92979. * @returns a new render target cube texture stored in an InternalTexture
  92980. */
  92981. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92982. }
  92983. }
  92984. declare module BABYLON {
  92985. /** @hidden */
  92986. export var proceduralVertexShader: {
  92987. name: string;
  92988. shader: string;
  92989. };
  92990. }
  92991. declare module BABYLON {
  92992. /**
  92993. * 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.
  92994. * This is the base class of any Procedural texture and contains most of the shareable code.
  92995. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92996. */
  92997. export class ProceduralTexture extends Texture {
  92998. /**
  92999. * Define if the texture is enabled or not (disabled texture will not render)
  93000. */
  93001. isEnabled: boolean;
  93002. /**
  93003. * Define if the texture must be cleared before rendering (default is true)
  93004. */
  93005. autoClear: boolean;
  93006. /**
  93007. * Callback called when the texture is generated
  93008. */
  93009. onGenerated: () => void;
  93010. /**
  93011. * Event raised when the texture is generated
  93012. */
  93013. onGeneratedObservable: Observable<ProceduralTexture>;
  93014. /**
  93015. * Event raised before the texture is generated
  93016. */
  93017. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  93018. /**
  93019. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  93020. */
  93021. nodeMaterialSource: Nullable<NodeMaterial>;
  93022. /** @hidden */
  93023. _generateMipMaps: boolean;
  93024. /** @hidden **/
  93025. _effect: Effect;
  93026. /** @hidden */
  93027. _textures: {
  93028. [key: string]: Texture;
  93029. };
  93030. /** @hidden */
  93031. protected _fallbackTexture: Nullable<Texture>;
  93032. private _size;
  93033. private _currentRefreshId;
  93034. private _frameId;
  93035. private _refreshRate;
  93036. private _vertexBuffers;
  93037. private _indexBuffer;
  93038. private _uniforms;
  93039. private _samplers;
  93040. private _fragment;
  93041. private _floats;
  93042. private _ints;
  93043. private _floatsArrays;
  93044. private _colors3;
  93045. private _colors4;
  93046. private _vectors2;
  93047. private _vectors3;
  93048. private _matrices;
  93049. private _fallbackTextureUsed;
  93050. private _fullEngine;
  93051. private _cachedDefines;
  93052. private _contentUpdateId;
  93053. private _contentData;
  93054. /**
  93055. * Instantiates a new procedural texture.
  93056. * 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.
  93057. * This is the base class of any Procedural texture and contains most of the shareable code.
  93058. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  93059. * @param name Define the name of the texture
  93060. * @param size Define the size of the texture to create
  93061. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  93062. * @param scene Define the scene the texture belongs to
  93063. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  93064. * @param generateMipMaps Define if the texture should creates mip maps or not
  93065. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  93066. * @param textureType The FBO internal texture type
  93067. */
  93068. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  93069. /**
  93070. * The effect that is created when initializing the post process.
  93071. * @returns The created effect corresponding the the postprocess.
  93072. */
  93073. getEffect(): Effect;
  93074. /**
  93075. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  93076. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  93077. */
  93078. getContent(): Nullable<ArrayBufferView>;
  93079. private _createIndexBuffer;
  93080. /** @hidden */
  93081. _rebuild(): void;
  93082. /**
  93083. * Resets the texture in order to recreate its associated resources.
  93084. * This can be called in case of context loss
  93085. */
  93086. reset(): void;
  93087. protected _getDefines(): string;
  93088. /**
  93089. * Is the texture ready to be used ? (rendered at least once)
  93090. * @returns true if ready, otherwise, false.
  93091. */
  93092. isReady(): boolean;
  93093. /**
  93094. * Resets the refresh counter of the texture and start bak from scratch.
  93095. * Could be useful to regenerate the texture if it is setup to render only once.
  93096. */
  93097. resetRefreshCounter(): void;
  93098. /**
  93099. * Set the fragment shader to use in order to render the texture.
  93100. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  93101. */
  93102. setFragment(fragment: any): void;
  93103. /**
  93104. * Define the refresh rate of the texture or the rendering frequency.
  93105. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93106. */
  93107. get refreshRate(): number;
  93108. set refreshRate(value: number);
  93109. /** @hidden */
  93110. _shouldRender(): boolean;
  93111. /**
  93112. * Get the size the texture is rendering at.
  93113. * @returns the size (on cube texture it is always squared)
  93114. */
  93115. getRenderSize(): RenderTargetTextureSize;
  93116. /**
  93117. * Resize the texture to new value.
  93118. * @param size Define the new size the texture should have
  93119. * @param generateMipMaps Define whether the new texture should create mip maps
  93120. */
  93121. resize(size: number, generateMipMaps: boolean): void;
  93122. private _checkUniform;
  93123. /**
  93124. * Set a texture in the shader program used to render.
  93125. * @param name Define the name of the uniform samplers as defined in the shader
  93126. * @param texture Define the texture to bind to this sampler
  93127. * @return the texture itself allowing "fluent" like uniform updates
  93128. */
  93129. setTexture(name: string, texture: Texture): ProceduralTexture;
  93130. /**
  93131. * Set a float in the shader.
  93132. * @param name Define the name of the uniform as defined in the shader
  93133. * @param value Define the value to give to the uniform
  93134. * @return the texture itself allowing "fluent" like uniform updates
  93135. */
  93136. setFloat(name: string, value: number): ProceduralTexture;
  93137. /**
  93138. * Set a int in the shader.
  93139. * @param name Define the name of the uniform as defined in the shader
  93140. * @param value Define the value to give to the uniform
  93141. * @return the texture itself allowing "fluent" like uniform updates
  93142. */
  93143. setInt(name: string, value: number): ProceduralTexture;
  93144. /**
  93145. * Set an array of floats in the shader.
  93146. * @param name Define the name of the uniform as defined in the shader
  93147. * @param value Define the value to give to the uniform
  93148. * @return the texture itself allowing "fluent" like uniform updates
  93149. */
  93150. setFloats(name: string, value: number[]): ProceduralTexture;
  93151. /**
  93152. * Set a vec3 in the shader from a Color3.
  93153. * @param name Define the name of the uniform as defined in the shader
  93154. * @param value Define the value to give to the uniform
  93155. * @return the texture itself allowing "fluent" like uniform updates
  93156. */
  93157. setColor3(name: string, value: Color3): ProceduralTexture;
  93158. /**
  93159. * Set a vec4 in the shader from a Color4.
  93160. * @param name Define the name of the uniform as defined in the shader
  93161. * @param value Define the value to give to the uniform
  93162. * @return the texture itself allowing "fluent" like uniform updates
  93163. */
  93164. setColor4(name: string, value: Color4): ProceduralTexture;
  93165. /**
  93166. * Set a vec2 in the shader from a Vector2.
  93167. * @param name Define the name of the uniform as defined in the shader
  93168. * @param value Define the value to give to the uniform
  93169. * @return the texture itself allowing "fluent" like uniform updates
  93170. */
  93171. setVector2(name: string, value: Vector2): ProceduralTexture;
  93172. /**
  93173. * Set a vec3 in the shader from a Vector3.
  93174. * @param name Define the name of the uniform as defined in the shader
  93175. * @param value Define the value to give to the uniform
  93176. * @return the texture itself allowing "fluent" like uniform updates
  93177. */
  93178. setVector3(name: string, value: Vector3): ProceduralTexture;
  93179. /**
  93180. * Set a mat4 in the shader from a MAtrix.
  93181. * @param name Define the name of the uniform as defined in the shader
  93182. * @param value Define the value to give to the uniform
  93183. * @return the texture itself allowing "fluent" like uniform updates
  93184. */
  93185. setMatrix(name: string, value: Matrix): ProceduralTexture;
  93186. /**
  93187. * Render the texture to its associated render target.
  93188. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  93189. */
  93190. render(useCameraPostProcess?: boolean): void;
  93191. /**
  93192. * Clone the texture.
  93193. * @returns the cloned texture
  93194. */
  93195. clone(): ProceduralTexture;
  93196. /**
  93197. * Dispose the texture and release its asoociated resources.
  93198. */
  93199. dispose(): void;
  93200. }
  93201. }
  93202. declare module BABYLON {
  93203. /**
  93204. * This represents the base class for particle system in Babylon.
  93205. * 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.
  93206. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93207. * @example https://doc.babylonjs.com/babylon101/particles
  93208. */
  93209. export class BaseParticleSystem {
  93210. /**
  93211. * Source color is added to the destination color without alpha affecting the result
  93212. */
  93213. static BLENDMODE_ONEONE: number;
  93214. /**
  93215. * Blend current color and particle color using particle’s alpha
  93216. */
  93217. static BLENDMODE_STANDARD: number;
  93218. /**
  93219. * Add current color and particle color multiplied by particle’s alpha
  93220. */
  93221. static BLENDMODE_ADD: number;
  93222. /**
  93223. * Multiply current color with particle color
  93224. */
  93225. static BLENDMODE_MULTIPLY: number;
  93226. /**
  93227. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  93228. */
  93229. static BLENDMODE_MULTIPLYADD: number;
  93230. /**
  93231. * List of animations used by the particle system.
  93232. */
  93233. animations: Animation[];
  93234. /**
  93235. * Gets or sets the unique id of the particle system
  93236. */
  93237. uniqueId: number;
  93238. /**
  93239. * The id of the Particle system.
  93240. */
  93241. id: string;
  93242. /**
  93243. * The friendly name of the Particle system.
  93244. */
  93245. name: string;
  93246. /**
  93247. * Snippet ID if the particle system was created from the snippet server
  93248. */
  93249. snippetId: string;
  93250. /**
  93251. * The rendering group used by the Particle system to chose when to render.
  93252. */
  93253. renderingGroupId: number;
  93254. /**
  93255. * The emitter represents the Mesh or position we are attaching the particle system to.
  93256. */
  93257. emitter: Nullable<AbstractMesh | Vector3>;
  93258. /**
  93259. * The maximum number of particles to emit per frame
  93260. */
  93261. emitRate: number;
  93262. /**
  93263. * If you want to launch only a few particles at once, that can be done, as well.
  93264. */
  93265. manualEmitCount: number;
  93266. /**
  93267. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93268. */
  93269. updateSpeed: number;
  93270. /**
  93271. * The amount of time the particle system is running (depends of the overall update speed).
  93272. */
  93273. targetStopDuration: number;
  93274. /**
  93275. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  93276. */
  93277. disposeOnStop: boolean;
  93278. /**
  93279. * Minimum power of emitting particles.
  93280. */
  93281. minEmitPower: number;
  93282. /**
  93283. * Maximum power of emitting particles.
  93284. */
  93285. maxEmitPower: number;
  93286. /**
  93287. * Minimum life time of emitting particles.
  93288. */
  93289. minLifeTime: number;
  93290. /**
  93291. * Maximum life time of emitting particles.
  93292. */
  93293. maxLifeTime: number;
  93294. /**
  93295. * Minimum Size of emitting particles.
  93296. */
  93297. minSize: number;
  93298. /**
  93299. * Maximum Size of emitting particles.
  93300. */
  93301. maxSize: number;
  93302. /**
  93303. * Minimum scale of emitting particles on X axis.
  93304. */
  93305. minScaleX: number;
  93306. /**
  93307. * Maximum scale of emitting particles on X axis.
  93308. */
  93309. maxScaleX: number;
  93310. /**
  93311. * Minimum scale of emitting particles on Y axis.
  93312. */
  93313. minScaleY: number;
  93314. /**
  93315. * Maximum scale of emitting particles on Y axis.
  93316. */
  93317. maxScaleY: number;
  93318. /**
  93319. * Gets or sets the minimal initial rotation in radians.
  93320. */
  93321. minInitialRotation: number;
  93322. /**
  93323. * Gets or sets the maximal initial rotation in radians.
  93324. */
  93325. maxInitialRotation: number;
  93326. /**
  93327. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  93328. */
  93329. minAngularSpeed: number;
  93330. /**
  93331. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  93332. */
  93333. maxAngularSpeed: number;
  93334. /**
  93335. * The texture used to render each particle. (this can be a spritesheet)
  93336. */
  93337. particleTexture: Nullable<BaseTexture>;
  93338. /**
  93339. * The layer mask we are rendering the particles through.
  93340. */
  93341. layerMask: number;
  93342. /**
  93343. * This can help using your own shader to render the particle system.
  93344. * The according effect will be created
  93345. */
  93346. customShader: any;
  93347. /**
  93348. * By default particle system starts as soon as they are created. This prevents the
  93349. * automatic start to happen and let you decide when to start emitting particles.
  93350. */
  93351. preventAutoStart: boolean;
  93352. private _noiseTexture;
  93353. /**
  93354. * Gets or sets a texture used to add random noise to particle positions
  93355. */
  93356. get noiseTexture(): Nullable<ProceduralTexture>;
  93357. set noiseTexture(value: Nullable<ProceduralTexture>);
  93358. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  93359. noiseStrength: Vector3;
  93360. /**
  93361. * Callback triggered when the particle animation is ending.
  93362. */
  93363. onAnimationEnd: Nullable<() => void>;
  93364. /**
  93365. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  93366. */
  93367. blendMode: number;
  93368. /**
  93369. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  93370. * to override the particles.
  93371. */
  93372. forceDepthWrite: boolean;
  93373. /** 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 */
  93374. preWarmCycles: number;
  93375. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  93376. preWarmStepOffset: number;
  93377. /**
  93378. * 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)
  93379. */
  93380. spriteCellChangeSpeed: number;
  93381. /**
  93382. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  93383. */
  93384. startSpriteCellID: number;
  93385. /**
  93386. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  93387. */
  93388. endSpriteCellID: number;
  93389. /**
  93390. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  93391. */
  93392. spriteCellWidth: number;
  93393. /**
  93394. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  93395. */
  93396. spriteCellHeight: number;
  93397. /**
  93398. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  93399. */
  93400. spriteRandomStartCell: boolean;
  93401. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  93402. translationPivot: Vector2;
  93403. /** @hidden */
  93404. protected _isAnimationSheetEnabled: boolean;
  93405. /**
  93406. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  93407. */
  93408. beginAnimationOnStart: boolean;
  93409. /**
  93410. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  93411. */
  93412. beginAnimationFrom: number;
  93413. /**
  93414. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  93415. */
  93416. beginAnimationTo: number;
  93417. /**
  93418. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  93419. */
  93420. beginAnimationLoop: boolean;
  93421. /**
  93422. * Gets or sets a world offset applied to all particles
  93423. */
  93424. worldOffset: Vector3;
  93425. /**
  93426. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  93427. */
  93428. get isAnimationSheetEnabled(): boolean;
  93429. set isAnimationSheetEnabled(value: boolean);
  93430. /**
  93431. * Get hosting scene
  93432. * @returns the scene
  93433. */
  93434. getScene(): Nullable<Scene>;
  93435. /**
  93436. * You can use gravity if you want to give an orientation to your particles.
  93437. */
  93438. gravity: Vector3;
  93439. protected _colorGradients: Nullable<Array<ColorGradient>>;
  93440. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  93441. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  93442. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  93443. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  93444. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  93445. protected _dragGradients: Nullable<Array<FactorGradient>>;
  93446. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  93447. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  93448. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  93449. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  93450. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  93451. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  93452. /**
  93453. * Defines the delay in milliseconds before starting the system (0 by default)
  93454. */
  93455. startDelay: number;
  93456. /**
  93457. * Gets the current list of drag gradients.
  93458. * You must use addDragGradient and removeDragGradient to udpate this list
  93459. * @returns the list of drag gradients
  93460. */
  93461. getDragGradients(): Nullable<Array<FactorGradient>>;
  93462. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93463. limitVelocityDamping: number;
  93464. /**
  93465. * Gets the current list of limit velocity gradients.
  93466. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93467. * @returns the list of limit velocity gradients
  93468. */
  93469. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93470. /**
  93471. * Gets the current list of color gradients.
  93472. * You must use addColorGradient and removeColorGradient to udpate this list
  93473. * @returns the list of color gradients
  93474. */
  93475. getColorGradients(): Nullable<Array<ColorGradient>>;
  93476. /**
  93477. * Gets the current list of size gradients.
  93478. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93479. * @returns the list of size gradients
  93480. */
  93481. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93482. /**
  93483. * Gets the current list of color remap gradients.
  93484. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93485. * @returns the list of color remap gradients
  93486. */
  93487. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93488. /**
  93489. * Gets the current list of alpha remap gradients.
  93490. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93491. * @returns the list of alpha remap gradients
  93492. */
  93493. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93494. /**
  93495. * Gets the current list of life time gradients.
  93496. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93497. * @returns the list of life time gradients
  93498. */
  93499. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93500. /**
  93501. * Gets the current list of angular speed gradients.
  93502. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93503. * @returns the list of angular speed gradients
  93504. */
  93505. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93506. /**
  93507. * Gets the current list of velocity gradients.
  93508. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93509. * @returns the list of velocity gradients
  93510. */
  93511. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93512. /**
  93513. * Gets the current list of start size gradients.
  93514. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93515. * @returns the list of start size gradients
  93516. */
  93517. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93518. /**
  93519. * Gets the current list of emit rate gradients.
  93520. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93521. * @returns the list of emit rate gradients
  93522. */
  93523. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93524. /**
  93525. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93526. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93527. */
  93528. get direction1(): Vector3;
  93529. set direction1(value: Vector3);
  93530. /**
  93531. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93532. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93533. */
  93534. get direction2(): Vector3;
  93535. set direction2(value: Vector3);
  93536. /**
  93537. * 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.
  93538. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93539. */
  93540. get minEmitBox(): Vector3;
  93541. set minEmitBox(value: Vector3);
  93542. /**
  93543. * 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.
  93544. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93545. */
  93546. get maxEmitBox(): Vector3;
  93547. set maxEmitBox(value: Vector3);
  93548. /**
  93549. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93550. */
  93551. color1: Color4;
  93552. /**
  93553. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93554. */
  93555. color2: Color4;
  93556. /**
  93557. * Color the particle will have at the end of its lifetime
  93558. */
  93559. colorDead: Color4;
  93560. /**
  93561. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  93562. */
  93563. textureMask: Color4;
  93564. /**
  93565. * The particle emitter type defines the emitter used by the particle system.
  93566. * It can be for example box, sphere, or cone...
  93567. */
  93568. particleEmitterType: IParticleEmitterType;
  93569. /** @hidden */
  93570. _isSubEmitter: boolean;
  93571. /**
  93572. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93573. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93574. */
  93575. billboardMode: number;
  93576. protected _isBillboardBased: boolean;
  93577. /**
  93578. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93579. */
  93580. get isBillboardBased(): boolean;
  93581. set isBillboardBased(value: boolean);
  93582. /**
  93583. * The scene the particle system belongs to.
  93584. */
  93585. protected _scene: Nullable<Scene>;
  93586. /**
  93587. * The engine the particle system belongs to.
  93588. */
  93589. protected _engine: ThinEngine;
  93590. /**
  93591. * Local cache of defines for image processing.
  93592. */
  93593. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  93594. /**
  93595. * Default configuration related to image processing available in the standard Material.
  93596. */
  93597. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  93598. /**
  93599. * Gets the image processing configuration used either in this material.
  93600. */
  93601. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  93602. /**
  93603. * Sets the Default image processing configuration used either in the this material.
  93604. *
  93605. * If sets to null, the scene one is in use.
  93606. */
  93607. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  93608. /**
  93609. * Attaches a new image processing configuration to the Standard Material.
  93610. * @param configuration
  93611. */
  93612. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  93613. /** @hidden */
  93614. protected _reset(): void;
  93615. /** @hidden */
  93616. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  93617. /**
  93618. * Instantiates a particle system.
  93619. * 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.
  93620. * @param name The name of the particle system
  93621. */
  93622. constructor(name: string);
  93623. /**
  93624. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93625. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93626. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93627. * @returns the emitter
  93628. */
  93629. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93630. /**
  93631. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93632. * @param radius The radius of the hemisphere to emit from
  93633. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93634. * @returns the emitter
  93635. */
  93636. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  93637. /**
  93638. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93639. * @param radius The radius of the sphere to emit from
  93640. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93641. * @returns the emitter
  93642. */
  93643. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  93644. /**
  93645. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93646. * @param radius The radius of the sphere to emit from
  93647. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93648. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93649. * @returns the emitter
  93650. */
  93651. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  93652. /**
  93653. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93654. * @param radius The radius of the emission cylinder
  93655. * @param height The height of the emission cylinder
  93656. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93657. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93658. * @returns the emitter
  93659. */
  93660. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  93661. /**
  93662. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93663. * @param radius The radius of the cylinder to emit from
  93664. * @param height The height of the emission cylinder
  93665. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93666. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93667. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93668. * @returns the emitter
  93669. */
  93670. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  93671. /**
  93672. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93673. * @param radius The radius of the cone to emit from
  93674. * @param angle The base angle of the cone
  93675. * @returns the emitter
  93676. */
  93677. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  93678. /**
  93679. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93680. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93681. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93682. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93683. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93684. * @returns the emitter
  93685. */
  93686. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93687. }
  93688. }
  93689. declare module BABYLON {
  93690. /**
  93691. * Type of sub emitter
  93692. */
  93693. export enum SubEmitterType {
  93694. /**
  93695. * Attached to the particle over it's lifetime
  93696. */
  93697. ATTACHED = 0,
  93698. /**
  93699. * Created when the particle dies
  93700. */
  93701. END = 1
  93702. }
  93703. /**
  93704. * Sub emitter class used to emit particles from an existing particle
  93705. */
  93706. export class SubEmitter {
  93707. /**
  93708. * the particle system to be used by the sub emitter
  93709. */
  93710. particleSystem: ParticleSystem;
  93711. /**
  93712. * Type of the submitter (Default: END)
  93713. */
  93714. type: SubEmitterType;
  93715. /**
  93716. * 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)
  93717. * Note: This only is supported when using an emitter of type Mesh
  93718. */
  93719. inheritDirection: boolean;
  93720. /**
  93721. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  93722. */
  93723. inheritedVelocityAmount: number;
  93724. /**
  93725. * Creates a sub emitter
  93726. * @param particleSystem the particle system to be used by the sub emitter
  93727. */
  93728. constructor(
  93729. /**
  93730. * the particle system to be used by the sub emitter
  93731. */
  93732. particleSystem: ParticleSystem);
  93733. /**
  93734. * Clones the sub emitter
  93735. * @returns the cloned sub emitter
  93736. */
  93737. clone(): SubEmitter;
  93738. /**
  93739. * Serialize current object to a JSON object
  93740. * @returns the serialized object
  93741. */
  93742. serialize(): any;
  93743. /** @hidden */
  93744. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  93745. /**
  93746. * Creates a new SubEmitter from a serialized JSON version
  93747. * @param serializationObject defines the JSON object to read from
  93748. * @param sceneOrEngine defines the hosting scene or the hosting engine
  93749. * @param rootUrl defines the rootUrl for data loading
  93750. * @returns a new SubEmitter
  93751. */
  93752. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  93753. /** Release associated resources */
  93754. dispose(): void;
  93755. }
  93756. }
  93757. declare module BABYLON {
  93758. /** @hidden */
  93759. export var imageProcessingDeclaration: {
  93760. name: string;
  93761. shader: string;
  93762. };
  93763. }
  93764. declare module BABYLON {
  93765. /** @hidden */
  93766. export var imageProcessingFunctions: {
  93767. name: string;
  93768. shader: string;
  93769. };
  93770. }
  93771. declare module BABYLON {
  93772. /** @hidden */
  93773. export var particlesPixelShader: {
  93774. name: string;
  93775. shader: string;
  93776. };
  93777. }
  93778. declare module BABYLON {
  93779. /** @hidden */
  93780. export var particlesVertexShader: {
  93781. name: string;
  93782. shader: string;
  93783. };
  93784. }
  93785. declare module BABYLON {
  93786. /**
  93787. * Interface used to define entities containing multiple clip planes
  93788. */
  93789. export interface IClipPlanesHolder {
  93790. /**
  93791. * Gets or sets the active clipplane 1
  93792. */
  93793. clipPlane: Nullable<Plane>;
  93794. /**
  93795. * Gets or sets the active clipplane 2
  93796. */
  93797. clipPlane2: Nullable<Plane>;
  93798. /**
  93799. * Gets or sets the active clipplane 3
  93800. */
  93801. clipPlane3: Nullable<Plane>;
  93802. /**
  93803. * Gets or sets the active clipplane 4
  93804. */
  93805. clipPlane4: Nullable<Plane>;
  93806. /**
  93807. * Gets or sets the active clipplane 5
  93808. */
  93809. clipPlane5: Nullable<Plane>;
  93810. /**
  93811. * Gets or sets the active clipplane 6
  93812. */
  93813. clipPlane6: Nullable<Plane>;
  93814. }
  93815. }
  93816. declare module BABYLON {
  93817. /**
  93818. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93819. *
  93820. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93821. *
  93822. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93823. */
  93824. export class ThinMaterialHelper {
  93825. /**
  93826. * Binds the clip plane information from the holder to the effect.
  93827. * @param effect The effect we are binding the data to
  93828. * @param holder The entity containing the clip plane information
  93829. */
  93830. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93831. }
  93832. }
  93833. declare module BABYLON {
  93834. interface ThinEngine {
  93835. /**
  93836. * Sets alpha constants used by some alpha blending modes
  93837. * @param r defines the red component
  93838. * @param g defines the green component
  93839. * @param b defines the blue component
  93840. * @param a defines the alpha component
  93841. */
  93842. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93843. /**
  93844. * Sets the current alpha mode
  93845. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93846. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93847. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93848. */
  93849. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93850. /**
  93851. * Gets the current alpha mode
  93852. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93853. * @returns the current alpha mode
  93854. */
  93855. getAlphaMode(): number;
  93856. /**
  93857. * Sets the current alpha equation
  93858. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93859. */
  93860. setAlphaEquation(equation: number): void;
  93861. /**
  93862. * Gets the current alpha equation.
  93863. * @returns the current alpha equation
  93864. */
  93865. getAlphaEquation(): number;
  93866. }
  93867. }
  93868. declare module BABYLON {
  93869. /**
  93870. * This represents a particle system in Babylon.
  93871. * 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.
  93872. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93873. * @example https://doc.babylonjs.com/babylon101/particles
  93874. */
  93875. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93876. /**
  93877. * Billboard mode will only apply to Y axis
  93878. */
  93879. static readonly BILLBOARDMODE_Y: number;
  93880. /**
  93881. * Billboard mode will apply to all axes
  93882. */
  93883. static readonly BILLBOARDMODE_ALL: number;
  93884. /**
  93885. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93886. */
  93887. static readonly BILLBOARDMODE_STRETCHED: number;
  93888. /**
  93889. * This function can be defined to provide custom update for active particles.
  93890. * This function will be called instead of regular update (age, position, color, etc.).
  93891. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93892. */
  93893. updateFunction: (particles: Particle[]) => void;
  93894. private _emitterWorldMatrix;
  93895. /**
  93896. * This function can be defined to specify initial direction for every new particle.
  93897. * It by default use the emitterType defined function
  93898. */
  93899. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93900. /**
  93901. * This function can be defined to specify initial position for every new particle.
  93902. * It by default use the emitterType defined function
  93903. */
  93904. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93905. /**
  93906. * @hidden
  93907. */
  93908. _inheritedVelocityOffset: Vector3;
  93909. /**
  93910. * An event triggered when the system is disposed
  93911. */
  93912. onDisposeObservable: Observable<IParticleSystem>;
  93913. /**
  93914. * An event triggered when the system is stopped
  93915. */
  93916. onStoppedObservable: Observable<IParticleSystem>;
  93917. private _onDisposeObserver;
  93918. /**
  93919. * Sets a callback that will be triggered when the system is disposed
  93920. */
  93921. set onDispose(callback: () => void);
  93922. private _particles;
  93923. private _epsilon;
  93924. private _capacity;
  93925. private _stockParticles;
  93926. private _newPartsExcess;
  93927. private _vertexData;
  93928. private _vertexBuffer;
  93929. private _vertexBuffers;
  93930. private _spriteBuffer;
  93931. private _indexBuffer;
  93932. private _effect;
  93933. private _customEffect;
  93934. private _cachedDefines;
  93935. private _scaledColorStep;
  93936. private _colorDiff;
  93937. private _scaledDirection;
  93938. private _scaledGravity;
  93939. private _currentRenderId;
  93940. private _alive;
  93941. private _useInstancing;
  93942. private _vertexArrayObject;
  93943. private _started;
  93944. private _stopped;
  93945. private _actualFrame;
  93946. private _scaledUpdateSpeed;
  93947. private _vertexBufferSize;
  93948. /** @hidden */
  93949. _currentEmitRateGradient: Nullable<FactorGradient>;
  93950. /** @hidden */
  93951. _currentEmitRate1: number;
  93952. /** @hidden */
  93953. _currentEmitRate2: number;
  93954. /** @hidden */
  93955. _currentStartSizeGradient: Nullable<FactorGradient>;
  93956. /** @hidden */
  93957. _currentStartSize1: number;
  93958. /** @hidden */
  93959. _currentStartSize2: number;
  93960. private readonly _rawTextureWidth;
  93961. private _rampGradientsTexture;
  93962. private _useRampGradients;
  93963. /** Gets or sets a matrix to use to compute projection */
  93964. defaultProjectionMatrix: Matrix;
  93965. /** Gets or sets a matrix to use to compute view */
  93966. defaultViewMatrix: Matrix;
  93967. /** Gets or sets a boolean indicating that ramp gradients must be used
  93968. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93969. */
  93970. get useRampGradients(): boolean;
  93971. set useRampGradients(value: boolean);
  93972. /**
  93973. * 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.
  93974. * 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: [])
  93975. */
  93976. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93977. private _subEmitters;
  93978. /**
  93979. * @hidden
  93980. * If the particle systems emitter should be disposed when the particle system is disposed
  93981. */
  93982. _disposeEmitterOnDispose: boolean;
  93983. /**
  93984. * The current active Sub-systems, this property is used by the root particle system only.
  93985. */
  93986. activeSubSystems: Array<ParticleSystem>;
  93987. /**
  93988. * Specifies if the particles are updated in emitter local space or world space
  93989. */
  93990. isLocal: boolean;
  93991. private _rootParticleSystem;
  93992. /**
  93993. * Gets the current list of active particles
  93994. */
  93995. get particles(): Particle[];
  93996. /**
  93997. * Gets the number of particles active at the same time.
  93998. * @returns The number of active particles.
  93999. */
  94000. getActiveCount(): number;
  94001. /**
  94002. * Returns the string "ParticleSystem"
  94003. * @returns a string containing the class name
  94004. */
  94005. getClassName(): string;
  94006. /**
  94007. * Gets a boolean indicating that the system is stopping
  94008. * @returns true if the system is currently stopping
  94009. */
  94010. isStopping(): boolean;
  94011. /**
  94012. * Gets the custom effect used to render the particles
  94013. * @param blendMode Blend mode for which the effect should be retrieved
  94014. * @returns The effect
  94015. */
  94016. getCustomEffect(blendMode?: number): Nullable<Effect>;
  94017. /**
  94018. * Sets the custom effect used to render the particles
  94019. * @param effect The effect to set
  94020. * @param blendMode Blend mode for which the effect should be set
  94021. */
  94022. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  94023. /** @hidden */
  94024. private _onBeforeDrawParticlesObservable;
  94025. /**
  94026. * Observable that will be called just before the particles are drawn
  94027. */
  94028. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  94029. /**
  94030. * Gets the name of the particle vertex shader
  94031. */
  94032. get vertexShaderName(): string;
  94033. /**
  94034. * Instantiates a particle system.
  94035. * 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.
  94036. * @param name The name of the particle system
  94037. * @param capacity The max number of particles alive at the same time
  94038. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  94039. * @param customEffect a custom effect used to change the way particles are rendered by default
  94040. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  94041. * @param epsilon Offset used to render the particles
  94042. */
  94043. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  94044. private _addFactorGradient;
  94045. private _removeFactorGradient;
  94046. /**
  94047. * Adds a new life time gradient
  94048. * @param gradient defines the gradient to use (between 0 and 1)
  94049. * @param factor defines the life time factor to affect to the specified gradient
  94050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94051. * @returns the current particle system
  94052. */
  94053. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94054. /**
  94055. * Remove a specific life time gradient
  94056. * @param gradient defines the gradient to remove
  94057. * @returns the current particle system
  94058. */
  94059. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94060. /**
  94061. * Adds a new size gradient
  94062. * @param gradient defines the gradient to use (between 0 and 1)
  94063. * @param factor defines the size factor to affect to the specified gradient
  94064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94065. * @returns the current particle system
  94066. */
  94067. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94068. /**
  94069. * Remove a specific size gradient
  94070. * @param gradient defines the gradient to remove
  94071. * @returns the current particle system
  94072. */
  94073. removeSizeGradient(gradient: number): IParticleSystem;
  94074. /**
  94075. * Adds a new color remap gradient
  94076. * @param gradient defines the gradient to use (between 0 and 1)
  94077. * @param min defines the color remap minimal range
  94078. * @param max defines the color remap maximal range
  94079. * @returns the current particle system
  94080. */
  94081. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94082. /**
  94083. * Remove a specific color remap gradient
  94084. * @param gradient defines the gradient to remove
  94085. * @returns the current particle system
  94086. */
  94087. removeColorRemapGradient(gradient: number): IParticleSystem;
  94088. /**
  94089. * Adds a new alpha remap gradient
  94090. * @param gradient defines the gradient to use (between 0 and 1)
  94091. * @param min defines the alpha remap minimal range
  94092. * @param max defines the alpha remap maximal range
  94093. * @returns the current particle system
  94094. */
  94095. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94096. /**
  94097. * Remove a specific alpha remap gradient
  94098. * @param gradient defines the gradient to remove
  94099. * @returns the current particle system
  94100. */
  94101. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  94102. /**
  94103. * Adds a new angular speed gradient
  94104. * @param gradient defines the gradient to use (between 0 and 1)
  94105. * @param factor defines the angular speed to affect to the specified gradient
  94106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94107. * @returns the current particle system
  94108. */
  94109. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94110. /**
  94111. * Remove a specific angular speed gradient
  94112. * @param gradient defines the gradient to remove
  94113. * @returns the current particle system
  94114. */
  94115. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94116. /**
  94117. * Adds a new velocity gradient
  94118. * @param gradient defines the gradient to use (between 0 and 1)
  94119. * @param factor defines the velocity to affect to the specified gradient
  94120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94121. * @returns the current particle system
  94122. */
  94123. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94124. /**
  94125. * Remove a specific velocity gradient
  94126. * @param gradient defines the gradient to remove
  94127. * @returns the current particle system
  94128. */
  94129. removeVelocityGradient(gradient: number): IParticleSystem;
  94130. /**
  94131. * Adds a new limit velocity gradient
  94132. * @param gradient defines the gradient to use (between 0 and 1)
  94133. * @param factor defines the limit velocity value to affect to the specified gradient
  94134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94135. * @returns the current particle system
  94136. */
  94137. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94138. /**
  94139. * Remove a specific limit velocity gradient
  94140. * @param gradient defines the gradient to remove
  94141. * @returns the current particle system
  94142. */
  94143. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94144. /**
  94145. * Adds a new drag gradient
  94146. * @param gradient defines the gradient to use (between 0 and 1)
  94147. * @param factor defines the drag value to affect to the specified gradient
  94148. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94149. * @returns the current particle system
  94150. */
  94151. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94152. /**
  94153. * Remove a specific drag gradient
  94154. * @param gradient defines the gradient to remove
  94155. * @returns the current particle system
  94156. */
  94157. removeDragGradient(gradient: number): IParticleSystem;
  94158. /**
  94159. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94160. * @param gradient defines the gradient to use (between 0 and 1)
  94161. * @param factor defines the emit rate value to affect to the specified gradient
  94162. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94163. * @returns the current particle system
  94164. */
  94165. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94166. /**
  94167. * Remove a specific emit rate gradient
  94168. * @param gradient defines the gradient to remove
  94169. * @returns the current particle system
  94170. */
  94171. removeEmitRateGradient(gradient: number): IParticleSystem;
  94172. /**
  94173. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94174. * @param gradient defines the gradient to use (between 0 and 1)
  94175. * @param factor defines the start size value to affect to the specified gradient
  94176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94177. * @returns the current particle system
  94178. */
  94179. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94180. /**
  94181. * Remove a specific start size gradient
  94182. * @param gradient defines the gradient to remove
  94183. * @returns the current particle system
  94184. */
  94185. removeStartSizeGradient(gradient: number): IParticleSystem;
  94186. private _createRampGradientTexture;
  94187. /**
  94188. * Gets the current list of ramp gradients.
  94189. * You must use addRampGradient and removeRampGradient to udpate this list
  94190. * @returns the list of ramp gradients
  94191. */
  94192. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94193. /** Force the system to rebuild all gradients that need to be resync */
  94194. forceRefreshGradients(): void;
  94195. private _syncRampGradientTexture;
  94196. /**
  94197. * Adds a new ramp gradient used to remap particle colors
  94198. * @param gradient defines the gradient to use (between 0 and 1)
  94199. * @param color defines the color to affect to the specified gradient
  94200. * @returns the current particle system
  94201. */
  94202. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  94203. /**
  94204. * Remove a specific ramp gradient
  94205. * @param gradient defines the gradient to remove
  94206. * @returns the current particle system
  94207. */
  94208. removeRampGradient(gradient: number): ParticleSystem;
  94209. /**
  94210. * Adds a new color gradient
  94211. * @param gradient defines the gradient to use (between 0 and 1)
  94212. * @param color1 defines the color to affect to the specified gradient
  94213. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94214. * @returns this particle system
  94215. */
  94216. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94217. /**
  94218. * Remove a specific color gradient
  94219. * @param gradient defines the gradient to remove
  94220. * @returns this particle system
  94221. */
  94222. removeColorGradient(gradient: number): IParticleSystem;
  94223. private _fetchR;
  94224. protected _reset(): void;
  94225. private _resetEffect;
  94226. private _createVertexBuffers;
  94227. private _createIndexBuffer;
  94228. /**
  94229. * Gets the maximum number of particles active at the same time.
  94230. * @returns The max number of active particles.
  94231. */
  94232. getCapacity(): number;
  94233. /**
  94234. * Gets whether there are still active particles in the system.
  94235. * @returns True if it is alive, otherwise false.
  94236. */
  94237. isAlive(): boolean;
  94238. /**
  94239. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94240. * @returns True if it has been started, otherwise false.
  94241. */
  94242. isStarted(): boolean;
  94243. private _prepareSubEmitterInternalArray;
  94244. /**
  94245. * Starts the particle system and begins to emit
  94246. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  94247. */
  94248. start(delay?: number): void;
  94249. /**
  94250. * Stops the particle system.
  94251. * @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.
  94252. */
  94253. stop(stopSubEmitters?: boolean): void;
  94254. /**
  94255. * Remove all active particles
  94256. */
  94257. reset(): void;
  94258. /**
  94259. * @hidden (for internal use only)
  94260. */
  94261. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  94262. /**
  94263. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  94264. * Its lifetime will start back at 0.
  94265. */
  94266. recycleParticle: (particle: Particle) => void;
  94267. private _stopSubEmitters;
  94268. private _createParticle;
  94269. private _removeFromRoot;
  94270. private _emitFromParticle;
  94271. private _update;
  94272. /** @hidden */
  94273. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  94274. /** @hidden */
  94275. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  94276. /**
  94277. * Fill the defines array according to the current settings of the particle system
  94278. * @param defines Array to be updated
  94279. * @param blendMode blend mode to take into account when updating the array
  94280. */
  94281. fillDefines(defines: Array<string>, blendMode: number): void;
  94282. /**
  94283. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94284. * @param uniforms Uniforms array to fill
  94285. * @param attributes Attributes array to fill
  94286. * @param samplers Samplers array to fill
  94287. */
  94288. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94289. /** @hidden */
  94290. private _getEffect;
  94291. /**
  94292. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  94293. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  94294. */
  94295. animate(preWarmOnly?: boolean): void;
  94296. private _appendParticleVertices;
  94297. /**
  94298. * Rebuilds the particle system.
  94299. */
  94300. rebuild(): void;
  94301. /**
  94302. * Is this system ready to be used/rendered
  94303. * @return true if the system is ready
  94304. */
  94305. isReady(): boolean;
  94306. private _render;
  94307. /**
  94308. * Renders the particle system in its current state.
  94309. * @returns the current number of particles
  94310. */
  94311. render(): number;
  94312. /**
  94313. * Disposes the particle system and free the associated resources
  94314. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94315. */
  94316. dispose(disposeTexture?: boolean): void;
  94317. /**
  94318. * Clones the particle system.
  94319. * @param name The name of the cloned object
  94320. * @param newEmitter The new emitter to use
  94321. * @returns the cloned particle system
  94322. */
  94323. clone(name: string, newEmitter: any): ParticleSystem;
  94324. /**
  94325. * Serializes the particle system to a JSON object
  94326. * @param serializeTexture defines if the texture must be serialized as well
  94327. * @returns the JSON object
  94328. */
  94329. serialize(serializeTexture?: boolean): any;
  94330. /** @hidden */
  94331. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  94332. /** @hidden */
  94333. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  94334. /**
  94335. * Parses a JSON object to create a particle system.
  94336. * @param parsedParticleSystem The JSON object to parse
  94337. * @param sceneOrEngine The scene or the engine to create the particle system in
  94338. * @param rootUrl The root url to use to load external dependencies like texture
  94339. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  94340. * @returns the Parsed particle system
  94341. */
  94342. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  94343. }
  94344. }
  94345. declare module BABYLON {
  94346. /**
  94347. * A particle represents one of the element emitted by a particle system.
  94348. * This is mainly define by its coordinates, direction, velocity and age.
  94349. */
  94350. export class Particle {
  94351. /**
  94352. * The particle system the particle belongs to.
  94353. */
  94354. particleSystem: ParticleSystem;
  94355. private static _Count;
  94356. /**
  94357. * Unique ID of the particle
  94358. */
  94359. id: number;
  94360. /**
  94361. * The world position of the particle in the scene.
  94362. */
  94363. position: Vector3;
  94364. /**
  94365. * The world direction of the particle in the scene.
  94366. */
  94367. direction: Vector3;
  94368. /**
  94369. * The color of the particle.
  94370. */
  94371. color: Color4;
  94372. /**
  94373. * The color change of the particle per step.
  94374. */
  94375. colorStep: Color4;
  94376. /**
  94377. * Defines how long will the life of the particle be.
  94378. */
  94379. lifeTime: number;
  94380. /**
  94381. * The current age of the particle.
  94382. */
  94383. age: number;
  94384. /**
  94385. * The current size of the particle.
  94386. */
  94387. size: number;
  94388. /**
  94389. * The current scale of the particle.
  94390. */
  94391. scale: Vector2;
  94392. /**
  94393. * The current angle of the particle.
  94394. */
  94395. angle: number;
  94396. /**
  94397. * Defines how fast is the angle changing.
  94398. */
  94399. angularSpeed: number;
  94400. /**
  94401. * Defines the cell index used by the particle to be rendered from a sprite.
  94402. */
  94403. cellIndex: number;
  94404. /**
  94405. * The information required to support color remapping
  94406. */
  94407. remapData: Vector4;
  94408. /** @hidden */
  94409. _randomCellOffset?: number;
  94410. /** @hidden */
  94411. _initialDirection: Nullable<Vector3>;
  94412. /** @hidden */
  94413. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  94414. /** @hidden */
  94415. _initialStartSpriteCellID: number;
  94416. /** @hidden */
  94417. _initialEndSpriteCellID: number;
  94418. /** @hidden */
  94419. _currentColorGradient: Nullable<ColorGradient>;
  94420. /** @hidden */
  94421. _currentColor1: Color4;
  94422. /** @hidden */
  94423. _currentColor2: Color4;
  94424. /** @hidden */
  94425. _currentSizeGradient: Nullable<FactorGradient>;
  94426. /** @hidden */
  94427. _currentSize1: number;
  94428. /** @hidden */
  94429. _currentSize2: number;
  94430. /** @hidden */
  94431. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  94432. /** @hidden */
  94433. _currentAngularSpeed1: number;
  94434. /** @hidden */
  94435. _currentAngularSpeed2: number;
  94436. /** @hidden */
  94437. _currentVelocityGradient: Nullable<FactorGradient>;
  94438. /** @hidden */
  94439. _currentVelocity1: number;
  94440. /** @hidden */
  94441. _currentVelocity2: number;
  94442. /** @hidden */
  94443. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  94444. /** @hidden */
  94445. _currentLimitVelocity1: number;
  94446. /** @hidden */
  94447. _currentLimitVelocity2: number;
  94448. /** @hidden */
  94449. _currentDragGradient: Nullable<FactorGradient>;
  94450. /** @hidden */
  94451. _currentDrag1: number;
  94452. /** @hidden */
  94453. _currentDrag2: number;
  94454. /** @hidden */
  94455. _randomNoiseCoordinates1: Vector3;
  94456. /** @hidden */
  94457. _randomNoiseCoordinates2: Vector3;
  94458. /** @hidden */
  94459. _localPosition?: Vector3;
  94460. /**
  94461. * Creates a new instance Particle
  94462. * @param particleSystem the particle system the particle belongs to
  94463. */
  94464. constructor(
  94465. /**
  94466. * The particle system the particle belongs to.
  94467. */
  94468. particleSystem: ParticleSystem);
  94469. private updateCellInfoFromSystem;
  94470. /**
  94471. * Defines how the sprite cell index is updated for the particle
  94472. */
  94473. updateCellIndex(): void;
  94474. /** @hidden */
  94475. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  94476. /** @hidden */
  94477. _inheritParticleInfoToSubEmitters(): void;
  94478. /** @hidden */
  94479. _reset(): void;
  94480. /**
  94481. * Copy the properties of particle to another one.
  94482. * @param other the particle to copy the information to.
  94483. */
  94484. copyTo(other: Particle): void;
  94485. }
  94486. }
  94487. declare module BABYLON {
  94488. /**
  94489. * Particle emitter represents a volume emitting particles.
  94490. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  94491. */
  94492. export interface IParticleEmitterType {
  94493. /**
  94494. * Called by the particle System when the direction is computed for the created particle.
  94495. * @param worldMatrix is the world matrix of the particle system
  94496. * @param directionToUpdate is the direction vector to update with the result
  94497. * @param particle is the particle we are computed the direction for
  94498. * @param isLocal defines if the direction should be set in local space
  94499. */
  94500. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94501. /**
  94502. * Called by the particle System when the position is computed for the created particle.
  94503. * @param worldMatrix is the world matrix of the particle system
  94504. * @param positionToUpdate is the position vector to update with the result
  94505. * @param particle is the particle we are computed the position for
  94506. * @param isLocal defines if the position should be set in local space
  94507. */
  94508. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94509. /**
  94510. * Clones the current emitter and returns a copy of it
  94511. * @returns the new emitter
  94512. */
  94513. clone(): IParticleEmitterType;
  94514. /**
  94515. * Called by the GPUParticleSystem to setup the update shader
  94516. * @param effect defines the update shader
  94517. */
  94518. applyToShader(effect: Effect): void;
  94519. /**
  94520. * Returns a string to use to update the GPU particles update shader
  94521. * @returns the effect defines string
  94522. */
  94523. getEffectDefines(): string;
  94524. /**
  94525. * Returns a string representing the class name
  94526. * @returns a string containing the class name
  94527. */
  94528. getClassName(): string;
  94529. /**
  94530. * Serializes the particle system to a JSON object.
  94531. * @returns the JSON object
  94532. */
  94533. serialize(): any;
  94534. /**
  94535. * Parse properties from a JSON object
  94536. * @param serializationObject defines the JSON object
  94537. * @param scene defines the hosting scene
  94538. */
  94539. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94540. }
  94541. }
  94542. declare module BABYLON {
  94543. /**
  94544. * Particle emitter emitting particles from the inside of a box.
  94545. * It emits the particles randomly between 2 given directions.
  94546. */
  94547. export class BoxParticleEmitter implements IParticleEmitterType {
  94548. /**
  94549. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94550. */
  94551. direction1: Vector3;
  94552. /**
  94553. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94554. */
  94555. direction2: Vector3;
  94556. /**
  94557. * 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.
  94558. */
  94559. minEmitBox: Vector3;
  94560. /**
  94561. * 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.
  94562. */
  94563. maxEmitBox: Vector3;
  94564. /**
  94565. * Creates a new instance BoxParticleEmitter
  94566. */
  94567. constructor();
  94568. /**
  94569. * Called by the particle System when the direction is computed for the created particle.
  94570. * @param worldMatrix is the world matrix of the particle system
  94571. * @param directionToUpdate is the direction vector to update with the result
  94572. * @param particle is the particle we are computed the direction for
  94573. * @param isLocal defines if the direction should be set in local space
  94574. */
  94575. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94576. /**
  94577. * Called by the particle System when the position is computed for the created particle.
  94578. * @param worldMatrix is the world matrix of the particle system
  94579. * @param positionToUpdate is the position vector to update with the result
  94580. * @param particle is the particle we are computed the position for
  94581. * @param isLocal defines if the position should be set in local space
  94582. */
  94583. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94584. /**
  94585. * Clones the current emitter and returns a copy of it
  94586. * @returns the new emitter
  94587. */
  94588. clone(): BoxParticleEmitter;
  94589. /**
  94590. * Called by the GPUParticleSystem to setup the update shader
  94591. * @param effect defines the update shader
  94592. */
  94593. applyToShader(effect: Effect): void;
  94594. /**
  94595. * Returns a string to use to update the GPU particles update shader
  94596. * @returns a string containng the defines string
  94597. */
  94598. getEffectDefines(): string;
  94599. /**
  94600. * Returns the string "BoxParticleEmitter"
  94601. * @returns a string containing the class name
  94602. */
  94603. getClassName(): string;
  94604. /**
  94605. * Serializes the particle system to a JSON object.
  94606. * @returns the JSON object
  94607. */
  94608. serialize(): any;
  94609. /**
  94610. * Parse properties from a JSON object
  94611. * @param serializationObject defines the JSON object
  94612. */
  94613. parse(serializationObject: any): void;
  94614. }
  94615. }
  94616. declare module BABYLON {
  94617. /**
  94618. * Particle emitter emitting particles from the inside of a cone.
  94619. * It emits the particles alongside the cone volume from the base to the particle.
  94620. * The emission direction might be randomized.
  94621. */
  94622. export class ConeParticleEmitter implements IParticleEmitterType {
  94623. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94624. directionRandomizer: number;
  94625. private _radius;
  94626. private _angle;
  94627. private _height;
  94628. /**
  94629. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  94630. */
  94631. radiusRange: number;
  94632. /**
  94633. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  94634. */
  94635. heightRange: number;
  94636. /**
  94637. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  94638. */
  94639. emitFromSpawnPointOnly: boolean;
  94640. /**
  94641. * Gets or sets the radius of the emission cone
  94642. */
  94643. get radius(): number;
  94644. set radius(value: number);
  94645. /**
  94646. * Gets or sets the angle of the emission cone
  94647. */
  94648. get angle(): number;
  94649. set angle(value: number);
  94650. private _buildHeight;
  94651. /**
  94652. * Creates a new instance ConeParticleEmitter
  94653. * @param radius the radius of the emission cone (1 by default)
  94654. * @param angle the cone base angle (PI by default)
  94655. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  94656. */
  94657. constructor(radius?: number, angle?: number,
  94658. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94659. directionRandomizer?: number);
  94660. /**
  94661. * Called by the particle System when the direction is computed for the created particle.
  94662. * @param worldMatrix is the world matrix of the particle system
  94663. * @param directionToUpdate is the direction vector to update with the result
  94664. * @param particle is the particle we are computed the direction for
  94665. * @param isLocal defines if the direction should be set in local space
  94666. */
  94667. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94668. /**
  94669. * Called by the particle System when the position is computed for the created particle.
  94670. * @param worldMatrix is the world matrix of the particle system
  94671. * @param positionToUpdate is the position vector to update with the result
  94672. * @param particle is the particle we are computed the position for
  94673. * @param isLocal defines if the position should be set in local space
  94674. */
  94675. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94676. /**
  94677. * Clones the current emitter and returns a copy of it
  94678. * @returns the new emitter
  94679. */
  94680. clone(): ConeParticleEmitter;
  94681. /**
  94682. * Called by the GPUParticleSystem to setup the update shader
  94683. * @param effect defines the update shader
  94684. */
  94685. applyToShader(effect: Effect): void;
  94686. /**
  94687. * Returns a string to use to update the GPU particles update shader
  94688. * @returns a string containng the defines string
  94689. */
  94690. getEffectDefines(): string;
  94691. /**
  94692. * Returns the string "ConeParticleEmitter"
  94693. * @returns a string containing the class name
  94694. */
  94695. getClassName(): string;
  94696. /**
  94697. * Serializes the particle system to a JSON object.
  94698. * @returns the JSON object
  94699. */
  94700. serialize(): any;
  94701. /**
  94702. * Parse properties from a JSON object
  94703. * @param serializationObject defines the JSON object
  94704. */
  94705. parse(serializationObject: any): void;
  94706. }
  94707. }
  94708. declare module BABYLON {
  94709. /**
  94710. * Particle emitter emitting particles from the inside of a cylinder.
  94711. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  94712. */
  94713. export class CylinderParticleEmitter implements IParticleEmitterType {
  94714. /**
  94715. * The radius of the emission cylinder.
  94716. */
  94717. radius: number;
  94718. /**
  94719. * The height of the emission cylinder.
  94720. */
  94721. height: number;
  94722. /**
  94723. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94724. */
  94725. radiusRange: number;
  94726. /**
  94727. * How much to randomize the particle direction [0-1].
  94728. */
  94729. directionRandomizer: number;
  94730. /**
  94731. * Creates a new instance CylinderParticleEmitter
  94732. * @param radius the radius of the emission cylinder (1 by default)
  94733. * @param height the height of the emission cylinder (1 by default)
  94734. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94735. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94736. */
  94737. constructor(
  94738. /**
  94739. * The radius of the emission cylinder.
  94740. */
  94741. radius?: number,
  94742. /**
  94743. * The height of the emission cylinder.
  94744. */
  94745. height?: number,
  94746. /**
  94747. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94748. */
  94749. radiusRange?: number,
  94750. /**
  94751. * How much to randomize the particle direction [0-1].
  94752. */
  94753. directionRandomizer?: number);
  94754. /**
  94755. * Called by the particle System when the direction is computed for the created particle.
  94756. * @param worldMatrix is the world matrix of the particle system
  94757. * @param directionToUpdate is the direction vector to update with the result
  94758. * @param particle is the particle we are computed the direction for
  94759. * @param isLocal defines if the direction should be set in local space
  94760. */
  94761. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94762. /**
  94763. * Called by the particle System when the position is computed for the created particle.
  94764. * @param worldMatrix is the world matrix of the particle system
  94765. * @param positionToUpdate is the position vector to update with the result
  94766. * @param particle is the particle we are computed the position for
  94767. * @param isLocal defines if the position should be set in local space
  94768. */
  94769. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94770. /**
  94771. * Clones the current emitter and returns a copy of it
  94772. * @returns the new emitter
  94773. */
  94774. clone(): CylinderParticleEmitter;
  94775. /**
  94776. * Called by the GPUParticleSystem to setup the update shader
  94777. * @param effect defines the update shader
  94778. */
  94779. applyToShader(effect: Effect): void;
  94780. /**
  94781. * Returns a string to use to update the GPU particles update shader
  94782. * @returns a string containng the defines string
  94783. */
  94784. getEffectDefines(): string;
  94785. /**
  94786. * Returns the string "CylinderParticleEmitter"
  94787. * @returns a string containing the class name
  94788. */
  94789. getClassName(): string;
  94790. /**
  94791. * Serializes the particle system to a JSON object.
  94792. * @returns the JSON object
  94793. */
  94794. serialize(): any;
  94795. /**
  94796. * Parse properties from a JSON object
  94797. * @param serializationObject defines the JSON object
  94798. */
  94799. parse(serializationObject: any): void;
  94800. }
  94801. /**
  94802. * Particle emitter emitting particles from the inside of a cylinder.
  94803. * It emits the particles randomly between two vectors.
  94804. */
  94805. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94806. /**
  94807. * The min limit of the emission direction.
  94808. */
  94809. direction1: Vector3;
  94810. /**
  94811. * The max limit of the emission direction.
  94812. */
  94813. direction2: Vector3;
  94814. /**
  94815. * Creates a new instance CylinderDirectedParticleEmitter
  94816. * @param radius the radius of the emission cylinder (1 by default)
  94817. * @param height the height of the emission cylinder (1 by default)
  94818. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94819. * @param direction1 the min limit of the emission direction (up vector by default)
  94820. * @param direction2 the max limit of the emission direction (up vector by default)
  94821. */
  94822. constructor(radius?: number, height?: number, radiusRange?: number,
  94823. /**
  94824. * The min limit of the emission direction.
  94825. */
  94826. direction1?: Vector3,
  94827. /**
  94828. * The max limit of the emission direction.
  94829. */
  94830. direction2?: Vector3);
  94831. /**
  94832. * Called by the particle System when the direction is computed for the created particle.
  94833. * @param worldMatrix is the world matrix of the particle system
  94834. * @param directionToUpdate is the direction vector to update with the result
  94835. * @param particle is the particle we are computed the direction for
  94836. */
  94837. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94838. /**
  94839. * Clones the current emitter and returns a copy of it
  94840. * @returns the new emitter
  94841. */
  94842. clone(): CylinderDirectedParticleEmitter;
  94843. /**
  94844. * Called by the GPUParticleSystem to setup the update shader
  94845. * @param effect defines the update shader
  94846. */
  94847. applyToShader(effect: Effect): void;
  94848. /**
  94849. * Returns a string to use to update the GPU particles update shader
  94850. * @returns a string containng the defines string
  94851. */
  94852. getEffectDefines(): string;
  94853. /**
  94854. * Returns the string "CylinderDirectedParticleEmitter"
  94855. * @returns a string containing the class name
  94856. */
  94857. getClassName(): string;
  94858. /**
  94859. * Serializes the particle system to a JSON object.
  94860. * @returns the JSON object
  94861. */
  94862. serialize(): any;
  94863. /**
  94864. * Parse properties from a JSON object
  94865. * @param serializationObject defines the JSON object
  94866. */
  94867. parse(serializationObject: any): void;
  94868. }
  94869. }
  94870. declare module BABYLON {
  94871. /**
  94872. * Particle emitter emitting particles from the inside of a hemisphere.
  94873. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94874. */
  94875. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94876. /**
  94877. * The radius of the emission hemisphere.
  94878. */
  94879. radius: number;
  94880. /**
  94881. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94882. */
  94883. radiusRange: number;
  94884. /**
  94885. * How much to randomize the particle direction [0-1].
  94886. */
  94887. directionRandomizer: number;
  94888. /**
  94889. * Creates a new instance HemisphericParticleEmitter
  94890. * @param radius the radius of the emission hemisphere (1 by default)
  94891. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94892. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94893. */
  94894. constructor(
  94895. /**
  94896. * The radius of the emission hemisphere.
  94897. */
  94898. radius?: number,
  94899. /**
  94900. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94901. */
  94902. radiusRange?: number,
  94903. /**
  94904. * How much to randomize the particle direction [0-1].
  94905. */
  94906. directionRandomizer?: number);
  94907. /**
  94908. * Called by the particle System when the direction is computed for the created particle.
  94909. * @param worldMatrix is the world matrix of the particle system
  94910. * @param directionToUpdate is the direction vector to update with the result
  94911. * @param particle is the particle we are computed the direction for
  94912. * @param isLocal defines if the direction should be set in local space
  94913. */
  94914. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94915. /**
  94916. * Called by the particle System when the position is computed for the created particle.
  94917. * @param worldMatrix is the world matrix of the particle system
  94918. * @param positionToUpdate is the position vector to update with the result
  94919. * @param particle is the particle we are computed the position for
  94920. * @param isLocal defines if the position should be set in local space
  94921. */
  94922. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94923. /**
  94924. * Clones the current emitter and returns a copy of it
  94925. * @returns the new emitter
  94926. */
  94927. clone(): HemisphericParticleEmitter;
  94928. /**
  94929. * Called by the GPUParticleSystem to setup the update shader
  94930. * @param effect defines the update shader
  94931. */
  94932. applyToShader(effect: Effect): void;
  94933. /**
  94934. * Returns a string to use to update the GPU particles update shader
  94935. * @returns a string containng the defines string
  94936. */
  94937. getEffectDefines(): string;
  94938. /**
  94939. * Returns the string "HemisphericParticleEmitter"
  94940. * @returns a string containing the class name
  94941. */
  94942. getClassName(): string;
  94943. /**
  94944. * Serializes the particle system to a JSON object.
  94945. * @returns the JSON object
  94946. */
  94947. serialize(): any;
  94948. /**
  94949. * Parse properties from a JSON object
  94950. * @param serializationObject defines the JSON object
  94951. */
  94952. parse(serializationObject: any): void;
  94953. }
  94954. }
  94955. declare module BABYLON {
  94956. /**
  94957. * Particle emitter emitting particles from a point.
  94958. * It emits the particles randomly between 2 given directions.
  94959. */
  94960. export class PointParticleEmitter implements IParticleEmitterType {
  94961. /**
  94962. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94963. */
  94964. direction1: Vector3;
  94965. /**
  94966. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94967. */
  94968. direction2: Vector3;
  94969. /**
  94970. * Creates a new instance PointParticleEmitter
  94971. */
  94972. constructor();
  94973. /**
  94974. * Called by the particle System when the direction is computed for the created particle.
  94975. * @param worldMatrix is the world matrix of the particle system
  94976. * @param directionToUpdate is the direction vector to update with the result
  94977. * @param particle is the particle we are computed the direction for
  94978. * @param isLocal defines if the direction should be set in local space
  94979. */
  94980. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94981. /**
  94982. * Called by the particle System when the position is computed for the created particle.
  94983. * @param worldMatrix is the world matrix of the particle system
  94984. * @param positionToUpdate is the position vector to update with the result
  94985. * @param particle is the particle we are computed the position for
  94986. * @param isLocal defines if the position should be set in local space
  94987. */
  94988. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94989. /**
  94990. * Clones the current emitter and returns a copy of it
  94991. * @returns the new emitter
  94992. */
  94993. clone(): PointParticleEmitter;
  94994. /**
  94995. * Called by the GPUParticleSystem to setup the update shader
  94996. * @param effect defines the update shader
  94997. */
  94998. applyToShader(effect: Effect): void;
  94999. /**
  95000. * Returns a string to use to update the GPU particles update shader
  95001. * @returns a string containng the defines string
  95002. */
  95003. getEffectDefines(): string;
  95004. /**
  95005. * Returns the string "PointParticleEmitter"
  95006. * @returns a string containing the class name
  95007. */
  95008. getClassName(): string;
  95009. /**
  95010. * Serializes the particle system to a JSON object.
  95011. * @returns the JSON object
  95012. */
  95013. serialize(): any;
  95014. /**
  95015. * Parse properties from a JSON object
  95016. * @param serializationObject defines the JSON object
  95017. */
  95018. parse(serializationObject: any): void;
  95019. }
  95020. }
  95021. declare module BABYLON {
  95022. /**
  95023. * Particle emitter emitting particles from the inside of a sphere.
  95024. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  95025. */
  95026. export class SphereParticleEmitter implements IParticleEmitterType {
  95027. /**
  95028. * The radius of the emission sphere.
  95029. */
  95030. radius: number;
  95031. /**
  95032. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  95033. */
  95034. radiusRange: number;
  95035. /**
  95036. * How much to randomize the particle direction [0-1].
  95037. */
  95038. directionRandomizer: number;
  95039. /**
  95040. * Creates a new instance SphereParticleEmitter
  95041. * @param radius the radius of the emission sphere (1 by default)
  95042. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95043. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  95044. */
  95045. constructor(
  95046. /**
  95047. * The radius of the emission sphere.
  95048. */
  95049. radius?: number,
  95050. /**
  95051. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  95052. */
  95053. radiusRange?: number,
  95054. /**
  95055. * How much to randomize the particle direction [0-1].
  95056. */
  95057. directionRandomizer?: number);
  95058. /**
  95059. * Called by the particle System when the direction is computed for the created particle.
  95060. * @param worldMatrix is the world matrix of the particle system
  95061. * @param directionToUpdate is the direction vector to update with the result
  95062. * @param particle is the particle we are computed the direction for
  95063. * @param isLocal defines if the direction should be set in local space
  95064. */
  95065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95066. /**
  95067. * Called by the particle System when the position is computed for the created particle.
  95068. * @param worldMatrix is the world matrix of the particle system
  95069. * @param positionToUpdate is the position vector to update with the result
  95070. * @param particle is the particle we are computed the position for
  95071. * @param isLocal defines if the position should be set in local space
  95072. */
  95073. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95074. /**
  95075. * Clones the current emitter and returns a copy of it
  95076. * @returns the new emitter
  95077. */
  95078. clone(): SphereParticleEmitter;
  95079. /**
  95080. * Called by the GPUParticleSystem to setup the update shader
  95081. * @param effect defines the update shader
  95082. */
  95083. applyToShader(effect: Effect): void;
  95084. /**
  95085. * Returns a string to use to update the GPU particles update shader
  95086. * @returns a string containng the defines string
  95087. */
  95088. getEffectDefines(): string;
  95089. /**
  95090. * Returns the string "SphereParticleEmitter"
  95091. * @returns a string containing the class name
  95092. */
  95093. getClassName(): string;
  95094. /**
  95095. * Serializes the particle system to a JSON object.
  95096. * @returns the JSON object
  95097. */
  95098. serialize(): any;
  95099. /**
  95100. * Parse properties from a JSON object
  95101. * @param serializationObject defines the JSON object
  95102. */
  95103. parse(serializationObject: any): void;
  95104. }
  95105. /**
  95106. * Particle emitter emitting particles from the inside of a sphere.
  95107. * It emits the particles randomly between two vectors.
  95108. */
  95109. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  95110. /**
  95111. * The min limit of the emission direction.
  95112. */
  95113. direction1: Vector3;
  95114. /**
  95115. * The max limit of the emission direction.
  95116. */
  95117. direction2: Vector3;
  95118. /**
  95119. * Creates a new instance SphereDirectedParticleEmitter
  95120. * @param radius the radius of the emission sphere (1 by default)
  95121. * @param direction1 the min limit of the emission direction (up vector by default)
  95122. * @param direction2 the max limit of the emission direction (up vector by default)
  95123. */
  95124. constructor(radius?: number,
  95125. /**
  95126. * The min limit of the emission direction.
  95127. */
  95128. direction1?: Vector3,
  95129. /**
  95130. * The max limit of the emission direction.
  95131. */
  95132. direction2?: Vector3);
  95133. /**
  95134. * Called by the particle System when the direction is computed for the created particle.
  95135. * @param worldMatrix is the world matrix of the particle system
  95136. * @param directionToUpdate is the direction vector to update with the result
  95137. * @param particle is the particle we are computed the direction for
  95138. */
  95139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  95140. /**
  95141. * Clones the current emitter and returns a copy of it
  95142. * @returns the new emitter
  95143. */
  95144. clone(): SphereDirectedParticleEmitter;
  95145. /**
  95146. * Called by the GPUParticleSystem to setup the update shader
  95147. * @param effect defines the update shader
  95148. */
  95149. applyToShader(effect: Effect): void;
  95150. /**
  95151. * Returns a string to use to update the GPU particles update shader
  95152. * @returns a string containng the defines string
  95153. */
  95154. getEffectDefines(): string;
  95155. /**
  95156. * Returns the string "SphereDirectedParticleEmitter"
  95157. * @returns a string containing the class name
  95158. */
  95159. getClassName(): string;
  95160. /**
  95161. * Serializes the particle system to a JSON object.
  95162. * @returns the JSON object
  95163. */
  95164. serialize(): any;
  95165. /**
  95166. * Parse properties from a JSON object
  95167. * @param serializationObject defines the JSON object
  95168. */
  95169. parse(serializationObject: any): void;
  95170. }
  95171. }
  95172. declare module BABYLON {
  95173. /**
  95174. * Particle emitter emitting particles from a custom list of positions.
  95175. */
  95176. export class CustomParticleEmitter implements IParticleEmitterType {
  95177. /**
  95178. * Gets or sets the position generator that will create the inital position of each particle.
  95179. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  95180. */
  95181. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  95182. /**
  95183. * Gets or sets the destination generator that will create the final destination of each particle.
  95184. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  95185. */
  95186. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  95187. /**
  95188. * Creates a new instance CustomParticleEmitter
  95189. */
  95190. constructor();
  95191. /**
  95192. * Called by the particle System when the direction is computed for the created particle.
  95193. * @param worldMatrix is the world matrix of the particle system
  95194. * @param directionToUpdate is the direction vector to update with the result
  95195. * @param particle is the particle we are computed the direction for
  95196. * @param isLocal defines if the direction should be set in local space
  95197. */
  95198. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95199. /**
  95200. * Called by the particle System when the position is computed for the created particle.
  95201. * @param worldMatrix is the world matrix of the particle system
  95202. * @param positionToUpdate is the position vector to update with the result
  95203. * @param particle is the particle we are computed the position for
  95204. * @param isLocal defines if the position should be set in local space
  95205. */
  95206. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95207. /**
  95208. * Clones the current emitter and returns a copy of it
  95209. * @returns the new emitter
  95210. */
  95211. clone(): CustomParticleEmitter;
  95212. /**
  95213. * Called by the GPUParticleSystem to setup the update shader
  95214. * @param effect defines the update shader
  95215. */
  95216. applyToShader(effect: Effect): void;
  95217. /**
  95218. * Returns a string to use to update the GPU particles update shader
  95219. * @returns a string containng the defines string
  95220. */
  95221. getEffectDefines(): string;
  95222. /**
  95223. * Returns the string "PointParticleEmitter"
  95224. * @returns a string containing the class name
  95225. */
  95226. getClassName(): string;
  95227. /**
  95228. * Serializes the particle system to a JSON object.
  95229. * @returns the JSON object
  95230. */
  95231. serialize(): any;
  95232. /**
  95233. * Parse properties from a JSON object
  95234. * @param serializationObject defines the JSON object
  95235. */
  95236. parse(serializationObject: any): void;
  95237. }
  95238. }
  95239. declare module BABYLON {
  95240. /**
  95241. * Particle emitter emitting particles from the inside of a box.
  95242. * It emits the particles randomly between 2 given directions.
  95243. */
  95244. export class MeshParticleEmitter implements IParticleEmitterType {
  95245. private _indices;
  95246. private _positions;
  95247. private _normals;
  95248. private _storedNormal;
  95249. private _mesh;
  95250. /**
  95251. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  95252. */
  95253. direction1: Vector3;
  95254. /**
  95255. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  95256. */
  95257. direction2: Vector3;
  95258. /**
  95259. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  95260. */
  95261. useMeshNormalsForDirection: boolean;
  95262. /** Defines the mesh to use as source */
  95263. get mesh(): Nullable<AbstractMesh>;
  95264. set mesh(value: Nullable<AbstractMesh>);
  95265. /**
  95266. * Creates a new instance MeshParticleEmitter
  95267. * @param mesh defines the mesh to use as source
  95268. */
  95269. constructor(mesh?: Nullable<AbstractMesh>);
  95270. /**
  95271. * Called by the particle System when the direction is computed for the created particle.
  95272. * @param worldMatrix is the world matrix of the particle system
  95273. * @param directionToUpdate is the direction vector to update with the result
  95274. * @param particle is the particle we are computed the direction for
  95275. * @param isLocal defines if the direction should be set in local space
  95276. */
  95277. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95278. /**
  95279. * Called by the particle System when the position is computed for the created particle.
  95280. * @param worldMatrix is the world matrix of the particle system
  95281. * @param positionToUpdate is the position vector to update with the result
  95282. * @param particle is the particle we are computed the position for
  95283. * @param isLocal defines if the position should be set in local space
  95284. */
  95285. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95286. /**
  95287. * Clones the current emitter and returns a copy of it
  95288. * @returns the new emitter
  95289. */
  95290. clone(): MeshParticleEmitter;
  95291. /**
  95292. * Called by the GPUParticleSystem to setup the update shader
  95293. * @param effect defines the update shader
  95294. */
  95295. applyToShader(effect: Effect): void;
  95296. /**
  95297. * Returns a string to use to update the GPU particles update shader
  95298. * @returns a string containng the defines string
  95299. */
  95300. getEffectDefines(): string;
  95301. /**
  95302. * Returns the string "BoxParticleEmitter"
  95303. * @returns a string containing the class name
  95304. */
  95305. getClassName(): string;
  95306. /**
  95307. * Serializes the particle system to a JSON object.
  95308. * @returns the JSON object
  95309. */
  95310. serialize(): any;
  95311. /**
  95312. * Parse properties from a JSON object
  95313. * @param serializationObject defines the JSON object
  95314. * @param scene defines the hosting scene
  95315. */
  95316. parse(serializationObject: any, scene: Nullable<Scene>): void;
  95317. }
  95318. }
  95319. declare module BABYLON {
  95320. /**
  95321. * Interface representing a particle system in Babylon.js.
  95322. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  95323. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  95324. */
  95325. export interface IParticleSystem {
  95326. /**
  95327. * List of animations used by the particle system.
  95328. */
  95329. animations: Animation[];
  95330. /**
  95331. * The id of the Particle system.
  95332. */
  95333. id: string;
  95334. /**
  95335. * The name of the Particle system.
  95336. */
  95337. name: string;
  95338. /**
  95339. * The emitter represents the Mesh or position we are attaching the particle system to.
  95340. */
  95341. emitter: Nullable<AbstractMesh | Vector3>;
  95342. /**
  95343. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  95344. */
  95345. isBillboardBased: boolean;
  95346. /**
  95347. * The rendering group used by the Particle system to chose when to render.
  95348. */
  95349. renderingGroupId: number;
  95350. /**
  95351. * The layer mask we are rendering the particles through.
  95352. */
  95353. layerMask: number;
  95354. /**
  95355. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  95356. */
  95357. updateSpeed: number;
  95358. /**
  95359. * The amount of time the particle system is running (depends of the overall update speed).
  95360. */
  95361. targetStopDuration: number;
  95362. /**
  95363. * The texture used to render each particle. (this can be a spritesheet)
  95364. */
  95365. particleTexture: Nullable<BaseTexture>;
  95366. /**
  95367. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  95368. */
  95369. blendMode: number;
  95370. /**
  95371. * Minimum life time of emitting particles.
  95372. */
  95373. minLifeTime: number;
  95374. /**
  95375. * Maximum life time of emitting particles.
  95376. */
  95377. maxLifeTime: number;
  95378. /**
  95379. * Minimum Size of emitting particles.
  95380. */
  95381. minSize: number;
  95382. /**
  95383. * Maximum Size of emitting particles.
  95384. */
  95385. maxSize: number;
  95386. /**
  95387. * Minimum scale of emitting particles on X axis.
  95388. */
  95389. minScaleX: number;
  95390. /**
  95391. * Maximum scale of emitting particles on X axis.
  95392. */
  95393. maxScaleX: number;
  95394. /**
  95395. * Minimum scale of emitting particles on Y axis.
  95396. */
  95397. minScaleY: number;
  95398. /**
  95399. * Maximum scale of emitting particles on Y axis.
  95400. */
  95401. maxScaleY: number;
  95402. /**
  95403. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  95404. */
  95405. color1: Color4;
  95406. /**
  95407. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  95408. */
  95409. color2: Color4;
  95410. /**
  95411. * Color the particle will have at the end of its lifetime.
  95412. */
  95413. colorDead: Color4;
  95414. /**
  95415. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  95416. */
  95417. emitRate: number;
  95418. /**
  95419. * You can use gravity if you want to give an orientation to your particles.
  95420. */
  95421. gravity: Vector3;
  95422. /**
  95423. * Minimum power of emitting particles.
  95424. */
  95425. minEmitPower: number;
  95426. /**
  95427. * Maximum power of emitting particles.
  95428. */
  95429. maxEmitPower: number;
  95430. /**
  95431. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  95432. */
  95433. minAngularSpeed: number;
  95434. /**
  95435. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  95436. */
  95437. maxAngularSpeed: number;
  95438. /**
  95439. * Gets or sets the minimal initial rotation in radians.
  95440. */
  95441. minInitialRotation: number;
  95442. /**
  95443. * Gets or sets the maximal initial rotation in radians.
  95444. */
  95445. maxInitialRotation: number;
  95446. /**
  95447. * The particle emitter type defines the emitter used by the particle system.
  95448. * It can be for example box, sphere, or cone...
  95449. */
  95450. particleEmitterType: Nullable<IParticleEmitterType>;
  95451. /**
  95452. * Defines the delay in milliseconds before starting the system (0 by default)
  95453. */
  95454. startDelay: number;
  95455. /**
  95456. * 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
  95457. */
  95458. preWarmCycles: number;
  95459. /**
  95460. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  95461. */
  95462. preWarmStepOffset: number;
  95463. /**
  95464. * 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)
  95465. */
  95466. spriteCellChangeSpeed: number;
  95467. /**
  95468. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  95469. */
  95470. startSpriteCellID: number;
  95471. /**
  95472. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  95473. */
  95474. endSpriteCellID: number;
  95475. /**
  95476. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  95477. */
  95478. spriteCellWidth: number;
  95479. /**
  95480. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  95481. */
  95482. spriteCellHeight: number;
  95483. /**
  95484. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  95485. */
  95486. spriteRandomStartCell: boolean;
  95487. /**
  95488. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  95489. */
  95490. isAnimationSheetEnabled: boolean;
  95491. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  95492. translationPivot: Vector2;
  95493. /**
  95494. * Gets or sets a texture used to add random noise to particle positions
  95495. */
  95496. noiseTexture: Nullable<BaseTexture>;
  95497. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  95498. noiseStrength: Vector3;
  95499. /**
  95500. * Gets or sets the billboard mode to use when isBillboardBased = true.
  95501. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  95502. */
  95503. billboardMode: number;
  95504. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  95505. limitVelocityDamping: number;
  95506. /**
  95507. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  95508. */
  95509. beginAnimationOnStart: boolean;
  95510. /**
  95511. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  95512. */
  95513. beginAnimationFrom: number;
  95514. /**
  95515. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  95516. */
  95517. beginAnimationTo: number;
  95518. /**
  95519. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  95520. */
  95521. beginAnimationLoop: boolean;
  95522. /**
  95523. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  95524. */
  95525. disposeOnStop: boolean;
  95526. /**
  95527. * Specifies if the particles are updated in emitter local space or world space
  95528. */
  95529. isLocal: boolean;
  95530. /** Snippet ID if the particle system was created from the snippet server */
  95531. snippetId: string;
  95532. /** Gets or sets a matrix to use to compute projection */
  95533. defaultProjectionMatrix: Matrix;
  95534. /**
  95535. * Gets the maximum number of particles active at the same time.
  95536. * @returns The max number of active particles.
  95537. */
  95538. getCapacity(): number;
  95539. /**
  95540. * Gets the number of particles active at the same time.
  95541. * @returns The number of active particles.
  95542. */
  95543. getActiveCount(): number;
  95544. /**
  95545. * Gets if the system has been started. (Note: this will still be true after stop is called)
  95546. * @returns True if it has been started, otherwise false.
  95547. */
  95548. isStarted(): boolean;
  95549. /**
  95550. * Animates the particle system for this frame.
  95551. */
  95552. animate(): void;
  95553. /**
  95554. * Renders the particle system in its current state.
  95555. * @returns the current number of particles
  95556. */
  95557. render(): number;
  95558. /**
  95559. * Dispose the particle system and frees its associated resources.
  95560. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  95561. */
  95562. dispose(disposeTexture?: boolean): void;
  95563. /**
  95564. * An event triggered when the system is disposed
  95565. */
  95566. onDisposeObservable: Observable<IParticleSystem>;
  95567. /**
  95568. * An event triggered when the system is stopped
  95569. */
  95570. onStoppedObservable: Observable<IParticleSystem>;
  95571. /**
  95572. * Clones the particle system.
  95573. * @param name The name of the cloned object
  95574. * @param newEmitter The new emitter to use
  95575. * @returns the cloned particle system
  95576. */
  95577. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  95578. /**
  95579. * Serializes the particle system to a JSON object
  95580. * @param serializeTexture defines if the texture must be serialized as well
  95581. * @returns the JSON object
  95582. */
  95583. serialize(serializeTexture: boolean): any;
  95584. /**
  95585. * Rebuild the particle system
  95586. */
  95587. rebuild(): void;
  95588. /** Force the system to rebuild all gradients that need to be resync */
  95589. forceRefreshGradients(): void;
  95590. /**
  95591. * Starts the particle system and begins to emit
  95592. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  95593. */
  95594. start(delay?: number): void;
  95595. /**
  95596. * Stops the particle system.
  95597. */
  95598. stop(): void;
  95599. /**
  95600. * Remove all active particles
  95601. */
  95602. reset(): void;
  95603. /**
  95604. * Gets a boolean indicating that the system is stopping
  95605. * @returns true if the system is currently stopping
  95606. */
  95607. isStopping(): boolean;
  95608. /**
  95609. * Is this system ready to be used/rendered
  95610. * @return true if the system is ready
  95611. */
  95612. isReady(): boolean;
  95613. /**
  95614. * Returns the string "ParticleSystem"
  95615. * @returns a string containing the class name
  95616. */
  95617. getClassName(): string;
  95618. /**
  95619. * Gets the custom effect used to render the particles
  95620. * @param blendMode Blend mode for which the effect should be retrieved
  95621. * @returns The effect
  95622. */
  95623. getCustomEffect(blendMode: number): Nullable<Effect>;
  95624. /**
  95625. * Sets the custom effect used to render the particles
  95626. * @param effect The effect to set
  95627. * @param blendMode Blend mode for which the effect should be set
  95628. */
  95629. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  95630. /**
  95631. * Fill the defines array according to the current settings of the particle system
  95632. * @param defines Array to be updated
  95633. * @param blendMode blend mode to take into account when updating the array
  95634. */
  95635. fillDefines(defines: Array<string>, blendMode: number): void;
  95636. /**
  95637. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  95638. * @param uniforms Uniforms array to fill
  95639. * @param attributes Attributes array to fill
  95640. * @param samplers Samplers array to fill
  95641. */
  95642. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  95643. /**
  95644. * Observable that will be called just before the particles are drawn
  95645. */
  95646. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  95647. /**
  95648. * Gets the name of the particle vertex shader
  95649. */
  95650. vertexShaderName: string;
  95651. /**
  95652. * Adds a new color gradient
  95653. * @param gradient defines the gradient to use (between 0 and 1)
  95654. * @param color1 defines the color to affect to the specified gradient
  95655. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  95656. * @returns the current particle system
  95657. */
  95658. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  95659. /**
  95660. * Remove a specific color gradient
  95661. * @param gradient defines the gradient to remove
  95662. * @returns the current particle system
  95663. */
  95664. removeColorGradient(gradient: number): IParticleSystem;
  95665. /**
  95666. * Adds a new size gradient
  95667. * @param gradient defines the gradient to use (between 0 and 1)
  95668. * @param factor defines the size factor to affect to the specified gradient
  95669. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95670. * @returns the current particle system
  95671. */
  95672. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95673. /**
  95674. * Remove a specific size gradient
  95675. * @param gradient defines the gradient to remove
  95676. * @returns the current particle system
  95677. */
  95678. removeSizeGradient(gradient: number): IParticleSystem;
  95679. /**
  95680. * Gets the current list of color gradients.
  95681. * You must use addColorGradient and removeColorGradient to udpate this list
  95682. * @returns the list of color gradients
  95683. */
  95684. getColorGradients(): Nullable<Array<ColorGradient>>;
  95685. /**
  95686. * Gets the current list of size gradients.
  95687. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95688. * @returns the list of size gradients
  95689. */
  95690. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95691. /**
  95692. * Gets the current list of angular speed gradients.
  95693. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95694. * @returns the list of angular speed gradients
  95695. */
  95696. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95697. /**
  95698. * Adds a new angular speed gradient
  95699. * @param gradient defines the gradient to use (between 0 and 1)
  95700. * @param factor defines the angular speed to affect to the specified gradient
  95701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95702. * @returns the current particle system
  95703. */
  95704. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95705. /**
  95706. * Remove a specific angular speed gradient
  95707. * @param gradient defines the gradient to remove
  95708. * @returns the current particle system
  95709. */
  95710. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  95711. /**
  95712. * Gets the current list of velocity gradients.
  95713. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95714. * @returns the list of velocity gradients
  95715. */
  95716. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95717. /**
  95718. * Adds a new velocity gradient
  95719. * @param gradient defines the gradient to use (between 0 and 1)
  95720. * @param factor defines the velocity to affect to the specified gradient
  95721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95722. * @returns the current particle system
  95723. */
  95724. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95725. /**
  95726. * Remove a specific velocity gradient
  95727. * @param gradient defines the gradient to remove
  95728. * @returns the current particle system
  95729. */
  95730. removeVelocityGradient(gradient: number): IParticleSystem;
  95731. /**
  95732. * Gets the current list of limit velocity gradients.
  95733. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95734. * @returns the list of limit velocity gradients
  95735. */
  95736. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95737. /**
  95738. * Adds a new limit velocity gradient
  95739. * @param gradient defines the gradient to use (between 0 and 1)
  95740. * @param factor defines the limit velocity to affect to the specified gradient
  95741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95742. * @returns the current particle system
  95743. */
  95744. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95745. /**
  95746. * Remove a specific limit velocity gradient
  95747. * @param gradient defines the gradient to remove
  95748. * @returns the current particle system
  95749. */
  95750. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  95751. /**
  95752. * Adds a new drag gradient
  95753. * @param gradient defines the gradient to use (between 0 and 1)
  95754. * @param factor defines the drag to affect to the specified gradient
  95755. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95756. * @returns the current particle system
  95757. */
  95758. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95759. /**
  95760. * Remove a specific drag gradient
  95761. * @param gradient defines the gradient to remove
  95762. * @returns the current particle system
  95763. */
  95764. removeDragGradient(gradient: number): IParticleSystem;
  95765. /**
  95766. * Gets the current list of drag gradients.
  95767. * You must use addDragGradient and removeDragGradient to udpate this list
  95768. * @returns the list of drag gradients
  95769. */
  95770. getDragGradients(): Nullable<Array<FactorGradient>>;
  95771. /**
  95772. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95773. * @param gradient defines the gradient to use (between 0 and 1)
  95774. * @param factor defines the emit rate to affect to the specified gradient
  95775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95776. * @returns the current particle system
  95777. */
  95778. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95779. /**
  95780. * Remove a specific emit rate gradient
  95781. * @param gradient defines the gradient to remove
  95782. * @returns the current particle system
  95783. */
  95784. removeEmitRateGradient(gradient: number): IParticleSystem;
  95785. /**
  95786. * Gets the current list of emit rate gradients.
  95787. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95788. * @returns the list of emit rate gradients
  95789. */
  95790. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95791. /**
  95792. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95793. * @param gradient defines the gradient to use (between 0 and 1)
  95794. * @param factor defines the start size to affect to the specified gradient
  95795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95796. * @returns the current particle system
  95797. */
  95798. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95799. /**
  95800. * Remove a specific start size gradient
  95801. * @param gradient defines the gradient to remove
  95802. * @returns the current particle system
  95803. */
  95804. removeStartSizeGradient(gradient: number): IParticleSystem;
  95805. /**
  95806. * Gets the current list of start size gradients.
  95807. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95808. * @returns the list of start size gradients
  95809. */
  95810. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95811. /**
  95812. * Adds a new life time gradient
  95813. * @param gradient defines the gradient to use (between 0 and 1)
  95814. * @param factor defines the life time factor to affect to the specified gradient
  95815. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95816. * @returns the current particle system
  95817. */
  95818. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95819. /**
  95820. * Remove a specific life time gradient
  95821. * @param gradient defines the gradient to remove
  95822. * @returns the current particle system
  95823. */
  95824. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95825. /**
  95826. * Gets the current list of life time gradients.
  95827. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95828. * @returns the list of life time gradients
  95829. */
  95830. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95831. /**
  95832. * Gets the current list of color gradients.
  95833. * You must use addColorGradient and removeColorGradient to udpate this list
  95834. * @returns the list of color gradients
  95835. */
  95836. getColorGradients(): Nullable<Array<ColorGradient>>;
  95837. /**
  95838. * Adds a new ramp gradient used to remap particle colors
  95839. * @param gradient defines the gradient to use (between 0 and 1)
  95840. * @param color defines the color to affect to the specified gradient
  95841. * @returns the current particle system
  95842. */
  95843. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95844. /**
  95845. * Gets the current list of ramp gradients.
  95846. * You must use addRampGradient and removeRampGradient to udpate this list
  95847. * @returns the list of ramp gradients
  95848. */
  95849. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95850. /** Gets or sets a boolean indicating that ramp gradients must be used
  95851. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95852. */
  95853. useRampGradients: boolean;
  95854. /**
  95855. * Adds a new color remap gradient
  95856. * @param gradient defines the gradient to use (between 0 and 1)
  95857. * @param min defines the color remap minimal range
  95858. * @param max defines the color remap maximal range
  95859. * @returns the current particle system
  95860. */
  95861. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95862. /**
  95863. * Gets the current list of color remap gradients.
  95864. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95865. * @returns the list of color remap gradients
  95866. */
  95867. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95868. /**
  95869. * Adds a new alpha remap gradient
  95870. * @param gradient defines the gradient to use (between 0 and 1)
  95871. * @param min defines the alpha remap minimal range
  95872. * @param max defines the alpha remap maximal range
  95873. * @returns the current particle system
  95874. */
  95875. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95876. /**
  95877. * Gets the current list of alpha remap gradients.
  95878. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95879. * @returns the list of alpha remap gradients
  95880. */
  95881. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95882. /**
  95883. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95884. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95885. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95886. * @returns the emitter
  95887. */
  95888. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95889. /**
  95890. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95891. * @param radius The radius of the hemisphere to emit from
  95892. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95893. * @returns the emitter
  95894. */
  95895. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95896. /**
  95897. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95898. * @param radius The radius of the sphere to emit from
  95899. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95900. * @returns the emitter
  95901. */
  95902. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95903. /**
  95904. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95905. * @param radius The radius of the sphere to emit from
  95906. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95907. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95908. * @returns the emitter
  95909. */
  95910. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95911. /**
  95912. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95913. * @param radius The radius of the emission cylinder
  95914. * @param height The height of the emission cylinder
  95915. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95916. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95917. * @returns the emitter
  95918. */
  95919. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95920. /**
  95921. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95922. * @param radius The radius of the cylinder to emit from
  95923. * @param height The height of the emission cylinder
  95924. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95925. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95926. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95927. * @returns the emitter
  95928. */
  95929. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95930. /**
  95931. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95932. * @param radius The radius of the cone to emit from
  95933. * @param angle The base angle of the cone
  95934. * @returns the emitter
  95935. */
  95936. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95937. /**
  95938. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95939. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95940. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95941. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95942. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95943. * @returns the emitter
  95944. */
  95945. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95946. /**
  95947. * Get hosting scene
  95948. * @returns the scene
  95949. */
  95950. getScene(): Nullable<Scene>;
  95951. }
  95952. }
  95953. declare module BABYLON {
  95954. /**
  95955. * 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.
  95956. * @see https://doc.babylonjs.com/how_to/transformnode
  95957. */
  95958. export class TransformNode extends Node {
  95959. /**
  95960. * Object will not rotate to face the camera
  95961. */
  95962. static BILLBOARDMODE_NONE: number;
  95963. /**
  95964. * Object will rotate to face the camera but only on the x axis
  95965. */
  95966. static BILLBOARDMODE_X: number;
  95967. /**
  95968. * Object will rotate to face the camera but only on the y axis
  95969. */
  95970. static BILLBOARDMODE_Y: number;
  95971. /**
  95972. * Object will rotate to face the camera but only on the z axis
  95973. */
  95974. static BILLBOARDMODE_Z: number;
  95975. /**
  95976. * Object will rotate to face the camera
  95977. */
  95978. static BILLBOARDMODE_ALL: number;
  95979. /**
  95980. * Object will rotate to face the camera's position instead of orientation
  95981. */
  95982. static BILLBOARDMODE_USE_POSITION: number;
  95983. private static _TmpRotation;
  95984. private static _TmpScaling;
  95985. private static _TmpTranslation;
  95986. private _forward;
  95987. private _forwardInverted;
  95988. private _up;
  95989. private _right;
  95990. private _rightInverted;
  95991. private _position;
  95992. private _rotation;
  95993. private _rotationQuaternion;
  95994. protected _scaling: Vector3;
  95995. protected _isDirty: boolean;
  95996. private _transformToBoneReferal;
  95997. private _isAbsoluteSynced;
  95998. private _billboardMode;
  95999. /**
  96000. * Gets or sets the billboard mode. Default is 0.
  96001. *
  96002. * | Value | Type | Description |
  96003. * | --- | --- | --- |
  96004. * | 0 | BILLBOARDMODE_NONE | |
  96005. * | 1 | BILLBOARDMODE_X | |
  96006. * | 2 | BILLBOARDMODE_Y | |
  96007. * | 4 | BILLBOARDMODE_Z | |
  96008. * | 7 | BILLBOARDMODE_ALL | |
  96009. *
  96010. */
  96011. get billboardMode(): number;
  96012. set billboardMode(value: number);
  96013. private _preserveParentRotationForBillboard;
  96014. /**
  96015. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  96016. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  96017. */
  96018. get preserveParentRotationForBillboard(): boolean;
  96019. set preserveParentRotationForBillboard(value: boolean);
  96020. /**
  96021. * 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
  96022. */
  96023. scalingDeterminant: number;
  96024. private _infiniteDistance;
  96025. /**
  96026. * Gets or sets the distance of the object to max, often used by skybox
  96027. */
  96028. get infiniteDistance(): boolean;
  96029. set infiniteDistance(value: boolean);
  96030. /**
  96031. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  96032. * By default the system will update normals to compensate
  96033. */
  96034. ignoreNonUniformScaling: boolean;
  96035. /**
  96036. * 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
  96037. */
  96038. reIntegrateRotationIntoRotationQuaternion: boolean;
  96039. /** @hidden */
  96040. _poseMatrix: Nullable<Matrix>;
  96041. /** @hidden */
  96042. _localMatrix: Matrix;
  96043. private _usePivotMatrix;
  96044. private _absolutePosition;
  96045. private _absoluteScaling;
  96046. private _absoluteRotationQuaternion;
  96047. private _pivotMatrix;
  96048. private _pivotMatrixInverse;
  96049. /** @hidden */
  96050. _postMultiplyPivotMatrix: boolean;
  96051. protected _isWorldMatrixFrozen: boolean;
  96052. /** @hidden */
  96053. _indexInSceneTransformNodesArray: number;
  96054. /**
  96055. * An event triggered after the world matrix is updated
  96056. */
  96057. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  96058. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  96059. /**
  96060. * Gets a string identifying the name of the class
  96061. * @returns "TransformNode" string
  96062. */
  96063. getClassName(): string;
  96064. /**
  96065. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  96066. */
  96067. get position(): Vector3;
  96068. set position(newPosition: Vector3);
  96069. /**
  96070. * 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)).
  96071. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  96072. */
  96073. get rotation(): Vector3;
  96074. set rotation(newRotation: Vector3);
  96075. /**
  96076. * 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)).
  96077. */
  96078. get scaling(): Vector3;
  96079. set scaling(newScaling: Vector3);
  96080. /**
  96081. * 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).
  96082. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  96083. */
  96084. get rotationQuaternion(): Nullable<Quaternion>;
  96085. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  96086. /**
  96087. * The forward direction of that transform in world space.
  96088. */
  96089. get forward(): Vector3;
  96090. /**
  96091. * The up direction of that transform in world space.
  96092. */
  96093. get up(): Vector3;
  96094. /**
  96095. * The right direction of that transform in world space.
  96096. */
  96097. get right(): Vector3;
  96098. /**
  96099. * Copies the parameter passed Matrix into the mesh Pose matrix.
  96100. * @param matrix the matrix to copy the pose from
  96101. * @returns this TransformNode.
  96102. */
  96103. updatePoseMatrix(matrix: Matrix): TransformNode;
  96104. /**
  96105. * Returns the mesh Pose matrix.
  96106. * @returns the pose matrix
  96107. */
  96108. getPoseMatrix(): Matrix;
  96109. /** @hidden */
  96110. _isSynchronized(): boolean;
  96111. /** @hidden */
  96112. _initCache(): void;
  96113. /**
  96114. * Flag the transform node as dirty (Forcing it to update everything)
  96115. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  96116. * @returns this transform node
  96117. */
  96118. markAsDirty(property: string): TransformNode;
  96119. /**
  96120. * Returns the current mesh absolute position.
  96121. * Returns a Vector3.
  96122. */
  96123. get absolutePosition(): Vector3;
  96124. /**
  96125. * Returns the current mesh absolute scaling.
  96126. * Returns a Vector3.
  96127. */
  96128. get absoluteScaling(): Vector3;
  96129. /**
  96130. * Returns the current mesh absolute rotation.
  96131. * Returns a Quaternion.
  96132. */
  96133. get absoluteRotationQuaternion(): Quaternion;
  96134. /**
  96135. * Sets a new matrix to apply before all other transformation
  96136. * @param matrix defines the transform matrix
  96137. * @returns the current TransformNode
  96138. */
  96139. setPreTransformMatrix(matrix: Matrix): TransformNode;
  96140. /**
  96141. * Sets a new pivot matrix to the current node
  96142. * @param matrix defines the new pivot matrix to use
  96143. * @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
  96144. * @returns the current TransformNode
  96145. */
  96146. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  96147. /**
  96148. * Returns the mesh pivot matrix.
  96149. * Default : Identity.
  96150. * @returns the matrix
  96151. */
  96152. getPivotMatrix(): Matrix;
  96153. /**
  96154. * Instantiate (when possible) or clone that node with its hierarchy
  96155. * @param newParent defines the new parent to use for the instance (or clone)
  96156. * @param options defines options to configure how copy is done
  96157. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  96158. * @returns an instance (or a clone) of the current node with its hiearchy
  96159. */
  96160. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  96161. doNotInstantiate: boolean;
  96162. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  96163. /**
  96164. * Prevents the World matrix to be computed any longer
  96165. * @param newWorldMatrix defines an optional matrix to use as world matrix
  96166. * @returns the TransformNode.
  96167. */
  96168. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  96169. /**
  96170. * Allows back the World matrix computation.
  96171. * @returns the TransformNode.
  96172. */
  96173. unfreezeWorldMatrix(): this;
  96174. /**
  96175. * True if the World matrix has been frozen.
  96176. */
  96177. get isWorldMatrixFrozen(): boolean;
  96178. /**
  96179. * Retuns the mesh absolute position in the World.
  96180. * @returns a Vector3.
  96181. */
  96182. getAbsolutePosition(): Vector3;
  96183. /**
  96184. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  96185. * @param absolutePosition the absolute position to set
  96186. * @returns the TransformNode.
  96187. */
  96188. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96189. /**
  96190. * Sets the mesh position in its local space.
  96191. * @param vector3 the position to set in localspace
  96192. * @returns the TransformNode.
  96193. */
  96194. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  96195. /**
  96196. * Returns the mesh position in the local space from the current World matrix values.
  96197. * @returns a new Vector3.
  96198. */
  96199. getPositionExpressedInLocalSpace(): Vector3;
  96200. /**
  96201. * Translates the mesh along the passed Vector3 in its local space.
  96202. * @param vector3 the distance to translate in localspace
  96203. * @returns the TransformNode.
  96204. */
  96205. locallyTranslate(vector3: Vector3): TransformNode;
  96206. private static _lookAtVectorCache;
  96207. /**
  96208. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  96209. * @param targetPoint the position (must be in same space as current mesh) to look at
  96210. * @param yawCor optional yaw (y-axis) correction in radians
  96211. * @param pitchCor optional pitch (x-axis) correction in radians
  96212. * @param rollCor optional roll (z-axis) correction in radians
  96213. * @param space the choosen space of the target
  96214. * @returns the TransformNode.
  96215. */
  96216. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  96217. /**
  96218. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  96219. * This Vector3 is expressed in the World space.
  96220. * @param localAxis axis to rotate
  96221. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  96222. */
  96223. getDirection(localAxis: Vector3): Vector3;
  96224. /**
  96225. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  96226. * localAxis is expressed in the mesh local space.
  96227. * result is computed in the Wordl space from the mesh World matrix.
  96228. * @param localAxis axis to rotate
  96229. * @param result the resulting transformnode
  96230. * @returns this TransformNode.
  96231. */
  96232. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  96233. /**
  96234. * Sets this transform node rotation to the given local axis.
  96235. * @param localAxis the axis in local space
  96236. * @param yawCor optional yaw (y-axis) correction in radians
  96237. * @param pitchCor optional pitch (x-axis) correction in radians
  96238. * @param rollCor optional roll (z-axis) correction in radians
  96239. * @returns this TransformNode
  96240. */
  96241. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  96242. /**
  96243. * Sets a new pivot point to the current node
  96244. * @param point defines the new pivot point to use
  96245. * @param space defines if the point is in world or local space (local by default)
  96246. * @returns the current TransformNode
  96247. */
  96248. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  96249. /**
  96250. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  96251. * @returns the pivot point
  96252. */
  96253. getPivotPoint(): Vector3;
  96254. /**
  96255. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  96256. * @param result the vector3 to store the result
  96257. * @returns this TransformNode.
  96258. */
  96259. getPivotPointToRef(result: Vector3): TransformNode;
  96260. /**
  96261. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  96262. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  96263. */
  96264. getAbsolutePivotPoint(): Vector3;
  96265. /**
  96266. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  96267. * @param result vector3 to store the result
  96268. * @returns this TransformNode.
  96269. */
  96270. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  96271. /**
  96272. * Defines the passed node as the parent of the current node.
  96273. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  96274. * @see https://doc.babylonjs.com/how_to/parenting
  96275. * @param node the node ot set as the parent
  96276. * @returns this TransformNode.
  96277. */
  96278. setParent(node: Nullable<Node>): TransformNode;
  96279. private _nonUniformScaling;
  96280. /**
  96281. * True if the scaling property of this object is non uniform eg. (1,2,1)
  96282. */
  96283. get nonUniformScaling(): boolean;
  96284. /** @hidden */
  96285. _updateNonUniformScalingState(value: boolean): boolean;
  96286. /**
  96287. * Attach the current TransformNode to another TransformNode associated with a bone
  96288. * @param bone Bone affecting the TransformNode
  96289. * @param affectedTransformNode TransformNode associated with the bone
  96290. * @returns this object
  96291. */
  96292. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  96293. /**
  96294. * Detach the transform node if its associated with a bone
  96295. * @returns this object
  96296. */
  96297. detachFromBone(): TransformNode;
  96298. private static _rotationAxisCache;
  96299. /**
  96300. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  96301. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  96302. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  96303. * The passed axis is also normalized.
  96304. * @param axis the axis to rotate around
  96305. * @param amount the amount to rotate in radians
  96306. * @param space Space to rotate in (Default: local)
  96307. * @returns the TransformNode.
  96308. */
  96309. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96310. /**
  96311. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  96312. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  96313. * The passed axis is also normalized. .
  96314. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  96315. * @param point the point to rotate around
  96316. * @param axis the axis to rotate around
  96317. * @param amount the amount to rotate in radians
  96318. * @returns the TransformNode
  96319. */
  96320. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  96321. /**
  96322. * Translates the mesh along the axis vector for the passed distance in the given space.
  96323. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  96324. * @param axis the axis to translate in
  96325. * @param distance the distance to translate
  96326. * @param space Space to rotate in (Default: local)
  96327. * @returns the TransformNode.
  96328. */
  96329. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96330. /**
  96331. * Adds a rotation step to the mesh current rotation.
  96332. * x, y, z are Euler angles expressed in radians.
  96333. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  96334. * This means this rotation is made in the mesh local space only.
  96335. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  96336. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  96337. * ```javascript
  96338. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  96339. * ```
  96340. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  96341. * 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.
  96342. * @param x Rotation to add
  96343. * @param y Rotation to add
  96344. * @param z Rotation to add
  96345. * @returns the TransformNode.
  96346. */
  96347. addRotation(x: number, y: number, z: number): TransformNode;
  96348. /**
  96349. * @hidden
  96350. */
  96351. protected _getEffectiveParent(): Nullable<Node>;
  96352. /**
  96353. * Computes the world matrix of the node
  96354. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  96355. * @returns the world matrix
  96356. */
  96357. computeWorldMatrix(force?: boolean): Matrix;
  96358. /**
  96359. * Resets this nodeTransform's local matrix to Matrix.Identity().
  96360. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  96361. */
  96362. resetLocalMatrix(independentOfChildren?: boolean): void;
  96363. protected _afterComputeWorldMatrix(): void;
  96364. /**
  96365. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  96366. * @param func callback function to add
  96367. *
  96368. * @returns the TransformNode.
  96369. */
  96370. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  96371. /**
  96372. * Removes a registered callback function.
  96373. * @param func callback function to remove
  96374. * @returns the TransformNode.
  96375. */
  96376. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  96377. /**
  96378. * Gets the position of the current mesh in camera space
  96379. * @param camera defines the camera to use
  96380. * @returns a position
  96381. */
  96382. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  96383. /**
  96384. * Returns the distance from the mesh to the active camera
  96385. * @param camera defines the camera to use
  96386. * @returns the distance
  96387. */
  96388. getDistanceToCamera(camera?: Nullable<Camera>): number;
  96389. /**
  96390. * Clone the current transform node
  96391. * @param name Name of the new clone
  96392. * @param newParent New parent for the clone
  96393. * @param doNotCloneChildren Do not clone children hierarchy
  96394. * @returns the new transform node
  96395. */
  96396. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  96397. /**
  96398. * Serializes the objects information.
  96399. * @param currentSerializationObject defines the object to serialize in
  96400. * @returns the serialized object
  96401. */
  96402. serialize(currentSerializationObject?: any): any;
  96403. /**
  96404. * Returns a new TransformNode object parsed from the source provided.
  96405. * @param parsedTransformNode is the source.
  96406. * @param scene the scne the object belongs to
  96407. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  96408. * @returns a new TransformNode object parsed from the source provided.
  96409. */
  96410. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  96411. /**
  96412. * Get all child-transformNodes of this node
  96413. * @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
  96414. * @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
  96415. * @returns an array of TransformNode
  96416. */
  96417. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  96418. /**
  96419. * Releases resources associated with this transform node.
  96420. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96421. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96422. */
  96423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96424. /**
  96425. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  96426. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  96427. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  96428. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  96429. * @returns the current mesh
  96430. */
  96431. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  96432. private _syncAbsoluteScalingAndRotation;
  96433. }
  96434. }
  96435. declare module BABYLON {
  96436. /**
  96437. * Class used to override all child animations of a given target
  96438. */
  96439. export class AnimationPropertiesOverride {
  96440. /**
  96441. * Gets or sets a value indicating if animation blending must be used
  96442. */
  96443. enableBlending: boolean;
  96444. /**
  96445. * Gets or sets the blending speed to use when enableBlending is true
  96446. */
  96447. blendingSpeed: number;
  96448. /**
  96449. * Gets or sets the default loop mode to use
  96450. */
  96451. loopMode: number;
  96452. }
  96453. }
  96454. declare module BABYLON {
  96455. /**
  96456. * Class used to store bone information
  96457. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96458. */
  96459. export class Bone extends Node {
  96460. /**
  96461. * defines the bone name
  96462. */
  96463. name: string;
  96464. private static _tmpVecs;
  96465. private static _tmpQuat;
  96466. private static _tmpMats;
  96467. /**
  96468. * Gets the list of child bones
  96469. */
  96470. children: Bone[];
  96471. /** Gets the animations associated with this bone */
  96472. animations: Animation[];
  96473. /**
  96474. * Gets or sets bone length
  96475. */
  96476. length: number;
  96477. /**
  96478. * @hidden Internal only
  96479. * Set this value to map this bone to a different index in the transform matrices
  96480. * Set this value to -1 to exclude the bone from the transform matrices
  96481. */
  96482. _index: Nullable<number>;
  96483. private _skeleton;
  96484. private _localMatrix;
  96485. private _restPose;
  96486. private _bindPose;
  96487. private _baseMatrix;
  96488. private _absoluteTransform;
  96489. private _invertedAbsoluteTransform;
  96490. private _parent;
  96491. private _scalingDeterminant;
  96492. private _worldTransform;
  96493. private _localScaling;
  96494. private _localRotation;
  96495. private _localPosition;
  96496. private _needToDecompose;
  96497. private _needToCompose;
  96498. /** @hidden */
  96499. _linkedTransformNode: Nullable<TransformNode>;
  96500. /** @hidden */
  96501. _waitingTransformNodeId: Nullable<string>;
  96502. /** @hidden */
  96503. get _matrix(): Matrix;
  96504. /** @hidden */
  96505. set _matrix(value: Matrix);
  96506. /**
  96507. * Create a new bone
  96508. * @param name defines the bone name
  96509. * @param skeleton defines the parent skeleton
  96510. * @param parentBone defines the parent (can be null if the bone is the root)
  96511. * @param localMatrix defines the local matrix
  96512. * @param restPose defines the rest pose matrix
  96513. * @param baseMatrix defines the base matrix
  96514. * @param index defines index of the bone in the hiearchy
  96515. */
  96516. constructor(
  96517. /**
  96518. * defines the bone name
  96519. */
  96520. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  96521. /**
  96522. * Gets the current object class name.
  96523. * @return the class name
  96524. */
  96525. getClassName(): string;
  96526. /**
  96527. * Gets the parent skeleton
  96528. * @returns a skeleton
  96529. */
  96530. getSkeleton(): Skeleton;
  96531. /**
  96532. * Gets parent bone
  96533. * @returns a bone or null if the bone is the root of the bone hierarchy
  96534. */
  96535. getParent(): Nullable<Bone>;
  96536. /**
  96537. * Returns an array containing the root bones
  96538. * @returns an array containing the root bones
  96539. */
  96540. getChildren(): Array<Bone>;
  96541. /**
  96542. * Gets the node index in matrix array generated for rendering
  96543. * @returns the node index
  96544. */
  96545. getIndex(): number;
  96546. /**
  96547. * Sets the parent bone
  96548. * @param parent defines the parent (can be null if the bone is the root)
  96549. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96550. */
  96551. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  96552. /**
  96553. * Gets the local matrix
  96554. * @returns a matrix
  96555. */
  96556. getLocalMatrix(): Matrix;
  96557. /**
  96558. * Gets the base matrix (initial matrix which remains unchanged)
  96559. * @returns a matrix
  96560. */
  96561. getBaseMatrix(): Matrix;
  96562. /**
  96563. * Gets the rest pose matrix
  96564. * @returns a matrix
  96565. */
  96566. getRestPose(): Matrix;
  96567. /**
  96568. * Sets the rest pose matrix
  96569. * @param matrix the local-space rest pose to set for this bone
  96570. */
  96571. setRestPose(matrix: Matrix): void;
  96572. /**
  96573. * Gets the bind pose matrix
  96574. * @returns the bind pose matrix
  96575. */
  96576. getBindPose(): Matrix;
  96577. /**
  96578. * Sets the bind pose matrix
  96579. * @param matrix the local-space bind pose to set for this bone
  96580. */
  96581. setBindPose(matrix: Matrix): void;
  96582. /**
  96583. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  96584. */
  96585. getWorldMatrix(): Matrix;
  96586. /**
  96587. * Sets the local matrix to rest pose matrix
  96588. */
  96589. returnToRest(): void;
  96590. /**
  96591. * Gets the inverse of the absolute transform matrix.
  96592. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  96593. * @returns a matrix
  96594. */
  96595. getInvertedAbsoluteTransform(): Matrix;
  96596. /**
  96597. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  96598. * @returns a matrix
  96599. */
  96600. getAbsoluteTransform(): Matrix;
  96601. /**
  96602. * Links with the given transform node.
  96603. * The local matrix of this bone is copied from the transform node every frame.
  96604. * @param transformNode defines the transform node to link to
  96605. */
  96606. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  96607. /**
  96608. * Gets the node used to drive the bone's transformation
  96609. * @returns a transform node or null
  96610. */
  96611. getTransformNode(): Nullable<TransformNode>;
  96612. /** Gets or sets current position (in local space) */
  96613. get position(): Vector3;
  96614. set position(newPosition: Vector3);
  96615. /** Gets or sets current rotation (in local space) */
  96616. get rotation(): Vector3;
  96617. set rotation(newRotation: Vector3);
  96618. /** Gets or sets current rotation quaternion (in local space) */
  96619. get rotationQuaternion(): Quaternion;
  96620. set rotationQuaternion(newRotation: Quaternion);
  96621. /** Gets or sets current scaling (in local space) */
  96622. get scaling(): Vector3;
  96623. set scaling(newScaling: Vector3);
  96624. /**
  96625. * Gets the animation properties override
  96626. */
  96627. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96628. private _decompose;
  96629. private _compose;
  96630. /**
  96631. * Update the base and local matrices
  96632. * @param matrix defines the new base or local matrix
  96633. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96634. * @param updateLocalMatrix defines if the local matrix should be updated
  96635. */
  96636. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  96637. /** @hidden */
  96638. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  96639. /**
  96640. * Flag the bone as dirty (Forcing it to update everything)
  96641. */
  96642. markAsDirty(): void;
  96643. /** @hidden */
  96644. _markAsDirtyAndCompose(): void;
  96645. private _markAsDirtyAndDecompose;
  96646. /**
  96647. * Translate the bone in local or world space
  96648. * @param vec The amount to translate the bone
  96649. * @param space The space that the translation is in
  96650. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96651. */
  96652. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96653. /**
  96654. * Set the postion of the bone in local or world space
  96655. * @param position The position to set the bone
  96656. * @param space The space that the position is in
  96657. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96658. */
  96659. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96660. /**
  96661. * Set the absolute position of the bone (world space)
  96662. * @param position The position to set the bone
  96663. * @param mesh The mesh that this bone is attached to
  96664. */
  96665. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  96666. /**
  96667. * Scale the bone on the x, y and z axes (in local space)
  96668. * @param x The amount to scale the bone on the x axis
  96669. * @param y The amount to scale the bone on the y axis
  96670. * @param z The amount to scale the bone on the z axis
  96671. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  96672. */
  96673. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  96674. /**
  96675. * Set the bone scaling in local space
  96676. * @param scale defines the scaling vector
  96677. */
  96678. setScale(scale: Vector3): void;
  96679. /**
  96680. * Gets the current scaling in local space
  96681. * @returns the current scaling vector
  96682. */
  96683. getScale(): Vector3;
  96684. /**
  96685. * Gets the current scaling in local space and stores it in a target vector
  96686. * @param result defines the target vector
  96687. */
  96688. getScaleToRef(result: Vector3): void;
  96689. /**
  96690. * Set the yaw, pitch, and roll of the bone in local or world space
  96691. * @param yaw The rotation of the bone on the y axis
  96692. * @param pitch The rotation of the bone on the x axis
  96693. * @param roll The rotation of the bone on the z axis
  96694. * @param space The space that the axes of rotation are in
  96695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96696. */
  96697. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  96698. /**
  96699. * Add a rotation to the bone on an axis in local or world space
  96700. * @param axis The axis to rotate the bone on
  96701. * @param amount The amount to rotate the bone
  96702. * @param space The space that the axis is in
  96703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96704. */
  96705. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  96706. /**
  96707. * Set the rotation of the bone to a particular axis angle in local or world space
  96708. * @param axis The axis to rotate the bone on
  96709. * @param angle The angle that the bone should be rotated to
  96710. * @param space The space that the axis is in
  96711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96712. */
  96713. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  96714. /**
  96715. * Set the euler rotation of the bone in local or world space
  96716. * @param rotation The euler rotation that the bone should be set to
  96717. * @param space The space that the rotation is in
  96718. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96719. */
  96720. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96721. /**
  96722. * Set the quaternion rotation of the bone in local or world space
  96723. * @param quat The quaternion rotation that the bone should be set to
  96724. * @param space The space that the rotation is in
  96725. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96726. */
  96727. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  96728. /**
  96729. * Set the rotation matrix of the bone in local or world space
  96730. * @param rotMat The rotation matrix that the bone should be set to
  96731. * @param space The space that the rotation is in
  96732. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96733. */
  96734. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  96735. private _rotateWithMatrix;
  96736. private _getNegativeRotationToRef;
  96737. /**
  96738. * Get the position of the bone in local or world space
  96739. * @param space The space that the returned position is in
  96740. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96741. * @returns The position of the bone
  96742. */
  96743. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96744. /**
  96745. * Copy the position of the bone to a vector3 in local or world space
  96746. * @param space The space that the returned position is in
  96747. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96748. * @param result The vector3 to copy the position to
  96749. */
  96750. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  96751. /**
  96752. * Get the absolute position of the bone (world space)
  96753. * @param mesh The mesh that this bone is attached to
  96754. * @returns The absolute position of the bone
  96755. */
  96756. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  96757. /**
  96758. * Copy the absolute position of the bone (world space) to the result param
  96759. * @param mesh The mesh that this bone is attached to
  96760. * @param result The vector3 to copy the absolute position to
  96761. */
  96762. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  96763. /**
  96764. * Compute the absolute transforms of this bone and its children
  96765. */
  96766. computeAbsoluteTransforms(): void;
  96767. /**
  96768. * Get the world direction from an axis that is in the local space of the bone
  96769. * @param localAxis The local direction that is used to compute the world direction
  96770. * @param mesh The mesh that this bone is attached to
  96771. * @returns The world direction
  96772. */
  96773. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96774. /**
  96775. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96776. * @param localAxis The local direction that is used to compute the world direction
  96777. * @param mesh The mesh that this bone is attached to
  96778. * @param result The vector3 that the world direction will be copied to
  96779. */
  96780. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96781. /**
  96782. * Get the euler rotation of the bone in local or world space
  96783. * @param space The space that the rotation should be in
  96784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96785. * @returns The euler rotation
  96786. */
  96787. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96788. /**
  96789. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96790. * @param space The space that the rotation should be in
  96791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96792. * @param result The vector3 that the rotation should be copied to
  96793. */
  96794. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96795. /**
  96796. * Get the quaternion rotation of the bone in either local or world space
  96797. * @param space The space that the rotation should be in
  96798. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96799. * @returns The quaternion rotation
  96800. */
  96801. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96802. /**
  96803. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96804. * @param space The space that the rotation should be in
  96805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96806. * @param result The quaternion that the rotation should be copied to
  96807. */
  96808. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96809. /**
  96810. * Get the rotation matrix of the bone in local or world space
  96811. * @param space The space that the rotation should be in
  96812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96813. * @returns The rotation matrix
  96814. */
  96815. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96816. /**
  96817. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96818. * @param space The space that the rotation should be in
  96819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96820. * @param result The quaternion that the rotation should be copied to
  96821. */
  96822. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96823. /**
  96824. * Get the world position of a point that is in the local space of the bone
  96825. * @param position The local position
  96826. * @param mesh The mesh that this bone is attached to
  96827. * @returns The world position
  96828. */
  96829. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96830. /**
  96831. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96832. * @param position The local position
  96833. * @param mesh The mesh that this bone is attached to
  96834. * @param result The vector3 that the world position should be copied to
  96835. */
  96836. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96837. /**
  96838. * Get the local position of a point that is in world space
  96839. * @param position The world position
  96840. * @param mesh The mesh that this bone is attached to
  96841. * @returns The local position
  96842. */
  96843. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96844. /**
  96845. * Get the local position of a point that is in world space and copy it to the result param
  96846. * @param position The world position
  96847. * @param mesh The mesh that this bone is attached to
  96848. * @param result The vector3 that the local position should be copied to
  96849. */
  96850. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96851. /**
  96852. * Set the current local matrix as the restPose for this bone.
  96853. */
  96854. setCurrentPoseAsRest(): void;
  96855. }
  96856. }
  96857. declare module BABYLON {
  96858. /**
  96859. * Defines a runtime animation
  96860. */
  96861. export class RuntimeAnimation {
  96862. private _events;
  96863. /**
  96864. * The current frame of the runtime animation
  96865. */
  96866. private _currentFrame;
  96867. /**
  96868. * The animation used by the runtime animation
  96869. */
  96870. private _animation;
  96871. /**
  96872. * The target of the runtime animation
  96873. */
  96874. private _target;
  96875. /**
  96876. * The initiating animatable
  96877. */
  96878. private _host;
  96879. /**
  96880. * The original value of the runtime animation
  96881. */
  96882. private _originalValue;
  96883. /**
  96884. * The original blend value of the runtime animation
  96885. */
  96886. private _originalBlendValue;
  96887. /**
  96888. * The offsets cache of the runtime animation
  96889. */
  96890. private _offsetsCache;
  96891. /**
  96892. * The high limits cache of the runtime animation
  96893. */
  96894. private _highLimitsCache;
  96895. /**
  96896. * Specifies if the runtime animation has been stopped
  96897. */
  96898. private _stopped;
  96899. /**
  96900. * The blending factor of the runtime animation
  96901. */
  96902. private _blendingFactor;
  96903. /**
  96904. * The BabylonJS scene
  96905. */
  96906. private _scene;
  96907. /**
  96908. * The current value of the runtime animation
  96909. */
  96910. private _currentValue;
  96911. /** @hidden */
  96912. _animationState: _IAnimationState;
  96913. /**
  96914. * The active target of the runtime animation
  96915. */
  96916. private _activeTargets;
  96917. private _currentActiveTarget;
  96918. private _directTarget;
  96919. /**
  96920. * The target path of the runtime animation
  96921. */
  96922. private _targetPath;
  96923. /**
  96924. * The weight of the runtime animation
  96925. */
  96926. private _weight;
  96927. /**
  96928. * The ratio offset of the runtime animation
  96929. */
  96930. private _ratioOffset;
  96931. /**
  96932. * The previous delay of the runtime animation
  96933. */
  96934. private _previousDelay;
  96935. /**
  96936. * The previous ratio of the runtime animation
  96937. */
  96938. private _previousRatio;
  96939. private _enableBlending;
  96940. private _keys;
  96941. private _minFrame;
  96942. private _maxFrame;
  96943. private _minValue;
  96944. private _maxValue;
  96945. private _targetIsArray;
  96946. /**
  96947. * Gets the current frame of the runtime animation
  96948. */
  96949. get currentFrame(): number;
  96950. /**
  96951. * Gets the weight of the runtime animation
  96952. */
  96953. get weight(): number;
  96954. /**
  96955. * Gets the current value of the runtime animation
  96956. */
  96957. get currentValue(): any;
  96958. /**
  96959. * Gets the target path of the runtime animation
  96960. */
  96961. get targetPath(): string;
  96962. /**
  96963. * Gets the actual target of the runtime animation
  96964. */
  96965. get target(): any;
  96966. /**
  96967. * Gets the additive state of the runtime animation
  96968. */
  96969. get isAdditive(): boolean;
  96970. /** @hidden */
  96971. _onLoop: () => void;
  96972. /**
  96973. * Create a new RuntimeAnimation object
  96974. * @param target defines the target of the animation
  96975. * @param animation defines the source animation object
  96976. * @param scene defines the hosting scene
  96977. * @param host defines the initiating Animatable
  96978. */
  96979. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96980. private _preparePath;
  96981. /**
  96982. * Gets the animation from the runtime animation
  96983. */
  96984. get animation(): Animation;
  96985. /**
  96986. * Resets the runtime animation to the beginning
  96987. * @param restoreOriginal defines whether to restore the target property to the original value
  96988. */
  96989. reset(restoreOriginal?: boolean): void;
  96990. /**
  96991. * Specifies if the runtime animation is stopped
  96992. * @returns Boolean specifying if the runtime animation is stopped
  96993. */
  96994. isStopped(): boolean;
  96995. /**
  96996. * Disposes of the runtime animation
  96997. */
  96998. dispose(): void;
  96999. /**
  97000. * Apply the interpolated value to the target
  97001. * @param currentValue defines the value computed by the animation
  97002. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  97003. */
  97004. setValue(currentValue: any, weight: number): void;
  97005. private _getOriginalValues;
  97006. private _setValue;
  97007. /**
  97008. * Gets the loop pmode of the runtime animation
  97009. * @returns Loop Mode
  97010. */
  97011. private _getCorrectLoopMode;
  97012. /**
  97013. * Move the current animation to a given frame
  97014. * @param frame defines the frame to move to
  97015. */
  97016. goToFrame(frame: number): void;
  97017. /**
  97018. * @hidden Internal use only
  97019. */
  97020. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  97021. /**
  97022. * Execute the current animation
  97023. * @param delay defines the delay to add to the current frame
  97024. * @param from defines the lower bound of the animation range
  97025. * @param to defines the upper bound of the animation range
  97026. * @param loop defines if the current animation must loop
  97027. * @param speedRatio defines the current speed ratio
  97028. * @param weight defines the weight of the animation (default is -1 so no weight)
  97029. * @param onLoop optional callback called when animation loops
  97030. * @returns a boolean indicating if the animation is running
  97031. */
  97032. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  97033. }
  97034. }
  97035. declare module BABYLON {
  97036. /**
  97037. * Class used to store an actual running animation
  97038. */
  97039. export class Animatable {
  97040. /** defines the target object */
  97041. target: any;
  97042. /** defines the starting frame number (default is 0) */
  97043. fromFrame: number;
  97044. /** defines the ending frame number (default is 100) */
  97045. toFrame: number;
  97046. /** defines if the animation must loop (default is false) */
  97047. loopAnimation: boolean;
  97048. /** defines a callback to call when animation ends if it is not looping */
  97049. onAnimationEnd?: (() => void) | null | undefined;
  97050. /** defines a callback to call when animation loops */
  97051. onAnimationLoop?: (() => void) | null | undefined;
  97052. /** defines whether the animation should be evaluated additively */
  97053. isAdditive: boolean;
  97054. private _localDelayOffset;
  97055. private _pausedDelay;
  97056. private _runtimeAnimations;
  97057. private _paused;
  97058. private _scene;
  97059. private _speedRatio;
  97060. private _weight;
  97061. private _syncRoot;
  97062. /**
  97063. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  97064. * This will only apply for non looping animation (default is true)
  97065. */
  97066. disposeOnEnd: boolean;
  97067. /**
  97068. * Gets a boolean indicating if the animation has started
  97069. */
  97070. animationStarted: boolean;
  97071. /**
  97072. * Observer raised when the animation ends
  97073. */
  97074. onAnimationEndObservable: Observable<Animatable>;
  97075. /**
  97076. * Observer raised when the animation loops
  97077. */
  97078. onAnimationLoopObservable: Observable<Animatable>;
  97079. /**
  97080. * Gets the root Animatable used to synchronize and normalize animations
  97081. */
  97082. get syncRoot(): Nullable<Animatable>;
  97083. /**
  97084. * Gets the current frame of the first RuntimeAnimation
  97085. * Used to synchronize Animatables
  97086. */
  97087. get masterFrame(): number;
  97088. /**
  97089. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  97090. */
  97091. get weight(): number;
  97092. set weight(value: number);
  97093. /**
  97094. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  97095. */
  97096. get speedRatio(): number;
  97097. set speedRatio(value: number);
  97098. /**
  97099. * Creates a new Animatable
  97100. * @param scene defines the hosting scene
  97101. * @param target defines the target object
  97102. * @param fromFrame defines the starting frame number (default is 0)
  97103. * @param toFrame defines the ending frame number (default is 100)
  97104. * @param loopAnimation defines if the animation must loop (default is false)
  97105. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  97106. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  97107. * @param animations defines a group of animation to add to the new Animatable
  97108. * @param onAnimationLoop defines a callback to call when animation loops
  97109. * @param isAdditive defines whether the animation should be evaluated additively
  97110. */
  97111. constructor(scene: Scene,
  97112. /** defines the target object */
  97113. target: any,
  97114. /** defines the starting frame number (default is 0) */
  97115. fromFrame?: number,
  97116. /** defines the ending frame number (default is 100) */
  97117. toFrame?: number,
  97118. /** defines if the animation must loop (default is false) */
  97119. loopAnimation?: boolean, speedRatio?: number,
  97120. /** defines a callback to call when animation ends if it is not looping */
  97121. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  97122. /** defines a callback to call when animation loops */
  97123. onAnimationLoop?: (() => void) | null | undefined,
  97124. /** defines whether the animation should be evaluated additively */
  97125. isAdditive?: boolean);
  97126. /**
  97127. * Synchronize and normalize current Animatable with a source Animatable
  97128. * This is useful when using animation weights and when animations are not of the same length
  97129. * @param root defines the root Animatable to synchronize with
  97130. * @returns the current Animatable
  97131. */
  97132. syncWith(root: Animatable): Animatable;
  97133. /**
  97134. * Gets the list of runtime animations
  97135. * @returns an array of RuntimeAnimation
  97136. */
  97137. getAnimations(): RuntimeAnimation[];
  97138. /**
  97139. * Adds more animations to the current animatable
  97140. * @param target defines the target of the animations
  97141. * @param animations defines the new animations to add
  97142. */
  97143. appendAnimations(target: any, animations: Animation[]): void;
  97144. /**
  97145. * Gets the source animation for a specific property
  97146. * @param property defines the propertyu to look for
  97147. * @returns null or the source animation for the given property
  97148. */
  97149. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  97150. /**
  97151. * Gets the runtime animation for a specific property
  97152. * @param property defines the propertyu to look for
  97153. * @returns null or the runtime animation for the given property
  97154. */
  97155. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  97156. /**
  97157. * Resets the animatable to its original state
  97158. */
  97159. reset(): void;
  97160. /**
  97161. * Allows the animatable to blend with current running animations
  97162. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97163. * @param blendingSpeed defines the blending speed to use
  97164. */
  97165. enableBlending(blendingSpeed: number): void;
  97166. /**
  97167. * Disable animation blending
  97168. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97169. */
  97170. disableBlending(): void;
  97171. /**
  97172. * Jump directly to a given frame
  97173. * @param frame defines the frame to jump to
  97174. */
  97175. goToFrame(frame: number): void;
  97176. /**
  97177. * Pause the animation
  97178. */
  97179. pause(): void;
  97180. /**
  97181. * Restart the animation
  97182. */
  97183. restart(): void;
  97184. private _raiseOnAnimationEnd;
  97185. /**
  97186. * Stop and delete the current animation
  97187. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  97188. * @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)
  97189. */
  97190. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  97191. /**
  97192. * Wait asynchronously for the animation to end
  97193. * @returns a promise which will be fullfilled when the animation ends
  97194. */
  97195. waitAsync(): Promise<Animatable>;
  97196. /** @hidden */
  97197. _animate(delay: number): boolean;
  97198. }
  97199. interface Scene {
  97200. /** @hidden */
  97201. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  97202. /** @hidden */
  97203. _processLateAnimationBindingsForMatrices(holder: {
  97204. totalWeight: number;
  97205. totalAdditiveWeight: number;
  97206. animations: RuntimeAnimation[];
  97207. additiveAnimations: RuntimeAnimation[];
  97208. originalValue: Matrix;
  97209. }): any;
  97210. /** @hidden */
  97211. _processLateAnimationBindingsForQuaternions(holder: {
  97212. totalWeight: number;
  97213. totalAdditiveWeight: number;
  97214. animations: RuntimeAnimation[];
  97215. additiveAnimations: RuntimeAnimation[];
  97216. originalValue: Quaternion;
  97217. }, refQuaternion: Quaternion): Quaternion;
  97218. /** @hidden */
  97219. _processLateAnimationBindings(): void;
  97220. /**
  97221. * Will start the animation sequence of a given target
  97222. * @param target defines the target
  97223. * @param from defines from which frame should animation start
  97224. * @param to defines until which frame should animation run.
  97225. * @param weight defines the weight to apply to the animation (1.0 by default)
  97226. * @param loop defines if the animation loops
  97227. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  97228. * @param onAnimationEnd defines the function to be executed when the animation ends
  97229. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  97230. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  97231. * @param onAnimationLoop defines the callback to call when an animation loops
  97232. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97233. * @returns the animatable object created for this animation
  97234. */
  97235. 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;
  97236. /**
  97237. * Will start the animation sequence of a given target
  97238. * @param target defines the target
  97239. * @param from defines from which frame should animation start
  97240. * @param to defines until which frame should animation run.
  97241. * @param loop defines if the animation loops
  97242. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  97243. * @param onAnimationEnd defines the function to be executed when the animation ends
  97244. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  97245. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  97246. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  97247. * @param onAnimationLoop defines the callback to call when an animation loops
  97248. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97249. * @returns the animatable object created for this animation
  97250. */
  97251. 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;
  97252. /**
  97253. * Will start the animation sequence of a given target and its hierarchy
  97254. * @param target defines the target
  97255. * @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.
  97256. * @param from defines from which frame should animation start
  97257. * @param to defines until which frame should animation run.
  97258. * @param loop defines if the animation loops
  97259. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  97260. * @param onAnimationEnd defines the function to be executed when the animation ends
  97261. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  97262. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  97263. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  97264. * @param onAnimationLoop defines the callback to call when an animation loops
  97265. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97266. * @returns the list of created animatables
  97267. */
  97268. 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[];
  97269. /**
  97270. * Begin a new animation on a given node
  97271. * @param target defines the target where the animation will take place
  97272. * @param animations defines the list of animations to start
  97273. * @param from defines the initial value
  97274. * @param to defines the final value
  97275. * @param loop defines if you want animation to loop (off by default)
  97276. * @param speedRatio defines the speed ratio to apply to all animations
  97277. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97278. * @param onAnimationLoop defines the callback to call when an animation loops
  97279. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97280. * @returns the list of created animatables
  97281. */
  97282. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  97283. /**
  97284. * Begin a new animation on a given node and its hierarchy
  97285. * @param target defines the root node where the animation will take place
  97286. * @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.
  97287. * @param animations defines the list of animations to start
  97288. * @param from defines the initial value
  97289. * @param to defines the final value
  97290. * @param loop defines if you want animation to loop (off by default)
  97291. * @param speedRatio defines the speed ratio to apply to all animations
  97292. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97293. * @param onAnimationLoop defines the callback to call when an animation loops
  97294. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97295. * @returns the list of animatables created for all nodes
  97296. */
  97297. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  97298. /**
  97299. * Gets the animatable associated with a specific target
  97300. * @param target defines the target of the animatable
  97301. * @returns the required animatable if found
  97302. */
  97303. getAnimatableByTarget(target: any): Nullable<Animatable>;
  97304. /**
  97305. * Gets all animatables associated with a given target
  97306. * @param target defines the target to look animatables for
  97307. * @returns an array of Animatables
  97308. */
  97309. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  97310. /**
  97311. * Stops and removes all animations that have been applied to the scene
  97312. */
  97313. stopAllAnimations(): void;
  97314. /**
  97315. * Gets the current delta time used by animation engine
  97316. */
  97317. deltaTime: number;
  97318. }
  97319. interface Bone {
  97320. /**
  97321. * Copy an animation range from another bone
  97322. * @param source defines the source bone
  97323. * @param rangeName defines the range name to copy
  97324. * @param frameOffset defines the frame offset
  97325. * @param rescaleAsRequired defines if rescaling must be applied if required
  97326. * @param skelDimensionsRatio defines the scaling ratio
  97327. * @returns true if operation was successful
  97328. */
  97329. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  97330. }
  97331. }
  97332. declare module BABYLON {
  97333. /**
  97334. * Class used to handle skinning animations
  97335. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  97336. */
  97337. export class Skeleton implements IAnimatable {
  97338. /** defines the skeleton name */
  97339. name: string;
  97340. /** defines the skeleton Id */
  97341. id: string;
  97342. /**
  97343. * Defines the list of child bones
  97344. */
  97345. bones: Bone[];
  97346. /**
  97347. * Defines an estimate of the dimension of the skeleton at rest
  97348. */
  97349. dimensionsAtRest: Vector3;
  97350. /**
  97351. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  97352. */
  97353. needInitialSkinMatrix: boolean;
  97354. /**
  97355. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  97356. */
  97357. overrideMesh: Nullable<AbstractMesh>;
  97358. /**
  97359. * Gets the list of animations attached to this skeleton
  97360. */
  97361. animations: Array<Animation>;
  97362. private _scene;
  97363. private _isDirty;
  97364. private _transformMatrices;
  97365. private _transformMatrixTexture;
  97366. private _meshesWithPoseMatrix;
  97367. private _animatables;
  97368. private _identity;
  97369. private _synchronizedWithMesh;
  97370. private _ranges;
  97371. private _lastAbsoluteTransformsUpdateId;
  97372. private _canUseTextureForBones;
  97373. private _uniqueId;
  97374. /** @hidden */
  97375. _numBonesWithLinkedTransformNode: number;
  97376. /** @hidden */
  97377. _hasWaitingData: Nullable<boolean>;
  97378. /** @hidden */
  97379. _waitingOverrideMeshId: Nullable<string>;
  97380. /**
  97381. * Specifies if the skeleton should be serialized
  97382. */
  97383. doNotSerialize: boolean;
  97384. private _useTextureToStoreBoneMatrices;
  97385. /**
  97386. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  97387. * Please note that this option is not available if the hardware does not support it
  97388. */
  97389. get useTextureToStoreBoneMatrices(): boolean;
  97390. set useTextureToStoreBoneMatrices(value: boolean);
  97391. private _animationPropertiesOverride;
  97392. /**
  97393. * Gets or sets the animation properties override
  97394. */
  97395. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  97396. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  97397. /**
  97398. * List of inspectable custom properties (used by the Inspector)
  97399. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97400. */
  97401. inspectableCustomProperties: IInspectable[];
  97402. /**
  97403. * An observable triggered before computing the skeleton's matrices
  97404. */
  97405. onBeforeComputeObservable: Observable<Skeleton>;
  97406. /**
  97407. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  97408. */
  97409. get isUsingTextureForMatrices(): boolean;
  97410. /**
  97411. * Gets the unique ID of this skeleton
  97412. */
  97413. get uniqueId(): number;
  97414. /**
  97415. * Creates a new skeleton
  97416. * @param name defines the skeleton name
  97417. * @param id defines the skeleton Id
  97418. * @param scene defines the hosting scene
  97419. */
  97420. constructor(
  97421. /** defines the skeleton name */
  97422. name: string,
  97423. /** defines the skeleton Id */
  97424. id: string, scene: Scene);
  97425. /**
  97426. * Gets the current object class name.
  97427. * @return the class name
  97428. */
  97429. getClassName(): string;
  97430. /**
  97431. * Returns an array containing the root bones
  97432. * @returns an array containing the root bones
  97433. */
  97434. getChildren(): Array<Bone>;
  97435. /**
  97436. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  97437. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  97438. * @returns a Float32Array containing matrices data
  97439. */
  97440. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  97441. /**
  97442. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  97443. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  97444. * @returns a raw texture containing the data
  97445. */
  97446. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  97447. /**
  97448. * Gets the current hosting scene
  97449. * @returns a scene object
  97450. */
  97451. getScene(): Scene;
  97452. /**
  97453. * Gets a string representing the current skeleton data
  97454. * @param fullDetails defines a boolean indicating if we want a verbose version
  97455. * @returns a string representing the current skeleton data
  97456. */
  97457. toString(fullDetails?: boolean): string;
  97458. /**
  97459. * Get bone's index searching by name
  97460. * @param name defines bone's name to search for
  97461. * @return the indice of the bone. Returns -1 if not found
  97462. */
  97463. getBoneIndexByName(name: string): number;
  97464. /**
  97465. * Creater a new animation range
  97466. * @param name defines the name of the range
  97467. * @param from defines the start key
  97468. * @param to defines the end key
  97469. */
  97470. createAnimationRange(name: string, from: number, to: number): void;
  97471. /**
  97472. * Delete a specific animation range
  97473. * @param name defines the name of the range
  97474. * @param deleteFrames defines if frames must be removed as well
  97475. */
  97476. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97477. /**
  97478. * Gets a specific animation range
  97479. * @param name defines the name of the range to look for
  97480. * @returns the requested animation range or null if not found
  97481. */
  97482. getAnimationRange(name: string): Nullable<AnimationRange>;
  97483. /**
  97484. * Gets the list of all animation ranges defined on this skeleton
  97485. * @returns an array
  97486. */
  97487. getAnimationRanges(): Nullable<AnimationRange>[];
  97488. /**
  97489. * Copy animation range from a source skeleton.
  97490. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  97491. * @param source defines the source skeleton
  97492. * @param name defines the name of the range to copy
  97493. * @param rescaleAsRequired defines if rescaling must be applied if required
  97494. * @returns true if operation was successful
  97495. */
  97496. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  97497. /**
  97498. * Forces the skeleton to go to rest pose
  97499. */
  97500. returnToRest(): void;
  97501. private _getHighestAnimationFrame;
  97502. /**
  97503. * Begin a specific animation range
  97504. * @param name defines the name of the range to start
  97505. * @param loop defines if looping must be turned on (false by default)
  97506. * @param speedRatio defines the speed ratio to apply (1 by default)
  97507. * @param onAnimationEnd defines a callback which will be called when animation will end
  97508. * @returns a new animatable
  97509. */
  97510. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97511. /**
  97512. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  97513. * @param skeleton defines the Skeleton containing the animation range to convert
  97514. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  97515. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  97516. * @returns the original skeleton
  97517. */
  97518. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  97519. /** @hidden */
  97520. _markAsDirty(): void;
  97521. /** @hidden */
  97522. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97523. /** @hidden */
  97524. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97525. private _computeTransformMatrices;
  97526. /**
  97527. * Build all resources required to render a skeleton
  97528. */
  97529. prepare(): void;
  97530. /**
  97531. * Gets the list of animatables currently running for this skeleton
  97532. * @returns an array of animatables
  97533. */
  97534. getAnimatables(): IAnimatable[];
  97535. /**
  97536. * Clone the current skeleton
  97537. * @param name defines the name of the new skeleton
  97538. * @param id defines the id of the new skeleton
  97539. * @returns the new skeleton
  97540. */
  97541. clone(name: string, id?: string): Skeleton;
  97542. /**
  97543. * Enable animation blending for this skeleton
  97544. * @param blendingSpeed defines the blending speed to apply
  97545. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97546. */
  97547. enableBlending(blendingSpeed?: number): void;
  97548. /**
  97549. * Releases all resources associated with the current skeleton
  97550. */
  97551. dispose(): void;
  97552. /**
  97553. * Serialize the skeleton in a JSON object
  97554. * @returns a JSON object
  97555. */
  97556. serialize(): any;
  97557. /**
  97558. * Creates a new skeleton from serialized data
  97559. * @param parsedSkeleton defines the serialized data
  97560. * @param scene defines the hosting scene
  97561. * @returns a new skeleton
  97562. */
  97563. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  97564. /**
  97565. * Compute all node absolute transforms
  97566. * @param forceUpdate defines if computation must be done even if cache is up to date
  97567. */
  97568. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  97569. /**
  97570. * Gets the root pose matrix
  97571. * @returns a matrix
  97572. */
  97573. getPoseMatrix(): Nullable<Matrix>;
  97574. /**
  97575. * Sorts bones per internal index
  97576. */
  97577. sortBones(): void;
  97578. private _sortBones;
  97579. /**
  97580. * Set the current local matrix as the restPose for all bones in the skeleton.
  97581. */
  97582. setCurrentPoseAsRest(): void;
  97583. }
  97584. }
  97585. declare module BABYLON {
  97586. /**
  97587. * Creates an instance based on a source mesh.
  97588. */
  97589. export class InstancedMesh extends AbstractMesh {
  97590. private _sourceMesh;
  97591. private _currentLOD;
  97592. /** @hidden */
  97593. _indexInSourceMeshInstanceArray: number;
  97594. constructor(name: string, source: Mesh);
  97595. /**
  97596. * Returns the string "InstancedMesh".
  97597. */
  97598. getClassName(): string;
  97599. /** Gets the list of lights affecting that mesh */
  97600. get lightSources(): Light[];
  97601. _resyncLightSources(): void;
  97602. _resyncLightSource(light: Light): void;
  97603. _removeLightSource(light: Light, dispose: boolean): void;
  97604. /**
  97605. * If the source mesh receives shadows
  97606. */
  97607. get receiveShadows(): boolean;
  97608. /**
  97609. * The material of the source mesh
  97610. */
  97611. get material(): Nullable<Material>;
  97612. /**
  97613. * Visibility of the source mesh
  97614. */
  97615. get visibility(): number;
  97616. /**
  97617. * Skeleton of the source mesh
  97618. */
  97619. get skeleton(): Nullable<Skeleton>;
  97620. /**
  97621. * Rendering ground id of the source mesh
  97622. */
  97623. get renderingGroupId(): number;
  97624. set renderingGroupId(value: number);
  97625. /**
  97626. * Returns the total number of vertices (integer).
  97627. */
  97628. getTotalVertices(): number;
  97629. /**
  97630. * Returns a positive integer : the total number of indices in this mesh geometry.
  97631. * @returns the numner of indices or zero if the mesh has no geometry.
  97632. */
  97633. getTotalIndices(): number;
  97634. /**
  97635. * The source mesh of the instance
  97636. */
  97637. get sourceMesh(): Mesh;
  97638. /**
  97639. * Creates a new InstancedMesh object from the mesh model.
  97640. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97641. * @param name defines the name of the new instance
  97642. * @returns a new InstancedMesh
  97643. */
  97644. createInstance(name: string): InstancedMesh;
  97645. /**
  97646. * Is this node ready to be used/rendered
  97647. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97648. * @return {boolean} is it ready
  97649. */
  97650. isReady(completeCheck?: boolean): boolean;
  97651. /**
  97652. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97653. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97654. * @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.
  97655. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97656. */
  97657. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  97658. /**
  97659. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97660. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97661. * The `data` are either a numeric array either a Float32Array.
  97662. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97663. * 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).
  97664. * Note that a new underlying VertexBuffer object is created each call.
  97665. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97666. *
  97667. * Possible `kind` values :
  97668. * - VertexBuffer.PositionKind
  97669. * - VertexBuffer.UVKind
  97670. * - VertexBuffer.UV2Kind
  97671. * - VertexBuffer.UV3Kind
  97672. * - VertexBuffer.UV4Kind
  97673. * - VertexBuffer.UV5Kind
  97674. * - VertexBuffer.UV6Kind
  97675. * - VertexBuffer.ColorKind
  97676. * - VertexBuffer.MatricesIndicesKind
  97677. * - VertexBuffer.MatricesIndicesExtraKind
  97678. * - VertexBuffer.MatricesWeightsKind
  97679. * - VertexBuffer.MatricesWeightsExtraKind
  97680. *
  97681. * Returns the Mesh.
  97682. */
  97683. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97684. /**
  97685. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97686. * If the mesh has no geometry, it is simply returned as it is.
  97687. * The `data` are either a numeric array either a Float32Array.
  97688. * No new underlying VertexBuffer object is created.
  97689. * 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.
  97690. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97691. *
  97692. * Possible `kind` values :
  97693. * - VertexBuffer.PositionKind
  97694. * - VertexBuffer.UVKind
  97695. * - VertexBuffer.UV2Kind
  97696. * - VertexBuffer.UV3Kind
  97697. * - VertexBuffer.UV4Kind
  97698. * - VertexBuffer.UV5Kind
  97699. * - VertexBuffer.UV6Kind
  97700. * - VertexBuffer.ColorKind
  97701. * - VertexBuffer.MatricesIndicesKind
  97702. * - VertexBuffer.MatricesIndicesExtraKind
  97703. * - VertexBuffer.MatricesWeightsKind
  97704. * - VertexBuffer.MatricesWeightsExtraKind
  97705. *
  97706. * Returns the Mesh.
  97707. */
  97708. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  97709. /**
  97710. * Sets the mesh indices.
  97711. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97712. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97713. * This method creates a new index buffer each call.
  97714. * Returns the Mesh.
  97715. */
  97716. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  97717. /**
  97718. * Boolean : True if the mesh owns the requested kind of data.
  97719. */
  97720. isVerticesDataPresent(kind: string): boolean;
  97721. /**
  97722. * Returns an array of indices (IndicesArray).
  97723. */
  97724. getIndices(): Nullable<IndicesArray>;
  97725. get _positions(): Nullable<Vector3[]>;
  97726. /**
  97727. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97728. * This means the mesh underlying bounding box and sphere are recomputed.
  97729. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97730. * @returns the current mesh
  97731. */
  97732. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  97733. /** @hidden */
  97734. _preActivate(): InstancedMesh;
  97735. /** @hidden */
  97736. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97737. /** @hidden */
  97738. _postActivate(): void;
  97739. getWorldMatrix(): Matrix;
  97740. get isAnInstance(): boolean;
  97741. /**
  97742. * Returns the current associated LOD AbstractMesh.
  97743. */
  97744. getLOD(camera: Camera): AbstractMesh;
  97745. /** @hidden */
  97746. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97747. /** @hidden */
  97748. _syncSubMeshes(): InstancedMesh;
  97749. /** @hidden */
  97750. _generatePointsArray(): boolean;
  97751. /** @hidden */
  97752. _updateBoundingInfo(): AbstractMesh;
  97753. /**
  97754. * Creates a new InstancedMesh from the current mesh.
  97755. * - name (string) : the cloned mesh name
  97756. * - newParent (optional Node) : the optional Node to parent the clone to.
  97757. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97758. *
  97759. * Returns the clone.
  97760. */
  97761. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  97762. /**
  97763. * Disposes the InstancedMesh.
  97764. * Returns nothing.
  97765. */
  97766. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97767. }
  97768. interface Mesh {
  97769. /**
  97770. * Register a custom buffer that will be instanced
  97771. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97772. * @param kind defines the buffer kind
  97773. * @param stride defines the stride in floats
  97774. */
  97775. registerInstancedBuffer(kind: string, stride: number): void;
  97776. /**
  97777. * true to use the edge renderer for all instances of this mesh
  97778. */
  97779. edgesShareWithInstances: boolean;
  97780. /** @hidden */
  97781. _userInstancedBuffersStorage: {
  97782. data: {
  97783. [key: string]: Float32Array;
  97784. };
  97785. sizes: {
  97786. [key: string]: number;
  97787. };
  97788. vertexBuffers: {
  97789. [key: string]: Nullable<VertexBuffer>;
  97790. };
  97791. strides: {
  97792. [key: string]: number;
  97793. };
  97794. };
  97795. }
  97796. interface AbstractMesh {
  97797. /**
  97798. * Object used to store instanced buffers defined by user
  97799. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97800. */
  97801. instancedBuffers: {
  97802. [key: string]: any;
  97803. };
  97804. }
  97805. }
  97806. declare module BABYLON {
  97807. /**
  97808. * Defines the options associated with the creation of a shader material.
  97809. */
  97810. export interface IShaderMaterialOptions {
  97811. /**
  97812. * Does the material work in alpha blend mode
  97813. */
  97814. needAlphaBlending: boolean;
  97815. /**
  97816. * Does the material work in alpha test mode
  97817. */
  97818. needAlphaTesting: boolean;
  97819. /**
  97820. * The list of attribute names used in the shader
  97821. */
  97822. attributes: string[];
  97823. /**
  97824. * The list of unifrom names used in the shader
  97825. */
  97826. uniforms: string[];
  97827. /**
  97828. * The list of UBO names used in the shader
  97829. */
  97830. uniformBuffers: string[];
  97831. /**
  97832. * The list of sampler names used in the shader
  97833. */
  97834. samplers: string[];
  97835. /**
  97836. * The list of defines used in the shader
  97837. */
  97838. defines: string[];
  97839. }
  97840. /**
  97841. * 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.
  97842. *
  97843. * This returned material effects how the mesh will look based on the code in the shaders.
  97844. *
  97845. * @see https://doc.babylonjs.com/how_to/shader_material
  97846. */
  97847. export class ShaderMaterial extends Material {
  97848. private _shaderPath;
  97849. private _options;
  97850. private _textures;
  97851. private _textureArrays;
  97852. private _floats;
  97853. private _ints;
  97854. private _floatsArrays;
  97855. private _colors3;
  97856. private _colors3Arrays;
  97857. private _colors4;
  97858. private _colors4Arrays;
  97859. private _vectors2;
  97860. private _vectors3;
  97861. private _vectors4;
  97862. private _matrices;
  97863. private _matrixArrays;
  97864. private _matrices3x3;
  97865. private _matrices2x2;
  97866. private _vectors2Arrays;
  97867. private _vectors3Arrays;
  97868. private _vectors4Arrays;
  97869. private _cachedWorldViewMatrix;
  97870. private _cachedWorldViewProjectionMatrix;
  97871. private _renderId;
  97872. private _multiview;
  97873. private _cachedDefines;
  97874. /** Define the Url to load snippets */
  97875. static SnippetUrl: string;
  97876. /** Snippet ID if the material was created from the snippet server */
  97877. snippetId: string;
  97878. /**
  97879. * Instantiate a new shader material.
  97880. * 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.
  97881. * This returned material effects how the mesh will look based on the code in the shaders.
  97882. * @see https://doc.babylonjs.com/how_to/shader_material
  97883. * @param name Define the name of the material in the scene
  97884. * @param scene Define the scene the material belongs to
  97885. * @param shaderPath Defines the route to the shader code in one of three ways:
  97886. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97887. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97888. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97889. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97890. * @param options Define the options used to create the shader
  97891. */
  97892. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97893. /**
  97894. * Gets the shader path used to define the shader code
  97895. * It can be modified to trigger a new compilation
  97896. */
  97897. get shaderPath(): any;
  97898. /**
  97899. * Sets the shader path used to define the shader code
  97900. * It can be modified to trigger a new compilation
  97901. */
  97902. set shaderPath(shaderPath: any);
  97903. /**
  97904. * Gets the options used to compile the shader.
  97905. * They can be modified to trigger a new compilation
  97906. */
  97907. get options(): IShaderMaterialOptions;
  97908. /**
  97909. * Gets the current class name of the material e.g. "ShaderMaterial"
  97910. * Mainly use in serialization.
  97911. * @returns the class name
  97912. */
  97913. getClassName(): string;
  97914. /**
  97915. * Specifies if the material will require alpha blending
  97916. * @returns a boolean specifying if alpha blending is needed
  97917. */
  97918. needAlphaBlending(): boolean;
  97919. /**
  97920. * Specifies if this material should be rendered in alpha test mode
  97921. * @returns a boolean specifying if an alpha test is needed.
  97922. */
  97923. needAlphaTesting(): boolean;
  97924. private _checkUniform;
  97925. /**
  97926. * Set a texture in the shader.
  97927. * @param name Define the name of the uniform samplers as defined in the shader
  97928. * @param texture Define the texture to bind to this sampler
  97929. * @return the material itself allowing "fluent" like uniform updates
  97930. */
  97931. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97932. /**
  97933. * Set a texture array in the shader.
  97934. * @param name Define the name of the uniform sampler array as defined in the shader
  97935. * @param textures Define the list of textures to bind to this sampler
  97936. * @return the material itself allowing "fluent" like uniform updates
  97937. */
  97938. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97939. /**
  97940. * Set a float in the shader.
  97941. * @param name Define the name of the uniform as defined in the shader
  97942. * @param value Define the value to give to the uniform
  97943. * @return the material itself allowing "fluent" like uniform updates
  97944. */
  97945. setFloat(name: string, value: number): ShaderMaterial;
  97946. /**
  97947. * Set a int in the shader.
  97948. * @param name Define the name of the uniform as defined in the shader
  97949. * @param value Define the value to give to the uniform
  97950. * @return the material itself allowing "fluent" like uniform updates
  97951. */
  97952. setInt(name: string, value: number): ShaderMaterial;
  97953. /**
  97954. * Set an array of floats in the shader.
  97955. * @param name Define the name of the uniform as defined in the shader
  97956. * @param value Define the value to give to the uniform
  97957. * @return the material itself allowing "fluent" like uniform updates
  97958. */
  97959. setFloats(name: string, value: number[]): ShaderMaterial;
  97960. /**
  97961. * Set a vec3 in the shader from a Color3.
  97962. * @param name Define the name of the uniform as defined in the shader
  97963. * @param value Define the value to give to the uniform
  97964. * @return the material itself allowing "fluent" like uniform updates
  97965. */
  97966. setColor3(name: string, value: Color3): ShaderMaterial;
  97967. /**
  97968. * Set a vec3 array in the shader from a Color3 array.
  97969. * @param name Define the name of the uniform as defined in the shader
  97970. * @param value Define the value to give to the uniform
  97971. * @return the material itself allowing "fluent" like uniform updates
  97972. */
  97973. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97974. /**
  97975. * Set a vec4 in the shader from a Color4.
  97976. * @param name Define the name of the uniform as defined in the shader
  97977. * @param value Define the value to give to the uniform
  97978. * @return the material itself allowing "fluent" like uniform updates
  97979. */
  97980. setColor4(name: string, value: Color4): ShaderMaterial;
  97981. /**
  97982. * Set a vec4 array in the shader from a Color4 array.
  97983. * @param name Define the name of the uniform as defined in the shader
  97984. * @param value Define the value to give to the uniform
  97985. * @return the material itself allowing "fluent" like uniform updates
  97986. */
  97987. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97988. /**
  97989. * Set a vec2 in the shader from a Vector2.
  97990. * @param name Define the name of the uniform as defined in the shader
  97991. * @param value Define the value to give to the uniform
  97992. * @return the material itself allowing "fluent" like uniform updates
  97993. */
  97994. setVector2(name: string, value: Vector2): ShaderMaterial;
  97995. /**
  97996. * Set a vec3 in the shader from a Vector3.
  97997. * @param name Define the name of the uniform as defined in the shader
  97998. * @param value Define the value to give to the uniform
  97999. * @return the material itself allowing "fluent" like uniform updates
  98000. */
  98001. setVector3(name: string, value: Vector3): ShaderMaterial;
  98002. /**
  98003. * Set a vec4 in the shader from a Vector4.
  98004. * @param name Define the name of the uniform as defined in the shader
  98005. * @param value Define the value to give to the uniform
  98006. * @return the material itself allowing "fluent" like uniform updates
  98007. */
  98008. setVector4(name: string, value: Vector4): ShaderMaterial;
  98009. /**
  98010. * Set a mat4 in the shader from a Matrix.
  98011. * @param name Define the name of the uniform as defined in the shader
  98012. * @param value Define the value to give to the uniform
  98013. * @return the material itself allowing "fluent" like uniform updates
  98014. */
  98015. setMatrix(name: string, value: Matrix): ShaderMaterial;
  98016. /**
  98017. * Set a float32Array in the shader from a matrix array.
  98018. * @param name Define the name of the uniform as defined in the shader
  98019. * @param value Define the value to give to the uniform
  98020. * @return the material itself allowing "fluent" like uniform updates
  98021. */
  98022. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  98023. /**
  98024. * Set a mat3 in the shader from a Float32Array.
  98025. * @param name Define the name of the uniform as defined in the shader
  98026. * @param value Define the value to give to the uniform
  98027. * @return the material itself allowing "fluent" like uniform updates
  98028. */
  98029. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  98030. /**
  98031. * Set a mat2 in the shader from a Float32Array.
  98032. * @param name Define the name of the uniform as defined in the shader
  98033. * @param value Define the value to give to the uniform
  98034. * @return the material itself allowing "fluent" like uniform updates
  98035. */
  98036. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  98037. /**
  98038. * Set a vec2 array in the shader from a number array.
  98039. * @param name Define the name of the uniform as defined in the shader
  98040. * @param value Define the value to give to the uniform
  98041. * @return the material itself allowing "fluent" like uniform updates
  98042. */
  98043. setArray2(name: string, value: number[]): ShaderMaterial;
  98044. /**
  98045. * Set a vec3 array in the shader from a number array.
  98046. * @param name Define the name of the uniform as defined in the shader
  98047. * @param value Define the value to give to the uniform
  98048. * @return the material itself allowing "fluent" like uniform updates
  98049. */
  98050. setArray3(name: string, value: number[]): ShaderMaterial;
  98051. /**
  98052. * Set a vec4 array in the shader from a number array.
  98053. * @param name Define the name of the uniform as defined in the shader
  98054. * @param value Define the value to give to the uniform
  98055. * @return the material itself allowing "fluent" like uniform updates
  98056. */
  98057. setArray4(name: string, value: number[]): ShaderMaterial;
  98058. private _checkCache;
  98059. /**
  98060. * Specifies that the submesh is ready to be used
  98061. * @param mesh defines the mesh to check
  98062. * @param subMesh defines which submesh to check
  98063. * @param useInstances specifies that instances should be used
  98064. * @returns a boolean indicating that the submesh is ready or not
  98065. */
  98066. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98067. /**
  98068. * Checks if the material is ready to render the requested mesh
  98069. * @param mesh Define the mesh to render
  98070. * @param useInstances Define whether or not the material is used with instances
  98071. * @returns true if ready, otherwise false
  98072. */
  98073. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98074. /**
  98075. * Binds the world matrix to the material
  98076. * @param world defines the world transformation matrix
  98077. * @param effectOverride - If provided, use this effect instead of internal effect
  98078. */
  98079. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  98080. /**
  98081. * Binds the submesh to this material by preparing the effect and shader to draw
  98082. * @param world defines the world transformation matrix
  98083. * @param mesh defines the mesh containing the submesh
  98084. * @param subMesh defines the submesh to bind the material to
  98085. */
  98086. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98087. /**
  98088. * Binds the material to the mesh
  98089. * @param world defines the world transformation matrix
  98090. * @param mesh defines the mesh to bind the material to
  98091. * @param effectOverride - If provided, use this effect instead of internal effect
  98092. */
  98093. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  98094. protected _afterBind(mesh?: Mesh): void;
  98095. /**
  98096. * Gets the active textures from the material
  98097. * @returns an array of textures
  98098. */
  98099. getActiveTextures(): BaseTexture[];
  98100. /**
  98101. * Specifies if the material uses a texture
  98102. * @param texture defines the texture to check against the material
  98103. * @returns a boolean specifying if the material uses the texture
  98104. */
  98105. hasTexture(texture: BaseTexture): boolean;
  98106. /**
  98107. * Makes a duplicate of the material, and gives it a new name
  98108. * @param name defines the new name for the duplicated material
  98109. * @returns the cloned material
  98110. */
  98111. clone(name: string): ShaderMaterial;
  98112. /**
  98113. * Disposes the material
  98114. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98115. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98116. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  98117. */
  98118. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  98119. /**
  98120. * Serializes this material in a JSON representation
  98121. * @returns the serialized material object
  98122. */
  98123. serialize(): any;
  98124. /**
  98125. * Creates a shader material from parsed shader material data
  98126. * @param source defines the JSON represnetation of the material
  98127. * @param scene defines the hosting scene
  98128. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98129. * @returns a new material
  98130. */
  98131. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  98132. /**
  98133. * Creates a new ShaderMaterial from a snippet saved in a remote file
  98134. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  98135. * @param url defines the url to load from
  98136. * @param scene defines the hosting scene
  98137. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98138. * @returns a promise that will resolve to the new ShaderMaterial
  98139. */
  98140. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  98141. /**
  98142. * Creates a ShaderMaterial from a snippet saved by the Inspector
  98143. * @param snippetId defines the snippet to load
  98144. * @param scene defines the hosting scene
  98145. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98146. * @returns a promise that will resolve to the new ShaderMaterial
  98147. */
  98148. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  98149. }
  98150. }
  98151. declare module BABYLON {
  98152. /** @hidden */
  98153. export var colorPixelShader: {
  98154. name: string;
  98155. shader: string;
  98156. };
  98157. }
  98158. declare module BABYLON {
  98159. /** @hidden */
  98160. export var colorVertexShader: {
  98161. name: string;
  98162. shader: string;
  98163. };
  98164. }
  98165. declare module BABYLON {
  98166. /**
  98167. * Line mesh
  98168. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  98169. */
  98170. export class LinesMesh extends Mesh {
  98171. /**
  98172. * If vertex color should be applied to the mesh
  98173. */
  98174. readonly useVertexColor?: boolean | undefined;
  98175. /**
  98176. * If vertex alpha should be applied to the mesh
  98177. */
  98178. readonly useVertexAlpha?: boolean | undefined;
  98179. /**
  98180. * Color of the line (Default: White)
  98181. */
  98182. color: Color3;
  98183. /**
  98184. * Alpha of the line (Default: 1)
  98185. */
  98186. alpha: number;
  98187. /**
  98188. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  98189. * This margin is expressed in world space coordinates, so its value may vary.
  98190. * Default value is 0.1
  98191. */
  98192. intersectionThreshold: number;
  98193. private _colorShader;
  98194. private color4;
  98195. /**
  98196. * Creates a new LinesMesh
  98197. * @param name defines the name
  98198. * @param scene defines the hosting scene
  98199. * @param parent defines the parent mesh if any
  98200. * @param source defines the optional source LinesMesh used to clone data from
  98201. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98202. * When false, achieved by calling a clone(), also passing False.
  98203. * This will make creation of children, recursive.
  98204. * @param useVertexColor defines if this LinesMesh supports vertex color
  98205. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  98206. */
  98207. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  98208. /**
  98209. * If vertex color should be applied to the mesh
  98210. */
  98211. useVertexColor?: boolean | undefined,
  98212. /**
  98213. * If vertex alpha should be applied to the mesh
  98214. */
  98215. useVertexAlpha?: boolean | undefined);
  98216. private _addClipPlaneDefine;
  98217. private _removeClipPlaneDefine;
  98218. isReady(): boolean;
  98219. /**
  98220. * Returns the string "LineMesh"
  98221. */
  98222. getClassName(): string;
  98223. /**
  98224. * @hidden
  98225. */
  98226. get material(): Material;
  98227. /**
  98228. * @hidden
  98229. */
  98230. set material(value: Material);
  98231. /**
  98232. * @hidden
  98233. */
  98234. get checkCollisions(): boolean;
  98235. /** @hidden */
  98236. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98237. /** @hidden */
  98238. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98239. /**
  98240. * Disposes of the line mesh
  98241. * @param doNotRecurse If children should be disposed
  98242. */
  98243. dispose(doNotRecurse?: boolean): void;
  98244. /**
  98245. * Returns a new LineMesh object cloned from the current one.
  98246. */
  98247. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  98248. /**
  98249. * Creates a new InstancedLinesMesh object from the mesh model.
  98250. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  98251. * @param name defines the name of the new instance
  98252. * @returns a new InstancedLinesMesh
  98253. */
  98254. createInstance(name: string): InstancedLinesMesh;
  98255. }
  98256. /**
  98257. * Creates an instance based on a source LinesMesh
  98258. */
  98259. export class InstancedLinesMesh extends InstancedMesh {
  98260. /**
  98261. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  98262. * This margin is expressed in world space coordinates, so its value may vary.
  98263. * Initilized with the intersectionThreshold value of the source LinesMesh
  98264. */
  98265. intersectionThreshold: number;
  98266. constructor(name: string, source: LinesMesh);
  98267. /**
  98268. * Returns the string "InstancedLinesMesh".
  98269. */
  98270. getClassName(): string;
  98271. }
  98272. }
  98273. declare module BABYLON {
  98274. /** @hidden */
  98275. export var linePixelShader: {
  98276. name: string;
  98277. shader: string;
  98278. };
  98279. }
  98280. declare module BABYLON {
  98281. /** @hidden */
  98282. export var lineVertexShader: {
  98283. name: string;
  98284. shader: string;
  98285. };
  98286. }
  98287. declare module BABYLON {
  98288. interface Scene {
  98289. /** @hidden */
  98290. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  98291. }
  98292. interface AbstractMesh {
  98293. /**
  98294. * Gets the edgesRenderer associated with the mesh
  98295. */
  98296. edgesRenderer: Nullable<EdgesRenderer>;
  98297. }
  98298. interface LinesMesh {
  98299. /**
  98300. * Enables the edge rendering mode on the mesh.
  98301. * This mode makes the mesh edges visible
  98302. * @param epsilon defines the maximal distance between two angles to detect a face
  98303. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98304. * @returns the currentAbstractMesh
  98305. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98306. */
  98307. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  98308. }
  98309. interface InstancedLinesMesh {
  98310. /**
  98311. * Enables the edge rendering mode on the mesh.
  98312. * This mode makes the mesh edges visible
  98313. * @param epsilon defines the maximal distance between two angles to detect a face
  98314. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98315. * @returns the current InstancedLinesMesh
  98316. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98317. */
  98318. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  98319. }
  98320. /**
  98321. * Defines the minimum contract an Edges renderer should follow.
  98322. */
  98323. export interface IEdgesRenderer extends IDisposable {
  98324. /**
  98325. * Gets or sets a boolean indicating if the edgesRenderer is active
  98326. */
  98327. isEnabled: boolean;
  98328. /**
  98329. * Renders the edges of the attached mesh,
  98330. */
  98331. render(): void;
  98332. /**
  98333. * Checks wether or not the edges renderer is ready to render.
  98334. * @return true if ready, otherwise false.
  98335. */
  98336. isReady(): boolean;
  98337. /**
  98338. * List of instances to render in case the source mesh has instances
  98339. */
  98340. customInstances: SmartArray<Matrix>;
  98341. }
  98342. /**
  98343. * Defines the additional options of the edges renderer
  98344. */
  98345. export interface IEdgesRendererOptions {
  98346. /**
  98347. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  98348. * If not defined, the default value is true
  98349. */
  98350. useAlternateEdgeFinder?: boolean;
  98351. /**
  98352. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  98353. * If not defined, the default value is true.
  98354. * 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)
  98355. * This option is used only if useAlternateEdgeFinder = true
  98356. */
  98357. useFastVertexMerger?: boolean;
  98358. /**
  98359. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  98360. * The default value is 1e-6
  98361. * This option is used only if useAlternateEdgeFinder = true
  98362. */
  98363. epsilonVertexMerge?: number;
  98364. /**
  98365. * 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
  98366. * 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.
  98367. * This option is used only if useAlternateEdgeFinder = true
  98368. */
  98369. applyTessellation?: boolean;
  98370. /**
  98371. * 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
  98372. * The default value is 1e-6
  98373. * This option is used only if useAlternateEdgeFinder = true
  98374. */
  98375. epsilonVertexAligned?: number;
  98376. }
  98377. /**
  98378. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  98379. */
  98380. export class EdgesRenderer implements IEdgesRenderer {
  98381. /**
  98382. * Define the size of the edges with an orthographic camera
  98383. */
  98384. edgesWidthScalerForOrthographic: number;
  98385. /**
  98386. * Define the size of the edges with a perspective camera
  98387. */
  98388. edgesWidthScalerForPerspective: number;
  98389. protected _source: AbstractMesh;
  98390. protected _linesPositions: number[];
  98391. protected _linesNormals: number[];
  98392. protected _linesIndices: number[];
  98393. protected _epsilon: number;
  98394. protected _indicesCount: number;
  98395. protected _lineShader: ShaderMaterial;
  98396. protected _ib: DataBuffer;
  98397. protected _buffers: {
  98398. [key: string]: Nullable<VertexBuffer>;
  98399. };
  98400. protected _buffersForInstances: {
  98401. [key: string]: Nullable<VertexBuffer>;
  98402. };
  98403. protected _checkVerticesInsteadOfIndices: boolean;
  98404. protected _options: Nullable<IEdgesRendererOptions>;
  98405. private _meshRebuildObserver;
  98406. private _meshDisposeObserver;
  98407. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  98408. isEnabled: boolean;
  98409. /**
  98410. * List of instances to render in case the source mesh has instances
  98411. */
  98412. customInstances: SmartArray<Matrix>;
  98413. private static GetShader;
  98414. /**
  98415. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  98416. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  98417. * @param source Mesh used to create edges
  98418. * @param epsilon sum of angles in adjacency to check for edge
  98419. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  98420. * @param generateEdgesLines - should generate Lines or only prepare resources.
  98421. * @param options The options to apply when generating the edges
  98422. */
  98423. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  98424. protected _prepareRessources(): void;
  98425. /** @hidden */
  98426. _rebuild(): void;
  98427. /**
  98428. * Releases the required resources for the edges renderer
  98429. */
  98430. dispose(): void;
  98431. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  98432. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  98433. /**
  98434. * Checks if the pair of p0 and p1 is en edge
  98435. * @param faceIndex
  98436. * @param edge
  98437. * @param faceNormals
  98438. * @param p0
  98439. * @param p1
  98440. * @private
  98441. */
  98442. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  98443. /**
  98444. * push line into the position, normal and index buffer
  98445. * @protected
  98446. */
  98447. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  98448. /**
  98449. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  98450. */
  98451. private _tessellateTriangle;
  98452. private _generateEdgesLinesAlternate;
  98453. /**
  98454. * Generates lines edges from adjacencjes
  98455. * @private
  98456. */
  98457. _generateEdgesLines(): void;
  98458. /**
  98459. * Checks wether or not the edges renderer is ready to render.
  98460. * @return true if ready, otherwise false.
  98461. */
  98462. isReady(): boolean;
  98463. /**
  98464. * Renders the edges of the attached mesh,
  98465. */
  98466. render(): void;
  98467. }
  98468. /**
  98469. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  98470. */
  98471. export class LineEdgesRenderer extends EdgesRenderer {
  98472. /**
  98473. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  98474. * @param source LineMesh used to generate edges
  98475. * @param epsilon not important (specified angle for edge detection)
  98476. * @param checkVerticesInsteadOfIndices not important for LineMesh
  98477. */
  98478. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  98479. /**
  98480. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  98481. */
  98482. _generateEdgesLines(): void;
  98483. }
  98484. }
  98485. declare module BABYLON {
  98486. /**
  98487. * This represents the object necessary to create a rendering group.
  98488. * This is exclusively used and created by the rendering manager.
  98489. * To modify the behavior, you use the available helpers in your scene or meshes.
  98490. * @hidden
  98491. */
  98492. export class RenderingGroup {
  98493. index: number;
  98494. private static _zeroVector;
  98495. private _scene;
  98496. private _opaqueSubMeshes;
  98497. private _transparentSubMeshes;
  98498. private _alphaTestSubMeshes;
  98499. private _depthOnlySubMeshes;
  98500. private _particleSystems;
  98501. private _spriteManagers;
  98502. private _opaqueSortCompareFn;
  98503. private _alphaTestSortCompareFn;
  98504. private _transparentSortCompareFn;
  98505. private _renderOpaque;
  98506. private _renderAlphaTest;
  98507. private _renderTransparent;
  98508. /** @hidden */
  98509. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  98510. onBeforeTransparentRendering: () => void;
  98511. /**
  98512. * Set the opaque sort comparison function.
  98513. * If null the sub meshes will be render in the order they were created
  98514. */
  98515. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98516. /**
  98517. * Set the alpha test sort comparison function.
  98518. * If null the sub meshes will be render in the order they were created
  98519. */
  98520. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98521. /**
  98522. * Set the transparent sort comparison function.
  98523. * If null the sub meshes will be render in the order they were created
  98524. */
  98525. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98526. /**
  98527. * Creates a new rendering group.
  98528. * @param index The rendering group index
  98529. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  98530. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  98531. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  98532. */
  98533. 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>);
  98534. /**
  98535. * Render all the sub meshes contained in the group.
  98536. * @param customRenderFunction Used to override the default render behaviour of the group.
  98537. * @returns true if rendered some submeshes.
  98538. */
  98539. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  98540. /**
  98541. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  98542. * @param subMeshes The submeshes to render
  98543. */
  98544. private renderOpaqueSorted;
  98545. /**
  98546. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  98547. * @param subMeshes The submeshes to render
  98548. */
  98549. private renderAlphaTestSorted;
  98550. /**
  98551. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  98552. * @param subMeshes The submeshes to render
  98553. */
  98554. private renderTransparentSorted;
  98555. /**
  98556. * Renders the submeshes in a specified order.
  98557. * @param subMeshes The submeshes to sort before render
  98558. * @param sortCompareFn The comparison function use to sort
  98559. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  98560. * @param transparent Specifies to activate blending if true
  98561. */
  98562. private static renderSorted;
  98563. /**
  98564. * Renders the submeshes in the order they were dispatched (no sort applied).
  98565. * @param subMeshes The submeshes to render
  98566. */
  98567. private static renderUnsorted;
  98568. /**
  98569. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98570. * are rendered back to front if in the same alpha index.
  98571. *
  98572. * @param a The first submesh
  98573. * @param b The second submesh
  98574. * @returns The result of the comparison
  98575. */
  98576. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  98577. /**
  98578. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98579. * are rendered back to front.
  98580. *
  98581. * @param a The first submesh
  98582. * @param b The second submesh
  98583. * @returns The result of the comparison
  98584. */
  98585. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  98586. /**
  98587. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98588. * are rendered front to back (prevent overdraw).
  98589. *
  98590. * @param a The first submesh
  98591. * @param b The second submesh
  98592. * @returns The result of the comparison
  98593. */
  98594. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  98595. /**
  98596. * Resets the different lists of submeshes to prepare a new frame.
  98597. */
  98598. prepare(): void;
  98599. dispose(): void;
  98600. /**
  98601. * Inserts the submesh in its correct queue depending on its material.
  98602. * @param subMesh The submesh to dispatch
  98603. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98604. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98605. */
  98606. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98607. dispatchSprites(spriteManager: ISpriteManager): void;
  98608. dispatchParticles(particleSystem: IParticleSystem): void;
  98609. private _renderParticles;
  98610. private _renderSprites;
  98611. }
  98612. }
  98613. declare module BABYLON {
  98614. /**
  98615. * Interface describing the different options available in the rendering manager
  98616. * regarding Auto Clear between groups.
  98617. */
  98618. export interface IRenderingManagerAutoClearSetup {
  98619. /**
  98620. * Defines whether or not autoclear is enable.
  98621. */
  98622. autoClear: boolean;
  98623. /**
  98624. * Defines whether or not to autoclear the depth buffer.
  98625. */
  98626. depth: boolean;
  98627. /**
  98628. * Defines whether or not to autoclear the stencil buffer.
  98629. */
  98630. stencil: boolean;
  98631. }
  98632. /**
  98633. * This class is used by the onRenderingGroupObservable
  98634. */
  98635. export class RenderingGroupInfo {
  98636. /**
  98637. * The Scene that being rendered
  98638. */
  98639. scene: Scene;
  98640. /**
  98641. * The camera currently used for the rendering pass
  98642. */
  98643. camera: Nullable<Camera>;
  98644. /**
  98645. * The ID of the renderingGroup being processed
  98646. */
  98647. renderingGroupId: number;
  98648. }
  98649. /**
  98650. * This is the manager responsible of all the rendering for meshes sprites and particles.
  98651. * It is enable to manage the different groups as well as the different necessary sort functions.
  98652. * This should not be used directly aside of the few static configurations
  98653. */
  98654. export class RenderingManager {
  98655. /**
  98656. * The max id used for rendering groups (not included)
  98657. */
  98658. static MAX_RENDERINGGROUPS: number;
  98659. /**
  98660. * The min id used for rendering groups (included)
  98661. */
  98662. static MIN_RENDERINGGROUPS: number;
  98663. /**
  98664. * Used to globally prevent autoclearing scenes.
  98665. */
  98666. static AUTOCLEAR: boolean;
  98667. /**
  98668. * @hidden
  98669. */
  98670. _useSceneAutoClearSetup: boolean;
  98671. private _scene;
  98672. private _renderingGroups;
  98673. private _depthStencilBufferAlreadyCleaned;
  98674. private _autoClearDepthStencil;
  98675. private _customOpaqueSortCompareFn;
  98676. private _customAlphaTestSortCompareFn;
  98677. private _customTransparentSortCompareFn;
  98678. private _renderingGroupInfo;
  98679. /**
  98680. * Instantiates a new rendering group for a particular scene
  98681. * @param scene Defines the scene the groups belongs to
  98682. */
  98683. constructor(scene: Scene);
  98684. private _clearDepthStencilBuffer;
  98685. /**
  98686. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  98687. * @hidden
  98688. */
  98689. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  98690. /**
  98691. * Resets the different information of the group to prepare a new frame
  98692. * @hidden
  98693. */
  98694. reset(): void;
  98695. /**
  98696. * Dispose and release the group and its associated resources.
  98697. * @hidden
  98698. */
  98699. dispose(): void;
  98700. /**
  98701. * Clear the info related to rendering groups preventing retention points during dispose.
  98702. */
  98703. freeRenderingGroups(): void;
  98704. private _prepareRenderingGroup;
  98705. /**
  98706. * Add a sprite manager to the rendering manager in order to render it this frame.
  98707. * @param spriteManager Define the sprite manager to render
  98708. */
  98709. dispatchSprites(spriteManager: ISpriteManager): void;
  98710. /**
  98711. * Add a particle system to the rendering manager in order to render it this frame.
  98712. * @param particleSystem Define the particle system to render
  98713. */
  98714. dispatchParticles(particleSystem: IParticleSystem): void;
  98715. /**
  98716. * Add a submesh to the manager in order to render it this frame
  98717. * @param subMesh The submesh to dispatch
  98718. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98719. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98720. */
  98721. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98722. /**
  98723. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98724. * This allowed control for front to back rendering or reversly depending of the special needs.
  98725. *
  98726. * @param renderingGroupId The rendering group id corresponding to its index
  98727. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98728. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98729. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98730. */
  98731. 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;
  98732. /**
  98733. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98734. *
  98735. * @param renderingGroupId The rendering group id corresponding to its index
  98736. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98737. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98738. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98739. */
  98740. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98741. /**
  98742. * Gets the current auto clear configuration for one rendering group of the rendering
  98743. * manager.
  98744. * @param index the rendering group index to get the information for
  98745. * @returns The auto clear setup for the requested rendering group
  98746. */
  98747. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98748. }
  98749. }
  98750. declare module BABYLON {
  98751. /**
  98752. * Defines the options associated with the creation of a custom shader for a shadow generator.
  98753. */
  98754. export interface ICustomShaderOptions {
  98755. /**
  98756. * Gets or sets the custom shader name to use
  98757. */
  98758. shaderName: string;
  98759. /**
  98760. * The list of attribute names used in the shader
  98761. */
  98762. attributes?: string[];
  98763. /**
  98764. * The list of unifrom names used in the shader
  98765. */
  98766. uniforms?: string[];
  98767. /**
  98768. * The list of sampler names used in the shader
  98769. */
  98770. samplers?: string[];
  98771. /**
  98772. * The list of defines used in the shader
  98773. */
  98774. defines?: string[];
  98775. }
  98776. /**
  98777. * Interface to implement to create a shadow generator compatible with BJS.
  98778. */
  98779. export interface IShadowGenerator {
  98780. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98781. id: string;
  98782. /**
  98783. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98784. * @returns The render target texture if present otherwise, null
  98785. */
  98786. getShadowMap(): Nullable<RenderTargetTexture>;
  98787. /**
  98788. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98789. * @param subMesh The submesh we want to render in the shadow map
  98790. * @param useInstances Defines wether will draw in the map using instances
  98791. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98792. * @returns true if ready otherwise, false
  98793. */
  98794. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98795. /**
  98796. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98797. * @param defines Defines of the material we want to update
  98798. * @param lightIndex Index of the light in the enabled light list of the material
  98799. */
  98800. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98801. /**
  98802. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98803. * defined in the generator but impacting the effect).
  98804. * It implies the unifroms available on the materials are the standard BJS ones.
  98805. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98806. * @param effect The effect we are binfing the information for
  98807. */
  98808. bindShadowLight(lightIndex: string, effect: Effect): void;
  98809. /**
  98810. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98811. * (eq to shadow prjection matrix * light transform matrix)
  98812. * @returns The transform matrix used to create the shadow map
  98813. */
  98814. getTransformMatrix(): Matrix;
  98815. /**
  98816. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98817. * Cube and 2D textures for instance.
  98818. */
  98819. recreateShadowMap(): void;
  98820. /**
  98821. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98822. * @param onCompiled Callback triggered at the and of the effects compilation
  98823. * @param options Sets of optional options forcing the compilation with different modes
  98824. */
  98825. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98826. useInstances: boolean;
  98827. }>): void;
  98828. /**
  98829. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98830. * @param options Sets of optional options forcing the compilation with different modes
  98831. * @returns A promise that resolves when the compilation completes
  98832. */
  98833. forceCompilationAsync(options?: Partial<{
  98834. useInstances: boolean;
  98835. }>): Promise<void>;
  98836. /**
  98837. * Serializes the shadow generator setup to a json object.
  98838. * @returns The serialized JSON object
  98839. */
  98840. serialize(): any;
  98841. /**
  98842. * Disposes the Shadow map and related Textures and effects.
  98843. */
  98844. dispose(): void;
  98845. }
  98846. /**
  98847. * Default implementation IShadowGenerator.
  98848. * This is the main object responsible of generating shadows in the framework.
  98849. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98850. */
  98851. export class ShadowGenerator implements IShadowGenerator {
  98852. /**
  98853. * Name of the shadow generator class
  98854. */
  98855. static CLASSNAME: string;
  98856. /**
  98857. * Shadow generator mode None: no filtering applied.
  98858. */
  98859. static readonly FILTER_NONE: number;
  98860. /**
  98861. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98862. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98863. */
  98864. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98865. /**
  98866. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98867. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98868. */
  98869. static readonly FILTER_POISSONSAMPLING: number;
  98870. /**
  98871. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98872. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98873. */
  98874. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98875. /**
  98876. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98877. * edge artifacts on steep falloff.
  98878. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98879. */
  98880. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98881. /**
  98882. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98883. * edge artifacts on steep falloff.
  98884. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98885. */
  98886. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98887. /**
  98888. * Shadow generator mode PCF: Percentage Closer Filtering
  98889. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98890. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98891. */
  98892. static readonly FILTER_PCF: number;
  98893. /**
  98894. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98895. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98896. * Contact Hardening
  98897. */
  98898. static readonly FILTER_PCSS: number;
  98899. /**
  98900. * Reserved for PCF and PCSS
  98901. * Highest Quality.
  98902. *
  98903. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98904. *
  98905. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98906. */
  98907. static readonly QUALITY_HIGH: number;
  98908. /**
  98909. * Reserved for PCF and PCSS
  98910. * Good tradeoff for quality/perf cross devices
  98911. *
  98912. * Execute PCF on a 3*3 kernel.
  98913. *
  98914. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98915. */
  98916. static readonly QUALITY_MEDIUM: number;
  98917. /**
  98918. * Reserved for PCF and PCSS
  98919. * The lowest quality but the fastest.
  98920. *
  98921. * Execute PCF on a 1*1 kernel.
  98922. *
  98923. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98924. */
  98925. static readonly QUALITY_LOW: number;
  98926. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98927. id: string;
  98928. /** Gets or sets the custom shader name to use */
  98929. customShaderOptions: ICustomShaderOptions;
  98930. /**
  98931. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98932. */
  98933. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98934. /**
  98935. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98936. */
  98937. onAfterShadowMapRenderObservable: Observable<Effect>;
  98938. /**
  98939. * Observable triggered before a mesh is rendered in the shadow map.
  98940. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98941. */
  98942. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98943. /**
  98944. * Observable triggered after a mesh is rendered in the shadow map.
  98945. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98946. */
  98947. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98948. protected _bias: number;
  98949. /**
  98950. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98951. */
  98952. get bias(): number;
  98953. /**
  98954. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98955. */
  98956. set bias(bias: number);
  98957. protected _normalBias: number;
  98958. /**
  98959. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98960. */
  98961. get normalBias(): number;
  98962. /**
  98963. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98964. */
  98965. set normalBias(normalBias: number);
  98966. protected _blurBoxOffset: number;
  98967. /**
  98968. * Gets the blur box offset: offset applied during the blur pass.
  98969. * Only useful if useKernelBlur = false
  98970. */
  98971. get blurBoxOffset(): number;
  98972. /**
  98973. * Sets the blur box offset: offset applied during the blur pass.
  98974. * Only useful if useKernelBlur = false
  98975. */
  98976. set blurBoxOffset(value: number);
  98977. protected _blurScale: number;
  98978. /**
  98979. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98980. * 2 means half of the size.
  98981. */
  98982. get blurScale(): number;
  98983. /**
  98984. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98985. * 2 means half of the size.
  98986. */
  98987. set blurScale(value: number);
  98988. protected _blurKernel: number;
  98989. /**
  98990. * Gets the blur kernel: kernel size of the blur pass.
  98991. * Only useful if useKernelBlur = true
  98992. */
  98993. get blurKernel(): number;
  98994. /**
  98995. * Sets the blur kernel: kernel size of the blur pass.
  98996. * Only useful if useKernelBlur = true
  98997. */
  98998. set blurKernel(value: number);
  98999. protected _useKernelBlur: boolean;
  99000. /**
  99001. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  99002. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  99003. */
  99004. get useKernelBlur(): boolean;
  99005. /**
  99006. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  99007. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  99008. */
  99009. set useKernelBlur(value: boolean);
  99010. protected _depthScale: number;
  99011. /**
  99012. * Gets the depth scale used in ESM mode.
  99013. */
  99014. get depthScale(): number;
  99015. /**
  99016. * Sets the depth scale used in ESM mode.
  99017. * This can override the scale stored on the light.
  99018. */
  99019. set depthScale(value: number);
  99020. protected _validateFilter(filter: number): number;
  99021. protected _filter: number;
  99022. /**
  99023. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  99024. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  99025. */
  99026. get filter(): number;
  99027. /**
  99028. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  99029. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  99030. */
  99031. set filter(value: number);
  99032. /**
  99033. * Gets if the current filter is set to Poisson Sampling.
  99034. */
  99035. get usePoissonSampling(): boolean;
  99036. /**
  99037. * Sets the current filter to Poisson Sampling.
  99038. */
  99039. set usePoissonSampling(value: boolean);
  99040. /**
  99041. * Gets if the current filter is set to ESM.
  99042. */
  99043. get useExponentialShadowMap(): boolean;
  99044. /**
  99045. * Sets the current filter is to ESM.
  99046. */
  99047. set useExponentialShadowMap(value: boolean);
  99048. /**
  99049. * Gets if the current filter is set to filtered ESM.
  99050. */
  99051. get useBlurExponentialShadowMap(): boolean;
  99052. /**
  99053. * Gets if the current filter is set to filtered ESM.
  99054. */
  99055. set useBlurExponentialShadowMap(value: boolean);
  99056. /**
  99057. * Gets if the current filter is set to "close ESM" (using the inverse of the
  99058. * exponential to prevent steep falloff artifacts).
  99059. */
  99060. get useCloseExponentialShadowMap(): boolean;
  99061. /**
  99062. * Sets the current filter to "close ESM" (using the inverse of the
  99063. * exponential to prevent steep falloff artifacts).
  99064. */
  99065. set useCloseExponentialShadowMap(value: boolean);
  99066. /**
  99067. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  99068. * exponential to prevent steep falloff artifacts).
  99069. */
  99070. get useBlurCloseExponentialShadowMap(): boolean;
  99071. /**
  99072. * Sets the current filter to filtered "close ESM" (using the inverse of the
  99073. * exponential to prevent steep falloff artifacts).
  99074. */
  99075. set useBlurCloseExponentialShadowMap(value: boolean);
  99076. /**
  99077. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  99078. */
  99079. get usePercentageCloserFiltering(): boolean;
  99080. /**
  99081. * Sets the current filter to "PCF" (percentage closer filtering).
  99082. */
  99083. set usePercentageCloserFiltering(value: boolean);
  99084. protected _filteringQuality: number;
  99085. /**
  99086. * Gets the PCF or PCSS Quality.
  99087. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  99088. */
  99089. get filteringQuality(): number;
  99090. /**
  99091. * Sets the PCF or PCSS Quality.
  99092. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  99093. */
  99094. set filteringQuality(filteringQuality: number);
  99095. /**
  99096. * Gets if the current filter is set to "PCSS" (contact hardening).
  99097. */
  99098. get useContactHardeningShadow(): boolean;
  99099. /**
  99100. * Sets the current filter to "PCSS" (contact hardening).
  99101. */
  99102. set useContactHardeningShadow(value: boolean);
  99103. protected _contactHardeningLightSizeUVRatio: number;
  99104. /**
  99105. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  99106. * Using a ratio helps keeping shape stability independently of the map size.
  99107. *
  99108. * It does not account for the light projection as it was having too much
  99109. * instability during the light setup or during light position changes.
  99110. *
  99111. * Only valid if useContactHardeningShadow is true.
  99112. */
  99113. get contactHardeningLightSizeUVRatio(): number;
  99114. /**
  99115. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  99116. * Using a ratio helps keeping shape stability independently of the map size.
  99117. *
  99118. * It does not account for the light projection as it was having too much
  99119. * instability during the light setup or during light position changes.
  99120. *
  99121. * Only valid if useContactHardeningShadow is true.
  99122. */
  99123. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  99124. protected _darkness: number;
  99125. /** Gets or sets the actual darkness of a shadow */
  99126. get darkness(): number;
  99127. set darkness(value: number);
  99128. /**
  99129. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  99130. * 0 means strongest and 1 would means no shadow.
  99131. * @returns the darkness.
  99132. */
  99133. getDarkness(): number;
  99134. /**
  99135. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  99136. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  99137. * @returns the shadow generator allowing fluent coding.
  99138. */
  99139. setDarkness(darkness: number): ShadowGenerator;
  99140. protected _transparencyShadow: boolean;
  99141. /** Gets or sets the ability to have transparent shadow */
  99142. get transparencyShadow(): boolean;
  99143. set transparencyShadow(value: boolean);
  99144. /**
  99145. * Sets the ability to have transparent shadow (boolean).
  99146. * @param transparent True if transparent else False
  99147. * @returns the shadow generator allowing fluent coding
  99148. */
  99149. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  99150. /**
  99151. * Enables or disables shadows with varying strength based on the transparency
  99152. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  99153. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  99154. * mesh.visibility * alphaTexture.a
  99155. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  99156. */
  99157. enableSoftTransparentShadow: boolean;
  99158. protected _shadowMap: Nullable<RenderTargetTexture>;
  99159. protected _shadowMap2: Nullable<RenderTargetTexture>;
  99160. /**
  99161. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  99162. * @returns The render target texture if present otherwise, null
  99163. */
  99164. getShadowMap(): Nullable<RenderTargetTexture>;
  99165. /**
  99166. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  99167. * @returns The render target texture if the shadow map is present otherwise, null
  99168. */
  99169. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  99170. /**
  99171. * Gets the class name of that object
  99172. * @returns "ShadowGenerator"
  99173. */
  99174. getClassName(): string;
  99175. /**
  99176. * Helper function to add a mesh and its descendants to the list of shadow casters.
  99177. * @param mesh Mesh to add
  99178. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  99179. * @returns the Shadow Generator itself
  99180. */
  99181. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  99182. /**
  99183. * Helper function to remove a mesh and its descendants from the list of shadow casters
  99184. * @param mesh Mesh to remove
  99185. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  99186. * @returns the Shadow Generator itself
  99187. */
  99188. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  99189. /**
  99190. * Controls the extent to which the shadows fade out at the edge of the frustum
  99191. */
  99192. frustumEdgeFalloff: number;
  99193. protected _light: IShadowLight;
  99194. /**
  99195. * Returns the associated light object.
  99196. * @returns the light generating the shadow
  99197. */
  99198. getLight(): IShadowLight;
  99199. /**
  99200. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  99201. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  99202. * It might on the other hand introduce peter panning.
  99203. */
  99204. forceBackFacesOnly: boolean;
  99205. protected _scene: Scene;
  99206. protected _lightDirection: Vector3;
  99207. protected _effect: Effect;
  99208. protected _viewMatrix: Matrix;
  99209. protected _projectionMatrix: Matrix;
  99210. protected _transformMatrix: Matrix;
  99211. protected _cachedPosition: Vector3;
  99212. protected _cachedDirection: Vector3;
  99213. protected _cachedDefines: string;
  99214. protected _currentRenderID: number;
  99215. protected _boxBlurPostprocess: Nullable<PostProcess>;
  99216. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  99217. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  99218. protected _blurPostProcesses: PostProcess[];
  99219. protected _mapSize: number;
  99220. protected _currentFaceIndex: number;
  99221. protected _currentFaceIndexCache: number;
  99222. protected _textureType: number;
  99223. protected _defaultTextureMatrix: Matrix;
  99224. protected _storedUniqueId: Nullable<number>;
  99225. /** @hidden */
  99226. static _SceneComponentInitialization: (scene: Scene) => void;
  99227. /**
  99228. * Gets or sets the size of the texture what stores the shadows
  99229. */
  99230. get mapSize(): number;
  99231. set mapSize(size: number);
  99232. /**
  99233. * Creates a ShadowGenerator object.
  99234. * A ShadowGenerator is the required tool to use the shadows.
  99235. * Each light casting shadows needs to use its own ShadowGenerator.
  99236. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  99237. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  99238. * @param light The light object generating the shadows.
  99239. * @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.
  99240. */
  99241. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  99242. protected _initializeGenerator(): void;
  99243. protected _createTargetRenderTexture(): void;
  99244. protected _initializeShadowMap(): void;
  99245. protected _initializeBlurRTTAndPostProcesses(): void;
  99246. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  99247. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  99248. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  99249. protected _applyFilterValues(): void;
  99250. /**
  99251. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  99252. * @param onCompiled Callback triggered at the and of the effects compilation
  99253. * @param options Sets of optional options forcing the compilation with different modes
  99254. */
  99255. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  99256. useInstances: boolean;
  99257. }>): void;
  99258. /**
  99259. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  99260. * @param options Sets of optional options forcing the compilation with different modes
  99261. * @returns A promise that resolves when the compilation completes
  99262. */
  99263. forceCompilationAsync(options?: Partial<{
  99264. useInstances: boolean;
  99265. }>): Promise<void>;
  99266. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  99267. private _prepareShadowDefines;
  99268. /**
  99269. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  99270. * @param subMesh The submesh we want to render in the shadow map
  99271. * @param useInstances Defines wether will draw in the map using instances
  99272. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  99273. * @returns true if ready otherwise, false
  99274. */
  99275. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  99276. /**
  99277. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  99278. * @param defines Defines of the material we want to update
  99279. * @param lightIndex Index of the light in the enabled light list of the material
  99280. */
  99281. prepareDefines(defines: any, lightIndex: number): void;
  99282. /**
  99283. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  99284. * defined in the generator but impacting the effect).
  99285. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  99286. * @param effect The effect we are binfing the information for
  99287. */
  99288. bindShadowLight(lightIndex: string, effect: Effect): void;
  99289. /**
  99290. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  99291. * (eq to shadow prjection matrix * light transform matrix)
  99292. * @returns The transform matrix used to create the shadow map
  99293. */
  99294. getTransformMatrix(): Matrix;
  99295. /**
  99296. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  99297. * Cube and 2D textures for instance.
  99298. */
  99299. recreateShadowMap(): void;
  99300. protected _disposeBlurPostProcesses(): void;
  99301. protected _disposeRTTandPostProcesses(): void;
  99302. /**
  99303. * Disposes the ShadowGenerator.
  99304. * Returns nothing.
  99305. */
  99306. dispose(): void;
  99307. /**
  99308. * Serializes the shadow generator setup to a json object.
  99309. * @returns The serialized JSON object
  99310. */
  99311. serialize(): any;
  99312. /**
  99313. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  99314. * @param parsedShadowGenerator The JSON object to parse
  99315. * @param scene The scene to create the shadow map for
  99316. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  99317. * @returns The parsed shadow generator
  99318. */
  99319. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  99320. }
  99321. }
  99322. declare module BABYLON {
  99323. /**
  99324. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  99325. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  99326. * 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.
  99327. */
  99328. export abstract class Light extends Node {
  99329. /**
  99330. * Falloff Default: light is falling off following the material specification:
  99331. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  99332. */
  99333. static readonly FALLOFF_DEFAULT: number;
  99334. /**
  99335. * Falloff Physical: light is falling off following the inverse squared distance law.
  99336. */
  99337. static readonly FALLOFF_PHYSICAL: number;
  99338. /**
  99339. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  99340. * to enhance interoperability with other engines.
  99341. */
  99342. static readonly FALLOFF_GLTF: number;
  99343. /**
  99344. * Falloff Standard: light is falling off like in the standard material
  99345. * to enhance interoperability with other materials.
  99346. */
  99347. static readonly FALLOFF_STANDARD: number;
  99348. /**
  99349. * If every light affecting the material is in this lightmapMode,
  99350. * material.lightmapTexture adds or multiplies
  99351. * (depends on material.useLightmapAsShadowmap)
  99352. * after every other light calculations.
  99353. */
  99354. static readonly LIGHTMAP_DEFAULT: number;
  99355. /**
  99356. * material.lightmapTexture as only diffuse lighting from this light
  99357. * adds only specular lighting from this light
  99358. * adds dynamic shadows
  99359. */
  99360. static readonly LIGHTMAP_SPECULAR: number;
  99361. /**
  99362. * material.lightmapTexture as only lighting
  99363. * no light calculation from this light
  99364. * only adds dynamic shadows from this light
  99365. */
  99366. static readonly LIGHTMAP_SHADOWSONLY: number;
  99367. /**
  99368. * Each light type uses the default quantity according to its type:
  99369. * point/spot lights use luminous intensity
  99370. * directional lights use illuminance
  99371. */
  99372. static readonly INTENSITYMODE_AUTOMATIC: number;
  99373. /**
  99374. * lumen (lm)
  99375. */
  99376. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  99377. /**
  99378. * candela (lm/sr)
  99379. */
  99380. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  99381. /**
  99382. * lux (lm/m^2)
  99383. */
  99384. static readonly INTENSITYMODE_ILLUMINANCE: number;
  99385. /**
  99386. * nit (cd/m^2)
  99387. */
  99388. static readonly INTENSITYMODE_LUMINANCE: number;
  99389. /**
  99390. * Light type const id of the point light.
  99391. */
  99392. static readonly LIGHTTYPEID_POINTLIGHT: number;
  99393. /**
  99394. * Light type const id of the directional light.
  99395. */
  99396. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  99397. /**
  99398. * Light type const id of the spot light.
  99399. */
  99400. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  99401. /**
  99402. * Light type const id of the hemispheric light.
  99403. */
  99404. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  99405. /**
  99406. * Diffuse gives the basic color to an object.
  99407. */
  99408. diffuse: Color3;
  99409. /**
  99410. * Specular produces a highlight color on an object.
  99411. * Note: This is note affecting PBR materials.
  99412. */
  99413. specular: Color3;
  99414. /**
  99415. * Defines the falloff type for this light. This lets overrriding how punctual light are
  99416. * falling off base on range or angle.
  99417. * This can be set to any values in Light.FALLOFF_x.
  99418. *
  99419. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  99420. * other types of materials.
  99421. */
  99422. falloffType: number;
  99423. /**
  99424. * Strength of the light.
  99425. * Note: By default it is define in the framework own unit.
  99426. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  99427. */
  99428. intensity: number;
  99429. private _range;
  99430. protected _inverseSquaredRange: number;
  99431. /**
  99432. * Defines how far from the source the light is impacting in scene units.
  99433. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  99434. */
  99435. get range(): number;
  99436. /**
  99437. * Defines how far from the source the light is impacting in scene units.
  99438. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  99439. */
  99440. set range(value: number);
  99441. /**
  99442. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  99443. * of light.
  99444. */
  99445. private _photometricScale;
  99446. private _intensityMode;
  99447. /**
  99448. * Gets the photometric scale used to interpret the intensity.
  99449. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  99450. */
  99451. get intensityMode(): number;
  99452. /**
  99453. * Sets the photometric scale used to interpret the intensity.
  99454. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  99455. */
  99456. set intensityMode(value: number);
  99457. private _radius;
  99458. /**
  99459. * Gets the light radius used by PBR Materials to simulate soft area lights.
  99460. */
  99461. get radius(): number;
  99462. /**
  99463. * sets the light radius used by PBR Materials to simulate soft area lights.
  99464. */
  99465. set radius(value: number);
  99466. private _renderPriority;
  99467. /**
  99468. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  99469. * exceeding the number allowed of the materials.
  99470. */
  99471. renderPriority: number;
  99472. private _shadowEnabled;
  99473. /**
  99474. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99475. * the current shadow generator.
  99476. */
  99477. get shadowEnabled(): boolean;
  99478. /**
  99479. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99480. * the current shadow generator.
  99481. */
  99482. set shadowEnabled(value: boolean);
  99483. private _includedOnlyMeshes;
  99484. /**
  99485. * Gets the only meshes impacted by this light.
  99486. */
  99487. get includedOnlyMeshes(): AbstractMesh[];
  99488. /**
  99489. * Sets the only meshes impacted by this light.
  99490. */
  99491. set includedOnlyMeshes(value: AbstractMesh[]);
  99492. private _excludedMeshes;
  99493. /**
  99494. * Gets the meshes not impacted by this light.
  99495. */
  99496. get excludedMeshes(): AbstractMesh[];
  99497. /**
  99498. * Sets the meshes not impacted by this light.
  99499. */
  99500. set excludedMeshes(value: AbstractMesh[]);
  99501. private _excludeWithLayerMask;
  99502. /**
  99503. * Gets the layer id use to find what meshes are not impacted by the light.
  99504. * Inactive if 0
  99505. */
  99506. get excludeWithLayerMask(): number;
  99507. /**
  99508. * Sets the layer id use to find what meshes are not impacted by the light.
  99509. * Inactive if 0
  99510. */
  99511. set excludeWithLayerMask(value: number);
  99512. private _includeOnlyWithLayerMask;
  99513. /**
  99514. * Gets the layer id use to find what meshes are impacted by the light.
  99515. * Inactive if 0
  99516. */
  99517. get includeOnlyWithLayerMask(): number;
  99518. /**
  99519. * Sets the layer id use to find what meshes are impacted by the light.
  99520. * Inactive if 0
  99521. */
  99522. set includeOnlyWithLayerMask(value: number);
  99523. private _lightmapMode;
  99524. /**
  99525. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99526. */
  99527. get lightmapMode(): number;
  99528. /**
  99529. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99530. */
  99531. set lightmapMode(value: number);
  99532. /**
  99533. * Shadow generator associted to the light.
  99534. * @hidden Internal use only.
  99535. */
  99536. _shadowGenerator: Nullable<IShadowGenerator>;
  99537. /**
  99538. * @hidden Internal use only.
  99539. */
  99540. _excludedMeshesIds: string[];
  99541. /**
  99542. * @hidden Internal use only.
  99543. */
  99544. _includedOnlyMeshesIds: string[];
  99545. /**
  99546. * The current light unifom buffer.
  99547. * @hidden Internal use only.
  99548. */
  99549. _uniformBuffer: UniformBuffer;
  99550. /** @hidden */
  99551. _renderId: number;
  99552. /**
  99553. * Creates a Light object in the scene.
  99554. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99555. * @param name The firendly name of the light
  99556. * @param scene The scene the light belongs too
  99557. */
  99558. constructor(name: string, scene: Scene);
  99559. protected abstract _buildUniformLayout(): void;
  99560. /**
  99561. * Sets the passed Effect "effect" with the Light information.
  99562. * @param effect The effect to update
  99563. * @param lightIndex The index of the light in the effect to update
  99564. * @returns The light
  99565. */
  99566. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  99567. /**
  99568. * Sets the passed Effect "effect" with the Light textures.
  99569. * @param effect The effect to update
  99570. * @param lightIndex The index of the light in the effect to update
  99571. * @returns The light
  99572. */
  99573. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  99574. /**
  99575. * Binds the lights information from the scene to the effect for the given mesh.
  99576. * @param lightIndex Light index
  99577. * @param scene The scene where the light belongs to
  99578. * @param effect The effect we are binding the data to
  99579. * @param useSpecular Defines if specular is supported
  99580. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99581. */
  99582. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99583. /**
  99584. * Sets the passed Effect "effect" with the Light information.
  99585. * @param effect The effect to update
  99586. * @param lightDataUniformName The uniform used to store light data (position or direction)
  99587. * @returns The light
  99588. */
  99589. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  99590. /**
  99591. * Returns the string "Light".
  99592. * @returns the class name
  99593. */
  99594. getClassName(): string;
  99595. /** @hidden */
  99596. readonly _isLight: boolean;
  99597. /**
  99598. * Converts the light information to a readable string for debug purpose.
  99599. * @param fullDetails Supports for multiple levels of logging within scene loading
  99600. * @returns the human readable light info
  99601. */
  99602. toString(fullDetails?: boolean): string;
  99603. /** @hidden */
  99604. protected _syncParentEnabledState(): void;
  99605. /**
  99606. * Set the enabled state of this node.
  99607. * @param value - the new enabled state
  99608. */
  99609. setEnabled(value: boolean): void;
  99610. /**
  99611. * Returns the Light associated shadow generator if any.
  99612. * @return the associated shadow generator.
  99613. */
  99614. getShadowGenerator(): Nullable<IShadowGenerator>;
  99615. /**
  99616. * Returns a Vector3, the absolute light position in the World.
  99617. * @returns the world space position of the light
  99618. */
  99619. getAbsolutePosition(): Vector3;
  99620. /**
  99621. * Specifies if the light will affect the passed mesh.
  99622. * @param mesh The mesh to test against the light
  99623. * @return true the mesh is affected otherwise, false.
  99624. */
  99625. canAffectMesh(mesh: AbstractMesh): boolean;
  99626. /**
  99627. * Sort function to order lights for rendering.
  99628. * @param a First Light object to compare to second.
  99629. * @param b Second Light object to compare first.
  99630. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  99631. */
  99632. static CompareLightsPriority(a: Light, b: Light): number;
  99633. /**
  99634. * Releases resources associated with this node.
  99635. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99636. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99637. */
  99638. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99639. /**
  99640. * Returns the light type ID (integer).
  99641. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99642. */
  99643. getTypeID(): number;
  99644. /**
  99645. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  99646. * @returns the scaled intensity in intensity mode unit
  99647. */
  99648. getScaledIntensity(): number;
  99649. /**
  99650. * Returns a new Light object, named "name", from the current one.
  99651. * @param name The name of the cloned light
  99652. * @param newParent The parent of this light, if it has one
  99653. * @returns the new created light
  99654. */
  99655. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  99656. /**
  99657. * Serializes the current light into a Serialization object.
  99658. * @returns the serialized object.
  99659. */
  99660. serialize(): any;
  99661. /**
  99662. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  99663. * This new light is named "name" and added to the passed scene.
  99664. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  99665. * @param name The friendly name of the light
  99666. * @param scene The scene the new light will belong to
  99667. * @returns the constructor function
  99668. */
  99669. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  99670. /**
  99671. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  99672. * @param parsedLight The JSON representation of the light
  99673. * @param scene The scene to create the parsed light in
  99674. * @returns the created light after parsing
  99675. */
  99676. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  99677. private _hookArrayForExcluded;
  99678. private _hookArrayForIncludedOnly;
  99679. private _resyncMeshes;
  99680. /**
  99681. * Forces the meshes to update their light related information in their rendering used effects
  99682. * @hidden Internal Use Only
  99683. */
  99684. _markMeshesAsLightDirty(): void;
  99685. /**
  99686. * Recomputes the cached photometric scale if needed.
  99687. */
  99688. private _computePhotometricScale;
  99689. /**
  99690. * Returns the Photometric Scale according to the light type and intensity mode.
  99691. */
  99692. private _getPhotometricScale;
  99693. /**
  99694. * Reorder the light in the scene according to their defined priority.
  99695. * @hidden Internal Use Only
  99696. */
  99697. _reorderLightsInScene(): void;
  99698. /**
  99699. * Prepares the list of defines specific to the light type.
  99700. * @param defines the list of defines
  99701. * @param lightIndex defines the index of the light for the effect
  99702. */
  99703. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99704. }
  99705. }
  99706. declare module BABYLON {
  99707. /**
  99708. * Configuration needed for prepass-capable materials
  99709. */
  99710. export class PrePassConfiguration {
  99711. /**
  99712. * Previous world matrices of meshes carrying this material
  99713. * Used for computing velocity
  99714. */
  99715. previousWorldMatrices: {
  99716. [index: number]: Matrix;
  99717. };
  99718. /**
  99719. * Previous view project matrix
  99720. * Used for computing velocity
  99721. */
  99722. previousViewProjection: Matrix;
  99723. /**
  99724. * Previous bones of meshes carrying this material
  99725. * Used for computing velocity
  99726. */
  99727. previousBones: {
  99728. [index: number]: Float32Array;
  99729. };
  99730. /**
  99731. * Add the required uniforms to the current list.
  99732. * @param uniforms defines the current uniform list.
  99733. */
  99734. static AddUniforms(uniforms: string[]): void;
  99735. /**
  99736. * Add the required samplers to the current list.
  99737. * @param samplers defines the current sampler list.
  99738. */
  99739. static AddSamplers(samplers: string[]): void;
  99740. /**
  99741. * Binds the material data.
  99742. * @param effect defines the effect to update
  99743. * @param scene defines the scene the material belongs to.
  99744. * @param mesh The mesh
  99745. * @param world World matrix of this mesh
  99746. * @param isFrozen Is the material frozen
  99747. */
  99748. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  99749. }
  99750. }
  99751. declare module BABYLON {
  99752. /**
  99753. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  99754. * This is the base of the follow, arc rotate cameras and Free camera
  99755. * @see https://doc.babylonjs.com/features/cameras
  99756. */
  99757. export class TargetCamera extends Camera {
  99758. private static _RigCamTransformMatrix;
  99759. private static _TargetTransformMatrix;
  99760. private static _TargetFocalPoint;
  99761. private _tmpUpVector;
  99762. private _tmpTargetVector;
  99763. /**
  99764. * Define the current direction the camera is moving to
  99765. */
  99766. cameraDirection: Vector3;
  99767. /**
  99768. * Define the current rotation the camera is rotating to
  99769. */
  99770. cameraRotation: Vector2;
  99771. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99772. ignoreParentScaling: boolean;
  99773. /**
  99774. * When set, the up vector of the camera will be updated by the rotation of the camera
  99775. */
  99776. updateUpVectorFromRotation: boolean;
  99777. private _tmpQuaternion;
  99778. /**
  99779. * Define the current rotation of the camera
  99780. */
  99781. rotation: Vector3;
  99782. /**
  99783. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99784. */
  99785. rotationQuaternion: Quaternion;
  99786. /**
  99787. * Define the current speed of the camera
  99788. */
  99789. speed: number;
  99790. /**
  99791. * Add constraint to the camera to prevent it to move freely in all directions and
  99792. * around all axis.
  99793. */
  99794. noRotationConstraint: boolean;
  99795. /**
  99796. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99797. * panning
  99798. */
  99799. invertRotation: boolean;
  99800. /**
  99801. * Speed multiplier for inverse camera panning
  99802. */
  99803. inverseRotationSpeed: number;
  99804. /**
  99805. * Define the current target of the camera as an object or a position.
  99806. */
  99807. lockedTarget: any;
  99808. /** @hidden */
  99809. _currentTarget: Vector3;
  99810. /** @hidden */
  99811. _initialFocalDistance: number;
  99812. /** @hidden */
  99813. _viewMatrix: Matrix;
  99814. /** @hidden */
  99815. _camMatrix: Matrix;
  99816. /** @hidden */
  99817. _cameraTransformMatrix: Matrix;
  99818. /** @hidden */
  99819. _cameraRotationMatrix: Matrix;
  99820. /** @hidden */
  99821. _referencePoint: Vector3;
  99822. /** @hidden */
  99823. _transformedReferencePoint: Vector3;
  99824. /** @hidden */
  99825. _reset: () => void;
  99826. private _defaultUp;
  99827. /**
  99828. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99829. * This is the base of the follow, arc rotate cameras and Free camera
  99830. * @see https://doc.babylonjs.com/features/cameras
  99831. * @param name Defines the name of the camera in the scene
  99832. * @param position Defines the start position of the camera in the scene
  99833. * @param scene Defines the scene the camera belongs to
  99834. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99835. */
  99836. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99837. /**
  99838. * Gets the position in front of the camera at a given distance.
  99839. * @param distance The distance from the camera we want the position to be
  99840. * @returns the position
  99841. */
  99842. getFrontPosition(distance: number): Vector3;
  99843. /** @hidden */
  99844. _getLockedTargetPosition(): Nullable<Vector3>;
  99845. private _storedPosition;
  99846. private _storedRotation;
  99847. private _storedRotationQuaternion;
  99848. /**
  99849. * Store current camera state of the camera (fov, position, rotation, etc..)
  99850. * @returns the camera
  99851. */
  99852. storeState(): Camera;
  99853. /**
  99854. * Restored camera state. You must call storeState() first
  99855. * @returns whether it was successful or not
  99856. * @hidden
  99857. */
  99858. _restoreStateValues(): boolean;
  99859. /** @hidden */
  99860. _initCache(): void;
  99861. /** @hidden */
  99862. _updateCache(ignoreParentClass?: boolean): void;
  99863. /** @hidden */
  99864. _isSynchronizedViewMatrix(): boolean;
  99865. /** @hidden */
  99866. _computeLocalCameraSpeed(): number;
  99867. /**
  99868. * Defines the target the camera should look at.
  99869. * @param target Defines the new target as a Vector or a mesh
  99870. */
  99871. setTarget(target: Vector3): void;
  99872. /**
  99873. * Defines the target point of the camera.
  99874. * The camera looks towards it form the radius distance.
  99875. */
  99876. get target(): Vector3;
  99877. set target(value: Vector3);
  99878. /**
  99879. * Return the current target position of the camera. This value is expressed in local space.
  99880. * @returns the target position
  99881. */
  99882. getTarget(): Vector3;
  99883. /** @hidden */
  99884. _decideIfNeedsToMove(): boolean;
  99885. /** @hidden */
  99886. _updatePosition(): void;
  99887. /** @hidden */
  99888. _checkInputs(): void;
  99889. protected _updateCameraRotationMatrix(): void;
  99890. /**
  99891. * 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)
  99892. * @returns the current camera
  99893. */
  99894. private _rotateUpVectorWithCameraRotationMatrix;
  99895. private _cachedRotationZ;
  99896. private _cachedQuaternionRotationZ;
  99897. /** @hidden */
  99898. _getViewMatrix(): Matrix;
  99899. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99900. /**
  99901. * @hidden
  99902. */
  99903. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99904. /**
  99905. * @hidden
  99906. */
  99907. _updateRigCameras(): void;
  99908. private _getRigCamPositionAndTarget;
  99909. /**
  99910. * Gets the current object class name.
  99911. * @return the class name
  99912. */
  99913. getClassName(): string;
  99914. }
  99915. }
  99916. declare module BABYLON {
  99917. /**
  99918. * Gather the list of keyboard event types as constants.
  99919. */
  99920. export class KeyboardEventTypes {
  99921. /**
  99922. * The keydown event is fired when a key becomes active (pressed).
  99923. */
  99924. static readonly KEYDOWN: number;
  99925. /**
  99926. * The keyup event is fired when a key has been released.
  99927. */
  99928. static readonly KEYUP: number;
  99929. }
  99930. /**
  99931. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99932. */
  99933. export class KeyboardInfo {
  99934. /**
  99935. * Defines the type of event (KeyboardEventTypes)
  99936. */
  99937. type: number;
  99938. /**
  99939. * Defines the related dom event
  99940. */
  99941. event: KeyboardEvent;
  99942. /**
  99943. * Instantiates a new keyboard info.
  99944. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99945. * @param type Defines the type of event (KeyboardEventTypes)
  99946. * @param event Defines the related dom event
  99947. */
  99948. constructor(
  99949. /**
  99950. * Defines the type of event (KeyboardEventTypes)
  99951. */
  99952. type: number,
  99953. /**
  99954. * Defines the related dom event
  99955. */
  99956. event: KeyboardEvent);
  99957. }
  99958. /**
  99959. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99960. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99961. */
  99962. export class KeyboardInfoPre extends KeyboardInfo {
  99963. /**
  99964. * Defines the type of event (KeyboardEventTypes)
  99965. */
  99966. type: number;
  99967. /**
  99968. * Defines the related dom event
  99969. */
  99970. event: KeyboardEvent;
  99971. /**
  99972. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99973. */
  99974. skipOnPointerObservable: boolean;
  99975. /**
  99976. * Instantiates a new keyboard pre info.
  99977. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99978. * @param type Defines the type of event (KeyboardEventTypes)
  99979. * @param event Defines the related dom event
  99980. */
  99981. constructor(
  99982. /**
  99983. * Defines the type of event (KeyboardEventTypes)
  99984. */
  99985. type: number,
  99986. /**
  99987. * Defines the related dom event
  99988. */
  99989. event: KeyboardEvent);
  99990. }
  99991. }
  99992. declare module BABYLON {
  99993. /**
  99994. * Manage the keyboard inputs to control the movement of a free camera.
  99995. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99996. */
  99997. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99998. /**
  99999. * Defines the camera the input is attached to.
  100000. */
  100001. camera: FreeCamera;
  100002. /**
  100003. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  100004. */
  100005. keysUp: number[];
  100006. /**
  100007. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  100008. */
  100009. keysUpward: number[];
  100010. /**
  100011. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  100012. */
  100013. keysDown: number[];
  100014. /**
  100015. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  100016. */
  100017. keysDownward: number[];
  100018. /**
  100019. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  100020. */
  100021. keysLeft: number[];
  100022. /**
  100023. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  100024. */
  100025. keysRight: number[];
  100026. private _keys;
  100027. private _onCanvasBlurObserver;
  100028. private _onKeyboardObserver;
  100029. private _engine;
  100030. private _scene;
  100031. /**
  100032. * Attach the input controls to a specific dom element to get the input from.
  100033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100034. */
  100035. attachControl(noPreventDefault?: boolean): void;
  100036. /**
  100037. * Detach the current controls from the specified dom element.
  100038. */
  100039. detachControl(): void;
  100040. /**
  100041. * Update the current camera state depending on the inputs that have been used this frame.
  100042. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100043. */
  100044. checkInputs(): void;
  100045. /**
  100046. * Gets the class name of the current intput.
  100047. * @returns the class name
  100048. */
  100049. getClassName(): string;
  100050. /** @hidden */
  100051. _onLostFocus(): void;
  100052. /**
  100053. * Get the friendly name associated with the input class.
  100054. * @returns the input friendly name
  100055. */
  100056. getSimpleName(): string;
  100057. }
  100058. }
  100059. declare module BABYLON {
  100060. /**
  100061. * Gather the list of pointer event types as constants.
  100062. */
  100063. export class PointerEventTypes {
  100064. /**
  100065. * 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.
  100066. */
  100067. static readonly POINTERDOWN: number;
  100068. /**
  100069. * The pointerup event is fired when a pointer is no longer active.
  100070. */
  100071. static readonly POINTERUP: number;
  100072. /**
  100073. * The pointermove event is fired when a pointer changes coordinates.
  100074. */
  100075. static readonly POINTERMOVE: number;
  100076. /**
  100077. * The pointerwheel event is fired when a mouse wheel has been rotated.
  100078. */
  100079. static readonly POINTERWHEEL: number;
  100080. /**
  100081. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  100082. */
  100083. static readonly POINTERPICK: number;
  100084. /**
  100085. * The pointertap event is fired when a the object has been touched and released without drag.
  100086. */
  100087. static readonly POINTERTAP: number;
  100088. /**
  100089. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  100090. */
  100091. static readonly POINTERDOUBLETAP: number;
  100092. }
  100093. /**
  100094. * Base class of pointer info types.
  100095. */
  100096. export class PointerInfoBase {
  100097. /**
  100098. * Defines the type of event (PointerEventTypes)
  100099. */
  100100. type: number;
  100101. /**
  100102. * Defines the related dom event
  100103. */
  100104. event: PointerEvent | MouseWheelEvent;
  100105. /**
  100106. * Instantiates the base class of pointers info.
  100107. * @param type Defines the type of event (PointerEventTypes)
  100108. * @param event Defines the related dom event
  100109. */
  100110. constructor(
  100111. /**
  100112. * Defines the type of event (PointerEventTypes)
  100113. */
  100114. type: number,
  100115. /**
  100116. * Defines the related dom event
  100117. */
  100118. event: PointerEvent | MouseWheelEvent);
  100119. }
  100120. /**
  100121. * This class is used to store pointer related info for the onPrePointerObservable event.
  100122. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  100123. */
  100124. export class PointerInfoPre extends PointerInfoBase {
  100125. /**
  100126. * Ray from a pointer if availible (eg. 6dof controller)
  100127. */
  100128. ray: Nullable<Ray>;
  100129. /**
  100130. * Defines the local position of the pointer on the canvas.
  100131. */
  100132. localPosition: Vector2;
  100133. /**
  100134. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  100135. */
  100136. skipOnPointerObservable: boolean;
  100137. /**
  100138. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  100139. * @param type Defines the type of event (PointerEventTypes)
  100140. * @param event Defines the related dom event
  100141. * @param localX Defines the local x coordinates of the pointer when the event occured
  100142. * @param localY Defines the local y coordinates of the pointer when the event occured
  100143. */
  100144. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  100145. }
  100146. /**
  100147. * This type contains all the data related to a pointer event in Babylon.js.
  100148. * 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.
  100149. */
  100150. export class PointerInfo extends PointerInfoBase {
  100151. /**
  100152. * Defines the picking info associated to the info (if any)\
  100153. */
  100154. pickInfo: Nullable<PickingInfo>;
  100155. /**
  100156. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  100157. * @param type Defines the type of event (PointerEventTypes)
  100158. * @param event Defines the related dom event
  100159. * @param pickInfo Defines the picking info associated to the info (if any)\
  100160. */
  100161. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  100162. /**
  100163. * Defines the picking info associated to the info (if any)\
  100164. */
  100165. pickInfo: Nullable<PickingInfo>);
  100166. }
  100167. /**
  100168. * Data relating to a touch event on the screen.
  100169. */
  100170. export interface PointerTouch {
  100171. /**
  100172. * X coordinate of touch.
  100173. */
  100174. x: number;
  100175. /**
  100176. * Y coordinate of touch.
  100177. */
  100178. y: number;
  100179. /**
  100180. * Id of touch. Unique for each finger.
  100181. */
  100182. pointerId: number;
  100183. /**
  100184. * Event type passed from DOM.
  100185. */
  100186. type: any;
  100187. }
  100188. }
  100189. declare module BABYLON {
  100190. /**
  100191. * Manage the mouse inputs to control the movement of a free camera.
  100192. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100193. */
  100194. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  100195. /**
  100196. * Define if touch is enabled in the mouse input
  100197. */
  100198. touchEnabled: boolean;
  100199. /**
  100200. * Defines the camera the input is attached to.
  100201. */
  100202. camera: FreeCamera;
  100203. /**
  100204. * Defines the buttons associated with the input to handle camera move.
  100205. */
  100206. buttons: number[];
  100207. /**
  100208. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  100209. */
  100210. angularSensibility: number;
  100211. private _pointerInput;
  100212. private _onMouseMove;
  100213. private _observer;
  100214. private previousPosition;
  100215. /**
  100216. * Observable for when a pointer move event occurs containing the move offset
  100217. */
  100218. onPointerMovedObservable: Observable<{
  100219. offsetX: number;
  100220. offsetY: number;
  100221. }>;
  100222. /**
  100223. * @hidden
  100224. * If the camera should be rotated automatically based on pointer movement
  100225. */
  100226. _allowCameraRotation: boolean;
  100227. /**
  100228. * Manage the mouse inputs to control the movement of a free camera.
  100229. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100230. * @param touchEnabled Defines if touch is enabled or not
  100231. */
  100232. constructor(
  100233. /**
  100234. * Define if touch is enabled in the mouse input
  100235. */
  100236. touchEnabled?: boolean);
  100237. /**
  100238. * Attach the input controls to a specific dom element to get the input from.
  100239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100240. */
  100241. attachControl(noPreventDefault?: boolean): void;
  100242. /**
  100243. * Called on JS contextmenu event.
  100244. * Override this method to provide functionality.
  100245. */
  100246. protected onContextMenu(evt: PointerEvent): void;
  100247. /**
  100248. * Detach the current controls from the specified dom element.
  100249. */
  100250. detachControl(): void;
  100251. /**
  100252. * Gets the class name of the current intput.
  100253. * @returns the class name
  100254. */
  100255. getClassName(): string;
  100256. /**
  100257. * Get the friendly name associated with the input class.
  100258. * @returns the input friendly name
  100259. */
  100260. getSimpleName(): string;
  100261. }
  100262. }
  100263. declare module BABYLON {
  100264. /**
  100265. * Base class for mouse wheel input..
  100266. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  100267. * for example usage.
  100268. */
  100269. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  100270. /**
  100271. * Defines the camera the input is attached to.
  100272. */
  100273. abstract camera: Camera;
  100274. /**
  100275. * How fast is the camera moves in relation to X axis mouseWheel events.
  100276. * Use negative value to reverse direction.
  100277. */
  100278. wheelPrecisionX: number;
  100279. /**
  100280. * How fast is the camera moves in relation to Y axis mouseWheel events.
  100281. * Use negative value to reverse direction.
  100282. */
  100283. wheelPrecisionY: number;
  100284. /**
  100285. * How fast is the camera moves in relation to Z axis mouseWheel events.
  100286. * Use negative value to reverse direction.
  100287. */
  100288. wheelPrecisionZ: number;
  100289. /**
  100290. * Observable for when a mouse wheel move event occurs.
  100291. */
  100292. onChangedObservable: Observable<{
  100293. wheelDeltaX: number;
  100294. wheelDeltaY: number;
  100295. wheelDeltaZ: number;
  100296. }>;
  100297. private _wheel;
  100298. private _observer;
  100299. /**
  100300. * Attach the input controls to a specific dom element to get the input from.
  100301. * @param noPreventDefault Defines whether event caught by the controls
  100302. * should call preventdefault().
  100303. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100304. */
  100305. attachControl(noPreventDefault?: boolean): void;
  100306. /**
  100307. * Detach the current controls from the specified dom element.
  100308. */
  100309. detachControl(): void;
  100310. /**
  100311. * Called for each rendered frame.
  100312. */
  100313. checkInputs(): void;
  100314. /**
  100315. * Gets the class name of the current intput.
  100316. * @returns the class name
  100317. */
  100318. getClassName(): string;
  100319. /**
  100320. * Get the friendly name associated with the input class.
  100321. * @returns the input friendly name
  100322. */
  100323. getSimpleName(): string;
  100324. /**
  100325. * Incremental value of multiple mouse wheel movements of the X axis.
  100326. * Should be zero-ed when read.
  100327. */
  100328. protected _wheelDeltaX: number;
  100329. /**
  100330. * Incremental value of multiple mouse wheel movements of the Y axis.
  100331. * Should be zero-ed when read.
  100332. */
  100333. protected _wheelDeltaY: number;
  100334. /**
  100335. * Incremental value of multiple mouse wheel movements of the Z axis.
  100336. * Should be zero-ed when read.
  100337. */
  100338. protected _wheelDeltaZ: number;
  100339. /**
  100340. * Firefox uses a different scheme to report scroll distances to other
  100341. * browsers. Rather than use complicated methods to calculate the exact
  100342. * multiple we need to apply, let's just cheat and use a constant.
  100343. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  100344. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  100345. */
  100346. private readonly _ffMultiplier;
  100347. /**
  100348. * Different event attributes for wheel data fall into a few set ranges.
  100349. * Some relevant but dated date here:
  100350. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  100351. */
  100352. private readonly _normalize;
  100353. }
  100354. }
  100355. declare module BABYLON {
  100356. /**
  100357. * Manage the mouse wheel inputs to control a free camera.
  100358. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100359. */
  100360. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  100361. /**
  100362. * Defines the camera the input is attached to.
  100363. */
  100364. camera: FreeCamera;
  100365. /**
  100366. * Gets the class name of the current input.
  100367. * @returns the class name
  100368. */
  100369. getClassName(): string;
  100370. /**
  100371. * Set which movement axis (relative to camera's orientation) the mouse
  100372. * wheel's X axis controls.
  100373. * @param axis The axis to be moved. Set null to clear.
  100374. */
  100375. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  100376. /**
  100377. * Get the configured movement axis (relative to camera's orientation) the
  100378. * mouse wheel's X axis controls.
  100379. * @returns The configured axis or null if none.
  100380. */
  100381. get wheelXMoveRelative(): Nullable<Coordinate>;
  100382. /**
  100383. * Set which movement axis (relative to camera's orientation) the mouse
  100384. * wheel's Y axis controls.
  100385. * @param axis The axis to be moved. Set null to clear.
  100386. */
  100387. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  100388. /**
  100389. * Get the configured movement axis (relative to camera's orientation) the
  100390. * mouse wheel's Y axis controls.
  100391. * @returns The configured axis or null if none.
  100392. */
  100393. get wheelYMoveRelative(): Nullable<Coordinate>;
  100394. /**
  100395. * Set which movement axis (relative to camera's orientation) the mouse
  100396. * wheel's Z axis controls.
  100397. * @param axis The axis to be moved. Set null to clear.
  100398. */
  100399. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  100400. /**
  100401. * Get the configured movement axis (relative to camera's orientation) the
  100402. * mouse wheel's Z axis controls.
  100403. * @returns The configured axis or null if none.
  100404. */
  100405. get wheelZMoveRelative(): Nullable<Coordinate>;
  100406. /**
  100407. * Set which rotation axis (relative to camera's orientation) the mouse
  100408. * wheel's X axis controls.
  100409. * @param axis The axis to be moved. Set null to clear.
  100410. */
  100411. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  100412. /**
  100413. * Get the configured rotation axis (relative to camera's orientation) the
  100414. * mouse wheel's X axis controls.
  100415. * @returns The configured axis or null if none.
  100416. */
  100417. get wheelXRotateRelative(): Nullable<Coordinate>;
  100418. /**
  100419. * Set which rotation axis (relative to camera's orientation) the mouse
  100420. * wheel's Y axis controls.
  100421. * @param axis The axis to be moved. Set null to clear.
  100422. */
  100423. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  100424. /**
  100425. * Get the configured rotation axis (relative to camera's orientation) the
  100426. * mouse wheel's Y axis controls.
  100427. * @returns The configured axis or null if none.
  100428. */
  100429. get wheelYRotateRelative(): Nullable<Coordinate>;
  100430. /**
  100431. * Set which rotation axis (relative to camera's orientation) the mouse
  100432. * wheel's Z axis controls.
  100433. * @param axis The axis to be moved. Set null to clear.
  100434. */
  100435. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  100436. /**
  100437. * Get the configured rotation axis (relative to camera's orientation) the
  100438. * mouse wheel's Z axis controls.
  100439. * @returns The configured axis or null if none.
  100440. */
  100441. get wheelZRotateRelative(): Nullable<Coordinate>;
  100442. /**
  100443. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  100444. * controls.
  100445. * @param axis The axis to be moved. Set null to clear.
  100446. */
  100447. set wheelXMoveScene(axis: Nullable<Coordinate>);
  100448. /**
  100449. * Get the configured movement axis (relative to the scene) the mouse wheel's
  100450. * X axis controls.
  100451. * @returns The configured axis or null if none.
  100452. */
  100453. get wheelXMoveScene(): Nullable<Coordinate>;
  100454. /**
  100455. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  100456. * controls.
  100457. * @param axis The axis to be moved. Set null to clear.
  100458. */
  100459. set wheelYMoveScene(axis: Nullable<Coordinate>);
  100460. /**
  100461. * Get the configured movement axis (relative to the scene) the mouse wheel's
  100462. * Y axis controls.
  100463. * @returns The configured axis or null if none.
  100464. */
  100465. get wheelYMoveScene(): Nullable<Coordinate>;
  100466. /**
  100467. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  100468. * controls.
  100469. * @param axis The axis to be moved. Set null to clear.
  100470. */
  100471. set wheelZMoveScene(axis: Nullable<Coordinate>);
  100472. /**
  100473. * Get the configured movement axis (relative to the scene) the mouse wheel's
  100474. * Z axis controls.
  100475. * @returns The configured axis or null if none.
  100476. */
  100477. get wheelZMoveScene(): Nullable<Coordinate>;
  100478. /**
  100479. * Called for each rendered frame.
  100480. */
  100481. checkInputs(): void;
  100482. private _moveRelative;
  100483. private _rotateRelative;
  100484. private _moveScene;
  100485. /**
  100486. * These are set to the desired default behaviour.
  100487. */
  100488. private _wheelXAction;
  100489. private _wheelXActionCoordinate;
  100490. private _wheelYAction;
  100491. private _wheelYActionCoordinate;
  100492. private _wheelZAction;
  100493. private _wheelZActionCoordinate;
  100494. /**
  100495. * Update the camera according to any configured properties for the 3
  100496. * mouse-wheel axis.
  100497. */
  100498. private _updateCamera;
  100499. }
  100500. }
  100501. declare module BABYLON {
  100502. /**
  100503. * Manage the touch inputs to control the movement of a free camera.
  100504. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100505. */
  100506. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  100507. /**
  100508. * Define if mouse events can be treated as touch events
  100509. */
  100510. allowMouse: boolean;
  100511. /**
  100512. * Defines the camera the input is attached to.
  100513. */
  100514. camera: FreeCamera;
  100515. /**
  100516. * Defines the touch sensibility for rotation.
  100517. * The higher the faster.
  100518. */
  100519. touchAngularSensibility: number;
  100520. /**
  100521. * Defines the touch sensibility for move.
  100522. * The higher the faster.
  100523. */
  100524. touchMoveSensibility: number;
  100525. private _offsetX;
  100526. private _offsetY;
  100527. private _pointerPressed;
  100528. private _pointerInput?;
  100529. private _observer;
  100530. private _onLostFocus;
  100531. /**
  100532. * Manage the touch inputs to control the movement of a free camera.
  100533. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100534. * @param allowMouse Defines if mouse events can be treated as touch events
  100535. */
  100536. constructor(
  100537. /**
  100538. * Define if mouse events can be treated as touch events
  100539. */
  100540. allowMouse?: boolean);
  100541. /**
  100542. * Attach the input controls to a specific dom element to get the input from.
  100543. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100544. */
  100545. attachControl(noPreventDefault?: boolean): void;
  100546. /**
  100547. * Detach the current controls from the specified dom element.
  100548. * @param element Defines the element to stop listening the inputs from
  100549. */
  100550. detachControl(): void;
  100551. /**
  100552. * Update the current camera state depending on the inputs that have been used this frame.
  100553. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100554. */
  100555. checkInputs(): void;
  100556. /**
  100557. * Gets the class name of the current intput.
  100558. * @returns the class name
  100559. */
  100560. getClassName(): string;
  100561. /**
  100562. * Get the friendly name associated with the input class.
  100563. * @returns the input friendly name
  100564. */
  100565. getSimpleName(): string;
  100566. }
  100567. }
  100568. declare module BABYLON {
  100569. /**
  100570. * Default Inputs manager for the FreeCamera.
  100571. * It groups all the default supported inputs for ease of use.
  100572. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100573. */
  100574. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  100575. /**
  100576. * @hidden
  100577. */
  100578. _mouseInput: Nullable<FreeCameraMouseInput>;
  100579. /**
  100580. * @hidden
  100581. */
  100582. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  100583. /**
  100584. * Instantiates a new FreeCameraInputsManager.
  100585. * @param camera Defines the camera the inputs belong to
  100586. */
  100587. constructor(camera: FreeCamera);
  100588. /**
  100589. * Add keyboard input support to the input manager.
  100590. * @returns the current input manager
  100591. */
  100592. addKeyboard(): FreeCameraInputsManager;
  100593. /**
  100594. * Add mouse input support to the input manager.
  100595. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  100596. * @returns the current input manager
  100597. */
  100598. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  100599. /**
  100600. * Removes the mouse input support from the manager
  100601. * @returns the current input manager
  100602. */
  100603. removeMouse(): FreeCameraInputsManager;
  100604. /**
  100605. * Add mouse wheel input support to the input manager.
  100606. * @returns the current input manager
  100607. */
  100608. addMouseWheel(): FreeCameraInputsManager;
  100609. /**
  100610. * Removes the mouse wheel input support from the manager
  100611. * @returns the current input manager
  100612. */
  100613. removeMouseWheel(): FreeCameraInputsManager;
  100614. /**
  100615. * Add touch input support to the input manager.
  100616. * @returns the current input manager
  100617. */
  100618. addTouch(): FreeCameraInputsManager;
  100619. /**
  100620. * Remove all attached input methods from a camera
  100621. */
  100622. clear(): void;
  100623. }
  100624. }
  100625. declare module BABYLON {
  100626. /**
  100627. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100628. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  100629. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  100630. */
  100631. export class FreeCamera extends TargetCamera {
  100632. /**
  100633. * Define the collision ellipsoid of the camera.
  100634. * This is helpful to simulate a camera body like the player body around the camera
  100635. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100636. */
  100637. ellipsoid: Vector3;
  100638. /**
  100639. * Define an offset for the position of the ellipsoid around the camera.
  100640. * This can be helpful to determine the center of the body near the gravity center of the body
  100641. * instead of its head.
  100642. */
  100643. ellipsoidOffset: Vector3;
  100644. /**
  100645. * Enable or disable collisions of the camera with the rest of the scene objects.
  100646. */
  100647. checkCollisions: boolean;
  100648. /**
  100649. * Enable or disable gravity on the camera.
  100650. */
  100651. applyGravity: boolean;
  100652. /**
  100653. * Define the input manager associated to the camera.
  100654. */
  100655. inputs: FreeCameraInputsManager;
  100656. /**
  100657. * Gets the input sensibility for a mouse input. (default is 2000.0)
  100658. * Higher values reduce sensitivity.
  100659. */
  100660. get angularSensibility(): number;
  100661. /**
  100662. * Sets the input sensibility for a mouse input. (default is 2000.0)
  100663. * Higher values reduce sensitivity.
  100664. */
  100665. set angularSensibility(value: number);
  100666. /**
  100667. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  100668. */
  100669. get keysUp(): number[];
  100670. set keysUp(value: number[]);
  100671. /**
  100672. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  100673. */
  100674. get keysUpward(): number[];
  100675. set keysUpward(value: number[]);
  100676. /**
  100677. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  100678. */
  100679. get keysDown(): number[];
  100680. set keysDown(value: number[]);
  100681. /**
  100682. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  100683. */
  100684. get keysDownward(): number[];
  100685. set keysDownward(value: number[]);
  100686. /**
  100687. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  100688. */
  100689. get keysLeft(): number[];
  100690. set keysLeft(value: number[]);
  100691. /**
  100692. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  100693. */
  100694. get keysRight(): number[];
  100695. set keysRight(value: number[]);
  100696. /**
  100697. * Event raised when the camera collide with a mesh in the scene.
  100698. */
  100699. onCollide: (collidedMesh: AbstractMesh) => void;
  100700. private _collider;
  100701. private _needMoveForGravity;
  100702. private _oldPosition;
  100703. private _diffPosition;
  100704. private _newPosition;
  100705. /** @hidden */
  100706. _localDirection: Vector3;
  100707. /** @hidden */
  100708. _transformedDirection: Vector3;
  100709. /**
  100710. * Instantiates a Free Camera.
  100711. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100712. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  100713. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  100714. * @param name Define the name of the camera in the scene
  100715. * @param position Define the start position of the camera in the scene
  100716. * @param scene Define the scene the camera belongs to
  100717. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100718. */
  100719. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100720. /**
  100721. * Attached controls to the current camera.
  100722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100723. */
  100724. attachControl(noPreventDefault?: boolean): void;
  100725. /**
  100726. * Detach the current controls from the camera.
  100727. * The camera will stop reacting to inputs.
  100728. */
  100729. detachControl(): void;
  100730. private _collisionMask;
  100731. /**
  100732. * Define a collision mask to limit the list of object the camera can collide with
  100733. */
  100734. get collisionMask(): number;
  100735. set collisionMask(mask: number);
  100736. /** @hidden */
  100737. _collideWithWorld(displacement: Vector3): void;
  100738. private _onCollisionPositionChange;
  100739. /** @hidden */
  100740. _checkInputs(): void;
  100741. /** @hidden */
  100742. _decideIfNeedsToMove(): boolean;
  100743. /** @hidden */
  100744. _updatePosition(): void;
  100745. /**
  100746. * Destroy the camera and release the current resources hold by it.
  100747. */
  100748. dispose(): void;
  100749. /**
  100750. * Gets the current object class name.
  100751. * @return the class name
  100752. */
  100753. getClassName(): string;
  100754. }
  100755. }
  100756. declare module BABYLON {
  100757. /**
  100758. * Represents a gamepad control stick position
  100759. */
  100760. export class StickValues {
  100761. /**
  100762. * The x component of the control stick
  100763. */
  100764. x: number;
  100765. /**
  100766. * The y component of the control stick
  100767. */
  100768. y: number;
  100769. /**
  100770. * Initializes the gamepad x and y control stick values
  100771. * @param x The x component of the gamepad control stick value
  100772. * @param y The y component of the gamepad control stick value
  100773. */
  100774. constructor(
  100775. /**
  100776. * The x component of the control stick
  100777. */
  100778. x: number,
  100779. /**
  100780. * The y component of the control stick
  100781. */
  100782. y: number);
  100783. }
  100784. /**
  100785. * An interface which manages callbacks for gamepad button changes
  100786. */
  100787. export interface GamepadButtonChanges {
  100788. /**
  100789. * Called when a gamepad has been changed
  100790. */
  100791. changed: boolean;
  100792. /**
  100793. * Called when a gamepad press event has been triggered
  100794. */
  100795. pressChanged: boolean;
  100796. /**
  100797. * Called when a touch event has been triggered
  100798. */
  100799. touchChanged: boolean;
  100800. /**
  100801. * Called when a value has changed
  100802. */
  100803. valueChanged: boolean;
  100804. }
  100805. /**
  100806. * Represents a gamepad
  100807. */
  100808. export class Gamepad {
  100809. /**
  100810. * The id of the gamepad
  100811. */
  100812. id: string;
  100813. /**
  100814. * The index of the gamepad
  100815. */
  100816. index: number;
  100817. /**
  100818. * The browser gamepad
  100819. */
  100820. browserGamepad: any;
  100821. /**
  100822. * Specifies what type of gamepad this represents
  100823. */
  100824. type: number;
  100825. private _leftStick;
  100826. private _rightStick;
  100827. /** @hidden */
  100828. _isConnected: boolean;
  100829. private _leftStickAxisX;
  100830. private _leftStickAxisY;
  100831. private _rightStickAxisX;
  100832. private _rightStickAxisY;
  100833. /**
  100834. * Triggered when the left control stick has been changed
  100835. */
  100836. private _onleftstickchanged;
  100837. /**
  100838. * Triggered when the right control stick has been changed
  100839. */
  100840. private _onrightstickchanged;
  100841. /**
  100842. * Represents a gamepad controller
  100843. */
  100844. static GAMEPAD: number;
  100845. /**
  100846. * Represents a generic controller
  100847. */
  100848. static GENERIC: number;
  100849. /**
  100850. * Represents an XBox controller
  100851. */
  100852. static XBOX: number;
  100853. /**
  100854. * Represents a pose-enabled controller
  100855. */
  100856. static POSE_ENABLED: number;
  100857. /**
  100858. * Represents an Dual Shock controller
  100859. */
  100860. static DUALSHOCK: number;
  100861. /**
  100862. * Specifies whether the left control stick should be Y-inverted
  100863. */
  100864. protected _invertLeftStickY: boolean;
  100865. /**
  100866. * Specifies if the gamepad has been connected
  100867. */
  100868. get isConnected(): boolean;
  100869. /**
  100870. * Initializes the gamepad
  100871. * @param id The id of the gamepad
  100872. * @param index The index of the gamepad
  100873. * @param browserGamepad The browser gamepad
  100874. * @param leftStickX The x component of the left joystick
  100875. * @param leftStickY The y component of the left joystick
  100876. * @param rightStickX The x component of the right joystick
  100877. * @param rightStickY The y component of the right joystick
  100878. */
  100879. constructor(
  100880. /**
  100881. * The id of the gamepad
  100882. */
  100883. id: string,
  100884. /**
  100885. * The index of the gamepad
  100886. */
  100887. index: number,
  100888. /**
  100889. * The browser gamepad
  100890. */
  100891. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  100892. /**
  100893. * Callback triggered when the left joystick has changed
  100894. * @param callback
  100895. */
  100896. onleftstickchanged(callback: (values: StickValues) => void): void;
  100897. /**
  100898. * Callback triggered when the right joystick has changed
  100899. * @param callback
  100900. */
  100901. onrightstickchanged(callback: (values: StickValues) => void): void;
  100902. /**
  100903. * Gets the left joystick
  100904. */
  100905. get leftStick(): StickValues;
  100906. /**
  100907. * Sets the left joystick values
  100908. */
  100909. set leftStick(newValues: StickValues);
  100910. /**
  100911. * Gets the right joystick
  100912. */
  100913. get rightStick(): StickValues;
  100914. /**
  100915. * Sets the right joystick value
  100916. */
  100917. set rightStick(newValues: StickValues);
  100918. /**
  100919. * Updates the gamepad joystick positions
  100920. */
  100921. update(): void;
  100922. /**
  100923. * Disposes the gamepad
  100924. */
  100925. dispose(): void;
  100926. }
  100927. /**
  100928. * Represents a generic gamepad
  100929. */
  100930. export class GenericPad extends Gamepad {
  100931. private _buttons;
  100932. private _onbuttondown;
  100933. private _onbuttonup;
  100934. /**
  100935. * Observable triggered when a button has been pressed
  100936. */
  100937. onButtonDownObservable: Observable<number>;
  100938. /**
  100939. * Observable triggered when a button has been released
  100940. */
  100941. onButtonUpObservable: Observable<number>;
  100942. /**
  100943. * Callback triggered when a button has been pressed
  100944. * @param callback Called when a button has been pressed
  100945. */
  100946. onbuttondown(callback: (buttonPressed: number) => void): void;
  100947. /**
  100948. * Callback triggered when a button has been released
  100949. * @param callback Called when a button has been released
  100950. */
  100951. onbuttonup(callback: (buttonReleased: number) => void): void;
  100952. /**
  100953. * Initializes the generic gamepad
  100954. * @param id The id of the generic gamepad
  100955. * @param index The index of the generic gamepad
  100956. * @param browserGamepad The browser gamepad
  100957. */
  100958. constructor(id: string, index: number, browserGamepad: any);
  100959. private _setButtonValue;
  100960. /**
  100961. * Updates the generic gamepad
  100962. */
  100963. update(): void;
  100964. /**
  100965. * Disposes the generic gamepad
  100966. */
  100967. dispose(): void;
  100968. }
  100969. }
  100970. declare module BABYLON {
  100971. /**
  100972. * Defines the types of pose enabled controllers that are supported
  100973. */
  100974. export enum PoseEnabledControllerType {
  100975. /**
  100976. * HTC Vive
  100977. */
  100978. VIVE = 0,
  100979. /**
  100980. * Oculus Rift
  100981. */
  100982. OCULUS = 1,
  100983. /**
  100984. * Windows mixed reality
  100985. */
  100986. WINDOWS = 2,
  100987. /**
  100988. * Samsung gear VR
  100989. */
  100990. GEAR_VR = 3,
  100991. /**
  100992. * Google Daydream
  100993. */
  100994. DAYDREAM = 4,
  100995. /**
  100996. * Generic
  100997. */
  100998. GENERIC = 5
  100999. }
  101000. /**
  101001. * Defines the MutableGamepadButton interface for the state of a gamepad button
  101002. */
  101003. export interface MutableGamepadButton {
  101004. /**
  101005. * Value of the button/trigger
  101006. */
  101007. value: number;
  101008. /**
  101009. * If the button/trigger is currently touched
  101010. */
  101011. touched: boolean;
  101012. /**
  101013. * If the button/trigger is currently pressed
  101014. */
  101015. pressed: boolean;
  101016. }
  101017. /**
  101018. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  101019. * @hidden
  101020. */
  101021. export interface ExtendedGamepadButton extends GamepadButton {
  101022. /**
  101023. * If the button/trigger is currently pressed
  101024. */
  101025. readonly pressed: boolean;
  101026. /**
  101027. * If the button/trigger is currently touched
  101028. */
  101029. readonly touched: boolean;
  101030. /**
  101031. * Value of the button/trigger
  101032. */
  101033. readonly value: number;
  101034. }
  101035. /** @hidden */
  101036. export interface _GamePadFactory {
  101037. /**
  101038. * Returns whether or not the current gamepad can be created for this type of controller.
  101039. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  101040. * @returns true if it can be created, otherwise false
  101041. */
  101042. canCreate(gamepadInfo: any): boolean;
  101043. /**
  101044. * Creates a new instance of the Gamepad.
  101045. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  101046. * @returns the new gamepad instance
  101047. */
  101048. create(gamepadInfo: any): Gamepad;
  101049. }
  101050. /**
  101051. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  101052. */
  101053. export class PoseEnabledControllerHelper {
  101054. /** @hidden */
  101055. static _ControllerFactories: _GamePadFactory[];
  101056. /** @hidden */
  101057. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  101058. /**
  101059. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  101060. * @param vrGamepad the gamepad to initialized
  101061. * @returns a vr controller of the type the gamepad identified as
  101062. */
  101063. static InitiateController(vrGamepad: any): Gamepad;
  101064. }
  101065. /**
  101066. * Defines the PoseEnabledController object that contains state of a vr capable controller
  101067. */
  101068. export class PoseEnabledController extends Gamepad implements PoseControlled {
  101069. /**
  101070. * If the controller is used in a webXR session
  101071. */
  101072. isXR: boolean;
  101073. private _deviceRoomPosition;
  101074. private _deviceRoomRotationQuaternion;
  101075. /**
  101076. * The device position in babylon space
  101077. */
  101078. devicePosition: Vector3;
  101079. /**
  101080. * The device rotation in babylon space
  101081. */
  101082. deviceRotationQuaternion: Quaternion;
  101083. /**
  101084. * The scale factor of the device in babylon space
  101085. */
  101086. deviceScaleFactor: number;
  101087. /**
  101088. * (Likely devicePosition should be used instead) The device position in its room space
  101089. */
  101090. position: Vector3;
  101091. /**
  101092. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  101093. */
  101094. rotationQuaternion: Quaternion;
  101095. /**
  101096. * The type of controller (Eg. Windows mixed reality)
  101097. */
  101098. controllerType: PoseEnabledControllerType;
  101099. protected _calculatedPosition: Vector3;
  101100. private _calculatedRotation;
  101101. /**
  101102. * The raw pose from the device
  101103. */
  101104. rawPose: DevicePose;
  101105. private _trackPosition;
  101106. private _maxRotationDistFromHeadset;
  101107. private _draggedRoomRotation;
  101108. /**
  101109. * @hidden
  101110. */
  101111. _disableTrackPosition(fixedPosition: Vector3): void;
  101112. /**
  101113. * Internal, the mesh attached to the controller
  101114. * @hidden
  101115. */
  101116. _mesh: Nullable<AbstractMesh>;
  101117. private _poseControlledCamera;
  101118. private _leftHandSystemQuaternion;
  101119. /**
  101120. * Internal, matrix used to convert room space to babylon space
  101121. * @hidden
  101122. */
  101123. _deviceToWorld: Matrix;
  101124. /**
  101125. * Node to be used when casting a ray from the controller
  101126. * @hidden
  101127. */
  101128. _pointingPoseNode: Nullable<TransformNode>;
  101129. /**
  101130. * Name of the child mesh that can be used to cast a ray from the controller
  101131. */
  101132. static readonly POINTING_POSE: string;
  101133. /**
  101134. * Creates a new PoseEnabledController from a gamepad
  101135. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  101136. */
  101137. constructor(browserGamepad: any);
  101138. private _workingMatrix;
  101139. /**
  101140. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  101141. */
  101142. update(): void;
  101143. /**
  101144. * Updates only the pose device and mesh without doing any button event checking
  101145. */
  101146. protected _updatePoseAndMesh(): void;
  101147. /**
  101148. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  101149. * @param poseData raw pose fromthe device
  101150. */
  101151. updateFromDevice(poseData: DevicePose): void;
  101152. /**
  101153. * @hidden
  101154. */
  101155. _meshAttachedObservable: Observable<AbstractMesh>;
  101156. /**
  101157. * Attaches a mesh to the controller
  101158. * @param mesh the mesh to be attached
  101159. */
  101160. attachToMesh(mesh: AbstractMesh): void;
  101161. /**
  101162. * Attaches the controllers mesh to a camera
  101163. * @param camera the camera the mesh should be attached to
  101164. */
  101165. attachToPoseControlledCamera(camera: TargetCamera): void;
  101166. /**
  101167. * Disposes of the controller
  101168. */
  101169. dispose(): void;
  101170. /**
  101171. * The mesh that is attached to the controller
  101172. */
  101173. get mesh(): Nullable<AbstractMesh>;
  101174. /**
  101175. * Gets the ray of the controller in the direction the controller is pointing
  101176. * @param length the length the resulting ray should be
  101177. * @returns a ray in the direction the controller is pointing
  101178. */
  101179. getForwardRay(length?: number): Ray;
  101180. }
  101181. }
  101182. declare module BABYLON {
  101183. /**
  101184. * Defines the WebVRController object that represents controllers tracked in 3D space
  101185. */
  101186. export abstract class WebVRController extends PoseEnabledController {
  101187. /**
  101188. * Internal, the default controller model for the controller
  101189. */
  101190. protected _defaultModel: Nullable<AbstractMesh>;
  101191. /**
  101192. * Fired when the trigger state has changed
  101193. */
  101194. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101195. /**
  101196. * Fired when the main button state has changed
  101197. */
  101198. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101199. /**
  101200. * Fired when the secondary button state has changed
  101201. */
  101202. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101203. /**
  101204. * Fired when the pad state has changed
  101205. */
  101206. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  101207. /**
  101208. * Fired when controllers stick values have changed
  101209. */
  101210. onPadValuesChangedObservable: Observable<StickValues>;
  101211. /**
  101212. * Array of button availible on the controller
  101213. */
  101214. protected _buttons: Array<MutableGamepadButton>;
  101215. private _onButtonStateChange;
  101216. /**
  101217. * Fired when a controller button's state has changed
  101218. * @param callback the callback containing the button that was modified
  101219. */
  101220. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  101221. /**
  101222. * X and Y axis corresponding to the controllers joystick
  101223. */
  101224. pad: StickValues;
  101225. /**
  101226. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  101227. */
  101228. hand: string;
  101229. /**
  101230. * The default controller model for the controller
  101231. */
  101232. get defaultModel(): Nullable<AbstractMesh>;
  101233. /**
  101234. * Creates a new WebVRController from a gamepad
  101235. * @param vrGamepad the gamepad that the WebVRController should be created from
  101236. */
  101237. constructor(vrGamepad: any);
  101238. /**
  101239. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  101240. */
  101241. update(): void;
  101242. /**
  101243. * Function to be called when a button is modified
  101244. */
  101245. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101246. /**
  101247. * Loads a mesh and attaches it to the controller
  101248. * @param scene the scene the mesh should be added to
  101249. * @param meshLoaded callback for when the mesh has been loaded
  101250. */
  101251. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101252. private _setButtonValue;
  101253. private _changes;
  101254. private _checkChanges;
  101255. /**
  101256. * Disposes of th webVRCOntroller
  101257. */
  101258. dispose(): void;
  101259. }
  101260. }
  101261. declare module BABYLON {
  101262. /**
  101263. * The HemisphericLight simulates the ambient environment light,
  101264. * so the passed direction is the light reflection direction, not the incoming direction.
  101265. */
  101266. export class HemisphericLight extends Light {
  101267. /**
  101268. * The groundColor is the light in the opposite direction to the one specified during creation.
  101269. * 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.
  101270. */
  101271. groundColor: Color3;
  101272. /**
  101273. * The light reflection direction, not the incoming direction.
  101274. */
  101275. direction: Vector3;
  101276. /**
  101277. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  101278. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  101279. * The HemisphericLight can't cast shadows.
  101280. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101281. * @param name The friendly name of the light
  101282. * @param direction The direction of the light reflection
  101283. * @param scene The scene the light belongs to
  101284. */
  101285. constructor(name: string, direction: Vector3, scene: Scene);
  101286. protected _buildUniformLayout(): void;
  101287. /**
  101288. * Returns the string "HemisphericLight".
  101289. * @return The class name
  101290. */
  101291. getClassName(): string;
  101292. /**
  101293. * Sets the HemisphericLight direction towards the passed target (Vector3).
  101294. * Returns the updated direction.
  101295. * @param target The target the direction should point to
  101296. * @return The computed direction
  101297. */
  101298. setDirectionToTarget(target: Vector3): Vector3;
  101299. /**
  101300. * Returns the shadow generator associated to the light.
  101301. * @returns Always null for hemispheric lights because it does not support shadows.
  101302. */
  101303. getShadowGenerator(): Nullable<IShadowGenerator>;
  101304. /**
  101305. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  101306. * @param effect The effect to update
  101307. * @param lightIndex The index of the light in the effect to update
  101308. * @returns The hemispheric light
  101309. */
  101310. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  101311. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  101312. /**
  101313. * Computes the world matrix of the node
  101314. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  101315. * @param useWasUpdatedFlag defines a reserved property
  101316. * @returns the world matrix
  101317. */
  101318. computeWorldMatrix(): Matrix;
  101319. /**
  101320. * Returns the integer 3.
  101321. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101322. */
  101323. getTypeID(): number;
  101324. /**
  101325. * Prepares the list of defines specific to the light type.
  101326. * @param defines the list of defines
  101327. * @param lightIndex defines the index of the light for the effect
  101328. */
  101329. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101330. }
  101331. }
  101332. declare module BABYLON {
  101333. /** @hidden */
  101334. export var vrMultiviewToSingleviewPixelShader: {
  101335. name: string;
  101336. shader: string;
  101337. };
  101338. }
  101339. declare module BABYLON {
  101340. /**
  101341. * Renders to multiple views with a single draw call
  101342. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  101343. */
  101344. export class MultiviewRenderTarget extends RenderTargetTexture {
  101345. /**
  101346. * Creates a multiview render target
  101347. * @param scene scene used with the render target
  101348. * @param size the size of the render target (used for each view)
  101349. */
  101350. constructor(scene: Scene, size?: number | {
  101351. width: number;
  101352. height: number;
  101353. } | {
  101354. ratio: number;
  101355. });
  101356. /**
  101357. * @hidden
  101358. * @param faceIndex the face index, if its a cube texture
  101359. */
  101360. _bindFrameBuffer(faceIndex?: number): void;
  101361. /**
  101362. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101363. * @returns the view count
  101364. */
  101365. getViewCount(): number;
  101366. }
  101367. }
  101368. declare module BABYLON {
  101369. interface Engine {
  101370. /**
  101371. * Creates a new multiview render target
  101372. * @param width defines the width of the texture
  101373. * @param height defines the height of the texture
  101374. * @returns the created multiview texture
  101375. */
  101376. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  101377. /**
  101378. * Binds a multiview framebuffer to be drawn to
  101379. * @param multiviewTexture texture to bind
  101380. */
  101381. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  101382. }
  101383. interface Camera {
  101384. /**
  101385. * @hidden
  101386. * 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)
  101387. */
  101388. _useMultiviewToSingleView: boolean;
  101389. /**
  101390. * @hidden
  101391. * 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)
  101392. */
  101393. _multiviewTexture: Nullable<RenderTargetTexture>;
  101394. /**
  101395. * @hidden
  101396. * ensures the multiview texture of the camera exists and has the specified width/height
  101397. * @param width height to set on the multiview texture
  101398. * @param height width to set on the multiview texture
  101399. */
  101400. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  101401. }
  101402. interface Scene {
  101403. /** @hidden */
  101404. _transformMatrixR: Matrix;
  101405. /** @hidden */
  101406. _multiviewSceneUbo: Nullable<UniformBuffer>;
  101407. /** @hidden */
  101408. _createMultiviewUbo(): void;
  101409. /** @hidden */
  101410. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  101411. /** @hidden */
  101412. _renderMultiviewToSingleView(camera: Camera): void;
  101413. }
  101414. }
  101415. declare module BABYLON {
  101416. /**
  101417. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  101418. * This will not be used for webXR as it supports displaying texture arrays directly
  101419. */
  101420. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  101421. /**
  101422. * Gets a string identifying the name of the class
  101423. * @returns "VRMultiviewToSingleviewPostProcess" string
  101424. */
  101425. getClassName(): string;
  101426. /**
  101427. * Initializes a VRMultiviewToSingleview
  101428. * @param name name of the post process
  101429. * @param camera camera to be applied to
  101430. * @param scaleFactor scaling factor to the size of the output texture
  101431. */
  101432. constructor(name: string, camera: Camera, scaleFactor: number);
  101433. }
  101434. }
  101435. declare module BABYLON {
  101436. /**
  101437. * Interface used to define additional presentation attributes
  101438. */
  101439. export interface IVRPresentationAttributes {
  101440. /**
  101441. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  101442. */
  101443. highRefreshRate: boolean;
  101444. /**
  101445. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  101446. */
  101447. foveationLevel: number;
  101448. }
  101449. interface Engine {
  101450. /** @hidden */
  101451. _vrDisplay: any;
  101452. /** @hidden */
  101453. _vrSupported: boolean;
  101454. /** @hidden */
  101455. _oldSize: Size;
  101456. /** @hidden */
  101457. _oldHardwareScaleFactor: number;
  101458. /** @hidden */
  101459. _vrExclusivePointerMode: boolean;
  101460. /** @hidden */
  101461. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  101462. /** @hidden */
  101463. _onVRDisplayPointerRestricted: () => void;
  101464. /** @hidden */
  101465. _onVRDisplayPointerUnrestricted: () => void;
  101466. /** @hidden */
  101467. _onVrDisplayConnect: Nullable<(display: any) => void>;
  101468. /** @hidden */
  101469. _onVrDisplayDisconnect: Nullable<() => void>;
  101470. /** @hidden */
  101471. _onVrDisplayPresentChange: Nullable<() => void>;
  101472. /**
  101473. * Observable signaled when VR display mode changes
  101474. */
  101475. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  101476. /**
  101477. * Observable signaled when VR request present is complete
  101478. */
  101479. onVRRequestPresentComplete: Observable<boolean>;
  101480. /**
  101481. * Observable signaled when VR request present starts
  101482. */
  101483. onVRRequestPresentStart: Observable<Engine>;
  101484. /**
  101485. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  101486. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  101487. */
  101488. isInVRExclusivePointerMode: boolean;
  101489. /**
  101490. * Gets a boolean indicating if a webVR device was detected
  101491. * @returns true if a webVR device was detected
  101492. */
  101493. isVRDevicePresent(): boolean;
  101494. /**
  101495. * Gets the current webVR device
  101496. * @returns the current webVR device (or null)
  101497. */
  101498. getVRDevice(): any;
  101499. /**
  101500. * Initializes a webVR display and starts listening to display change events
  101501. * The onVRDisplayChangedObservable will be notified upon these changes
  101502. * @returns A promise containing a VRDisplay and if vr is supported
  101503. */
  101504. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  101505. /** @hidden */
  101506. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  101507. /**
  101508. * Gets or sets the presentation attributes used to configure VR rendering
  101509. */
  101510. vrPresentationAttributes?: IVRPresentationAttributes;
  101511. /**
  101512. * Call this function to switch to webVR mode
  101513. * Will do nothing if webVR is not supported or if there is no webVR device
  101514. * @param options the webvr options provided to the camera. mainly used for multiview
  101515. * @see https://doc.babylonjs.com/how_to/webvr_camera
  101516. */
  101517. enableVR(options: WebVROptions): void;
  101518. /** @hidden */
  101519. _onVRFullScreenTriggered(): void;
  101520. }
  101521. }
  101522. declare module BABYLON {
  101523. /**
  101524. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  101525. * IMPORTANT!! The data is right-hand data.
  101526. * @export
  101527. * @interface DevicePose
  101528. */
  101529. export interface DevicePose {
  101530. /**
  101531. * The position of the device, values in array are [x,y,z].
  101532. */
  101533. readonly position: Nullable<Float32Array>;
  101534. /**
  101535. * The linearVelocity of the device, values in array are [x,y,z].
  101536. */
  101537. readonly linearVelocity: Nullable<Float32Array>;
  101538. /**
  101539. * The linearAcceleration of the device, values in array are [x,y,z].
  101540. */
  101541. readonly linearAcceleration: Nullable<Float32Array>;
  101542. /**
  101543. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  101544. */
  101545. readonly orientation: Nullable<Float32Array>;
  101546. /**
  101547. * The angularVelocity of the device, values in array are [x,y,z].
  101548. */
  101549. readonly angularVelocity: Nullable<Float32Array>;
  101550. /**
  101551. * The angularAcceleration of the device, values in array are [x,y,z].
  101552. */
  101553. readonly angularAcceleration: Nullable<Float32Array>;
  101554. }
  101555. /**
  101556. * Interface representing a pose controlled object in Babylon.
  101557. * A pose controlled object has both regular pose values as well as pose values
  101558. * from an external device such as a VR head mounted display
  101559. */
  101560. export interface PoseControlled {
  101561. /**
  101562. * The position of the object in babylon space.
  101563. */
  101564. position: Vector3;
  101565. /**
  101566. * The rotation quaternion of the object in babylon space.
  101567. */
  101568. rotationQuaternion: Quaternion;
  101569. /**
  101570. * The position of the device in babylon space.
  101571. */
  101572. devicePosition?: Vector3;
  101573. /**
  101574. * The rotation quaternion of the device in babylon space.
  101575. */
  101576. deviceRotationQuaternion: Quaternion;
  101577. /**
  101578. * The raw pose coming from the device.
  101579. */
  101580. rawPose: Nullable<DevicePose>;
  101581. /**
  101582. * The scale of the device to be used when translating from device space to babylon space.
  101583. */
  101584. deviceScaleFactor: number;
  101585. /**
  101586. * Updates the poseControlled values based on the input device pose.
  101587. * @param poseData the pose data to update the object with
  101588. */
  101589. updateFromDevice(poseData: DevicePose): void;
  101590. }
  101591. /**
  101592. * Set of options to customize the webVRCamera
  101593. */
  101594. export interface WebVROptions {
  101595. /**
  101596. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  101597. */
  101598. trackPosition?: boolean;
  101599. /**
  101600. * Sets the scale of the vrDevice in babylon space. (default: 1)
  101601. */
  101602. positionScale?: number;
  101603. /**
  101604. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  101605. */
  101606. displayName?: string;
  101607. /**
  101608. * Should the native controller meshes be initialized. (default: true)
  101609. */
  101610. controllerMeshes?: boolean;
  101611. /**
  101612. * Creating a default HemiLight only on controllers. (default: true)
  101613. */
  101614. defaultLightingOnControllers?: boolean;
  101615. /**
  101616. * If you don't want to use the default VR button of the helper. (default: false)
  101617. */
  101618. useCustomVRButton?: boolean;
  101619. /**
  101620. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  101621. */
  101622. customVRButton?: HTMLButtonElement;
  101623. /**
  101624. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  101625. */
  101626. rayLength?: number;
  101627. /**
  101628. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  101629. */
  101630. defaultHeight?: number;
  101631. /**
  101632. * If multiview should be used if availible (default: false)
  101633. */
  101634. useMultiview?: boolean;
  101635. }
  101636. /**
  101637. * This represents a WebVR camera.
  101638. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  101639. * @example https://doc.babylonjs.com/how_to/webvr_camera
  101640. */
  101641. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  101642. private webVROptions;
  101643. /**
  101644. * @hidden
  101645. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  101646. */
  101647. _vrDevice: any;
  101648. /**
  101649. * The rawPose of the vrDevice.
  101650. */
  101651. rawPose: Nullable<DevicePose>;
  101652. private _onVREnabled;
  101653. private _specsVersion;
  101654. private _attached;
  101655. private _frameData;
  101656. protected _descendants: Array<Node>;
  101657. private _deviceRoomPosition;
  101658. /** @hidden */
  101659. _deviceRoomRotationQuaternion: Quaternion;
  101660. private _standingMatrix;
  101661. /**
  101662. * Represents device position in babylon space.
  101663. */
  101664. devicePosition: Vector3;
  101665. /**
  101666. * Represents device rotation in babylon space.
  101667. */
  101668. deviceRotationQuaternion: Quaternion;
  101669. /**
  101670. * The scale of the device to be used when translating from device space to babylon space.
  101671. */
  101672. deviceScaleFactor: number;
  101673. private _deviceToWorld;
  101674. private _worldToDevice;
  101675. /**
  101676. * References to the webVR controllers for the vrDevice.
  101677. */
  101678. controllers: Array<WebVRController>;
  101679. /**
  101680. * Emits an event when a controller is attached.
  101681. */
  101682. onControllersAttachedObservable: Observable<WebVRController[]>;
  101683. /**
  101684. * Emits an event when a controller's mesh has been loaded;
  101685. */
  101686. onControllerMeshLoadedObservable: Observable<WebVRController>;
  101687. /**
  101688. * Emits an event when the HMD's pose has been updated.
  101689. */
  101690. onPoseUpdatedFromDeviceObservable: Observable<any>;
  101691. private _poseSet;
  101692. /**
  101693. * If the rig cameras be used as parent instead of this camera.
  101694. */
  101695. rigParenting: boolean;
  101696. private _lightOnControllers;
  101697. private _defaultHeight?;
  101698. /**
  101699. * Instantiates a WebVRFreeCamera.
  101700. * @param name The name of the WebVRFreeCamera
  101701. * @param position The starting anchor position for the camera
  101702. * @param scene The scene the camera belongs to
  101703. * @param webVROptions a set of customizable options for the webVRCamera
  101704. */
  101705. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  101706. /**
  101707. * Gets the device distance from the ground in meters.
  101708. * @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.
  101709. */
  101710. deviceDistanceToRoomGround(): number;
  101711. /**
  101712. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101713. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  101714. */
  101715. useStandingMatrix(callback?: (bool: boolean) => void): void;
  101716. /**
  101717. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101718. * @returns A promise with a boolean set to if the standing matrix is supported.
  101719. */
  101720. useStandingMatrixAsync(): Promise<boolean>;
  101721. /**
  101722. * Disposes the camera
  101723. */
  101724. dispose(): void;
  101725. /**
  101726. * Gets a vrController by name.
  101727. * @param name The name of the controller to retreive
  101728. * @returns the controller matching the name specified or null if not found
  101729. */
  101730. getControllerByName(name: string): Nullable<WebVRController>;
  101731. private _leftController;
  101732. /**
  101733. * The controller corresponding to the users left hand.
  101734. */
  101735. get leftController(): Nullable<WebVRController>;
  101736. private _rightController;
  101737. /**
  101738. * The controller corresponding to the users right hand.
  101739. */
  101740. get rightController(): Nullable<WebVRController>;
  101741. /**
  101742. * Casts a ray forward from the vrCamera's gaze.
  101743. * @param length Length of the ray (default: 100)
  101744. * @returns the ray corresponding to the gaze
  101745. */
  101746. getForwardRay(length?: number): Ray;
  101747. /**
  101748. * @hidden
  101749. * Updates the camera based on device's frame data
  101750. */
  101751. _checkInputs(): void;
  101752. /**
  101753. * Updates the poseControlled values based on the input device pose.
  101754. * @param poseData Pose coming from the device
  101755. */
  101756. updateFromDevice(poseData: DevicePose): void;
  101757. private _detachIfAttached;
  101758. /**
  101759. * WebVR's attach control will start broadcasting frames to the device.
  101760. * Note that in certain browsers (chrome for example) this function must be called
  101761. * within a user-interaction callback. Example:
  101762. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  101763. *
  101764. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  101765. */
  101766. attachControl(noPreventDefault?: boolean): void;
  101767. /**
  101768. * Detaches the camera from the html element and disables VR
  101769. */
  101770. detachControl(): void;
  101771. /**
  101772. * @returns the name of this class
  101773. */
  101774. getClassName(): string;
  101775. /**
  101776. * Calls resetPose on the vrDisplay
  101777. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  101778. */
  101779. resetToCurrentRotation(): void;
  101780. /**
  101781. * @hidden
  101782. * Updates the rig cameras (left and right eye)
  101783. */
  101784. _updateRigCameras(): void;
  101785. private _workingVector;
  101786. private _oneVector;
  101787. private _workingMatrix;
  101788. private updateCacheCalled;
  101789. private _correctPositionIfNotTrackPosition;
  101790. /**
  101791. * @hidden
  101792. * Updates the cached values of the camera
  101793. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  101794. */
  101795. _updateCache(ignoreParentClass?: boolean): void;
  101796. /**
  101797. * @hidden
  101798. * Get current device position in babylon world
  101799. */
  101800. _computeDevicePosition(): void;
  101801. /**
  101802. * Updates the current device position and rotation in the babylon world
  101803. */
  101804. update(): void;
  101805. /**
  101806. * @hidden
  101807. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  101808. * @returns an identity matrix
  101809. */
  101810. _getViewMatrix(): Matrix;
  101811. private _tmpMatrix;
  101812. /**
  101813. * This function is called by the two RIG cameras.
  101814. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  101815. * @hidden
  101816. */
  101817. _getWebVRViewMatrix(): Matrix;
  101818. /** @hidden */
  101819. _getWebVRProjectionMatrix(): Matrix;
  101820. private _onGamepadConnectedObserver;
  101821. private _onGamepadDisconnectedObserver;
  101822. private _updateCacheWhenTrackingDisabledObserver;
  101823. /**
  101824. * Initializes the controllers and their meshes
  101825. */
  101826. initControllers(): void;
  101827. }
  101828. }
  101829. declare module BABYLON {
  101830. /**
  101831. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  101832. *
  101833. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  101834. *
  101835. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  101836. */
  101837. export class MaterialHelper {
  101838. /**
  101839. * Bind the current view position to an effect.
  101840. * @param effect The effect to be bound
  101841. * @param scene The scene the eyes position is used from
  101842. * @param variableName name of the shader variable that will hold the eye position
  101843. */
  101844. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  101845. /**
  101846. * Helps preparing the defines values about the UVs in used in the effect.
  101847. * UVs are shared as much as we can accross channels in the shaders.
  101848. * @param texture The texture we are preparing the UVs for
  101849. * @param defines The defines to update
  101850. * @param key The channel key "diffuse", "specular"... used in the shader
  101851. */
  101852. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  101853. /**
  101854. * Binds a texture matrix value to its corrsponding uniform
  101855. * @param texture The texture to bind the matrix for
  101856. * @param uniformBuffer The uniform buffer receivin the data
  101857. * @param key The channel key "diffuse", "specular"... used in the shader
  101858. */
  101859. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  101860. /**
  101861. * Gets the current status of the fog (should it be enabled?)
  101862. * @param mesh defines the mesh to evaluate for fog support
  101863. * @param scene defines the hosting scene
  101864. * @returns true if fog must be enabled
  101865. */
  101866. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  101867. /**
  101868. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  101869. * @param mesh defines the current mesh
  101870. * @param scene defines the current scene
  101871. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  101872. * @param pointsCloud defines if point cloud rendering has to be turned on
  101873. * @param fogEnabled defines if fog has to be turned on
  101874. * @param alphaTest defines if alpha testing has to be turned on
  101875. * @param defines defines the current list of defines
  101876. */
  101877. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  101878. /**
  101879. * Helper used to prepare the list of defines associated with frame values for shader compilation
  101880. * @param scene defines the current scene
  101881. * @param engine defines the current engine
  101882. * @param defines specifies the list of active defines
  101883. * @param useInstances defines if instances have to be turned on
  101884. * @param useClipPlane defines if clip plane have to be turned on
  101885. * @param useInstances defines if instances have to be turned on
  101886. * @param useThinInstances defines if thin instances have to be turned on
  101887. */
  101888. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  101889. /**
  101890. * Prepares the defines for bones
  101891. * @param mesh The mesh containing the geometry data we will draw
  101892. * @param defines The defines to update
  101893. */
  101894. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  101895. /**
  101896. * Prepares the defines for morph targets
  101897. * @param mesh The mesh containing the geometry data we will draw
  101898. * @param defines The defines to update
  101899. */
  101900. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  101901. /**
  101902. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  101903. * @param mesh The mesh containing the geometry data we will draw
  101904. * @param defines The defines to update
  101905. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  101906. * @param useBones Precise whether bones should be used or not (override mesh info)
  101907. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  101908. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  101909. * @returns false if defines are considered not dirty and have not been checked
  101910. */
  101911. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  101912. /**
  101913. * Prepares the defines related to multiview
  101914. * @param scene The scene we are intending to draw
  101915. * @param defines The defines to update
  101916. */
  101917. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  101918. /**
  101919. * Prepares the defines related to the prepass
  101920. * @param scene The scene we are intending to draw
  101921. * @param defines The defines to update
  101922. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  101923. */
  101924. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  101925. /**
  101926. * Prepares the defines related to the light information passed in parameter
  101927. * @param scene The scene we are intending to draw
  101928. * @param mesh The mesh the effect is compiling for
  101929. * @param light The light the effect is compiling for
  101930. * @param lightIndex The index of the light
  101931. * @param defines The defines to update
  101932. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101933. * @param state Defines the current state regarding what is needed (normals, etc...)
  101934. */
  101935. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  101936. needNormals: boolean;
  101937. needRebuild: boolean;
  101938. shadowEnabled: boolean;
  101939. specularEnabled: boolean;
  101940. lightmapMode: boolean;
  101941. }): void;
  101942. /**
  101943. * Prepares the defines related to the light information passed in parameter
  101944. * @param scene The scene we are intending to draw
  101945. * @param mesh The mesh the effect is compiling for
  101946. * @param defines The defines to update
  101947. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101948. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  101949. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  101950. * @returns true if normals will be required for the rest of the effect
  101951. */
  101952. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  101953. /**
  101954. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  101955. * @param lightIndex defines the light index
  101956. * @param uniformsList The uniform list
  101957. * @param samplersList The sampler list
  101958. * @param projectedLightTexture defines if projected texture must be used
  101959. * @param uniformBuffersList defines an optional list of uniform buffers
  101960. */
  101961. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  101962. /**
  101963. * Prepares the uniforms and samplers list to be used in the effect
  101964. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  101965. * @param samplersList The sampler list
  101966. * @param defines The defines helping in the list generation
  101967. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  101968. */
  101969. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  101970. /**
  101971. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  101972. * @param defines The defines to update while falling back
  101973. * @param fallbacks The authorized effect fallbacks
  101974. * @param maxSimultaneousLights The maximum number of lights allowed
  101975. * @param rank the current rank of the Effect
  101976. * @returns The newly affected rank
  101977. */
  101978. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  101979. private static _TmpMorphInfluencers;
  101980. /**
  101981. * Prepares the list of attributes required for morph targets according to the effect defines.
  101982. * @param attribs The current list of supported attribs
  101983. * @param mesh The mesh to prepare the morph targets attributes for
  101984. * @param influencers The number of influencers
  101985. */
  101986. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  101987. /**
  101988. * Prepares the list of attributes required for morph targets according to the effect defines.
  101989. * @param attribs The current list of supported attribs
  101990. * @param mesh The mesh to prepare the morph targets attributes for
  101991. * @param defines The current Defines of the effect
  101992. */
  101993. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  101994. /**
  101995. * Prepares the list of attributes required for bones according to the effect defines.
  101996. * @param attribs The current list of supported attribs
  101997. * @param mesh The mesh to prepare the bones attributes for
  101998. * @param defines The current Defines of the effect
  101999. * @param fallbacks The current efffect fallback strategy
  102000. */
  102001. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  102002. /**
  102003. * Check and prepare the list of attributes required for instances according to the effect defines.
  102004. * @param attribs The current list of supported attribs
  102005. * @param defines The current MaterialDefines of the effect
  102006. */
  102007. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  102008. /**
  102009. * Add the list of attributes required for instances to the attribs array.
  102010. * @param attribs The current list of supported attribs
  102011. */
  102012. static PushAttributesForInstances(attribs: string[]): void;
  102013. /**
  102014. * Binds the light information to the effect.
  102015. * @param light The light containing the generator
  102016. * @param effect The effect we are binding the data to
  102017. * @param lightIndex The light index in the effect used to render
  102018. */
  102019. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  102020. /**
  102021. * Binds the lights information from the scene to the effect for the given mesh.
  102022. * @param light Light to bind
  102023. * @param lightIndex Light index
  102024. * @param scene The scene where the light belongs to
  102025. * @param effect The effect we are binding the data to
  102026. * @param useSpecular Defines if specular is supported
  102027. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  102028. */
  102029. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  102030. /**
  102031. * Binds the lights information from the scene to the effect for the given mesh.
  102032. * @param scene The scene the lights belongs to
  102033. * @param mesh The mesh we are binding the information to render
  102034. * @param effect The effect we are binding the data to
  102035. * @param defines The generated defines for the effect
  102036. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  102037. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  102038. */
  102039. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  102040. private static _tempFogColor;
  102041. /**
  102042. * Binds the fog information from the scene to the effect for the given mesh.
  102043. * @param scene The scene the lights belongs to
  102044. * @param mesh The mesh we are binding the information to render
  102045. * @param effect The effect we are binding the data to
  102046. * @param linearSpace Defines if the fog effect is applied in linear space
  102047. */
  102048. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  102049. /**
  102050. * Binds the bones information from the mesh to the effect.
  102051. * @param mesh The mesh we are binding the information to render
  102052. * @param effect The effect we are binding the data to
  102053. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  102054. */
  102055. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  102056. private static _CopyBonesTransformationMatrices;
  102057. /**
  102058. * Binds the morph targets information from the mesh to the effect.
  102059. * @param abstractMesh The mesh we are binding the information to render
  102060. * @param effect The effect we are binding the data to
  102061. */
  102062. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  102063. /**
  102064. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  102065. * @param defines The generated defines used in the effect
  102066. * @param effect The effect we are binding the data to
  102067. * @param scene The scene we are willing to render with logarithmic scale for
  102068. */
  102069. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  102070. /**
  102071. * Binds the clip plane information from the scene to the effect.
  102072. * @param scene The scene the clip plane information are extracted from
  102073. * @param effect The effect we are binding the data to
  102074. */
  102075. static BindClipPlane(effect: Effect, scene: Scene): void;
  102076. }
  102077. }
  102078. declare module BABYLON {
  102079. /**
  102080. * Block used to expose an input value
  102081. */
  102082. export class InputBlock extends NodeMaterialBlock {
  102083. private _mode;
  102084. private _associatedVariableName;
  102085. private _storedValue;
  102086. private _valueCallback;
  102087. private _type;
  102088. private _animationType;
  102089. /** Gets or set a value used to limit the range of float values */
  102090. min: number;
  102091. /** Gets or set a value used to limit the range of float values */
  102092. max: number;
  102093. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  102094. isBoolean: boolean;
  102095. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  102096. matrixMode: number;
  102097. /** @hidden */
  102098. _systemValue: Nullable<NodeMaterialSystemValues>;
  102099. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  102100. isConstant: boolean;
  102101. /** Gets or sets the group to use to display this block in the Inspector */
  102102. groupInInspector: string;
  102103. /** Gets an observable raised when the value is changed */
  102104. onValueChangedObservable: Observable<InputBlock>;
  102105. /**
  102106. * Gets or sets the connection point type (default is float)
  102107. */
  102108. get type(): NodeMaterialBlockConnectionPointTypes;
  102109. /**
  102110. * Creates a new InputBlock
  102111. * @param name defines the block name
  102112. * @param target defines the target of that block (Vertex by default)
  102113. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  102114. */
  102115. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  102116. /**
  102117. * Validates if a name is a reserve word.
  102118. * @param newName the new name to be given to the node.
  102119. * @returns false if the name is a reserve word, else true.
  102120. */
  102121. validateBlockName(newName: string): boolean;
  102122. /**
  102123. * Gets the output component
  102124. */
  102125. get output(): NodeMaterialConnectionPoint;
  102126. /**
  102127. * Set the source of this connection point to a vertex attribute
  102128. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  102129. * @returns the current connection point
  102130. */
  102131. setAsAttribute(attributeName?: string): InputBlock;
  102132. /**
  102133. * Set the source of this connection point to a system value
  102134. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  102135. * @returns the current connection point
  102136. */
  102137. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  102138. /**
  102139. * Gets or sets the value of that point.
  102140. * Please note that this value will be ignored if valueCallback is defined
  102141. */
  102142. get value(): any;
  102143. set value(value: any);
  102144. /**
  102145. * Gets or sets a callback used to get the value of that point.
  102146. * Please note that setting this value will force the connection point to ignore the value property
  102147. */
  102148. get valueCallback(): () => any;
  102149. set valueCallback(value: () => any);
  102150. /**
  102151. * Gets or sets the associated variable name in the shader
  102152. */
  102153. get associatedVariableName(): string;
  102154. set associatedVariableName(value: string);
  102155. /** Gets or sets the type of animation applied to the input */
  102156. get animationType(): AnimatedInputBlockTypes;
  102157. set animationType(value: AnimatedInputBlockTypes);
  102158. /**
  102159. * Gets a boolean indicating that this connection point not defined yet
  102160. */
  102161. get isUndefined(): boolean;
  102162. /**
  102163. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  102164. * In this case the connection point name must be the name of the uniform to use.
  102165. * Can only be set on inputs
  102166. */
  102167. get isUniform(): boolean;
  102168. set isUniform(value: boolean);
  102169. /**
  102170. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  102171. * In this case the connection point name must be the name of the attribute to use
  102172. * Can only be set on inputs
  102173. */
  102174. get isAttribute(): boolean;
  102175. set isAttribute(value: boolean);
  102176. /**
  102177. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  102178. * Can only be set on exit points
  102179. */
  102180. get isVarying(): boolean;
  102181. set isVarying(value: boolean);
  102182. /**
  102183. * Gets a boolean indicating that the current connection point is a system value
  102184. */
  102185. get isSystemValue(): boolean;
  102186. /**
  102187. * Gets or sets the current well known value or null if not defined as a system value
  102188. */
  102189. get systemValue(): Nullable<NodeMaterialSystemValues>;
  102190. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  102191. /**
  102192. * Gets the current class name
  102193. * @returns the class name
  102194. */
  102195. getClassName(): string;
  102196. /**
  102197. * Animate the input if animationType !== None
  102198. * @param scene defines the rendering scene
  102199. */
  102200. animate(scene: Scene): void;
  102201. private _emitDefine;
  102202. initialize(state: NodeMaterialBuildState): void;
  102203. /**
  102204. * Set the input block to its default value (based on its type)
  102205. */
  102206. setDefaultValue(): void;
  102207. private _emitConstant;
  102208. /** @hidden */
  102209. get _noContextSwitch(): boolean;
  102210. private _emit;
  102211. /** @hidden */
  102212. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  102213. /** @hidden */
  102214. _transmit(effect: Effect, scene: Scene): void;
  102215. protected _buildBlock(state: NodeMaterialBuildState): void;
  102216. protected _dumpPropertiesCode(): string;
  102217. dispose(): void;
  102218. serialize(): any;
  102219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102220. }
  102221. }
  102222. declare module BABYLON {
  102223. /**
  102224. * Enum used to define the compatibility state between two connection points
  102225. */
  102226. export enum NodeMaterialConnectionPointCompatibilityStates {
  102227. /** Points are compatibles */
  102228. Compatible = 0,
  102229. /** Points are incompatible because of their types */
  102230. TypeIncompatible = 1,
  102231. /** Points are incompatible because of their targets (vertex vs fragment) */
  102232. TargetIncompatible = 2
  102233. }
  102234. /**
  102235. * Defines the direction of a connection point
  102236. */
  102237. export enum NodeMaterialConnectionPointDirection {
  102238. /** Input */
  102239. Input = 0,
  102240. /** Output */
  102241. Output = 1
  102242. }
  102243. /**
  102244. * Defines a connection point for a block
  102245. */
  102246. export class NodeMaterialConnectionPoint {
  102247. /** @hidden */
  102248. _ownerBlock: NodeMaterialBlock;
  102249. /** @hidden */
  102250. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  102251. private _endpoints;
  102252. private _associatedVariableName;
  102253. private _direction;
  102254. /** @hidden */
  102255. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  102256. /** @hidden */
  102257. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  102258. private _type;
  102259. /** @hidden */
  102260. _enforceAssociatedVariableName: boolean;
  102261. /** Gets the direction of the point */
  102262. get direction(): NodeMaterialConnectionPointDirection;
  102263. /** Indicates that this connection point needs dual validation before being connected to another point */
  102264. needDualDirectionValidation: boolean;
  102265. /**
  102266. * Gets or sets the additional types supported by this connection point
  102267. */
  102268. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  102269. /**
  102270. * Gets or sets the additional types excluded by this connection point
  102271. */
  102272. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  102273. /**
  102274. * Observable triggered when this point is connected
  102275. */
  102276. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  102277. /**
  102278. * Gets or sets the associated variable name in the shader
  102279. */
  102280. get associatedVariableName(): string;
  102281. set associatedVariableName(value: string);
  102282. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  102283. get innerType(): NodeMaterialBlockConnectionPointTypes;
  102284. /**
  102285. * Gets or sets the connection point type (default is float)
  102286. */
  102287. get type(): NodeMaterialBlockConnectionPointTypes;
  102288. set type(value: NodeMaterialBlockConnectionPointTypes);
  102289. /**
  102290. * Gets or sets the connection point name
  102291. */
  102292. name: string;
  102293. /**
  102294. * Gets or sets the connection point name
  102295. */
  102296. displayName: string;
  102297. /**
  102298. * Gets or sets a boolean indicating that this connection point can be omitted
  102299. */
  102300. isOptional: boolean;
  102301. /**
  102302. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  102303. */
  102304. isExposedOnFrame: boolean;
  102305. /**
  102306. * Gets or sets number indicating the position that the port is exposed to on a frame
  102307. */
  102308. exposedPortPosition: number;
  102309. /**
  102310. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  102311. */
  102312. define: string;
  102313. /** @hidden */
  102314. _prioritizeVertex: boolean;
  102315. private _target;
  102316. /** Gets or sets the target of that connection point */
  102317. get target(): NodeMaterialBlockTargets;
  102318. set target(value: NodeMaterialBlockTargets);
  102319. /**
  102320. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  102321. */
  102322. get isConnected(): boolean;
  102323. /**
  102324. * Gets a boolean indicating that the current point is connected to an input block
  102325. */
  102326. get isConnectedToInputBlock(): boolean;
  102327. /**
  102328. * Gets a the connected input block (if any)
  102329. */
  102330. get connectInputBlock(): Nullable<InputBlock>;
  102331. /** Get the other side of the connection (if any) */
  102332. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  102333. /** Get the block that owns this connection point */
  102334. get ownerBlock(): NodeMaterialBlock;
  102335. /** Get the block connected on the other side of this connection (if any) */
  102336. get sourceBlock(): Nullable<NodeMaterialBlock>;
  102337. /** Get the block connected on the endpoints of this connection (if any) */
  102338. get connectedBlocks(): Array<NodeMaterialBlock>;
  102339. /** Gets the list of connected endpoints */
  102340. get endpoints(): NodeMaterialConnectionPoint[];
  102341. /** Gets a boolean indicating if that output point is connected to at least one input */
  102342. get hasEndpoints(): boolean;
  102343. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  102344. get isConnectedInVertexShader(): boolean;
  102345. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  102346. get isConnectedInFragmentShader(): boolean;
  102347. /**
  102348. * Creates a block suitable to be used as an input for this input point.
  102349. * If null is returned, a block based on the point type will be created.
  102350. * @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
  102351. */
  102352. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  102353. /**
  102354. * Creates a new connection point
  102355. * @param name defines the connection point name
  102356. * @param ownerBlock defines the block hosting this connection point
  102357. * @param direction defines the direction of the connection point
  102358. */
  102359. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  102360. /**
  102361. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  102362. * @returns the class name
  102363. */
  102364. getClassName(): string;
  102365. /**
  102366. * Gets a boolean indicating if the current point can be connected to another point
  102367. * @param connectionPoint defines the other connection point
  102368. * @returns a boolean
  102369. */
  102370. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  102371. /**
  102372. * Gets a number indicating if the current point can be connected to another point
  102373. * @param connectionPoint defines the other connection point
  102374. * @returns a number defining the compatibility state
  102375. */
  102376. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  102377. /**
  102378. * Connect this point to another connection point
  102379. * @param connectionPoint defines the other connection point
  102380. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  102381. * @returns the current connection point
  102382. */
  102383. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  102384. /**
  102385. * Disconnect this point from one of his endpoint
  102386. * @param endpoint defines the other connection point
  102387. * @returns the current connection point
  102388. */
  102389. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  102390. /**
  102391. * Serializes this point in a JSON representation
  102392. * @param isInput defines if the connection point is an input (default is true)
  102393. * @returns the serialized point object
  102394. */
  102395. serialize(isInput?: boolean): any;
  102396. /**
  102397. * Release resources
  102398. */
  102399. dispose(): void;
  102400. }
  102401. }
  102402. declare module BABYLON {
  102403. /**
  102404. * Enum used to define the material modes
  102405. */
  102406. export enum NodeMaterialModes {
  102407. /** Regular material */
  102408. Material = 0,
  102409. /** For post process */
  102410. PostProcess = 1,
  102411. /** For particle system */
  102412. Particle = 2,
  102413. /** For procedural texture */
  102414. ProceduralTexture = 3
  102415. }
  102416. }
  102417. declare module BABYLON {
  102418. /**
  102419. * Block used to read a texture from a sampler
  102420. */
  102421. export class TextureBlock extends NodeMaterialBlock {
  102422. private _defineName;
  102423. private _linearDefineName;
  102424. private _gammaDefineName;
  102425. private _tempTextureRead;
  102426. private _samplerName;
  102427. private _transformedUVName;
  102428. private _textureTransformName;
  102429. private _textureInfoName;
  102430. private _mainUVName;
  102431. private _mainUVDefineName;
  102432. private _fragmentOnly;
  102433. /**
  102434. * Gets or sets the texture associated with the node
  102435. */
  102436. texture: Nullable<Texture>;
  102437. /**
  102438. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102439. */
  102440. convertToGammaSpace: boolean;
  102441. /**
  102442. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102443. */
  102444. convertToLinearSpace: boolean;
  102445. /**
  102446. * Create a new TextureBlock
  102447. * @param name defines the block name
  102448. */
  102449. constructor(name: string, fragmentOnly?: boolean);
  102450. /**
  102451. * Gets the current class name
  102452. * @returns the class name
  102453. */
  102454. getClassName(): string;
  102455. /**
  102456. * Gets the uv input component
  102457. */
  102458. get uv(): NodeMaterialConnectionPoint;
  102459. /**
  102460. * Gets the rgba output component
  102461. */
  102462. get rgba(): NodeMaterialConnectionPoint;
  102463. /**
  102464. * Gets the rgb output component
  102465. */
  102466. get rgb(): NodeMaterialConnectionPoint;
  102467. /**
  102468. * Gets the r output component
  102469. */
  102470. get r(): NodeMaterialConnectionPoint;
  102471. /**
  102472. * Gets the g output component
  102473. */
  102474. get g(): NodeMaterialConnectionPoint;
  102475. /**
  102476. * Gets the b output component
  102477. */
  102478. get b(): NodeMaterialConnectionPoint;
  102479. /**
  102480. * Gets the a output component
  102481. */
  102482. get a(): NodeMaterialConnectionPoint;
  102483. get target(): NodeMaterialBlockTargets;
  102484. autoConfigure(material: NodeMaterial): void;
  102485. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102486. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102487. isReady(): boolean;
  102488. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  102489. private get _isMixed();
  102490. private _injectVertexCode;
  102491. private _writeTextureRead;
  102492. private _writeOutput;
  102493. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102494. protected _dumpPropertiesCode(): string;
  102495. serialize(): any;
  102496. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102497. }
  102498. }
  102499. declare module BABYLON {
  102500. /** @hidden */
  102501. export var reflectionFunction: {
  102502. name: string;
  102503. shader: string;
  102504. };
  102505. }
  102506. declare module BABYLON {
  102507. /**
  102508. * Base block used to read a reflection texture from a sampler
  102509. */
  102510. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  102511. /** @hidden */
  102512. _define3DName: string;
  102513. /** @hidden */
  102514. _defineCubicName: string;
  102515. /** @hidden */
  102516. _defineExplicitName: string;
  102517. /** @hidden */
  102518. _defineProjectionName: string;
  102519. /** @hidden */
  102520. _defineLocalCubicName: string;
  102521. /** @hidden */
  102522. _defineSphericalName: string;
  102523. /** @hidden */
  102524. _definePlanarName: string;
  102525. /** @hidden */
  102526. _defineEquirectangularName: string;
  102527. /** @hidden */
  102528. _defineMirroredEquirectangularFixedName: string;
  102529. /** @hidden */
  102530. _defineEquirectangularFixedName: string;
  102531. /** @hidden */
  102532. _defineSkyboxName: string;
  102533. /** @hidden */
  102534. _defineOppositeZ: string;
  102535. /** @hidden */
  102536. _cubeSamplerName: string;
  102537. /** @hidden */
  102538. _2DSamplerName: string;
  102539. protected _positionUVWName: string;
  102540. protected _directionWName: string;
  102541. protected _reflectionVectorName: string;
  102542. /** @hidden */
  102543. _reflectionCoordsName: string;
  102544. /** @hidden */
  102545. _reflectionMatrixName: string;
  102546. protected _reflectionColorName: string;
  102547. /**
  102548. * Gets or sets the texture associated with the node
  102549. */
  102550. texture: Nullable<BaseTexture>;
  102551. /**
  102552. * Create a new ReflectionTextureBaseBlock
  102553. * @param name defines the block name
  102554. */
  102555. constructor(name: string);
  102556. /**
  102557. * Gets the current class name
  102558. * @returns the class name
  102559. */
  102560. getClassName(): string;
  102561. /**
  102562. * Gets the world position input component
  102563. */
  102564. abstract get position(): NodeMaterialConnectionPoint;
  102565. /**
  102566. * Gets the world position input component
  102567. */
  102568. abstract get worldPosition(): NodeMaterialConnectionPoint;
  102569. /**
  102570. * Gets the world normal input component
  102571. */
  102572. abstract get worldNormal(): NodeMaterialConnectionPoint;
  102573. /**
  102574. * Gets the world input component
  102575. */
  102576. abstract get world(): NodeMaterialConnectionPoint;
  102577. /**
  102578. * Gets the camera (or eye) position component
  102579. */
  102580. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  102581. /**
  102582. * Gets the view input component
  102583. */
  102584. abstract get view(): NodeMaterialConnectionPoint;
  102585. protected _getTexture(): Nullable<BaseTexture>;
  102586. autoConfigure(material: NodeMaterial): void;
  102587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102588. isReady(): boolean;
  102589. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  102590. /**
  102591. * Gets the code to inject in the vertex shader
  102592. * @param state current state of the node material building
  102593. * @returns the shader code
  102594. */
  102595. handleVertexSide(state: NodeMaterialBuildState): string;
  102596. /**
  102597. * Handles the inits for the fragment code path
  102598. * @param state node material build state
  102599. */
  102600. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  102601. /**
  102602. * Generates the reflection coords code for the fragment code path
  102603. * @param worldNormalVarName name of the world normal variable
  102604. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  102605. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  102606. * @returns the shader code
  102607. */
  102608. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  102609. /**
  102610. * Generates the reflection color code for the fragment code path
  102611. * @param lodVarName name of the lod variable
  102612. * @param swizzleLookupTexture swizzle to use for the final color variable
  102613. * @returns the shader code
  102614. */
  102615. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  102616. /**
  102617. * Generates the code corresponding to the connected output points
  102618. * @param state node material build state
  102619. * @param varName name of the variable to output
  102620. * @returns the shader code
  102621. */
  102622. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  102623. protected _buildBlock(state: NodeMaterialBuildState): this;
  102624. protected _dumpPropertiesCode(): string;
  102625. serialize(): any;
  102626. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102627. }
  102628. }
  102629. declare module BABYLON {
  102630. /**
  102631. * Defines a connection point to be used for points with a custom object type
  102632. */
  102633. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  102634. private _blockType;
  102635. private _blockName;
  102636. private _nameForCheking?;
  102637. /**
  102638. * Creates a new connection point
  102639. * @param name defines the connection point name
  102640. * @param ownerBlock defines the block hosting this connection point
  102641. * @param direction defines the direction of the connection point
  102642. */
  102643. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  102644. /**
  102645. * Gets a number indicating if the current point can be connected to another point
  102646. * @param connectionPoint defines the other connection point
  102647. * @returns a number defining the compatibility state
  102648. */
  102649. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  102650. /**
  102651. * Creates a block suitable to be used as an input for this input point.
  102652. * If null is returned, a block based on the point type will be created.
  102653. * @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
  102654. */
  102655. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  102656. }
  102657. }
  102658. declare module BABYLON {
  102659. /**
  102660. * Enum defining the type of properties that can be edited in the property pages in the NME
  102661. */
  102662. export enum PropertyTypeForEdition {
  102663. /** property is a boolean */
  102664. Boolean = 0,
  102665. /** property is a float */
  102666. Float = 1,
  102667. /** property is a Vector2 */
  102668. Vector2 = 2,
  102669. /** property is a list of values */
  102670. List = 3
  102671. }
  102672. /**
  102673. * Interface that defines an option in a variable of type list
  102674. */
  102675. export interface IEditablePropertyListOption {
  102676. /** label of the option */
  102677. "label": string;
  102678. /** value of the option */
  102679. "value": number;
  102680. }
  102681. /**
  102682. * Interface that defines the options available for an editable property
  102683. */
  102684. export interface IEditablePropertyOption {
  102685. /** min value */
  102686. "min"?: number;
  102687. /** max value */
  102688. "max"?: number;
  102689. /** notifiers: indicates which actions to take when the property is changed */
  102690. "notifiers"?: {
  102691. /** the material should be rebuilt */
  102692. "rebuild"?: boolean;
  102693. /** the preview should be updated */
  102694. "update"?: boolean;
  102695. };
  102696. /** list of the options for a variable of type list */
  102697. "options"?: IEditablePropertyListOption[];
  102698. }
  102699. /**
  102700. * Interface that describes an editable property
  102701. */
  102702. export interface IPropertyDescriptionForEdition {
  102703. /** name of the property */
  102704. "propertyName": string;
  102705. /** display name of the property */
  102706. "displayName": string;
  102707. /** type of the property */
  102708. "type": PropertyTypeForEdition;
  102709. /** group of the property - all properties with the same group value will be displayed in a specific section */
  102710. "groupName": string;
  102711. /** options for the property */
  102712. "options": IEditablePropertyOption;
  102713. }
  102714. /**
  102715. * Decorator that flags a property in a node material block as being editable
  102716. */
  102717. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  102718. }
  102719. declare module BABYLON {
  102720. /**
  102721. * Block used to implement the refraction part of the sub surface module of the PBR material
  102722. */
  102723. export class RefractionBlock extends NodeMaterialBlock {
  102724. /** @hidden */
  102725. _define3DName: string;
  102726. /** @hidden */
  102727. _refractionMatrixName: string;
  102728. /** @hidden */
  102729. _defineLODRefractionAlpha: string;
  102730. /** @hidden */
  102731. _defineLinearSpecularRefraction: string;
  102732. /** @hidden */
  102733. _defineOppositeZ: string;
  102734. /** @hidden */
  102735. _cubeSamplerName: string;
  102736. /** @hidden */
  102737. _2DSamplerName: string;
  102738. /** @hidden */
  102739. _vRefractionMicrosurfaceInfosName: string;
  102740. /** @hidden */
  102741. _vRefractionInfosName: string;
  102742. private _scene;
  102743. /**
  102744. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102745. * Materials half opaque for instance using refraction could benefit from this control.
  102746. */
  102747. linkRefractionWithTransparency: boolean;
  102748. /**
  102749. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102750. */
  102751. invertRefractionY: boolean;
  102752. /**
  102753. * Gets or sets the texture associated with the node
  102754. */
  102755. texture: Nullable<BaseTexture>;
  102756. /**
  102757. * Create a new RefractionBlock
  102758. * @param name defines the block name
  102759. */
  102760. constructor(name: string);
  102761. /**
  102762. * Gets the current class name
  102763. * @returns the class name
  102764. */
  102765. getClassName(): string;
  102766. /**
  102767. * Gets the intensity input component
  102768. */
  102769. get intensity(): NodeMaterialConnectionPoint;
  102770. /**
  102771. * Gets the index of refraction input component
  102772. */
  102773. get indexOfRefraction(): NodeMaterialConnectionPoint;
  102774. /**
  102775. * Gets the tint at distance input component
  102776. */
  102777. get tintAtDistance(): NodeMaterialConnectionPoint;
  102778. /**
  102779. * Gets the view input component
  102780. */
  102781. get view(): NodeMaterialConnectionPoint;
  102782. /**
  102783. * Gets the refraction object output component
  102784. */
  102785. get refraction(): NodeMaterialConnectionPoint;
  102786. /**
  102787. * Returns true if the block has a texture
  102788. */
  102789. get hasTexture(): boolean;
  102790. protected _getTexture(): Nullable<BaseTexture>;
  102791. autoConfigure(material: NodeMaterial): void;
  102792. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102793. isReady(): boolean;
  102794. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102795. /**
  102796. * Gets the main code of the block (fragment side)
  102797. * @param state current state of the node material building
  102798. * @returns the shader code
  102799. */
  102800. getCode(state: NodeMaterialBuildState): string;
  102801. protected _buildBlock(state: NodeMaterialBuildState): this;
  102802. protected _dumpPropertiesCode(): string;
  102803. serialize(): any;
  102804. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102805. }
  102806. }
  102807. declare module BABYLON {
  102808. /**
  102809. * Base block used as input for post process
  102810. */
  102811. export class CurrentScreenBlock extends NodeMaterialBlock {
  102812. private _samplerName;
  102813. private _linearDefineName;
  102814. private _gammaDefineName;
  102815. private _mainUVName;
  102816. private _tempTextureRead;
  102817. /**
  102818. * Gets or sets the texture associated with the node
  102819. */
  102820. texture: Nullable<BaseTexture>;
  102821. /**
  102822. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102823. */
  102824. convertToGammaSpace: boolean;
  102825. /**
  102826. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102827. */
  102828. convertToLinearSpace: boolean;
  102829. /**
  102830. * Create a new CurrentScreenBlock
  102831. * @param name defines the block name
  102832. */
  102833. constructor(name: string);
  102834. /**
  102835. * Gets the current class name
  102836. * @returns the class name
  102837. */
  102838. getClassName(): string;
  102839. /**
  102840. * Gets the uv input component
  102841. */
  102842. get uv(): NodeMaterialConnectionPoint;
  102843. /**
  102844. * Gets the rgba output component
  102845. */
  102846. get rgba(): NodeMaterialConnectionPoint;
  102847. /**
  102848. * Gets the rgb output component
  102849. */
  102850. get rgb(): NodeMaterialConnectionPoint;
  102851. /**
  102852. * Gets the r output component
  102853. */
  102854. get r(): NodeMaterialConnectionPoint;
  102855. /**
  102856. * Gets the g output component
  102857. */
  102858. get g(): NodeMaterialConnectionPoint;
  102859. /**
  102860. * Gets the b output component
  102861. */
  102862. get b(): NodeMaterialConnectionPoint;
  102863. /**
  102864. * Gets the a output component
  102865. */
  102866. get a(): NodeMaterialConnectionPoint;
  102867. /**
  102868. * Initialize the block and prepare the context for build
  102869. * @param state defines the state that will be used for the build
  102870. */
  102871. initialize(state: NodeMaterialBuildState): void;
  102872. get target(): NodeMaterialBlockTargets;
  102873. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102874. isReady(): boolean;
  102875. private _injectVertexCode;
  102876. private _writeTextureRead;
  102877. private _writeOutput;
  102878. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102879. serialize(): any;
  102880. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102881. }
  102882. }
  102883. declare module BABYLON {
  102884. /**
  102885. * Base block used for the particle texture
  102886. */
  102887. export class ParticleTextureBlock extends NodeMaterialBlock {
  102888. private _samplerName;
  102889. private _linearDefineName;
  102890. private _gammaDefineName;
  102891. private _tempTextureRead;
  102892. /**
  102893. * Gets or sets the texture associated with the node
  102894. */
  102895. texture: Nullable<BaseTexture>;
  102896. /**
  102897. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102898. */
  102899. convertToGammaSpace: boolean;
  102900. /**
  102901. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102902. */
  102903. convertToLinearSpace: boolean;
  102904. /**
  102905. * Create a new ParticleTextureBlock
  102906. * @param name defines the block name
  102907. */
  102908. constructor(name: string);
  102909. /**
  102910. * Gets the current class name
  102911. * @returns the class name
  102912. */
  102913. getClassName(): string;
  102914. /**
  102915. * Gets the uv input component
  102916. */
  102917. get uv(): NodeMaterialConnectionPoint;
  102918. /**
  102919. * Gets the rgba output component
  102920. */
  102921. get rgba(): NodeMaterialConnectionPoint;
  102922. /**
  102923. * Gets the rgb output component
  102924. */
  102925. get rgb(): NodeMaterialConnectionPoint;
  102926. /**
  102927. * Gets the r output component
  102928. */
  102929. get r(): NodeMaterialConnectionPoint;
  102930. /**
  102931. * Gets the g output component
  102932. */
  102933. get g(): NodeMaterialConnectionPoint;
  102934. /**
  102935. * Gets the b output component
  102936. */
  102937. get b(): NodeMaterialConnectionPoint;
  102938. /**
  102939. * Gets the a output component
  102940. */
  102941. get a(): NodeMaterialConnectionPoint;
  102942. /**
  102943. * Initialize the block and prepare the context for build
  102944. * @param state defines the state that will be used for the build
  102945. */
  102946. initialize(state: NodeMaterialBuildState): void;
  102947. autoConfigure(material: NodeMaterial): void;
  102948. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102949. isReady(): boolean;
  102950. private _writeOutput;
  102951. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102952. serialize(): any;
  102953. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102954. }
  102955. }
  102956. declare module BABYLON {
  102957. /**
  102958. * Class used to store shared data between 2 NodeMaterialBuildState
  102959. */
  102960. export class NodeMaterialBuildStateSharedData {
  102961. /**
  102962. * Gets the list of emitted varyings
  102963. */
  102964. temps: string[];
  102965. /**
  102966. * Gets the list of emitted varyings
  102967. */
  102968. varyings: string[];
  102969. /**
  102970. * Gets the varying declaration string
  102971. */
  102972. varyingDeclaration: string;
  102973. /**
  102974. * Input blocks
  102975. */
  102976. inputBlocks: InputBlock[];
  102977. /**
  102978. * Input blocks
  102979. */
  102980. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102981. /**
  102982. * Bindable blocks (Blocks that need to set data to the effect)
  102983. */
  102984. bindableBlocks: NodeMaterialBlock[];
  102985. /**
  102986. * List of blocks that can provide a compilation fallback
  102987. */
  102988. blocksWithFallbacks: NodeMaterialBlock[];
  102989. /**
  102990. * List of blocks that can provide a define update
  102991. */
  102992. blocksWithDefines: NodeMaterialBlock[];
  102993. /**
  102994. * List of blocks that can provide a repeatable content
  102995. */
  102996. repeatableContentBlocks: NodeMaterialBlock[];
  102997. /**
  102998. * List of blocks that can provide a dynamic list of uniforms
  102999. */
  103000. dynamicUniformBlocks: NodeMaterialBlock[];
  103001. /**
  103002. * List of blocks that can block the isReady function for the material
  103003. */
  103004. blockingBlocks: NodeMaterialBlock[];
  103005. /**
  103006. * Gets the list of animated inputs
  103007. */
  103008. animatedInputs: InputBlock[];
  103009. /**
  103010. * Build Id used to avoid multiple recompilations
  103011. */
  103012. buildId: number;
  103013. /** List of emitted variables */
  103014. variableNames: {
  103015. [key: string]: number;
  103016. };
  103017. /** List of emitted defines */
  103018. defineNames: {
  103019. [key: string]: number;
  103020. };
  103021. /** Should emit comments? */
  103022. emitComments: boolean;
  103023. /** Emit build activity */
  103024. verbose: boolean;
  103025. /** Gets or sets the hosting scene */
  103026. scene: Scene;
  103027. /**
  103028. * Gets the compilation hints emitted at compilation time
  103029. */
  103030. hints: {
  103031. needWorldViewMatrix: boolean;
  103032. needWorldViewProjectionMatrix: boolean;
  103033. needAlphaBlending: boolean;
  103034. needAlphaTesting: boolean;
  103035. };
  103036. /**
  103037. * List of compilation checks
  103038. */
  103039. checks: {
  103040. emitVertex: boolean;
  103041. emitFragment: boolean;
  103042. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  103043. };
  103044. /**
  103045. * Is vertex program allowed to be empty?
  103046. */
  103047. allowEmptyVertexProgram: boolean;
  103048. /** Creates a new shared data */
  103049. constructor();
  103050. /**
  103051. * Emits console errors and exceptions if there is a failing check
  103052. */
  103053. emitErrors(): void;
  103054. }
  103055. }
  103056. declare module BABYLON {
  103057. /**
  103058. * Class used to store node based material build state
  103059. */
  103060. export class NodeMaterialBuildState {
  103061. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  103062. supportUniformBuffers: boolean;
  103063. /**
  103064. * Gets the list of emitted attributes
  103065. */
  103066. attributes: string[];
  103067. /**
  103068. * Gets the list of emitted uniforms
  103069. */
  103070. uniforms: string[];
  103071. /**
  103072. * Gets the list of emitted constants
  103073. */
  103074. constants: string[];
  103075. /**
  103076. * Gets the list of emitted samplers
  103077. */
  103078. samplers: string[];
  103079. /**
  103080. * Gets the list of emitted functions
  103081. */
  103082. functions: {
  103083. [key: string]: string;
  103084. };
  103085. /**
  103086. * Gets the list of emitted extensions
  103087. */
  103088. extensions: {
  103089. [key: string]: string;
  103090. };
  103091. /**
  103092. * Gets the target of the compilation state
  103093. */
  103094. target: NodeMaterialBlockTargets;
  103095. /**
  103096. * Gets the list of emitted counters
  103097. */
  103098. counters: {
  103099. [key: string]: number;
  103100. };
  103101. /**
  103102. * Shared data between multiple NodeMaterialBuildState instances
  103103. */
  103104. sharedData: NodeMaterialBuildStateSharedData;
  103105. /** @hidden */
  103106. _vertexState: NodeMaterialBuildState;
  103107. /** @hidden */
  103108. _attributeDeclaration: string;
  103109. /** @hidden */
  103110. _uniformDeclaration: string;
  103111. /** @hidden */
  103112. _constantDeclaration: string;
  103113. /** @hidden */
  103114. _samplerDeclaration: string;
  103115. /** @hidden */
  103116. _varyingTransfer: string;
  103117. /** @hidden */
  103118. _injectAtEnd: string;
  103119. private _repeatableContentAnchorIndex;
  103120. /** @hidden */
  103121. _builtCompilationString: string;
  103122. /**
  103123. * Gets the emitted compilation strings
  103124. */
  103125. compilationString: string;
  103126. /**
  103127. * Finalize the compilation strings
  103128. * @param state defines the current compilation state
  103129. */
  103130. finalize(state: NodeMaterialBuildState): void;
  103131. /** @hidden */
  103132. get _repeatableContentAnchor(): string;
  103133. /** @hidden */
  103134. _getFreeVariableName(prefix: string): string;
  103135. /** @hidden */
  103136. _getFreeDefineName(prefix: string): string;
  103137. /** @hidden */
  103138. _excludeVariableName(name: string): void;
  103139. /** @hidden */
  103140. _emit2DSampler(name: string): void;
  103141. /** @hidden */
  103142. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  103143. /** @hidden */
  103144. _emitExtension(name: string, extension: string, define?: string): void;
  103145. /** @hidden */
  103146. _emitFunction(name: string, code: string, comments: string): void;
  103147. /** @hidden */
  103148. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  103149. replaceStrings?: {
  103150. search: RegExp;
  103151. replace: string;
  103152. }[];
  103153. repeatKey?: string;
  103154. }): string;
  103155. /** @hidden */
  103156. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  103157. repeatKey?: string;
  103158. removeAttributes?: boolean;
  103159. removeUniforms?: boolean;
  103160. removeVaryings?: boolean;
  103161. removeIfDef?: boolean;
  103162. replaceStrings?: {
  103163. search: RegExp;
  103164. replace: string;
  103165. }[];
  103166. }, storeKey?: string): void;
  103167. /** @hidden */
  103168. _registerTempVariable(name: string): boolean;
  103169. /** @hidden */
  103170. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  103171. /** @hidden */
  103172. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  103173. /** @hidden */
  103174. _emitFloat(value: number): string;
  103175. }
  103176. }
  103177. declare module BABYLON {
  103178. /**
  103179. * Helper class used to generate session unique ID
  103180. */
  103181. export class UniqueIdGenerator {
  103182. private static _UniqueIdCounter;
  103183. /**
  103184. * Gets an unique (relatively to the current scene) Id
  103185. */
  103186. static get UniqueId(): number;
  103187. }
  103188. }
  103189. declare module BABYLON {
  103190. /**
  103191. * Defines a block that can be used inside a node based material
  103192. */
  103193. export class NodeMaterialBlock {
  103194. private _buildId;
  103195. private _buildTarget;
  103196. private _target;
  103197. private _isFinalMerger;
  103198. private _isInput;
  103199. private _name;
  103200. protected _isUnique: boolean;
  103201. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  103202. inputsAreExclusive: boolean;
  103203. /** @hidden */
  103204. _codeVariableName: string;
  103205. /** @hidden */
  103206. _inputs: NodeMaterialConnectionPoint[];
  103207. /** @hidden */
  103208. _outputs: NodeMaterialConnectionPoint[];
  103209. /** @hidden */
  103210. _preparationId: number;
  103211. /**
  103212. * Gets the name of the block
  103213. */
  103214. get name(): string;
  103215. /**
  103216. * Sets the name of the block. Will check if the name is valid.
  103217. */
  103218. set name(newName: string);
  103219. /**
  103220. * Gets or sets the unique id of the node
  103221. */
  103222. uniqueId: number;
  103223. /**
  103224. * Gets or sets the comments associated with this block
  103225. */
  103226. comments: string;
  103227. /**
  103228. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  103229. */
  103230. get isUnique(): boolean;
  103231. /**
  103232. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  103233. */
  103234. get isFinalMerger(): boolean;
  103235. /**
  103236. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  103237. */
  103238. get isInput(): boolean;
  103239. /**
  103240. * Gets or sets the build Id
  103241. */
  103242. get buildId(): number;
  103243. set buildId(value: number);
  103244. /**
  103245. * Gets or sets the target of the block
  103246. */
  103247. get target(): NodeMaterialBlockTargets;
  103248. set target(value: NodeMaterialBlockTargets);
  103249. /**
  103250. * Gets the list of input points
  103251. */
  103252. get inputs(): NodeMaterialConnectionPoint[];
  103253. /** Gets the list of output points */
  103254. get outputs(): NodeMaterialConnectionPoint[];
  103255. /**
  103256. * Find an input by its name
  103257. * @param name defines the name of the input to look for
  103258. * @returns the input or null if not found
  103259. */
  103260. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  103261. /**
  103262. * Find an output by its name
  103263. * @param name defines the name of the outputto look for
  103264. * @returns the output or null if not found
  103265. */
  103266. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  103267. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  103268. visibleInInspector: boolean;
  103269. /**
  103270. * Creates a new NodeMaterialBlock
  103271. * @param name defines the block name
  103272. * @param target defines the target of that block (Vertex by default)
  103273. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  103274. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  103275. */
  103276. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  103277. /**
  103278. * Initialize the block and prepare the context for build
  103279. * @param state defines the state that will be used for the build
  103280. */
  103281. initialize(state: NodeMaterialBuildState): void;
  103282. /**
  103283. * Bind data to effect. Will only be called for blocks with isBindable === true
  103284. * @param effect defines the effect to bind data to
  103285. * @param nodeMaterial defines the hosting NodeMaterial
  103286. * @param mesh defines the mesh that will be rendered
  103287. * @param subMesh defines the submesh that will be rendered
  103288. */
  103289. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  103290. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  103291. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  103292. protected _writeFloat(value: number): string;
  103293. /**
  103294. * Gets the current class name e.g. "NodeMaterialBlock"
  103295. * @returns the class name
  103296. */
  103297. getClassName(): string;
  103298. /**
  103299. * Register a new input. Must be called inside a block constructor
  103300. * @param name defines the connection point name
  103301. * @param type defines the connection point type
  103302. * @param isOptional defines a boolean indicating that this input can be omitted
  103303. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  103304. * @param point an already created connection point. If not provided, create a new one
  103305. * @returns the current block
  103306. */
  103307. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  103308. /**
  103309. * Register a new output. Must be called inside a block constructor
  103310. * @param name defines the connection point name
  103311. * @param type defines the connection point type
  103312. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  103313. * @param point an already created connection point. If not provided, create a new one
  103314. * @returns the current block
  103315. */
  103316. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  103317. /**
  103318. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  103319. * @param forOutput defines an optional connection point to check compatibility with
  103320. * @returns the first available input or null
  103321. */
  103322. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  103323. /**
  103324. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  103325. * @param forBlock defines an optional block to check compatibility with
  103326. * @returns the first available input or null
  103327. */
  103328. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  103329. /**
  103330. * Gets the sibling of the given output
  103331. * @param current defines the current output
  103332. * @returns the next output in the list or null
  103333. */
  103334. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  103335. /**
  103336. * Connect current block with another block
  103337. * @param other defines the block to connect with
  103338. * @param options define the various options to help pick the right connections
  103339. * @returns the current block
  103340. */
  103341. connectTo(other: NodeMaterialBlock, options?: {
  103342. input?: string;
  103343. output?: string;
  103344. outputSwizzle?: string;
  103345. }): this | undefined;
  103346. protected _buildBlock(state: NodeMaterialBuildState): void;
  103347. /**
  103348. * Add uniforms, samplers and uniform buffers at compilation time
  103349. * @param state defines the state to update
  103350. * @param nodeMaterial defines the node material requesting the update
  103351. * @param defines defines the material defines to update
  103352. * @param uniformBuffers defines the list of uniform buffer names
  103353. */
  103354. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  103355. /**
  103356. * Add potential fallbacks if shader compilation fails
  103357. * @param mesh defines the mesh to be rendered
  103358. * @param fallbacks defines the current prioritized list of fallbacks
  103359. */
  103360. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  103361. /**
  103362. * Initialize defines for shader compilation
  103363. * @param mesh defines the mesh to be rendered
  103364. * @param nodeMaterial defines the node material requesting the update
  103365. * @param defines defines the material defines to update
  103366. * @param useInstances specifies that instances should be used
  103367. */
  103368. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  103369. /**
  103370. * Update defines for shader compilation
  103371. * @param mesh defines the mesh to be rendered
  103372. * @param nodeMaterial defines the node material requesting the update
  103373. * @param defines defines the material defines to update
  103374. * @param useInstances specifies that instances should be used
  103375. * @param subMesh defines which submesh to render
  103376. */
  103377. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  103378. /**
  103379. * Lets the block try to connect some inputs automatically
  103380. * @param material defines the hosting NodeMaterial
  103381. */
  103382. autoConfigure(material: NodeMaterial): void;
  103383. /**
  103384. * Function called when a block is declared as repeatable content generator
  103385. * @param vertexShaderState defines the current compilation state for the vertex shader
  103386. * @param fragmentShaderState defines the current compilation state for the fragment shader
  103387. * @param mesh defines the mesh to be rendered
  103388. * @param defines defines the material defines to update
  103389. */
  103390. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  103391. /**
  103392. * Checks if the block is ready
  103393. * @param mesh defines the mesh to be rendered
  103394. * @param nodeMaterial defines the node material requesting the update
  103395. * @param defines defines the material defines to update
  103396. * @param useInstances specifies that instances should be used
  103397. * @returns true if the block is ready
  103398. */
  103399. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  103400. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  103401. private _processBuild;
  103402. /**
  103403. * Validates the new name for the block node.
  103404. * @param newName the new name to be given to the node.
  103405. * @returns false if the name is a reserve word, else true.
  103406. */
  103407. validateBlockName(newName: string): boolean;
  103408. /**
  103409. * Compile the current node and generate the shader code
  103410. * @param state defines the current compilation state (uniforms, samplers, current string)
  103411. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  103412. * @returns true if already built
  103413. */
  103414. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  103415. protected _inputRename(name: string): string;
  103416. protected _outputRename(name: string): string;
  103417. protected _dumpPropertiesCode(): string;
  103418. /** @hidden */
  103419. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  103420. /** @hidden */
  103421. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  103422. /**
  103423. * Clone the current block to a new identical block
  103424. * @param scene defines the hosting scene
  103425. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103426. * @returns a copy of the current block
  103427. */
  103428. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  103429. /**
  103430. * Serializes this block in a JSON representation
  103431. * @returns the serialized block object
  103432. */
  103433. serialize(): any;
  103434. /** @hidden */
  103435. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103436. private _deserializePortDisplayNamesAndExposedOnFrame;
  103437. /**
  103438. * Release resources
  103439. */
  103440. dispose(): void;
  103441. }
  103442. }
  103443. declare module BABYLON {
  103444. /**
  103445. * Base class of materials working in push mode in babylon JS
  103446. * @hidden
  103447. */
  103448. export class PushMaterial extends Material {
  103449. protected _activeEffect: Effect;
  103450. protected _normalMatrix: Matrix;
  103451. constructor(name: string, scene: Scene);
  103452. getEffect(): Effect;
  103453. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103454. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  103455. /**
  103456. * Binds the given world matrix to the active effect
  103457. *
  103458. * @param world the matrix to bind
  103459. */
  103460. bindOnlyWorldMatrix(world: Matrix): void;
  103461. /**
  103462. * Binds the given normal matrix to the active effect
  103463. *
  103464. * @param normalMatrix the matrix to bind
  103465. */
  103466. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  103467. bind(world: Matrix, mesh?: Mesh): void;
  103468. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  103469. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  103470. }
  103471. }
  103472. declare module BABYLON {
  103473. /**
  103474. * Root class for all node material optimizers
  103475. */
  103476. export class NodeMaterialOptimizer {
  103477. /**
  103478. * Function used to optimize a NodeMaterial graph
  103479. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  103480. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  103481. */
  103482. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  103483. }
  103484. }
  103485. declare module BABYLON {
  103486. /**
  103487. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  103488. */
  103489. export class TransformBlock extends NodeMaterialBlock {
  103490. /**
  103491. * Defines the value to use to complement W value to transform it to a Vector4
  103492. */
  103493. complementW: number;
  103494. /**
  103495. * Defines the value to use to complement z value to transform it to a Vector4
  103496. */
  103497. complementZ: number;
  103498. /**
  103499. * Creates a new TransformBlock
  103500. * @param name defines the block name
  103501. */
  103502. constructor(name: string);
  103503. /**
  103504. * Gets the current class name
  103505. * @returns the class name
  103506. */
  103507. getClassName(): string;
  103508. /**
  103509. * Gets the vector input
  103510. */
  103511. get vector(): NodeMaterialConnectionPoint;
  103512. /**
  103513. * Gets the output component
  103514. */
  103515. get output(): NodeMaterialConnectionPoint;
  103516. /**
  103517. * Gets the xyz output component
  103518. */
  103519. get xyz(): NodeMaterialConnectionPoint;
  103520. /**
  103521. * Gets the matrix transform input
  103522. */
  103523. get transform(): NodeMaterialConnectionPoint;
  103524. protected _buildBlock(state: NodeMaterialBuildState): this;
  103525. /**
  103526. * Update defines for shader compilation
  103527. * @param mesh defines the mesh to be rendered
  103528. * @param nodeMaterial defines the node material requesting the update
  103529. * @param defines defines the material defines to update
  103530. * @param useInstances specifies that instances should be used
  103531. * @param subMesh defines which submesh to render
  103532. */
  103533. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  103534. serialize(): any;
  103535. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103536. protected _dumpPropertiesCode(): string;
  103537. }
  103538. }
  103539. declare module BABYLON {
  103540. /**
  103541. * Block used to output the vertex position
  103542. */
  103543. export class VertexOutputBlock extends NodeMaterialBlock {
  103544. /**
  103545. * Creates a new VertexOutputBlock
  103546. * @param name defines the block name
  103547. */
  103548. constructor(name: string);
  103549. /**
  103550. * Gets the current class name
  103551. * @returns the class name
  103552. */
  103553. getClassName(): string;
  103554. /**
  103555. * Gets the vector input component
  103556. */
  103557. get vector(): NodeMaterialConnectionPoint;
  103558. protected _buildBlock(state: NodeMaterialBuildState): this;
  103559. }
  103560. }
  103561. declare module BABYLON {
  103562. /**
  103563. * Block used to output the final color
  103564. */
  103565. export class FragmentOutputBlock extends NodeMaterialBlock {
  103566. /**
  103567. * Create a new FragmentOutputBlock
  103568. * @param name defines the block name
  103569. */
  103570. constructor(name: string);
  103571. /**
  103572. * Gets the current class name
  103573. * @returns the class name
  103574. */
  103575. getClassName(): string;
  103576. /**
  103577. * Gets the rgba input component
  103578. */
  103579. get rgba(): NodeMaterialConnectionPoint;
  103580. /**
  103581. * Gets the rgb input component
  103582. */
  103583. get rgb(): NodeMaterialConnectionPoint;
  103584. /**
  103585. * Gets the a input component
  103586. */
  103587. get a(): NodeMaterialConnectionPoint;
  103588. protected _buildBlock(state: NodeMaterialBuildState): this;
  103589. }
  103590. }
  103591. declare module BABYLON {
  103592. /**
  103593. * Block used for the particle ramp gradient section
  103594. */
  103595. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  103596. /**
  103597. * Create a new ParticleRampGradientBlock
  103598. * @param name defines the block name
  103599. */
  103600. constructor(name: string);
  103601. /**
  103602. * Gets the current class name
  103603. * @returns the class name
  103604. */
  103605. getClassName(): string;
  103606. /**
  103607. * Gets the color input component
  103608. */
  103609. get color(): NodeMaterialConnectionPoint;
  103610. /**
  103611. * Gets the rampColor output component
  103612. */
  103613. get rampColor(): NodeMaterialConnectionPoint;
  103614. /**
  103615. * Initialize the block and prepare the context for build
  103616. * @param state defines the state that will be used for the build
  103617. */
  103618. initialize(state: NodeMaterialBuildState): void;
  103619. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103620. }
  103621. }
  103622. declare module BABYLON {
  103623. /**
  103624. * Block used for the particle blend multiply section
  103625. */
  103626. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  103627. /**
  103628. * Create a new ParticleBlendMultiplyBlock
  103629. * @param name defines the block name
  103630. */
  103631. constructor(name: string);
  103632. /**
  103633. * Gets the current class name
  103634. * @returns the class name
  103635. */
  103636. getClassName(): string;
  103637. /**
  103638. * Gets the color input component
  103639. */
  103640. get color(): NodeMaterialConnectionPoint;
  103641. /**
  103642. * Gets the alphaTexture input component
  103643. */
  103644. get alphaTexture(): NodeMaterialConnectionPoint;
  103645. /**
  103646. * Gets the alphaColor input component
  103647. */
  103648. get alphaColor(): NodeMaterialConnectionPoint;
  103649. /**
  103650. * Gets the blendColor output component
  103651. */
  103652. get blendColor(): NodeMaterialConnectionPoint;
  103653. /**
  103654. * Initialize the block and prepare the context for build
  103655. * @param state defines the state that will be used for the build
  103656. */
  103657. initialize(state: NodeMaterialBuildState): void;
  103658. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103659. }
  103660. }
  103661. declare module BABYLON {
  103662. /**
  103663. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  103664. */
  103665. export class VectorMergerBlock extends NodeMaterialBlock {
  103666. /**
  103667. * Create a new VectorMergerBlock
  103668. * @param name defines the block name
  103669. */
  103670. constructor(name: string);
  103671. /**
  103672. * Gets the current class name
  103673. * @returns the class name
  103674. */
  103675. getClassName(): string;
  103676. /**
  103677. * Gets the xyz component (input)
  103678. */
  103679. get xyzIn(): NodeMaterialConnectionPoint;
  103680. /**
  103681. * Gets the xy component (input)
  103682. */
  103683. get xyIn(): NodeMaterialConnectionPoint;
  103684. /**
  103685. * Gets the x component (input)
  103686. */
  103687. get x(): NodeMaterialConnectionPoint;
  103688. /**
  103689. * Gets the y component (input)
  103690. */
  103691. get y(): NodeMaterialConnectionPoint;
  103692. /**
  103693. * Gets the z component (input)
  103694. */
  103695. get z(): NodeMaterialConnectionPoint;
  103696. /**
  103697. * Gets the w component (input)
  103698. */
  103699. get w(): NodeMaterialConnectionPoint;
  103700. /**
  103701. * Gets the xyzw component (output)
  103702. */
  103703. get xyzw(): NodeMaterialConnectionPoint;
  103704. /**
  103705. * Gets the xyz component (output)
  103706. */
  103707. get xyzOut(): NodeMaterialConnectionPoint;
  103708. /**
  103709. * Gets the xy component (output)
  103710. */
  103711. get xyOut(): NodeMaterialConnectionPoint;
  103712. /**
  103713. * Gets the xy component (output)
  103714. * @deprecated Please use xyOut instead.
  103715. */
  103716. get xy(): NodeMaterialConnectionPoint;
  103717. /**
  103718. * Gets the xyz component (output)
  103719. * @deprecated Please use xyzOut instead.
  103720. */
  103721. get xyz(): NodeMaterialConnectionPoint;
  103722. protected _buildBlock(state: NodeMaterialBuildState): this;
  103723. }
  103724. }
  103725. declare module BABYLON {
  103726. /**
  103727. * Block used to remap a float from a range to a new one
  103728. */
  103729. export class RemapBlock extends NodeMaterialBlock {
  103730. /**
  103731. * Gets or sets the source range
  103732. */
  103733. sourceRange: Vector2;
  103734. /**
  103735. * Gets or sets the target range
  103736. */
  103737. targetRange: Vector2;
  103738. /**
  103739. * Creates a new RemapBlock
  103740. * @param name defines the block name
  103741. */
  103742. constructor(name: string);
  103743. /**
  103744. * Gets the current class name
  103745. * @returns the class name
  103746. */
  103747. getClassName(): string;
  103748. /**
  103749. * Gets the input component
  103750. */
  103751. get input(): NodeMaterialConnectionPoint;
  103752. /**
  103753. * Gets the source min input component
  103754. */
  103755. get sourceMin(): NodeMaterialConnectionPoint;
  103756. /**
  103757. * Gets the source max input component
  103758. */
  103759. get sourceMax(): NodeMaterialConnectionPoint;
  103760. /**
  103761. * Gets the target min input component
  103762. */
  103763. get targetMin(): NodeMaterialConnectionPoint;
  103764. /**
  103765. * Gets the target max input component
  103766. */
  103767. get targetMax(): NodeMaterialConnectionPoint;
  103768. /**
  103769. * Gets the output component
  103770. */
  103771. get output(): NodeMaterialConnectionPoint;
  103772. protected _buildBlock(state: NodeMaterialBuildState): this;
  103773. protected _dumpPropertiesCode(): string;
  103774. serialize(): any;
  103775. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103776. }
  103777. }
  103778. declare module BABYLON {
  103779. /**
  103780. * Block used to multiply 2 values
  103781. */
  103782. export class MultiplyBlock extends NodeMaterialBlock {
  103783. /**
  103784. * Creates a new MultiplyBlock
  103785. * @param name defines the block name
  103786. */
  103787. constructor(name: string);
  103788. /**
  103789. * Gets the current class name
  103790. * @returns the class name
  103791. */
  103792. getClassName(): string;
  103793. /**
  103794. * Gets the left operand input component
  103795. */
  103796. get left(): NodeMaterialConnectionPoint;
  103797. /**
  103798. * Gets the right operand input component
  103799. */
  103800. get right(): NodeMaterialConnectionPoint;
  103801. /**
  103802. * Gets the output component
  103803. */
  103804. get output(): NodeMaterialConnectionPoint;
  103805. protected _buildBlock(state: NodeMaterialBuildState): this;
  103806. }
  103807. }
  103808. declare module BABYLON {
  103809. /**
  103810. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  103811. */
  103812. export class ColorSplitterBlock extends NodeMaterialBlock {
  103813. /**
  103814. * Create a new ColorSplitterBlock
  103815. * @param name defines the block name
  103816. */
  103817. constructor(name: string);
  103818. /**
  103819. * Gets the current class name
  103820. * @returns the class name
  103821. */
  103822. getClassName(): string;
  103823. /**
  103824. * Gets the rgba component (input)
  103825. */
  103826. get rgba(): NodeMaterialConnectionPoint;
  103827. /**
  103828. * Gets the rgb component (input)
  103829. */
  103830. get rgbIn(): NodeMaterialConnectionPoint;
  103831. /**
  103832. * Gets the rgb component (output)
  103833. */
  103834. get rgbOut(): NodeMaterialConnectionPoint;
  103835. /**
  103836. * Gets the r component (output)
  103837. */
  103838. get r(): NodeMaterialConnectionPoint;
  103839. /**
  103840. * Gets the g component (output)
  103841. */
  103842. get g(): NodeMaterialConnectionPoint;
  103843. /**
  103844. * Gets the b component (output)
  103845. */
  103846. get b(): NodeMaterialConnectionPoint;
  103847. /**
  103848. * Gets the a component (output)
  103849. */
  103850. get a(): NodeMaterialConnectionPoint;
  103851. protected _inputRename(name: string): string;
  103852. protected _outputRename(name: string): string;
  103853. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103854. }
  103855. }
  103856. declare module BABYLON {
  103857. /**
  103858. * Operations supported by the Trigonometry block
  103859. */
  103860. export enum TrigonometryBlockOperations {
  103861. /** Cos */
  103862. Cos = 0,
  103863. /** Sin */
  103864. Sin = 1,
  103865. /** Abs */
  103866. Abs = 2,
  103867. /** Exp */
  103868. Exp = 3,
  103869. /** Exp2 */
  103870. Exp2 = 4,
  103871. /** Round */
  103872. Round = 5,
  103873. /** Floor */
  103874. Floor = 6,
  103875. /** Ceiling */
  103876. Ceiling = 7,
  103877. /** Square root */
  103878. Sqrt = 8,
  103879. /** Log */
  103880. Log = 9,
  103881. /** Tangent */
  103882. Tan = 10,
  103883. /** Arc tangent */
  103884. ArcTan = 11,
  103885. /** Arc cosinus */
  103886. ArcCos = 12,
  103887. /** Arc sinus */
  103888. ArcSin = 13,
  103889. /** Fraction */
  103890. Fract = 14,
  103891. /** Sign */
  103892. Sign = 15,
  103893. /** To radians (from degrees) */
  103894. Radians = 16,
  103895. /** To degrees (from radians) */
  103896. Degrees = 17
  103897. }
  103898. /**
  103899. * Block used to apply trigonometry operation to floats
  103900. */
  103901. export class TrigonometryBlock extends NodeMaterialBlock {
  103902. /**
  103903. * Gets or sets the operation applied by the block
  103904. */
  103905. operation: TrigonometryBlockOperations;
  103906. /**
  103907. * Creates a new TrigonometryBlock
  103908. * @param name defines the block name
  103909. */
  103910. constructor(name: string);
  103911. /**
  103912. * Gets the current class name
  103913. * @returns the class name
  103914. */
  103915. getClassName(): string;
  103916. /**
  103917. * Gets the input component
  103918. */
  103919. get input(): NodeMaterialConnectionPoint;
  103920. /**
  103921. * Gets the output component
  103922. */
  103923. get output(): NodeMaterialConnectionPoint;
  103924. protected _buildBlock(state: NodeMaterialBuildState): this;
  103925. serialize(): any;
  103926. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103927. protected _dumpPropertiesCode(): string;
  103928. }
  103929. }
  103930. declare module BABYLON {
  103931. /**
  103932. * Interface used to configure the node material editor
  103933. */
  103934. export interface INodeMaterialEditorOptions {
  103935. /** Define the URl to load node editor script */
  103936. editorURL?: string;
  103937. }
  103938. /** @hidden */
  103939. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103940. NORMAL: boolean;
  103941. TANGENT: boolean;
  103942. UV1: boolean;
  103943. /** BONES */
  103944. NUM_BONE_INFLUENCERS: number;
  103945. BonesPerMesh: number;
  103946. BONETEXTURE: boolean;
  103947. /** MORPH TARGETS */
  103948. MORPHTARGETS: boolean;
  103949. MORPHTARGETS_NORMAL: boolean;
  103950. MORPHTARGETS_TANGENT: boolean;
  103951. MORPHTARGETS_UV: boolean;
  103952. NUM_MORPH_INFLUENCERS: number;
  103953. /** IMAGE PROCESSING */
  103954. IMAGEPROCESSING: boolean;
  103955. VIGNETTE: boolean;
  103956. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103957. VIGNETTEBLENDMODEOPAQUE: boolean;
  103958. TONEMAPPING: boolean;
  103959. TONEMAPPING_ACES: boolean;
  103960. CONTRAST: boolean;
  103961. EXPOSURE: boolean;
  103962. COLORCURVES: boolean;
  103963. COLORGRADING: boolean;
  103964. COLORGRADING3D: boolean;
  103965. SAMPLER3DGREENDEPTH: boolean;
  103966. SAMPLER3DBGRMAP: boolean;
  103967. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103968. /** MISC. */
  103969. BUMPDIRECTUV: number;
  103970. constructor();
  103971. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103972. }
  103973. /**
  103974. * Class used to configure NodeMaterial
  103975. */
  103976. export interface INodeMaterialOptions {
  103977. /**
  103978. * Defines if blocks should emit comments
  103979. */
  103980. emitComments: boolean;
  103981. }
  103982. /**
  103983. * Class used to create a node based material built by assembling shader blocks
  103984. */
  103985. export class NodeMaterial extends PushMaterial {
  103986. private static _BuildIdGenerator;
  103987. private _options;
  103988. private _vertexCompilationState;
  103989. private _fragmentCompilationState;
  103990. private _sharedData;
  103991. private _buildId;
  103992. private _buildWasSuccessful;
  103993. private _cachedWorldViewMatrix;
  103994. private _cachedWorldViewProjectionMatrix;
  103995. private _optimizers;
  103996. private _animationFrame;
  103997. /** Define the Url to load node editor script */
  103998. static EditorURL: string;
  103999. /** Define the Url to load snippets */
  104000. static SnippetUrl: string;
  104001. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  104002. static IgnoreTexturesAtLoadTime: boolean;
  104003. private BJSNODEMATERIALEDITOR;
  104004. /** Get the inspector from bundle or global */
  104005. private _getGlobalNodeMaterialEditor;
  104006. /**
  104007. * Snippet ID if the material was created from the snippet server
  104008. */
  104009. snippetId: string;
  104010. /**
  104011. * Gets or sets data used by visual editor
  104012. * @see https://nme.babylonjs.com
  104013. */
  104014. editorData: any;
  104015. /**
  104016. * 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)
  104017. */
  104018. ignoreAlpha: boolean;
  104019. /**
  104020. * Defines the maximum number of lights that can be used in the material
  104021. */
  104022. maxSimultaneousLights: number;
  104023. /**
  104024. * Observable raised when the material is built
  104025. */
  104026. onBuildObservable: Observable<NodeMaterial>;
  104027. /**
  104028. * Gets or sets the root nodes of the material vertex shader
  104029. */
  104030. _vertexOutputNodes: NodeMaterialBlock[];
  104031. /**
  104032. * Gets or sets the root nodes of the material fragment (pixel) shader
  104033. */
  104034. _fragmentOutputNodes: NodeMaterialBlock[];
  104035. /** Gets or sets options to control the node material overall behavior */
  104036. get options(): INodeMaterialOptions;
  104037. set options(options: INodeMaterialOptions);
  104038. /**
  104039. * Default configuration related to image processing available in the standard Material.
  104040. */
  104041. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104042. /**
  104043. * Gets the image processing configuration used either in this material.
  104044. */
  104045. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104046. /**
  104047. * Sets the Default image processing configuration used either in the this material.
  104048. *
  104049. * If sets to null, the scene one is in use.
  104050. */
  104051. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104052. /**
  104053. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  104054. */
  104055. attachedBlocks: NodeMaterialBlock[];
  104056. /**
  104057. * Specifies the mode of the node material
  104058. * @hidden
  104059. */
  104060. _mode: NodeMaterialModes;
  104061. /**
  104062. * Gets the mode property
  104063. */
  104064. get mode(): NodeMaterialModes;
  104065. /**
  104066. * A free comment about the material
  104067. */
  104068. comment: string;
  104069. /**
  104070. * Create a new node based material
  104071. * @param name defines the material name
  104072. * @param scene defines the hosting scene
  104073. * @param options defines creation option
  104074. */
  104075. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  104076. /**
  104077. * Gets the current class name of the material e.g. "NodeMaterial"
  104078. * @returns the class name
  104079. */
  104080. getClassName(): string;
  104081. /**
  104082. * Keep track of the image processing observer to allow dispose and replace.
  104083. */
  104084. private _imageProcessingObserver;
  104085. /**
  104086. * Attaches a new image processing configuration to the Standard Material.
  104087. * @param configuration
  104088. */
  104089. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104090. /**
  104091. * Get a block by its name
  104092. * @param name defines the name of the block to retrieve
  104093. * @returns the required block or null if not found
  104094. */
  104095. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  104096. /**
  104097. * Get a block by its name
  104098. * @param predicate defines the predicate used to find the good candidate
  104099. * @returns the required block or null if not found
  104100. */
  104101. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  104102. /**
  104103. * Get an input block by its name
  104104. * @param predicate defines the predicate used to find the good candidate
  104105. * @returns the required input block or null if not found
  104106. */
  104107. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  104108. /**
  104109. * Gets the list of input blocks attached to this material
  104110. * @returns an array of InputBlocks
  104111. */
  104112. getInputBlocks(): InputBlock[];
  104113. /**
  104114. * Adds a new optimizer to the list of optimizers
  104115. * @param optimizer defines the optimizers to add
  104116. * @returns the current material
  104117. */
  104118. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  104119. /**
  104120. * Remove an optimizer from the list of optimizers
  104121. * @param optimizer defines the optimizers to remove
  104122. * @returns the current material
  104123. */
  104124. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  104125. /**
  104126. * Add a new block to the list of output nodes
  104127. * @param node defines the node to add
  104128. * @returns the current material
  104129. */
  104130. addOutputNode(node: NodeMaterialBlock): this;
  104131. /**
  104132. * Remove a block from the list of root nodes
  104133. * @param node defines the node to remove
  104134. * @returns the current material
  104135. */
  104136. removeOutputNode(node: NodeMaterialBlock): this;
  104137. private _addVertexOutputNode;
  104138. private _removeVertexOutputNode;
  104139. private _addFragmentOutputNode;
  104140. private _removeFragmentOutputNode;
  104141. /**
  104142. * Specifies if the material will require alpha blending
  104143. * @returns a boolean specifying if alpha blending is needed
  104144. */
  104145. needAlphaBlending(): boolean;
  104146. /**
  104147. * Specifies if this material should be rendered in alpha test mode
  104148. * @returns a boolean specifying if an alpha test is needed.
  104149. */
  104150. needAlphaTesting(): boolean;
  104151. private _initializeBlock;
  104152. private _resetDualBlocks;
  104153. /**
  104154. * Remove a block from the current node material
  104155. * @param block defines the block to remove
  104156. */
  104157. removeBlock(block: NodeMaterialBlock): void;
  104158. /**
  104159. * Build the material and generates the inner effect
  104160. * @param verbose defines if the build should log activity
  104161. */
  104162. build(verbose?: boolean): void;
  104163. /**
  104164. * Runs an otpimization phase to try to improve the shader code
  104165. */
  104166. optimize(): void;
  104167. private _prepareDefinesForAttributes;
  104168. /**
  104169. * Create a post process from the material
  104170. * @param camera The camera to apply the render pass to.
  104171. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104173. * @param engine The engine which the post process will be applied. (default: current engine)
  104174. * @param reusable If the post process can be reused on the same frame. (default: false)
  104175. * @param textureType Type of textures used when performing the post process. (default: 0)
  104176. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  104177. * @returns the post process created
  104178. */
  104179. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  104180. /**
  104181. * Create the post process effect from the material
  104182. * @param postProcess The post process to create the effect for
  104183. */
  104184. createEffectForPostProcess(postProcess: PostProcess): void;
  104185. private _createEffectForPostProcess;
  104186. /**
  104187. * Create a new procedural texture based on this node material
  104188. * @param size defines the size of the texture
  104189. * @param scene defines the hosting scene
  104190. * @returns the new procedural texture attached to this node material
  104191. */
  104192. createProceduralTexture(size: number | {
  104193. width: number;
  104194. height: number;
  104195. layers?: number;
  104196. }, scene: Scene): Nullable<ProceduralTexture>;
  104197. private _createEffectForParticles;
  104198. private _checkInternals;
  104199. /**
  104200. * Create the effect to be used as the custom effect for a particle system
  104201. * @param particleSystem Particle system to create the effect for
  104202. * @param onCompiled defines a function to call when the effect creation is successful
  104203. * @param onError defines a function to call when the effect creation has failed
  104204. */
  104205. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104206. private _processDefines;
  104207. /**
  104208. * Get if the submesh is ready to be used and all its information available.
  104209. * Child classes can use it to update shaders
  104210. * @param mesh defines the mesh to check
  104211. * @param subMesh defines which submesh to check
  104212. * @param useInstances specifies that instances should be used
  104213. * @returns a boolean indicating that the submesh is ready or not
  104214. */
  104215. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104216. /**
  104217. * Get a string representing the shaders built by the current node graph
  104218. */
  104219. get compiledShaders(): string;
  104220. /**
  104221. * Binds the world matrix to the material
  104222. * @param world defines the world transformation matrix
  104223. */
  104224. bindOnlyWorldMatrix(world: Matrix): void;
  104225. /**
  104226. * Binds the submesh to this material by preparing the effect and shader to draw
  104227. * @param world defines the world transformation matrix
  104228. * @param mesh defines the mesh containing the submesh
  104229. * @param subMesh defines the submesh to bind the material to
  104230. */
  104231. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104232. /**
  104233. * Gets the active textures from the material
  104234. * @returns an array of textures
  104235. */
  104236. getActiveTextures(): BaseTexture[];
  104237. /**
  104238. * Gets the list of texture blocks
  104239. * @returns an array of texture blocks
  104240. */
  104241. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  104242. /**
  104243. * Specifies if the material uses a texture
  104244. * @param texture defines the texture to check against the material
  104245. * @returns a boolean specifying if the material uses the texture
  104246. */
  104247. hasTexture(texture: BaseTexture): boolean;
  104248. /**
  104249. * Disposes the material
  104250. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104251. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104252. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  104253. */
  104254. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  104255. /** Creates the node editor window. */
  104256. private _createNodeEditor;
  104257. /**
  104258. * Launch the node material editor
  104259. * @param config Define the configuration of the editor
  104260. * @return a promise fulfilled when the node editor is visible
  104261. */
  104262. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  104263. /**
  104264. * Clear the current material
  104265. */
  104266. clear(): void;
  104267. /**
  104268. * Clear the current material and set it to a default state
  104269. */
  104270. setToDefault(): void;
  104271. /**
  104272. * Clear the current material and set it to a default state for post process
  104273. */
  104274. setToDefaultPostProcess(): void;
  104275. /**
  104276. * Clear the current material and set it to a default state for procedural texture
  104277. */
  104278. setToDefaultProceduralTexture(): void;
  104279. /**
  104280. * Clear the current material and set it to a default state for particle
  104281. */
  104282. setToDefaultParticle(): void;
  104283. /**
  104284. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  104285. * @param url defines the url to load from
  104286. * @returns a promise that will fullfil when the material is fully loaded
  104287. */
  104288. loadAsync(url: string): Promise<void>;
  104289. private _gatherBlocks;
  104290. /**
  104291. * Generate a string containing the code declaration required to create an equivalent of this material
  104292. * @returns a string
  104293. */
  104294. generateCode(): string;
  104295. /**
  104296. * Serializes this material in a JSON representation
  104297. * @returns the serialized material object
  104298. */
  104299. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  104300. private _restoreConnections;
  104301. /**
  104302. * Clear the current graph and load a new one from a serialization object
  104303. * @param source defines the JSON representation of the material
  104304. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104305. * @param merge defines whether or not the source must be merged or replace the current content
  104306. */
  104307. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  104308. /**
  104309. * Makes a duplicate of the current material.
  104310. * @param name - name to use for the new material.
  104311. */
  104312. clone(name: string): NodeMaterial;
  104313. /**
  104314. * Creates a node material from parsed material data
  104315. * @param source defines the JSON representation of the material
  104316. * @param scene defines the hosting scene
  104317. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104318. * @returns a new node material
  104319. */
  104320. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  104321. /**
  104322. * Creates a node material from a snippet saved in a remote file
  104323. * @param name defines the name of the material to create
  104324. * @param url defines the url to load from
  104325. * @param scene defines the hosting scene
  104326. * @returns a promise that will resolve to the new node material
  104327. */
  104328. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  104329. /**
  104330. * Creates a node material from a snippet saved by the node material editor
  104331. * @param snippetId defines the snippet to load
  104332. * @param scene defines the hosting scene
  104333. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104334. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  104335. * @returns a promise that will resolve to the new node material
  104336. */
  104337. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  104338. /**
  104339. * Creates a new node material set to default basic configuration
  104340. * @param name defines the name of the material
  104341. * @param scene defines the hosting scene
  104342. * @returns a new NodeMaterial
  104343. */
  104344. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  104345. }
  104346. }
  104347. declare module BABYLON {
  104348. interface ThinEngine {
  104349. /**
  104350. * Unbind a list of render target textures from the webGL context
  104351. * This is used only when drawBuffer extension or webGL2 are active
  104352. * @param textures defines the render target textures to unbind
  104353. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104354. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104355. */
  104356. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104357. /**
  104358. * Create a multi render target texture
  104359. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  104360. * @param size defines the size of the texture
  104361. * @param options defines the creation options
  104362. * @returns the cube texture as an InternalTexture
  104363. */
  104364. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104365. /**
  104366. * Update the sample count for a given multiple render target texture
  104367. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104368. * @param textures defines the textures to update
  104369. * @param samples defines the sample count to set
  104370. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104371. */
  104372. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104373. /**
  104374. * Select a subsets of attachments to draw to.
  104375. * @param attachments gl attachments
  104376. */
  104377. bindAttachments(attachments: number[]): void;
  104378. /**
  104379. * Creates a layout object to draw/clear on specific textures in a MRT
  104380. * @param textureStatus textureStatus[i] indicates if the i-th is active
  104381. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  104382. */
  104383. buildTextureLayout(textureStatus: boolean[]): number[];
  104384. /**
  104385. * Restores the webgl state to only draw on the main color attachment
  104386. */
  104387. restoreSingleAttachment(): void;
  104388. }
  104389. }
  104390. declare module BABYLON {
  104391. /**
  104392. * Creation options of the multi render target texture.
  104393. */
  104394. export interface IMultiRenderTargetOptions {
  104395. /**
  104396. * Define if the texture needs to create mip maps after render.
  104397. */
  104398. generateMipMaps?: boolean;
  104399. /**
  104400. * Define the types of all the draw buffers we want to create
  104401. */
  104402. types?: number[];
  104403. /**
  104404. * Define the sampling modes of all the draw buffers we want to create
  104405. */
  104406. samplingModes?: number[];
  104407. /**
  104408. * Define if a depth buffer is required
  104409. */
  104410. generateDepthBuffer?: boolean;
  104411. /**
  104412. * Define if a stencil buffer is required
  104413. */
  104414. generateStencilBuffer?: boolean;
  104415. /**
  104416. * Define if a depth texture is required instead of a depth buffer
  104417. */
  104418. generateDepthTexture?: boolean;
  104419. /**
  104420. * Define the number of desired draw buffers
  104421. */
  104422. textureCount?: number;
  104423. /**
  104424. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104425. */
  104426. doNotChangeAspectRatio?: boolean;
  104427. /**
  104428. * Define the default type of the buffers we are creating
  104429. */
  104430. defaultType?: number;
  104431. }
  104432. /**
  104433. * A multi render target, like a render target provides the ability to render to a texture.
  104434. * Unlike the render target, it can render to several draw buffers in one draw.
  104435. * This is specially interesting in deferred rendering or for any effects requiring more than
  104436. * just one color from a single pass.
  104437. */
  104438. export class MultiRenderTarget extends RenderTargetTexture {
  104439. private _internalTextures;
  104440. private _textures;
  104441. private _multiRenderTargetOptions;
  104442. private _count;
  104443. /**
  104444. * Get if draw buffers are currently supported by the used hardware and browser.
  104445. */
  104446. get isSupported(): boolean;
  104447. /**
  104448. * Get the list of textures generated by the multi render target.
  104449. */
  104450. get textures(): Texture[];
  104451. /**
  104452. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  104453. */
  104454. get count(): number;
  104455. /**
  104456. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104457. */
  104458. get depthTexture(): Texture;
  104459. /**
  104460. * Set the wrapping mode on U of all the textures we are rendering to.
  104461. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104462. */
  104463. set wrapU(wrap: number);
  104464. /**
  104465. * Set the wrapping mode on V of all the textures we are rendering to.
  104466. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104467. */
  104468. set wrapV(wrap: number);
  104469. /**
  104470. * Instantiate a new multi render target texture.
  104471. * A multi render target, like a render target provides the ability to render to a texture.
  104472. * Unlike the render target, it can render to several draw buffers in one draw.
  104473. * This is specially interesting in deferred rendering or for any effects requiring more than
  104474. * just one color from a single pass.
  104475. * @param name Define the name of the texture
  104476. * @param size Define the size of the buffers to render to
  104477. * @param count Define the number of target we are rendering into
  104478. * @param scene Define the scene the texture belongs to
  104479. * @param options Define the options used to create the multi render target
  104480. */
  104481. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104482. private _initTypes;
  104483. /** @hidden */
  104484. _rebuild(forceFullRebuild?: boolean): void;
  104485. private _createInternalTextures;
  104486. private _createTextures;
  104487. /**
  104488. * Replaces a texture within the MRT.
  104489. * @param texture The new texture to insert in the MRT
  104490. * @param index The index of the texture to replace
  104491. */
  104492. replaceTexture(texture: Texture, index: number): void;
  104493. /**
  104494. * Define the number of samples used if MSAA is enabled.
  104495. */
  104496. get samples(): number;
  104497. set samples(value: number);
  104498. /**
  104499. * Resize all the textures in the multi render target.
  104500. * Be careful as it will recreate all the data in the new texture.
  104501. * @param size Define the new size
  104502. */
  104503. resize(size: any): void;
  104504. /**
  104505. * Changes the number of render targets in this MRT
  104506. * Be careful as it will recreate all the data in the new texture.
  104507. * @param count new texture count
  104508. * @param options Specifies texture types and sampling modes for new textures
  104509. */
  104510. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  104511. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104512. /**
  104513. * Dispose the render targets and their associated resources
  104514. */
  104515. dispose(): void;
  104516. /**
  104517. * Release all the underlying texture used as draw buffers.
  104518. */
  104519. releaseInternalTextures(): void;
  104520. }
  104521. }
  104522. declare module BABYLON {
  104523. /** @hidden */
  104524. export var imageProcessingPixelShader: {
  104525. name: string;
  104526. shader: string;
  104527. };
  104528. }
  104529. declare module BABYLON {
  104530. /**
  104531. * ImageProcessingPostProcess
  104532. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104533. */
  104534. export class ImageProcessingPostProcess extends PostProcess {
  104535. /**
  104536. * Default configuration related to image processing available in the PBR Material.
  104537. */
  104538. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104539. /**
  104540. * Gets the image processing configuration used either in this material.
  104541. */
  104542. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104543. /**
  104544. * Sets the Default image processing configuration used either in the this material.
  104545. *
  104546. * If sets to null, the scene one is in use.
  104547. */
  104548. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104549. /**
  104550. * Keep track of the image processing observer to allow dispose and replace.
  104551. */
  104552. private _imageProcessingObserver;
  104553. /**
  104554. * Attaches a new image processing configuration to the PBR Material.
  104555. * @param configuration
  104556. */
  104557. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104558. /**
  104559. * If the post process is supported.
  104560. */
  104561. get isSupported(): boolean;
  104562. /**
  104563. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104564. */
  104565. get colorCurves(): Nullable<ColorCurves>;
  104566. /**
  104567. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104568. */
  104569. set colorCurves(value: Nullable<ColorCurves>);
  104570. /**
  104571. * Gets wether the color curves effect is enabled.
  104572. */
  104573. get colorCurvesEnabled(): boolean;
  104574. /**
  104575. * Sets wether the color curves effect is enabled.
  104576. */
  104577. set colorCurvesEnabled(value: boolean);
  104578. /**
  104579. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104580. */
  104581. get colorGradingTexture(): Nullable<BaseTexture>;
  104582. /**
  104583. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104584. */
  104585. set colorGradingTexture(value: Nullable<BaseTexture>);
  104586. /**
  104587. * Gets wether the color grading effect is enabled.
  104588. */
  104589. get colorGradingEnabled(): boolean;
  104590. /**
  104591. * Gets wether the color grading effect is enabled.
  104592. */
  104593. set colorGradingEnabled(value: boolean);
  104594. /**
  104595. * Gets exposure used in the effect.
  104596. */
  104597. get exposure(): number;
  104598. /**
  104599. * Sets exposure used in the effect.
  104600. */
  104601. set exposure(value: number);
  104602. /**
  104603. * Gets wether tonemapping is enabled or not.
  104604. */
  104605. get toneMappingEnabled(): boolean;
  104606. /**
  104607. * Sets wether tonemapping is enabled or not
  104608. */
  104609. set toneMappingEnabled(value: boolean);
  104610. /**
  104611. * Gets the type of tone mapping effect.
  104612. */
  104613. get toneMappingType(): number;
  104614. /**
  104615. * Sets the type of tone mapping effect.
  104616. */
  104617. set toneMappingType(value: number);
  104618. /**
  104619. * Gets contrast used in the effect.
  104620. */
  104621. get contrast(): number;
  104622. /**
  104623. * Sets contrast used in the effect.
  104624. */
  104625. set contrast(value: number);
  104626. /**
  104627. * Gets Vignette stretch size.
  104628. */
  104629. get vignetteStretch(): number;
  104630. /**
  104631. * Sets Vignette stretch size.
  104632. */
  104633. set vignetteStretch(value: number);
  104634. /**
  104635. * Gets Vignette centre X Offset.
  104636. */
  104637. get vignetteCentreX(): number;
  104638. /**
  104639. * Sets Vignette centre X Offset.
  104640. */
  104641. set vignetteCentreX(value: number);
  104642. /**
  104643. * Gets Vignette centre Y Offset.
  104644. */
  104645. get vignetteCentreY(): number;
  104646. /**
  104647. * Sets Vignette centre Y Offset.
  104648. */
  104649. set vignetteCentreY(value: number);
  104650. /**
  104651. * Gets Vignette weight or intensity of the vignette effect.
  104652. */
  104653. get vignetteWeight(): number;
  104654. /**
  104655. * Sets Vignette weight or intensity of the vignette effect.
  104656. */
  104657. set vignetteWeight(value: number);
  104658. /**
  104659. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104660. * if vignetteEnabled is set to true.
  104661. */
  104662. get vignetteColor(): Color4;
  104663. /**
  104664. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104665. * if vignetteEnabled is set to true.
  104666. */
  104667. set vignetteColor(value: Color4);
  104668. /**
  104669. * Gets Camera field of view used by the Vignette effect.
  104670. */
  104671. get vignetteCameraFov(): number;
  104672. /**
  104673. * Sets Camera field of view used by the Vignette effect.
  104674. */
  104675. set vignetteCameraFov(value: number);
  104676. /**
  104677. * Gets the vignette blend mode allowing different kind of effect.
  104678. */
  104679. get vignetteBlendMode(): number;
  104680. /**
  104681. * Sets the vignette blend mode allowing different kind of effect.
  104682. */
  104683. set vignetteBlendMode(value: number);
  104684. /**
  104685. * Gets wether the vignette effect is enabled.
  104686. */
  104687. get vignetteEnabled(): boolean;
  104688. /**
  104689. * Sets wether the vignette effect is enabled.
  104690. */
  104691. set vignetteEnabled(value: boolean);
  104692. private _fromLinearSpace;
  104693. /**
  104694. * Gets wether the input of the processing is in Gamma or Linear Space.
  104695. */
  104696. get fromLinearSpace(): boolean;
  104697. /**
  104698. * Sets wether the input of the processing is in Gamma or Linear Space.
  104699. */
  104700. set fromLinearSpace(value: boolean);
  104701. /**
  104702. * Defines cache preventing GC.
  104703. */
  104704. private _defines;
  104705. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104706. /**
  104707. * "ImageProcessingPostProcess"
  104708. * @returns "ImageProcessingPostProcess"
  104709. */
  104710. getClassName(): string;
  104711. /**
  104712. * @hidden
  104713. */
  104714. _updateParameters(): void;
  104715. dispose(camera?: Camera): void;
  104716. }
  104717. }
  104718. declare module BABYLON {
  104719. /**
  104720. * Interface for defining prepass effects in the prepass post-process pipeline
  104721. */
  104722. export interface PrePassEffectConfiguration {
  104723. /**
  104724. * Name of the effect
  104725. */
  104726. name: string;
  104727. /**
  104728. * Post process to attach for this effect
  104729. */
  104730. postProcess?: PostProcess;
  104731. /**
  104732. * Textures required in the MRT
  104733. */
  104734. texturesRequired: number[];
  104735. /**
  104736. * Is the effect enabled
  104737. */
  104738. enabled: boolean;
  104739. /**
  104740. * Disposes the effect configuration
  104741. */
  104742. dispose?: () => void;
  104743. /**
  104744. * Creates the associated post process
  104745. */
  104746. createPostProcess?: () => PostProcess;
  104747. }
  104748. }
  104749. declare module BABYLON {
  104750. /**
  104751. * Options to be used when creating a FresnelParameters.
  104752. */
  104753. export type IFresnelParametersCreationOptions = {
  104754. /**
  104755. * Define the color used on edges (grazing angle)
  104756. */
  104757. leftColor?: Color3;
  104758. /**
  104759. * Define the color used on center
  104760. */
  104761. rightColor?: Color3;
  104762. /**
  104763. * Define bias applied to computed fresnel term
  104764. */
  104765. bias?: number;
  104766. /**
  104767. * Defined the power exponent applied to fresnel term
  104768. */
  104769. power?: number;
  104770. /**
  104771. * Define if the fresnel effect is enable or not.
  104772. */
  104773. isEnabled?: boolean;
  104774. };
  104775. /**
  104776. * Serialized format for FresnelParameters.
  104777. */
  104778. export type IFresnelParametersSerialized = {
  104779. /**
  104780. * Define the color used on edges (grazing angle) [as an array]
  104781. */
  104782. leftColor: number[];
  104783. /**
  104784. * Define the color used on center [as an array]
  104785. */
  104786. rightColor: number[];
  104787. /**
  104788. * Define bias applied to computed fresnel term
  104789. */
  104790. bias: number;
  104791. /**
  104792. * Defined the power exponent applied to fresnel term
  104793. */
  104794. power?: number;
  104795. /**
  104796. * Define if the fresnel effect is enable or not.
  104797. */
  104798. isEnabled: boolean;
  104799. };
  104800. /**
  104801. * This represents all the required information to add a fresnel effect on a material:
  104802. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104803. */
  104804. export class FresnelParameters {
  104805. private _isEnabled;
  104806. /**
  104807. * Define if the fresnel effect is enable or not.
  104808. */
  104809. get isEnabled(): boolean;
  104810. set isEnabled(value: boolean);
  104811. /**
  104812. * Define the color used on edges (grazing angle)
  104813. */
  104814. leftColor: Color3;
  104815. /**
  104816. * Define the color used on center
  104817. */
  104818. rightColor: Color3;
  104819. /**
  104820. * Define bias applied to computed fresnel term
  104821. */
  104822. bias: number;
  104823. /**
  104824. * Defined the power exponent applied to fresnel term
  104825. */
  104826. power: number;
  104827. /**
  104828. * Creates a new FresnelParameters object.
  104829. *
  104830. * @param options provide your own settings to optionally to override defaults
  104831. */
  104832. constructor(options?: IFresnelParametersCreationOptions);
  104833. /**
  104834. * Clones the current fresnel and its valuues
  104835. * @returns a clone fresnel configuration
  104836. */
  104837. clone(): FresnelParameters;
  104838. /**
  104839. * Determines equality between FresnelParameters objects
  104840. * @param otherFresnelParameters defines the second operand
  104841. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  104842. */
  104843. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  104844. /**
  104845. * Serializes the current fresnel parameters to a JSON representation.
  104846. * @return the JSON serialization
  104847. */
  104848. serialize(): IFresnelParametersSerialized;
  104849. /**
  104850. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  104851. * @param parsedFresnelParameters Define the JSON representation
  104852. * @returns the parsed parameters
  104853. */
  104854. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  104855. }
  104856. }
  104857. declare module BABYLON {
  104858. /**
  104859. * This groups all the flags used to control the materials channel.
  104860. */
  104861. export class MaterialFlags {
  104862. private static _DiffuseTextureEnabled;
  104863. /**
  104864. * Are diffuse textures enabled in the application.
  104865. */
  104866. static get DiffuseTextureEnabled(): boolean;
  104867. static set DiffuseTextureEnabled(value: boolean);
  104868. private static _DetailTextureEnabled;
  104869. /**
  104870. * Are detail textures enabled in the application.
  104871. */
  104872. static get DetailTextureEnabled(): boolean;
  104873. static set DetailTextureEnabled(value: boolean);
  104874. private static _AmbientTextureEnabled;
  104875. /**
  104876. * Are ambient textures enabled in the application.
  104877. */
  104878. static get AmbientTextureEnabled(): boolean;
  104879. static set AmbientTextureEnabled(value: boolean);
  104880. private static _OpacityTextureEnabled;
  104881. /**
  104882. * Are opacity textures enabled in the application.
  104883. */
  104884. static get OpacityTextureEnabled(): boolean;
  104885. static set OpacityTextureEnabled(value: boolean);
  104886. private static _ReflectionTextureEnabled;
  104887. /**
  104888. * Are reflection textures enabled in the application.
  104889. */
  104890. static get ReflectionTextureEnabled(): boolean;
  104891. static set ReflectionTextureEnabled(value: boolean);
  104892. private static _EmissiveTextureEnabled;
  104893. /**
  104894. * Are emissive textures enabled in the application.
  104895. */
  104896. static get EmissiveTextureEnabled(): boolean;
  104897. static set EmissiveTextureEnabled(value: boolean);
  104898. private static _SpecularTextureEnabled;
  104899. /**
  104900. * Are specular textures enabled in the application.
  104901. */
  104902. static get SpecularTextureEnabled(): boolean;
  104903. static set SpecularTextureEnabled(value: boolean);
  104904. private static _BumpTextureEnabled;
  104905. /**
  104906. * Are bump textures enabled in the application.
  104907. */
  104908. static get BumpTextureEnabled(): boolean;
  104909. static set BumpTextureEnabled(value: boolean);
  104910. private static _LightmapTextureEnabled;
  104911. /**
  104912. * Are lightmap textures enabled in the application.
  104913. */
  104914. static get LightmapTextureEnabled(): boolean;
  104915. static set LightmapTextureEnabled(value: boolean);
  104916. private static _RefractionTextureEnabled;
  104917. /**
  104918. * Are refraction textures enabled in the application.
  104919. */
  104920. static get RefractionTextureEnabled(): boolean;
  104921. static set RefractionTextureEnabled(value: boolean);
  104922. private static _ColorGradingTextureEnabled;
  104923. /**
  104924. * Are color grading textures enabled in the application.
  104925. */
  104926. static get ColorGradingTextureEnabled(): boolean;
  104927. static set ColorGradingTextureEnabled(value: boolean);
  104928. private static _FresnelEnabled;
  104929. /**
  104930. * Are fresnels enabled in the application.
  104931. */
  104932. static get FresnelEnabled(): boolean;
  104933. static set FresnelEnabled(value: boolean);
  104934. private static _ClearCoatTextureEnabled;
  104935. /**
  104936. * Are clear coat textures enabled in the application.
  104937. */
  104938. static get ClearCoatTextureEnabled(): boolean;
  104939. static set ClearCoatTextureEnabled(value: boolean);
  104940. private static _ClearCoatBumpTextureEnabled;
  104941. /**
  104942. * Are clear coat bump textures enabled in the application.
  104943. */
  104944. static get ClearCoatBumpTextureEnabled(): boolean;
  104945. static set ClearCoatBumpTextureEnabled(value: boolean);
  104946. private static _ClearCoatTintTextureEnabled;
  104947. /**
  104948. * Are clear coat tint textures enabled in the application.
  104949. */
  104950. static get ClearCoatTintTextureEnabled(): boolean;
  104951. static set ClearCoatTintTextureEnabled(value: boolean);
  104952. private static _SheenTextureEnabled;
  104953. /**
  104954. * Are sheen textures enabled in the application.
  104955. */
  104956. static get SheenTextureEnabled(): boolean;
  104957. static set SheenTextureEnabled(value: boolean);
  104958. private static _AnisotropicTextureEnabled;
  104959. /**
  104960. * Are anisotropic textures enabled in the application.
  104961. */
  104962. static get AnisotropicTextureEnabled(): boolean;
  104963. static set AnisotropicTextureEnabled(value: boolean);
  104964. private static _ThicknessTextureEnabled;
  104965. /**
  104966. * Are thickness textures enabled in the application.
  104967. */
  104968. static get ThicknessTextureEnabled(): boolean;
  104969. static set ThicknessTextureEnabled(value: boolean);
  104970. }
  104971. }
  104972. declare module BABYLON {
  104973. /** @hidden */
  104974. export var defaultFragmentDeclaration: {
  104975. name: string;
  104976. shader: string;
  104977. };
  104978. }
  104979. declare module BABYLON {
  104980. /** @hidden */
  104981. export var defaultUboDeclaration: {
  104982. name: string;
  104983. shader: string;
  104984. };
  104985. }
  104986. declare module BABYLON {
  104987. /** @hidden */
  104988. export var prePassDeclaration: {
  104989. name: string;
  104990. shader: string;
  104991. };
  104992. }
  104993. declare module BABYLON {
  104994. /** @hidden */
  104995. export var lightFragmentDeclaration: {
  104996. name: string;
  104997. shader: string;
  104998. };
  104999. }
  105000. declare module BABYLON {
  105001. /** @hidden */
  105002. export var lightUboDeclaration: {
  105003. name: string;
  105004. shader: string;
  105005. };
  105006. }
  105007. declare module BABYLON {
  105008. /** @hidden */
  105009. export var lightsFragmentFunctions: {
  105010. name: string;
  105011. shader: string;
  105012. };
  105013. }
  105014. declare module BABYLON {
  105015. /** @hidden */
  105016. export var shadowsFragmentFunctions: {
  105017. name: string;
  105018. shader: string;
  105019. };
  105020. }
  105021. declare module BABYLON {
  105022. /** @hidden */
  105023. export var fresnelFunction: {
  105024. name: string;
  105025. shader: string;
  105026. };
  105027. }
  105028. declare module BABYLON {
  105029. /** @hidden */
  105030. export var bumpFragmentMainFunctions: {
  105031. name: string;
  105032. shader: string;
  105033. };
  105034. }
  105035. declare module BABYLON {
  105036. /** @hidden */
  105037. export var bumpFragmentFunctions: {
  105038. name: string;
  105039. shader: string;
  105040. };
  105041. }
  105042. declare module BABYLON {
  105043. /** @hidden */
  105044. export var logDepthDeclaration: {
  105045. name: string;
  105046. shader: string;
  105047. };
  105048. }
  105049. declare module BABYLON {
  105050. /** @hidden */
  105051. export var bumpFragment: {
  105052. name: string;
  105053. shader: string;
  105054. };
  105055. }
  105056. declare module BABYLON {
  105057. /** @hidden */
  105058. export var depthPrePass: {
  105059. name: string;
  105060. shader: string;
  105061. };
  105062. }
  105063. declare module BABYLON {
  105064. /** @hidden */
  105065. export var lightFragment: {
  105066. name: string;
  105067. shader: string;
  105068. };
  105069. }
  105070. declare module BABYLON {
  105071. /** @hidden */
  105072. export var logDepthFragment: {
  105073. name: string;
  105074. shader: string;
  105075. };
  105076. }
  105077. declare module BABYLON {
  105078. /** @hidden */
  105079. export var defaultPixelShader: {
  105080. name: string;
  105081. shader: string;
  105082. };
  105083. }
  105084. declare module BABYLON {
  105085. /** @hidden */
  105086. export var defaultVertexDeclaration: {
  105087. name: string;
  105088. shader: string;
  105089. };
  105090. }
  105091. declare module BABYLON {
  105092. /** @hidden */
  105093. export var prePassVertexDeclaration: {
  105094. name: string;
  105095. shader: string;
  105096. };
  105097. }
  105098. declare module BABYLON {
  105099. /** @hidden */
  105100. export var bumpVertexDeclaration: {
  105101. name: string;
  105102. shader: string;
  105103. };
  105104. }
  105105. declare module BABYLON {
  105106. /** @hidden */
  105107. export var prePassVertex: {
  105108. name: string;
  105109. shader: string;
  105110. };
  105111. }
  105112. declare module BABYLON {
  105113. /** @hidden */
  105114. export var bumpVertex: {
  105115. name: string;
  105116. shader: string;
  105117. };
  105118. }
  105119. declare module BABYLON {
  105120. /** @hidden */
  105121. export var fogVertex: {
  105122. name: string;
  105123. shader: string;
  105124. };
  105125. }
  105126. declare module BABYLON {
  105127. /** @hidden */
  105128. export var shadowsVertex: {
  105129. name: string;
  105130. shader: string;
  105131. };
  105132. }
  105133. declare module BABYLON {
  105134. /** @hidden */
  105135. export var pointCloudVertex: {
  105136. name: string;
  105137. shader: string;
  105138. };
  105139. }
  105140. declare module BABYLON {
  105141. /** @hidden */
  105142. export var logDepthVertex: {
  105143. name: string;
  105144. shader: string;
  105145. };
  105146. }
  105147. declare module BABYLON {
  105148. /** @hidden */
  105149. export var defaultVertexShader: {
  105150. name: string;
  105151. shader: string;
  105152. };
  105153. }
  105154. declare module BABYLON {
  105155. /**
  105156. * @hidden
  105157. */
  105158. export interface IMaterialDetailMapDefines {
  105159. DETAIL: boolean;
  105160. DETAILDIRECTUV: number;
  105161. DETAIL_NORMALBLENDMETHOD: number;
  105162. /** @hidden */
  105163. _areTexturesDirty: boolean;
  105164. }
  105165. /**
  105166. * Define the code related to the detail map parameters of a material
  105167. *
  105168. * Inspired from:
  105169. * 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
  105170. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  105171. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  105172. */
  105173. export class DetailMapConfiguration {
  105174. private _texture;
  105175. /**
  105176. * The detail texture of the material.
  105177. */
  105178. texture: Nullable<BaseTexture>;
  105179. /**
  105180. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  105181. * Bigger values mean stronger blending
  105182. */
  105183. diffuseBlendLevel: number;
  105184. /**
  105185. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  105186. * Bigger values mean stronger blending. Only used with PBR materials
  105187. */
  105188. roughnessBlendLevel: number;
  105189. /**
  105190. * Defines how strong the bump effect from the detail map is
  105191. * Bigger values mean stronger effect
  105192. */
  105193. bumpLevel: number;
  105194. private _normalBlendMethod;
  105195. /**
  105196. * The method used to blend the bump and detail normals together
  105197. */
  105198. normalBlendMethod: number;
  105199. private _isEnabled;
  105200. /**
  105201. * Enable or disable the detail map on this material
  105202. */
  105203. isEnabled: boolean;
  105204. /** @hidden */
  105205. private _internalMarkAllSubMeshesAsTexturesDirty;
  105206. /** @hidden */
  105207. _markAllSubMeshesAsTexturesDirty(): void;
  105208. /**
  105209. * Instantiate a new detail map
  105210. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105211. */
  105212. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105213. /**
  105214. * Gets whether the submesh is ready to be used or not.
  105215. * @param defines the list of "defines" to update.
  105216. * @param scene defines the scene the material belongs to.
  105217. * @returns - boolean indicating that the submesh is ready or not.
  105218. */
  105219. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  105220. /**
  105221. * Update the defines for detail map usage
  105222. * @param defines the list of "defines" to update.
  105223. * @param scene defines the scene the material belongs to.
  105224. */
  105225. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  105226. /**
  105227. * Binds the material data.
  105228. * @param uniformBuffer defines the Uniform buffer to fill in.
  105229. * @param scene defines the scene the material belongs to.
  105230. * @param isFrozen defines whether the material is frozen or not.
  105231. */
  105232. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105233. /**
  105234. * Checks to see if a texture is used in the material.
  105235. * @param texture - Base texture to use.
  105236. * @returns - Boolean specifying if a texture is used in the material.
  105237. */
  105238. hasTexture(texture: BaseTexture): boolean;
  105239. /**
  105240. * Returns an array of the actively used textures.
  105241. * @param activeTextures Array of BaseTextures
  105242. */
  105243. getActiveTextures(activeTextures: BaseTexture[]): void;
  105244. /**
  105245. * Returns the animatable textures.
  105246. * @param animatables Array of animatable textures.
  105247. */
  105248. getAnimatables(animatables: IAnimatable[]): void;
  105249. /**
  105250. * Disposes the resources of the material.
  105251. * @param forceDisposeTextures - Forces the disposal of all textures.
  105252. */
  105253. dispose(forceDisposeTextures?: boolean): void;
  105254. /**
  105255. * Get the current class name useful for serialization or dynamic coding.
  105256. * @returns "DetailMap"
  105257. */
  105258. getClassName(): string;
  105259. /**
  105260. * Add the required uniforms to the current list.
  105261. * @param uniforms defines the current uniform list.
  105262. */
  105263. static AddUniforms(uniforms: string[]): void;
  105264. /**
  105265. * Add the required samplers to the current list.
  105266. * @param samplers defines the current sampler list.
  105267. */
  105268. static AddSamplers(samplers: string[]): void;
  105269. /**
  105270. * Add the required uniforms to the current buffer.
  105271. * @param uniformBuffer defines the current uniform buffer.
  105272. */
  105273. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105274. /**
  105275. * Makes a duplicate of the current instance into another one.
  105276. * @param detailMap define the instance where to copy the info
  105277. */
  105278. copyTo(detailMap: DetailMapConfiguration): void;
  105279. /**
  105280. * Serializes this detail map instance
  105281. * @returns - An object with the serialized instance.
  105282. */
  105283. serialize(): any;
  105284. /**
  105285. * Parses a detail map setting from a serialized object.
  105286. * @param source - Serialized object.
  105287. * @param scene Defines the scene we are parsing for
  105288. * @param rootUrl Defines the rootUrl to load from
  105289. */
  105290. parse(source: any, scene: Scene, rootUrl: string): void;
  105291. }
  105292. }
  105293. declare module BABYLON {
  105294. /** @hidden */
  105295. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  105296. MAINUV1: boolean;
  105297. MAINUV2: boolean;
  105298. DIFFUSE: boolean;
  105299. DIFFUSEDIRECTUV: number;
  105300. DETAIL: boolean;
  105301. DETAILDIRECTUV: number;
  105302. DETAIL_NORMALBLENDMETHOD: number;
  105303. AMBIENT: boolean;
  105304. AMBIENTDIRECTUV: number;
  105305. OPACITY: boolean;
  105306. OPACITYDIRECTUV: number;
  105307. OPACITYRGB: boolean;
  105308. REFLECTION: boolean;
  105309. EMISSIVE: boolean;
  105310. EMISSIVEDIRECTUV: number;
  105311. SPECULAR: boolean;
  105312. SPECULARDIRECTUV: number;
  105313. BUMP: boolean;
  105314. BUMPDIRECTUV: number;
  105315. PARALLAX: boolean;
  105316. PARALLAXOCCLUSION: boolean;
  105317. SPECULAROVERALPHA: boolean;
  105318. CLIPPLANE: boolean;
  105319. CLIPPLANE2: boolean;
  105320. CLIPPLANE3: boolean;
  105321. CLIPPLANE4: boolean;
  105322. CLIPPLANE5: boolean;
  105323. CLIPPLANE6: boolean;
  105324. ALPHATEST: boolean;
  105325. DEPTHPREPASS: boolean;
  105326. ALPHAFROMDIFFUSE: boolean;
  105327. POINTSIZE: boolean;
  105328. FOG: boolean;
  105329. SPECULARTERM: boolean;
  105330. DIFFUSEFRESNEL: boolean;
  105331. OPACITYFRESNEL: boolean;
  105332. REFLECTIONFRESNEL: boolean;
  105333. REFRACTIONFRESNEL: boolean;
  105334. EMISSIVEFRESNEL: boolean;
  105335. FRESNEL: boolean;
  105336. NORMAL: boolean;
  105337. UV1: boolean;
  105338. UV2: boolean;
  105339. VERTEXCOLOR: boolean;
  105340. VERTEXALPHA: boolean;
  105341. NUM_BONE_INFLUENCERS: number;
  105342. BonesPerMesh: number;
  105343. BONETEXTURE: boolean;
  105344. BONES_VELOCITY_ENABLED: boolean;
  105345. INSTANCES: boolean;
  105346. THIN_INSTANCES: boolean;
  105347. GLOSSINESS: boolean;
  105348. ROUGHNESS: boolean;
  105349. EMISSIVEASILLUMINATION: boolean;
  105350. LINKEMISSIVEWITHDIFFUSE: boolean;
  105351. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105352. LIGHTMAP: boolean;
  105353. LIGHTMAPDIRECTUV: number;
  105354. OBJECTSPACE_NORMALMAP: boolean;
  105355. USELIGHTMAPASSHADOWMAP: boolean;
  105356. REFLECTIONMAP_3D: boolean;
  105357. REFLECTIONMAP_SPHERICAL: boolean;
  105358. REFLECTIONMAP_PLANAR: boolean;
  105359. REFLECTIONMAP_CUBIC: boolean;
  105360. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105361. REFLECTIONMAP_PROJECTION: boolean;
  105362. REFLECTIONMAP_SKYBOX: boolean;
  105363. REFLECTIONMAP_EXPLICIT: boolean;
  105364. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105365. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105366. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105367. INVERTCUBICMAP: boolean;
  105368. LOGARITHMICDEPTH: boolean;
  105369. REFRACTION: boolean;
  105370. REFRACTIONMAP_3D: boolean;
  105371. REFLECTIONOVERALPHA: boolean;
  105372. TWOSIDEDLIGHTING: boolean;
  105373. SHADOWFLOAT: boolean;
  105374. MORPHTARGETS: boolean;
  105375. MORPHTARGETS_NORMAL: boolean;
  105376. MORPHTARGETS_TANGENT: boolean;
  105377. MORPHTARGETS_UV: boolean;
  105378. NUM_MORPH_INFLUENCERS: number;
  105379. NONUNIFORMSCALING: boolean;
  105380. PREMULTIPLYALPHA: boolean;
  105381. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  105382. ALPHABLEND: boolean;
  105383. PREPASS: boolean;
  105384. PREPASS_IRRADIANCE: boolean;
  105385. PREPASS_IRRADIANCE_INDEX: number;
  105386. PREPASS_ALBEDO: boolean;
  105387. PREPASS_ALBEDO_INDEX: number;
  105388. PREPASS_DEPTHNORMAL: boolean;
  105389. PREPASS_DEPTHNORMAL_INDEX: number;
  105390. PREPASS_POSITION: boolean;
  105391. PREPASS_POSITION_INDEX: number;
  105392. PREPASS_VELOCITY: boolean;
  105393. PREPASS_VELOCITY_INDEX: number;
  105394. PREPASS_REFLECTIVITY: boolean;
  105395. PREPASS_REFLECTIVITY_INDEX: number;
  105396. SCENE_MRT_COUNT: number;
  105397. RGBDLIGHTMAP: boolean;
  105398. RGBDREFLECTION: boolean;
  105399. RGBDREFRACTION: boolean;
  105400. IMAGEPROCESSING: boolean;
  105401. VIGNETTE: boolean;
  105402. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105403. VIGNETTEBLENDMODEOPAQUE: boolean;
  105404. TONEMAPPING: boolean;
  105405. TONEMAPPING_ACES: boolean;
  105406. CONTRAST: boolean;
  105407. COLORCURVES: boolean;
  105408. COLORGRADING: boolean;
  105409. COLORGRADING3D: boolean;
  105410. SAMPLER3DGREENDEPTH: boolean;
  105411. SAMPLER3DBGRMAP: boolean;
  105412. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105413. MULTIVIEW: boolean;
  105414. /**
  105415. * If the reflection texture on this material is in linear color space
  105416. * @hidden
  105417. */
  105418. IS_REFLECTION_LINEAR: boolean;
  105419. /**
  105420. * If the refraction texture on this material is in linear color space
  105421. * @hidden
  105422. */
  105423. IS_REFRACTION_LINEAR: boolean;
  105424. EXPOSURE: boolean;
  105425. constructor();
  105426. setReflectionMode(modeToEnable: string): void;
  105427. }
  105428. /**
  105429. * This is the default material used in Babylon. It is the best trade off between quality
  105430. * and performances.
  105431. * @see https://doc.babylonjs.com/babylon101/materials
  105432. */
  105433. export class StandardMaterial extends PushMaterial {
  105434. private _diffuseTexture;
  105435. /**
  105436. * The basic texture of the material as viewed under a light.
  105437. */
  105438. diffuseTexture: Nullable<BaseTexture>;
  105439. private _ambientTexture;
  105440. /**
  105441. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105442. */
  105443. ambientTexture: Nullable<BaseTexture>;
  105444. private _opacityTexture;
  105445. /**
  105446. * Define the transparency of the material from a texture.
  105447. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105448. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105449. */
  105450. opacityTexture: Nullable<BaseTexture>;
  105451. private _reflectionTexture;
  105452. /**
  105453. * Define the texture used to display the reflection.
  105454. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105455. */
  105456. reflectionTexture: Nullable<BaseTexture>;
  105457. private _emissiveTexture;
  105458. /**
  105459. * Define texture of the material as if self lit.
  105460. * This will be mixed in the final result even in the absence of light.
  105461. */
  105462. emissiveTexture: Nullable<BaseTexture>;
  105463. private _specularTexture;
  105464. /**
  105465. * Define how the color and intensity of the highlight given by the light in the material.
  105466. */
  105467. specularTexture: Nullable<BaseTexture>;
  105468. private _bumpTexture;
  105469. /**
  105470. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105471. * 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.
  105472. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  105473. */
  105474. bumpTexture: Nullable<BaseTexture>;
  105475. private _lightmapTexture;
  105476. /**
  105477. * Complex lighting can be computationally expensive to compute at runtime.
  105478. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105479. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  105480. */
  105481. lightmapTexture: Nullable<BaseTexture>;
  105482. private _refractionTexture;
  105483. /**
  105484. * Define the texture used to display the refraction.
  105485. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105486. */
  105487. refractionTexture: Nullable<BaseTexture>;
  105488. /**
  105489. * The color of the material lit by the environmental background lighting.
  105490. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105491. */
  105492. ambientColor: Color3;
  105493. /**
  105494. * The basic color of the material as viewed under a light.
  105495. */
  105496. diffuseColor: Color3;
  105497. /**
  105498. * Define how the color and intensity of the highlight given by the light in the material.
  105499. */
  105500. specularColor: Color3;
  105501. /**
  105502. * Define the color of the material as if self lit.
  105503. * This will be mixed in the final result even in the absence of light.
  105504. */
  105505. emissiveColor: Color3;
  105506. /**
  105507. * Defines how sharp are the highlights in the material.
  105508. * The bigger the value the sharper giving a more glossy feeling to the result.
  105509. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105510. */
  105511. specularPower: number;
  105512. private _useAlphaFromDiffuseTexture;
  105513. /**
  105514. * Does the transparency come from the diffuse texture alpha channel.
  105515. */
  105516. useAlphaFromDiffuseTexture: boolean;
  105517. private _useEmissiveAsIllumination;
  105518. /**
  105519. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105520. */
  105521. useEmissiveAsIllumination: boolean;
  105522. private _linkEmissiveWithDiffuse;
  105523. /**
  105524. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105525. * the emissive level when the final color is close to one.
  105526. */
  105527. linkEmissiveWithDiffuse: boolean;
  105528. private _useSpecularOverAlpha;
  105529. /**
  105530. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105531. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105532. */
  105533. useSpecularOverAlpha: boolean;
  105534. private _useReflectionOverAlpha;
  105535. /**
  105536. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105537. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105538. */
  105539. useReflectionOverAlpha: boolean;
  105540. private _disableLighting;
  105541. /**
  105542. * Does lights from the scene impacts this material.
  105543. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105544. */
  105545. disableLighting: boolean;
  105546. private _useObjectSpaceNormalMap;
  105547. /**
  105548. * Allows using an object space normal map (instead of tangent space).
  105549. */
  105550. useObjectSpaceNormalMap: boolean;
  105551. private _useParallax;
  105552. /**
  105553. * Is parallax enabled or not.
  105554. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  105555. */
  105556. useParallax: boolean;
  105557. private _useParallaxOcclusion;
  105558. /**
  105559. * Is parallax occlusion enabled or not.
  105560. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105561. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  105562. */
  105563. useParallaxOcclusion: boolean;
  105564. /**
  105565. * 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.
  105566. */
  105567. parallaxScaleBias: number;
  105568. private _roughness;
  105569. /**
  105570. * Helps to define how blurry the reflections should appears in the material.
  105571. */
  105572. roughness: number;
  105573. /**
  105574. * In case of refraction, define the value of the index of refraction.
  105575. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105576. */
  105577. indexOfRefraction: number;
  105578. /**
  105579. * Invert the refraction texture alongside the y axis.
  105580. * It can be useful with procedural textures or probe for instance.
  105581. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105582. */
  105583. invertRefractionY: boolean;
  105584. /**
  105585. * Defines the alpha limits in alpha test mode.
  105586. */
  105587. alphaCutOff: number;
  105588. private _useLightmapAsShadowmap;
  105589. /**
  105590. * In case of light mapping, define whether the map contains light or shadow informations.
  105591. */
  105592. useLightmapAsShadowmap: boolean;
  105593. private _diffuseFresnelParameters;
  105594. /**
  105595. * Define the diffuse fresnel parameters of the material.
  105596. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105597. */
  105598. diffuseFresnelParameters: FresnelParameters;
  105599. private _opacityFresnelParameters;
  105600. /**
  105601. * Define the opacity fresnel parameters of the material.
  105602. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105603. */
  105604. opacityFresnelParameters: FresnelParameters;
  105605. private _reflectionFresnelParameters;
  105606. /**
  105607. * Define the reflection fresnel parameters of the material.
  105608. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105609. */
  105610. reflectionFresnelParameters: FresnelParameters;
  105611. private _refractionFresnelParameters;
  105612. /**
  105613. * Define the refraction fresnel parameters of the material.
  105614. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105615. */
  105616. refractionFresnelParameters: FresnelParameters;
  105617. private _emissiveFresnelParameters;
  105618. /**
  105619. * Define the emissive fresnel parameters of the material.
  105620. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105621. */
  105622. emissiveFresnelParameters: FresnelParameters;
  105623. private _useReflectionFresnelFromSpecular;
  105624. /**
  105625. * If true automatically deducts the fresnels values from the material specularity.
  105626. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105627. */
  105628. useReflectionFresnelFromSpecular: boolean;
  105629. private _useGlossinessFromSpecularMapAlpha;
  105630. /**
  105631. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  105632. */
  105633. useGlossinessFromSpecularMapAlpha: boolean;
  105634. private _maxSimultaneousLights;
  105635. /**
  105636. * Defines the maximum number of lights that can be used in the material
  105637. */
  105638. maxSimultaneousLights: number;
  105639. private _invertNormalMapX;
  105640. /**
  105641. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105642. */
  105643. invertNormalMapX: boolean;
  105644. private _invertNormalMapY;
  105645. /**
  105646. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105647. */
  105648. invertNormalMapY: boolean;
  105649. private _twoSidedLighting;
  105650. /**
  105651. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105652. */
  105653. twoSidedLighting: boolean;
  105654. /**
  105655. * Default configuration related to image processing available in the standard Material.
  105656. */
  105657. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105658. /**
  105659. * Gets the image processing configuration used either in this material.
  105660. */
  105661. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105662. /**
  105663. * Sets the Default image processing configuration used either in the this material.
  105664. *
  105665. * If sets to null, the scene one is in use.
  105666. */
  105667. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  105668. /**
  105669. * Keep track of the image processing observer to allow dispose and replace.
  105670. */
  105671. private _imageProcessingObserver;
  105672. /**
  105673. * Attaches a new image processing configuration to the Standard Material.
  105674. * @param configuration
  105675. */
  105676. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105677. /**
  105678. * Defines additionnal PrePass parameters for the material.
  105679. */
  105680. readonly prePassConfiguration: PrePassConfiguration;
  105681. /**
  105682. * Gets wether the color curves effect is enabled.
  105683. */
  105684. get cameraColorCurvesEnabled(): boolean;
  105685. /**
  105686. * Sets wether the color curves effect is enabled.
  105687. */
  105688. set cameraColorCurvesEnabled(value: boolean);
  105689. /**
  105690. * Gets wether the color grading effect is enabled.
  105691. */
  105692. get cameraColorGradingEnabled(): boolean;
  105693. /**
  105694. * Gets wether the color grading effect is enabled.
  105695. */
  105696. set cameraColorGradingEnabled(value: boolean);
  105697. /**
  105698. * Gets wether tonemapping is enabled or not.
  105699. */
  105700. get cameraToneMappingEnabled(): boolean;
  105701. /**
  105702. * Sets wether tonemapping is enabled or not
  105703. */
  105704. set cameraToneMappingEnabled(value: boolean);
  105705. /**
  105706. * The camera exposure used on this material.
  105707. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105708. * This corresponds to a photographic exposure.
  105709. */
  105710. get cameraExposure(): number;
  105711. /**
  105712. * The camera exposure used on this material.
  105713. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105714. * This corresponds to a photographic exposure.
  105715. */
  105716. set cameraExposure(value: number);
  105717. /**
  105718. * Gets The camera contrast used on this material.
  105719. */
  105720. get cameraContrast(): number;
  105721. /**
  105722. * Sets The camera contrast used on this material.
  105723. */
  105724. set cameraContrast(value: number);
  105725. /**
  105726. * Gets the Color Grading 2D Lookup Texture.
  105727. */
  105728. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  105729. /**
  105730. * Sets the Color Grading 2D Lookup Texture.
  105731. */
  105732. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  105733. /**
  105734. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105735. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105736. * 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;
  105737. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105738. */
  105739. get cameraColorCurves(): Nullable<ColorCurves>;
  105740. /**
  105741. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105742. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105743. * 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;
  105744. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105745. */
  105746. set cameraColorCurves(value: Nullable<ColorCurves>);
  105747. /**
  105748. * Can this material render to several textures at once
  105749. */
  105750. get canRenderToMRT(): boolean;
  105751. /**
  105752. * Defines the detail map parameters for the material.
  105753. */
  105754. readonly detailMap: DetailMapConfiguration;
  105755. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105756. protected _worldViewProjectionMatrix: Matrix;
  105757. protected _globalAmbientColor: Color3;
  105758. protected _useLogarithmicDepth: boolean;
  105759. protected _rebuildInParallel: boolean;
  105760. /**
  105761. * Instantiates a new standard material.
  105762. * This is the default material used in Babylon. It is the best trade off between quality
  105763. * and performances.
  105764. * @see https://doc.babylonjs.com/babylon101/materials
  105765. * @param name Define the name of the material in the scene
  105766. * @param scene Define the scene the material belong to
  105767. */
  105768. constructor(name: string, scene: Scene);
  105769. /**
  105770. * Gets a boolean indicating that current material needs to register RTT
  105771. */
  105772. get hasRenderTargetTextures(): boolean;
  105773. /**
  105774. * Gets the current class name of the material e.g. "StandardMaterial"
  105775. * Mainly use in serialization.
  105776. * @returns the class name
  105777. */
  105778. getClassName(): string;
  105779. /**
  105780. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105781. * You can try switching to logarithmic depth.
  105782. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105783. */
  105784. get useLogarithmicDepth(): boolean;
  105785. set useLogarithmicDepth(value: boolean);
  105786. /**
  105787. * Specifies if the material will require alpha blending
  105788. * @returns a boolean specifying if alpha blending is needed
  105789. */
  105790. needAlphaBlending(): boolean;
  105791. /**
  105792. * Specifies if this material should be rendered in alpha test mode
  105793. * @returns a boolean specifying if an alpha test is needed.
  105794. */
  105795. needAlphaTesting(): boolean;
  105796. /**
  105797. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  105798. */
  105799. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105800. /**
  105801. * Specifies whether or not there is a usable alpha channel for transparency.
  105802. */
  105803. protected _hasAlphaChannel(): boolean;
  105804. /**
  105805. * Get the texture used for alpha test purpose.
  105806. * @returns the diffuse texture in case of the standard material.
  105807. */
  105808. getAlphaTestTexture(): Nullable<BaseTexture>;
  105809. /**
  105810. * Get if the submesh is ready to be used and all its information available.
  105811. * Child classes can use it to update shaders
  105812. * @param mesh defines the mesh to check
  105813. * @param subMesh defines which submesh to check
  105814. * @param useInstances specifies that instances should be used
  105815. * @returns a boolean indicating that the submesh is ready or not
  105816. */
  105817. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105818. /**
  105819. * Builds the material UBO layouts.
  105820. * Used internally during the effect preparation.
  105821. */
  105822. buildUniformLayout(): void;
  105823. /**
  105824. * Unbinds the material from the mesh
  105825. */
  105826. unbind(): void;
  105827. /**
  105828. * Binds the submesh to this material by preparing the effect and shader to draw
  105829. * @param world defines the world transformation matrix
  105830. * @param mesh defines the mesh containing the submesh
  105831. * @param subMesh defines the submesh to bind the material to
  105832. */
  105833. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105834. /**
  105835. * Get the list of animatables in the material.
  105836. * @returns the list of animatables object used in the material
  105837. */
  105838. getAnimatables(): IAnimatable[];
  105839. /**
  105840. * Gets the active textures from the material
  105841. * @returns an array of textures
  105842. */
  105843. getActiveTextures(): BaseTexture[];
  105844. /**
  105845. * Specifies if the material uses a texture
  105846. * @param texture defines the texture to check against the material
  105847. * @returns a boolean specifying if the material uses the texture
  105848. */
  105849. hasTexture(texture: BaseTexture): boolean;
  105850. /**
  105851. * Disposes the material
  105852. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105853. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105854. */
  105855. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105856. /**
  105857. * Makes a duplicate of the material, and gives it a new name
  105858. * @param name defines the new name for the duplicated material
  105859. * @returns the cloned material
  105860. */
  105861. clone(name: string): StandardMaterial;
  105862. /**
  105863. * Serializes this material in a JSON representation
  105864. * @returns the serialized material object
  105865. */
  105866. serialize(): any;
  105867. /**
  105868. * Creates a standard material from parsed material data
  105869. * @param source defines the JSON representation of the material
  105870. * @param scene defines the hosting scene
  105871. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105872. * @returns a new standard material
  105873. */
  105874. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105875. /**
  105876. * Are diffuse textures enabled in the application.
  105877. */
  105878. static get DiffuseTextureEnabled(): boolean;
  105879. static set DiffuseTextureEnabled(value: boolean);
  105880. /**
  105881. * Are detail textures enabled in the application.
  105882. */
  105883. static get DetailTextureEnabled(): boolean;
  105884. static set DetailTextureEnabled(value: boolean);
  105885. /**
  105886. * Are ambient textures enabled in the application.
  105887. */
  105888. static get AmbientTextureEnabled(): boolean;
  105889. static set AmbientTextureEnabled(value: boolean);
  105890. /**
  105891. * Are opacity textures enabled in the application.
  105892. */
  105893. static get OpacityTextureEnabled(): boolean;
  105894. static set OpacityTextureEnabled(value: boolean);
  105895. /**
  105896. * Are reflection textures enabled in the application.
  105897. */
  105898. static get ReflectionTextureEnabled(): boolean;
  105899. static set ReflectionTextureEnabled(value: boolean);
  105900. /**
  105901. * Are emissive textures enabled in the application.
  105902. */
  105903. static get EmissiveTextureEnabled(): boolean;
  105904. static set EmissiveTextureEnabled(value: boolean);
  105905. /**
  105906. * Are specular textures enabled in the application.
  105907. */
  105908. static get SpecularTextureEnabled(): boolean;
  105909. static set SpecularTextureEnabled(value: boolean);
  105910. /**
  105911. * Are bump textures enabled in the application.
  105912. */
  105913. static get BumpTextureEnabled(): boolean;
  105914. static set BumpTextureEnabled(value: boolean);
  105915. /**
  105916. * Are lightmap textures enabled in the application.
  105917. */
  105918. static get LightmapTextureEnabled(): boolean;
  105919. static set LightmapTextureEnabled(value: boolean);
  105920. /**
  105921. * Are refraction textures enabled in the application.
  105922. */
  105923. static get RefractionTextureEnabled(): boolean;
  105924. static set RefractionTextureEnabled(value: boolean);
  105925. /**
  105926. * Are color grading textures enabled in the application.
  105927. */
  105928. static get ColorGradingTextureEnabled(): boolean;
  105929. static set ColorGradingTextureEnabled(value: boolean);
  105930. /**
  105931. * Are fresnels enabled in the application.
  105932. */
  105933. static get FresnelEnabled(): boolean;
  105934. static set FresnelEnabled(value: boolean);
  105935. }
  105936. }
  105937. declare module BABYLON {
  105938. /** @hidden */
  105939. export var rgbdDecodePixelShader: {
  105940. name: string;
  105941. shader: string;
  105942. };
  105943. }
  105944. declare module BABYLON {
  105945. /**
  105946. * Class used to host RGBD texture specific utilities
  105947. */
  105948. export class RGBDTextureTools {
  105949. /**
  105950. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105951. * @param texture the texture to expand.
  105952. */
  105953. static ExpandRGBDTexture(texture: Texture): void;
  105954. }
  105955. }
  105956. declare module BABYLON {
  105957. /**
  105958. * Class used to host texture specific utilities
  105959. */
  105960. export class BRDFTextureTools {
  105961. /**
  105962. * Prevents texture cache collision
  105963. */
  105964. private static _instanceNumber;
  105965. /**
  105966. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105967. * @param scene defines the hosting scene
  105968. * @returns the environment BRDF texture
  105969. */
  105970. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105971. private static _environmentBRDFBase64Texture;
  105972. }
  105973. }
  105974. declare module BABYLON {
  105975. /**
  105976. * @hidden
  105977. */
  105978. export interface IMaterialClearCoatDefines {
  105979. CLEARCOAT: boolean;
  105980. CLEARCOAT_DEFAULTIOR: boolean;
  105981. CLEARCOAT_TEXTURE: boolean;
  105982. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  105983. CLEARCOAT_TEXTUREDIRECTUV: number;
  105984. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  105985. CLEARCOAT_BUMP: boolean;
  105986. CLEARCOAT_BUMPDIRECTUV: number;
  105987. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105988. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105989. CLEARCOAT_REMAP_F0: boolean;
  105990. CLEARCOAT_TINT: boolean;
  105991. CLEARCOAT_TINT_TEXTURE: boolean;
  105992. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105993. /** @hidden */
  105994. _areTexturesDirty: boolean;
  105995. }
  105996. /**
  105997. * Define the code related to the clear coat parameters of the pbr material.
  105998. */
  105999. export class PBRClearCoatConfiguration {
  106000. /**
  106001. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106002. * The default fits with a polyurethane material.
  106003. */
  106004. private static readonly _DefaultIndexOfRefraction;
  106005. private _isEnabled;
  106006. /**
  106007. * Defines if the clear coat is enabled in the material.
  106008. */
  106009. isEnabled: boolean;
  106010. /**
  106011. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  106012. */
  106013. intensity: number;
  106014. /**
  106015. * Defines the clear coat layer roughness.
  106016. */
  106017. roughness: number;
  106018. private _indexOfRefraction;
  106019. /**
  106020. * Defines the index of refraction of the clear coat.
  106021. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106022. * The default fits with a polyurethane material.
  106023. * Changing the default value is more performance intensive.
  106024. */
  106025. indexOfRefraction: number;
  106026. private _texture;
  106027. /**
  106028. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  106029. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  106030. * if textureRoughness is not empty, else no texture roughness is used
  106031. */
  106032. texture: Nullable<BaseTexture>;
  106033. private _useRoughnessFromMainTexture;
  106034. /**
  106035. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  106036. * If false, the green channel from textureRoughness is used for roughness
  106037. */
  106038. useRoughnessFromMainTexture: boolean;
  106039. private _textureRoughness;
  106040. /**
  106041. * Stores the clear coat roughness in a texture (green channel)
  106042. * Not used if useRoughnessFromMainTexture is true
  106043. */
  106044. textureRoughness: Nullable<BaseTexture>;
  106045. private _remapF0OnInterfaceChange;
  106046. /**
  106047. * Defines if the F0 value should be remapped to account for the interface change in the material.
  106048. */
  106049. remapF0OnInterfaceChange: boolean;
  106050. private _bumpTexture;
  106051. /**
  106052. * Define the clear coat specific bump texture.
  106053. */
  106054. bumpTexture: Nullable<BaseTexture>;
  106055. private _isTintEnabled;
  106056. /**
  106057. * Defines if the clear coat tint is enabled in the material.
  106058. */
  106059. isTintEnabled: boolean;
  106060. /**
  106061. * Defines the clear coat tint of the material.
  106062. * This is only use if tint is enabled
  106063. */
  106064. tintColor: Color3;
  106065. /**
  106066. * Defines the distance at which the tint color should be found in the
  106067. * clear coat media.
  106068. * This is only use if tint is enabled
  106069. */
  106070. tintColorAtDistance: number;
  106071. /**
  106072. * Defines the clear coat layer thickness.
  106073. * This is only use if tint is enabled
  106074. */
  106075. tintThickness: number;
  106076. private _tintTexture;
  106077. /**
  106078. * Stores the clear tint values in a texture.
  106079. * rgb is tint
  106080. * a is a thickness factor
  106081. */
  106082. tintTexture: Nullable<BaseTexture>;
  106083. /** @hidden */
  106084. private _internalMarkAllSubMeshesAsTexturesDirty;
  106085. /** @hidden */
  106086. _markAllSubMeshesAsTexturesDirty(): void;
  106087. /**
  106088. * Instantiate a new istance of clear coat configuration.
  106089. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106090. */
  106091. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106092. /**
  106093. * Gets wehter the submesh is ready to be used or not.
  106094. * @param defines the list of "defines" to update.
  106095. * @param scene defines the scene the material belongs to.
  106096. * @param engine defines the engine the material belongs to.
  106097. * @param disableBumpMap defines wether the material disables bump or not.
  106098. * @returns - boolean indicating that the submesh is ready or not.
  106099. */
  106100. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  106101. /**
  106102. * Checks to see if a texture is used in the material.
  106103. * @param defines the list of "defines" to update.
  106104. * @param scene defines the scene to the material belongs to.
  106105. */
  106106. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  106107. /**
  106108. * Binds the material data.
  106109. * @param uniformBuffer defines the Uniform buffer to fill in.
  106110. * @param scene defines the scene the material belongs to.
  106111. * @param engine defines the engine the material belongs to.
  106112. * @param disableBumpMap defines wether the material disables bump or not.
  106113. * @param isFrozen defines wether the material is frozen or not.
  106114. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106115. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106116. * @param subMesh the submesh to bind data for
  106117. */
  106118. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  106119. /**
  106120. * Checks to see if a texture is used in the material.
  106121. * @param texture - Base texture to use.
  106122. * @returns - Boolean specifying if a texture is used in the material.
  106123. */
  106124. hasTexture(texture: BaseTexture): boolean;
  106125. /**
  106126. * Returns an array of the actively used textures.
  106127. * @param activeTextures Array of BaseTextures
  106128. */
  106129. getActiveTextures(activeTextures: BaseTexture[]): void;
  106130. /**
  106131. * Returns the animatable textures.
  106132. * @param animatables Array of animatable textures.
  106133. */
  106134. getAnimatables(animatables: IAnimatable[]): void;
  106135. /**
  106136. * Disposes the resources of the material.
  106137. * @param forceDisposeTextures - Forces the disposal of all textures.
  106138. */
  106139. dispose(forceDisposeTextures?: boolean): void;
  106140. /**
  106141. * Get the current class name of the texture useful for serialization or dynamic coding.
  106142. * @returns "PBRClearCoatConfiguration"
  106143. */
  106144. getClassName(): string;
  106145. /**
  106146. * Add fallbacks to the effect fallbacks list.
  106147. * @param defines defines the Base texture to use.
  106148. * @param fallbacks defines the current fallback list.
  106149. * @param currentRank defines the current fallback rank.
  106150. * @returns the new fallback rank.
  106151. */
  106152. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106153. /**
  106154. * Add the required uniforms to the current list.
  106155. * @param uniforms defines the current uniform list.
  106156. */
  106157. static AddUniforms(uniforms: string[]): void;
  106158. /**
  106159. * Add the required samplers to the current list.
  106160. * @param samplers defines the current sampler list.
  106161. */
  106162. static AddSamplers(samplers: string[]): void;
  106163. /**
  106164. * Add the required uniforms to the current buffer.
  106165. * @param uniformBuffer defines the current uniform buffer.
  106166. */
  106167. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106168. /**
  106169. * Makes a duplicate of the current configuration into another one.
  106170. * @param clearCoatConfiguration define the config where to copy the info
  106171. */
  106172. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  106173. /**
  106174. * Serializes this clear coat configuration.
  106175. * @returns - An object with the serialized config.
  106176. */
  106177. serialize(): any;
  106178. /**
  106179. * Parses a anisotropy Configuration from a serialized object.
  106180. * @param source - Serialized object.
  106181. * @param scene Defines the scene we are parsing for
  106182. * @param rootUrl Defines the rootUrl to load from
  106183. */
  106184. parse(source: any, scene: Scene, rootUrl: string): void;
  106185. }
  106186. }
  106187. declare module BABYLON {
  106188. /**
  106189. * @hidden
  106190. */
  106191. export interface IMaterialAnisotropicDefines {
  106192. ANISOTROPIC: boolean;
  106193. ANISOTROPIC_TEXTURE: boolean;
  106194. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106195. MAINUV1: boolean;
  106196. _areTexturesDirty: boolean;
  106197. _needUVs: boolean;
  106198. }
  106199. /**
  106200. * Define the code related to the anisotropic parameters of the pbr material.
  106201. */
  106202. export class PBRAnisotropicConfiguration {
  106203. private _isEnabled;
  106204. /**
  106205. * Defines if the anisotropy is enabled in the material.
  106206. */
  106207. isEnabled: boolean;
  106208. /**
  106209. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  106210. */
  106211. intensity: number;
  106212. /**
  106213. * Defines if the effect is along the tangents, bitangents or in between.
  106214. * By default, the effect is "strectching" the highlights along the tangents.
  106215. */
  106216. direction: Vector2;
  106217. private _texture;
  106218. /**
  106219. * Stores the anisotropy values in a texture.
  106220. * rg is direction (like normal from -1 to 1)
  106221. * b is a intensity
  106222. */
  106223. texture: Nullable<BaseTexture>;
  106224. /** @hidden */
  106225. private _internalMarkAllSubMeshesAsTexturesDirty;
  106226. /** @hidden */
  106227. _markAllSubMeshesAsTexturesDirty(): void;
  106228. /**
  106229. * Instantiate a new istance of anisotropy configuration.
  106230. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106231. */
  106232. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106233. /**
  106234. * Specifies that the submesh is ready to be used.
  106235. * @param defines the list of "defines" to update.
  106236. * @param scene defines the scene the material belongs to.
  106237. * @returns - boolean indicating that the submesh is ready or not.
  106238. */
  106239. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  106240. /**
  106241. * Checks to see if a texture is used in the material.
  106242. * @param defines the list of "defines" to update.
  106243. * @param mesh the mesh we are preparing the defines for.
  106244. * @param scene defines the scene the material belongs to.
  106245. */
  106246. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  106247. /**
  106248. * Binds the material data.
  106249. * @param uniformBuffer defines the Uniform buffer to fill in.
  106250. * @param scene defines the scene the material belongs to.
  106251. * @param isFrozen defines wether the material is frozen or not.
  106252. */
  106253. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  106254. /**
  106255. * Checks to see if a texture is used in the material.
  106256. * @param texture - Base texture to use.
  106257. * @returns - Boolean specifying if a texture is used in the material.
  106258. */
  106259. hasTexture(texture: BaseTexture): boolean;
  106260. /**
  106261. * Returns an array of the actively used textures.
  106262. * @param activeTextures Array of BaseTextures
  106263. */
  106264. getActiveTextures(activeTextures: BaseTexture[]): void;
  106265. /**
  106266. * Returns the animatable textures.
  106267. * @param animatables Array of animatable textures.
  106268. */
  106269. getAnimatables(animatables: IAnimatable[]): void;
  106270. /**
  106271. * Disposes the resources of the material.
  106272. * @param forceDisposeTextures - Forces the disposal of all textures.
  106273. */
  106274. dispose(forceDisposeTextures?: boolean): void;
  106275. /**
  106276. * Get the current class name of the texture useful for serialization or dynamic coding.
  106277. * @returns "PBRAnisotropicConfiguration"
  106278. */
  106279. getClassName(): string;
  106280. /**
  106281. * Add fallbacks to the effect fallbacks list.
  106282. * @param defines defines the Base texture to use.
  106283. * @param fallbacks defines the current fallback list.
  106284. * @param currentRank defines the current fallback rank.
  106285. * @returns the new fallback rank.
  106286. */
  106287. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106288. /**
  106289. * Add the required uniforms to the current list.
  106290. * @param uniforms defines the current uniform list.
  106291. */
  106292. static AddUniforms(uniforms: string[]): void;
  106293. /**
  106294. * Add the required uniforms to the current buffer.
  106295. * @param uniformBuffer defines the current uniform buffer.
  106296. */
  106297. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106298. /**
  106299. * Add the required samplers to the current list.
  106300. * @param samplers defines the current sampler list.
  106301. */
  106302. static AddSamplers(samplers: string[]): void;
  106303. /**
  106304. * Makes a duplicate of the current configuration into another one.
  106305. * @param anisotropicConfiguration define the config where to copy the info
  106306. */
  106307. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  106308. /**
  106309. * Serializes this anisotropy configuration.
  106310. * @returns - An object with the serialized config.
  106311. */
  106312. serialize(): any;
  106313. /**
  106314. * Parses a anisotropy Configuration from a serialized object.
  106315. * @param source - Serialized object.
  106316. * @param scene Defines the scene we are parsing for
  106317. * @param rootUrl Defines the rootUrl to load from
  106318. */
  106319. parse(source: any, scene: Scene, rootUrl: string): void;
  106320. }
  106321. }
  106322. declare module BABYLON {
  106323. /**
  106324. * @hidden
  106325. */
  106326. export interface IMaterialBRDFDefines {
  106327. BRDF_V_HEIGHT_CORRELATED: boolean;
  106328. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106329. SPHERICAL_HARMONICS: boolean;
  106330. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106331. /** @hidden */
  106332. _areMiscDirty: boolean;
  106333. }
  106334. /**
  106335. * Define the code related to the BRDF parameters of the pbr material.
  106336. */
  106337. export class PBRBRDFConfiguration {
  106338. /**
  106339. * Default value used for the energy conservation.
  106340. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106341. */
  106342. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  106343. /**
  106344. * Default value used for the Smith Visibility Height Correlated mode.
  106345. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106346. */
  106347. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  106348. /**
  106349. * Default value used for the IBL diffuse part.
  106350. * This can help switching back to the polynomials mode globally which is a tiny bit
  106351. * less GPU intensive at the drawback of a lower quality.
  106352. */
  106353. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  106354. /**
  106355. * Default value used for activating energy conservation for the specular workflow.
  106356. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  106357. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  106358. */
  106359. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  106360. private _useEnergyConservation;
  106361. /**
  106362. * Defines if the material uses energy conservation.
  106363. */
  106364. useEnergyConservation: boolean;
  106365. private _useSmithVisibilityHeightCorrelated;
  106366. /**
  106367. * LEGACY Mode set to false
  106368. * Defines if the material uses height smith correlated visibility term.
  106369. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  106370. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  106371. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  106372. * Not relying on height correlated will also disable energy conservation.
  106373. */
  106374. useSmithVisibilityHeightCorrelated: boolean;
  106375. private _useSphericalHarmonics;
  106376. /**
  106377. * LEGACY Mode set to false
  106378. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  106379. * diffuse part of the IBL.
  106380. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  106381. * to the ground truth.
  106382. */
  106383. useSphericalHarmonics: boolean;
  106384. private _useSpecularGlossinessInputEnergyConservation;
  106385. /**
  106386. * Defines if the material uses energy conservation, when the specular workflow is active.
  106387. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  106388. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  106389. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  106390. */
  106391. useSpecularGlossinessInputEnergyConservation: boolean;
  106392. /** @hidden */
  106393. private _internalMarkAllSubMeshesAsMiscDirty;
  106394. /** @hidden */
  106395. _markAllSubMeshesAsMiscDirty(): void;
  106396. /**
  106397. * Instantiate a new istance of clear coat configuration.
  106398. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  106399. */
  106400. constructor(markAllSubMeshesAsMiscDirty: () => void);
  106401. /**
  106402. * Checks to see if a texture is used in the material.
  106403. * @param defines the list of "defines" to update.
  106404. */
  106405. prepareDefines(defines: IMaterialBRDFDefines): void;
  106406. /**
  106407. * Get the current class name of the texture useful for serialization or dynamic coding.
  106408. * @returns "PBRClearCoatConfiguration"
  106409. */
  106410. getClassName(): string;
  106411. /**
  106412. * Makes a duplicate of the current configuration into another one.
  106413. * @param brdfConfiguration define the config where to copy the info
  106414. */
  106415. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  106416. /**
  106417. * Serializes this BRDF configuration.
  106418. * @returns - An object with the serialized config.
  106419. */
  106420. serialize(): any;
  106421. /**
  106422. * Parses a anisotropy Configuration from a serialized object.
  106423. * @param source - Serialized object.
  106424. * @param scene Defines the scene we are parsing for
  106425. * @param rootUrl Defines the rootUrl to load from
  106426. */
  106427. parse(source: any, scene: Scene, rootUrl: string): void;
  106428. }
  106429. }
  106430. declare module BABYLON {
  106431. /**
  106432. * @hidden
  106433. */
  106434. export interface IMaterialSheenDefines {
  106435. SHEEN: boolean;
  106436. SHEEN_TEXTURE: boolean;
  106437. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106438. SHEEN_TEXTUREDIRECTUV: number;
  106439. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106440. SHEEN_LINKWITHALBEDO: boolean;
  106441. SHEEN_ROUGHNESS: boolean;
  106442. SHEEN_ALBEDOSCALING: boolean;
  106443. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106444. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106445. /** @hidden */
  106446. _areTexturesDirty: boolean;
  106447. }
  106448. /**
  106449. * Define the code related to the Sheen parameters of the pbr material.
  106450. */
  106451. export class PBRSheenConfiguration {
  106452. private _isEnabled;
  106453. /**
  106454. * Defines if the material uses sheen.
  106455. */
  106456. isEnabled: boolean;
  106457. private _linkSheenWithAlbedo;
  106458. /**
  106459. * Defines if the sheen is linked to the sheen color.
  106460. */
  106461. linkSheenWithAlbedo: boolean;
  106462. /**
  106463. * Defines the sheen intensity.
  106464. */
  106465. intensity: number;
  106466. /**
  106467. * Defines the sheen color.
  106468. */
  106469. color: Color3;
  106470. private _texture;
  106471. /**
  106472. * Stores the sheen tint values in a texture.
  106473. * rgb is tint
  106474. * 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)
  106475. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  106476. */
  106477. texture: Nullable<BaseTexture>;
  106478. private _useRoughnessFromMainTexture;
  106479. /**
  106480. * Indicates that the alpha channel of the texture property will be used for roughness.
  106481. * Has no effect if the roughness (and texture!) property is not defined
  106482. */
  106483. useRoughnessFromMainTexture: boolean;
  106484. private _roughness;
  106485. /**
  106486. * Defines the sheen roughness.
  106487. * It is not taken into account if linkSheenWithAlbedo is true.
  106488. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  106489. */
  106490. roughness: Nullable<number>;
  106491. private _textureRoughness;
  106492. /**
  106493. * Stores the sheen roughness in a texture.
  106494. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  106495. */
  106496. textureRoughness: Nullable<BaseTexture>;
  106497. private _albedoScaling;
  106498. /**
  106499. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  106500. * It allows the strength of the sheen effect to not depend on the base color of the material,
  106501. * making it easier to setup and tweak the effect
  106502. */
  106503. albedoScaling: boolean;
  106504. /** @hidden */
  106505. private _internalMarkAllSubMeshesAsTexturesDirty;
  106506. /** @hidden */
  106507. _markAllSubMeshesAsTexturesDirty(): void;
  106508. /**
  106509. * Instantiate a new istance of clear coat configuration.
  106510. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106511. */
  106512. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106513. /**
  106514. * Specifies that the submesh is ready to be used.
  106515. * @param defines the list of "defines" to update.
  106516. * @param scene defines the scene the material belongs to.
  106517. * @returns - boolean indicating that the submesh is ready or not.
  106518. */
  106519. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  106520. /**
  106521. * Checks to see if a texture is used in the material.
  106522. * @param defines the list of "defines" to update.
  106523. * @param scene defines the scene the material belongs to.
  106524. */
  106525. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  106526. /**
  106527. * Binds the material data.
  106528. * @param uniformBuffer defines the Uniform buffer to fill in.
  106529. * @param scene defines the scene the material belongs to.
  106530. * @param isFrozen defines wether the material is frozen or not.
  106531. * @param subMesh the submesh to bind data for
  106532. */
  106533. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  106534. /**
  106535. * Checks to see if a texture is used in the material.
  106536. * @param texture - Base texture to use.
  106537. * @returns - Boolean specifying if a texture is used in the material.
  106538. */
  106539. hasTexture(texture: BaseTexture): boolean;
  106540. /**
  106541. * Returns an array of the actively used textures.
  106542. * @param activeTextures Array of BaseTextures
  106543. */
  106544. getActiveTextures(activeTextures: BaseTexture[]): void;
  106545. /**
  106546. * Returns the animatable textures.
  106547. * @param animatables Array of animatable textures.
  106548. */
  106549. getAnimatables(animatables: IAnimatable[]): void;
  106550. /**
  106551. * Disposes the resources of the material.
  106552. * @param forceDisposeTextures - Forces the disposal of all textures.
  106553. */
  106554. dispose(forceDisposeTextures?: boolean): void;
  106555. /**
  106556. * Get the current class name of the texture useful for serialization or dynamic coding.
  106557. * @returns "PBRSheenConfiguration"
  106558. */
  106559. getClassName(): string;
  106560. /**
  106561. * Add fallbacks to the effect fallbacks list.
  106562. * @param defines defines the Base texture to use.
  106563. * @param fallbacks defines the current fallback list.
  106564. * @param currentRank defines the current fallback rank.
  106565. * @returns the new fallback rank.
  106566. */
  106567. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106568. /**
  106569. * Add the required uniforms to the current list.
  106570. * @param uniforms defines the current uniform list.
  106571. */
  106572. static AddUniforms(uniforms: string[]): void;
  106573. /**
  106574. * Add the required uniforms to the current buffer.
  106575. * @param uniformBuffer defines the current uniform buffer.
  106576. */
  106577. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106578. /**
  106579. * Add the required samplers to the current list.
  106580. * @param samplers defines the current sampler list.
  106581. */
  106582. static AddSamplers(samplers: string[]): void;
  106583. /**
  106584. * Makes a duplicate of the current configuration into another one.
  106585. * @param sheenConfiguration define the config where to copy the info
  106586. */
  106587. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  106588. /**
  106589. * Serializes this BRDF configuration.
  106590. * @returns - An object with the serialized config.
  106591. */
  106592. serialize(): any;
  106593. /**
  106594. * Parses a anisotropy Configuration from a serialized object.
  106595. * @param source - Serialized object.
  106596. * @param scene Defines the scene we are parsing for
  106597. * @param rootUrl Defines the rootUrl to load from
  106598. */
  106599. parse(source: any, scene: Scene, rootUrl: string): void;
  106600. }
  106601. }
  106602. declare module BABYLON {
  106603. /**
  106604. * @hidden
  106605. */
  106606. export interface IMaterialSubSurfaceDefines {
  106607. SUBSURFACE: boolean;
  106608. SS_REFRACTION: boolean;
  106609. SS_TRANSLUCENCY: boolean;
  106610. SS_SCATTERING: boolean;
  106611. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106612. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106613. SS_REFRACTIONMAP_3D: boolean;
  106614. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106615. SS_LODINREFRACTIONALPHA: boolean;
  106616. SS_GAMMAREFRACTION: boolean;
  106617. SS_RGBDREFRACTION: boolean;
  106618. SS_LINEARSPECULARREFRACTION: boolean;
  106619. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106620. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106621. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106622. /** @hidden */
  106623. _areTexturesDirty: boolean;
  106624. }
  106625. /**
  106626. * Define the code related to the sub surface parameters of the pbr material.
  106627. */
  106628. export class PBRSubSurfaceConfiguration {
  106629. private _isRefractionEnabled;
  106630. /**
  106631. * Defines if the refraction is enabled in the material.
  106632. */
  106633. isRefractionEnabled: boolean;
  106634. private _isTranslucencyEnabled;
  106635. /**
  106636. * Defines if the translucency is enabled in the material.
  106637. */
  106638. isTranslucencyEnabled: boolean;
  106639. private _isScatteringEnabled;
  106640. /**
  106641. * Defines if the sub surface scattering is enabled in the material.
  106642. */
  106643. isScatteringEnabled: boolean;
  106644. private _scatteringDiffusionProfileIndex;
  106645. /**
  106646. * Diffusion profile for subsurface scattering.
  106647. * Useful for better scattering in the skins or foliages.
  106648. */
  106649. get scatteringDiffusionProfile(): Nullable<Color3>;
  106650. set scatteringDiffusionProfile(c: Nullable<Color3>);
  106651. /**
  106652. * Defines the refraction intensity of the material.
  106653. * The refraction when enabled replaces the Diffuse part of the material.
  106654. * The intensity helps transitionning between diffuse and refraction.
  106655. */
  106656. refractionIntensity: number;
  106657. /**
  106658. * Defines the translucency intensity of the material.
  106659. * When translucency has been enabled, this defines how much of the "translucency"
  106660. * is addded to the diffuse part of the material.
  106661. */
  106662. translucencyIntensity: number;
  106663. /**
  106664. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  106665. */
  106666. useAlbedoToTintRefraction: boolean;
  106667. private _thicknessTexture;
  106668. /**
  106669. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  106670. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  106671. * 0 would mean minimumThickness
  106672. * 1 would mean maximumThickness
  106673. * The other channels might be use as a mask to vary the different effects intensity.
  106674. */
  106675. thicknessTexture: Nullable<BaseTexture>;
  106676. private _refractionTexture;
  106677. /**
  106678. * Defines the texture to use for refraction.
  106679. */
  106680. refractionTexture: Nullable<BaseTexture>;
  106681. private _indexOfRefraction;
  106682. /**
  106683. * Index of refraction of the material base layer.
  106684. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106685. *
  106686. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  106687. *
  106688. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  106689. */
  106690. indexOfRefraction: number;
  106691. private _volumeIndexOfRefraction;
  106692. /**
  106693. * Index of refraction of the material's volume.
  106694. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106695. *
  106696. * This ONLY impacts refraction. If not provided or given a non-valid value,
  106697. * the volume will use the same IOR as the surface.
  106698. */
  106699. get volumeIndexOfRefraction(): number;
  106700. set volumeIndexOfRefraction(value: number);
  106701. private _invertRefractionY;
  106702. /**
  106703. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  106704. */
  106705. invertRefractionY: boolean;
  106706. private _linkRefractionWithTransparency;
  106707. /**
  106708. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  106709. * Materials half opaque for instance using refraction could benefit from this control.
  106710. */
  106711. linkRefractionWithTransparency: boolean;
  106712. /**
  106713. * Defines the minimum thickness stored in the thickness map.
  106714. * If no thickness map is defined, this value will be used to simulate thickness.
  106715. */
  106716. minimumThickness: number;
  106717. /**
  106718. * Defines the maximum thickness stored in the thickness map.
  106719. */
  106720. maximumThickness: number;
  106721. /**
  106722. * Defines the volume tint of the material.
  106723. * This is used for both translucency and scattering.
  106724. */
  106725. tintColor: Color3;
  106726. /**
  106727. * Defines the distance at which the tint color should be found in the media.
  106728. * This is used for refraction only.
  106729. */
  106730. tintColorAtDistance: number;
  106731. /**
  106732. * Defines how far each channel transmit through the media.
  106733. * It is defined as a color to simplify it selection.
  106734. */
  106735. diffusionDistance: Color3;
  106736. private _useMaskFromThicknessTexture;
  106737. /**
  106738. * Stores the intensity of the different subsurface effects in the thickness texture.
  106739. * * the green channel is the translucency intensity.
  106740. * * the blue channel is the scattering intensity.
  106741. * * the alpha channel is the refraction intensity.
  106742. */
  106743. useMaskFromThicknessTexture: boolean;
  106744. private _scene;
  106745. /** @hidden */
  106746. private _internalMarkAllSubMeshesAsTexturesDirty;
  106747. private _internalMarkScenePrePassDirty;
  106748. /** @hidden */
  106749. _markAllSubMeshesAsTexturesDirty(): void;
  106750. /** @hidden */
  106751. _markScenePrePassDirty(): void;
  106752. /**
  106753. * Instantiate a new istance of sub surface configuration.
  106754. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106755. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  106756. * @param scene The scene
  106757. */
  106758. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  106759. /**
  106760. * Gets wehter the submesh is ready to be used or not.
  106761. * @param defines the list of "defines" to update.
  106762. * @param scene defines the scene the material belongs to.
  106763. * @returns - boolean indicating that the submesh is ready or not.
  106764. */
  106765. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  106766. /**
  106767. * Checks to see if a texture is used in the material.
  106768. * @param defines the list of "defines" to update.
  106769. * @param scene defines the scene to the material belongs to.
  106770. */
  106771. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  106772. /**
  106773. * Binds the material data.
  106774. * @param uniformBuffer defines the Uniform buffer to fill in.
  106775. * @param scene defines the scene the material belongs to.
  106776. * @param engine defines the engine the material belongs to.
  106777. * @param isFrozen defines whether the material is frozen or not.
  106778. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  106779. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  106780. */
  106781. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  106782. /**
  106783. * Unbinds the material from the mesh.
  106784. * @param activeEffect defines the effect that should be unbound from.
  106785. * @returns true if unbound, otherwise false
  106786. */
  106787. unbind(activeEffect: Effect): boolean;
  106788. /**
  106789. * Returns the texture used for refraction or null if none is used.
  106790. * @param scene defines the scene the material belongs to.
  106791. * @returns - Refraction texture if present. If no refraction texture and refraction
  106792. * is linked with transparency, returns environment texture. Otherwise, returns null.
  106793. */
  106794. private _getRefractionTexture;
  106795. /**
  106796. * Returns true if alpha blending should be disabled.
  106797. */
  106798. get disableAlphaBlending(): boolean;
  106799. /**
  106800. * Fills the list of render target textures.
  106801. * @param renderTargets the list of render targets to update
  106802. */
  106803. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  106804. /**
  106805. * Checks to see if a texture is used in the material.
  106806. * @param texture - Base texture to use.
  106807. * @returns - Boolean specifying if a texture is used in the material.
  106808. */
  106809. hasTexture(texture: BaseTexture): boolean;
  106810. /**
  106811. * Gets a boolean indicating that current material needs to register RTT
  106812. * @returns true if this uses a render target otherwise false.
  106813. */
  106814. hasRenderTargetTextures(): boolean;
  106815. /**
  106816. * Returns an array of the actively used textures.
  106817. * @param activeTextures Array of BaseTextures
  106818. */
  106819. getActiveTextures(activeTextures: BaseTexture[]): void;
  106820. /**
  106821. * Returns the animatable textures.
  106822. * @param animatables Array of animatable textures.
  106823. */
  106824. getAnimatables(animatables: IAnimatable[]): void;
  106825. /**
  106826. * Disposes the resources of the material.
  106827. * @param forceDisposeTextures - Forces the disposal of all textures.
  106828. */
  106829. dispose(forceDisposeTextures?: boolean): void;
  106830. /**
  106831. * Get the current class name of the texture useful for serialization or dynamic coding.
  106832. * @returns "PBRSubSurfaceConfiguration"
  106833. */
  106834. getClassName(): string;
  106835. /**
  106836. * Add fallbacks to the effect fallbacks list.
  106837. * @param defines defines the Base texture to use.
  106838. * @param fallbacks defines the current fallback list.
  106839. * @param currentRank defines the current fallback rank.
  106840. * @returns the new fallback rank.
  106841. */
  106842. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106843. /**
  106844. * Add the required uniforms to the current list.
  106845. * @param uniforms defines the current uniform list.
  106846. */
  106847. static AddUniforms(uniforms: string[]): void;
  106848. /**
  106849. * Add the required samplers to the current list.
  106850. * @param samplers defines the current sampler list.
  106851. */
  106852. static AddSamplers(samplers: string[]): void;
  106853. /**
  106854. * Add the required uniforms to the current buffer.
  106855. * @param uniformBuffer defines the current uniform buffer.
  106856. */
  106857. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106858. /**
  106859. * Makes a duplicate of the current configuration into another one.
  106860. * @param configuration define the config where to copy the info
  106861. */
  106862. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  106863. /**
  106864. * Serializes this Sub Surface configuration.
  106865. * @returns - An object with the serialized config.
  106866. */
  106867. serialize(): any;
  106868. /**
  106869. * Parses a anisotropy Configuration from a serialized object.
  106870. * @param source - Serialized object.
  106871. * @param scene Defines the scene we are parsing for
  106872. * @param rootUrl Defines the rootUrl to load from
  106873. */
  106874. parse(source: any, scene: Scene, rootUrl: string): void;
  106875. }
  106876. }
  106877. declare module BABYLON {
  106878. /**
  106879. * Class representing spherical harmonics coefficients to the 3rd degree
  106880. */
  106881. export class SphericalHarmonics {
  106882. /**
  106883. * Defines whether or not the harmonics have been prescaled for rendering.
  106884. */
  106885. preScaled: boolean;
  106886. /**
  106887. * The l0,0 coefficients of the spherical harmonics
  106888. */
  106889. l00: Vector3;
  106890. /**
  106891. * The l1,-1 coefficients of the spherical harmonics
  106892. */
  106893. l1_1: Vector3;
  106894. /**
  106895. * The l1,0 coefficients of the spherical harmonics
  106896. */
  106897. l10: Vector3;
  106898. /**
  106899. * The l1,1 coefficients of the spherical harmonics
  106900. */
  106901. l11: Vector3;
  106902. /**
  106903. * The l2,-2 coefficients of the spherical harmonics
  106904. */
  106905. l2_2: Vector3;
  106906. /**
  106907. * The l2,-1 coefficients of the spherical harmonics
  106908. */
  106909. l2_1: Vector3;
  106910. /**
  106911. * The l2,0 coefficients of the spherical harmonics
  106912. */
  106913. l20: Vector3;
  106914. /**
  106915. * The l2,1 coefficients of the spherical harmonics
  106916. */
  106917. l21: Vector3;
  106918. /**
  106919. * The l2,2 coefficients of the spherical harmonics
  106920. */
  106921. l22: Vector3;
  106922. /**
  106923. * Adds a light to the spherical harmonics
  106924. * @param direction the direction of the light
  106925. * @param color the color of the light
  106926. * @param deltaSolidAngle the delta solid angle of the light
  106927. */
  106928. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106929. /**
  106930. * Scales the spherical harmonics by the given amount
  106931. * @param scale the amount to scale
  106932. */
  106933. scaleInPlace(scale: number): void;
  106934. /**
  106935. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106936. *
  106937. * ```
  106938. * E_lm = A_l * L_lm
  106939. * ```
  106940. *
  106941. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106942. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106943. * the scaling factors are given in equation 9.
  106944. */
  106945. convertIncidentRadianceToIrradiance(): void;
  106946. /**
  106947. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106948. *
  106949. * ```
  106950. * L = (1/pi) * E * rho
  106951. * ```
  106952. *
  106953. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106954. */
  106955. convertIrradianceToLambertianRadiance(): void;
  106956. /**
  106957. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106958. * required operations at run time.
  106959. *
  106960. * This is simply done by scaling back the SH with Ylm constants parameter.
  106961. * The trigonometric part being applied by the shader at run time.
  106962. */
  106963. preScaleForRendering(): void;
  106964. /**
  106965. * Constructs a spherical harmonics from an array.
  106966. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106967. * @returns the spherical harmonics
  106968. */
  106969. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106970. /**
  106971. * Gets the spherical harmonics from polynomial
  106972. * @param polynomial the spherical polynomial
  106973. * @returns the spherical harmonics
  106974. */
  106975. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106976. }
  106977. /**
  106978. * Class representing spherical polynomial coefficients to the 3rd degree
  106979. */
  106980. export class SphericalPolynomial {
  106981. private _harmonics;
  106982. /**
  106983. * The spherical harmonics used to create the polynomials.
  106984. */
  106985. get preScaledHarmonics(): SphericalHarmonics;
  106986. /**
  106987. * The x coefficients of the spherical polynomial
  106988. */
  106989. x: Vector3;
  106990. /**
  106991. * The y coefficients of the spherical polynomial
  106992. */
  106993. y: Vector3;
  106994. /**
  106995. * The z coefficients of the spherical polynomial
  106996. */
  106997. z: Vector3;
  106998. /**
  106999. * The xx coefficients of the spherical polynomial
  107000. */
  107001. xx: Vector3;
  107002. /**
  107003. * The yy coefficients of the spherical polynomial
  107004. */
  107005. yy: Vector3;
  107006. /**
  107007. * The zz coefficients of the spherical polynomial
  107008. */
  107009. zz: Vector3;
  107010. /**
  107011. * The xy coefficients of the spherical polynomial
  107012. */
  107013. xy: Vector3;
  107014. /**
  107015. * The yz coefficients of the spherical polynomial
  107016. */
  107017. yz: Vector3;
  107018. /**
  107019. * The zx coefficients of the spherical polynomial
  107020. */
  107021. zx: Vector3;
  107022. /**
  107023. * Adds an ambient color to the spherical polynomial
  107024. * @param color the color to add
  107025. */
  107026. addAmbient(color: Color3): void;
  107027. /**
  107028. * Scales the spherical polynomial by the given amount
  107029. * @param scale the amount to scale
  107030. */
  107031. scaleInPlace(scale: number): void;
  107032. /**
  107033. * Gets the spherical polynomial from harmonics
  107034. * @param harmonics the spherical harmonics
  107035. * @returns the spherical polynomial
  107036. */
  107037. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  107038. /**
  107039. * Constructs a spherical polynomial from an array.
  107040. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  107041. * @returns the spherical polynomial
  107042. */
  107043. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  107044. }
  107045. }
  107046. declare module BABYLON {
  107047. /**
  107048. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  107049. */
  107050. export interface CubeMapInfo {
  107051. /**
  107052. * The pixel array for the front face.
  107053. * This is stored in format, left to right, up to down format.
  107054. */
  107055. front: Nullable<ArrayBufferView>;
  107056. /**
  107057. * The pixel array for the back face.
  107058. * This is stored in format, left to right, up to down format.
  107059. */
  107060. back: Nullable<ArrayBufferView>;
  107061. /**
  107062. * The pixel array for the left face.
  107063. * This is stored in format, left to right, up to down format.
  107064. */
  107065. left: Nullable<ArrayBufferView>;
  107066. /**
  107067. * The pixel array for the right face.
  107068. * This is stored in format, left to right, up to down format.
  107069. */
  107070. right: Nullable<ArrayBufferView>;
  107071. /**
  107072. * The pixel array for the up face.
  107073. * This is stored in format, left to right, up to down format.
  107074. */
  107075. up: Nullable<ArrayBufferView>;
  107076. /**
  107077. * The pixel array for the down face.
  107078. * This is stored in format, left to right, up to down format.
  107079. */
  107080. down: Nullable<ArrayBufferView>;
  107081. /**
  107082. * The size of the cubemap stored.
  107083. *
  107084. * Each faces will be size * size pixels.
  107085. */
  107086. size: number;
  107087. /**
  107088. * The format of the texture.
  107089. *
  107090. * RGBA, RGB.
  107091. */
  107092. format: number;
  107093. /**
  107094. * The type of the texture data.
  107095. *
  107096. * UNSIGNED_INT, FLOAT.
  107097. */
  107098. type: number;
  107099. /**
  107100. * Specifies whether the texture is in gamma space.
  107101. */
  107102. gammaSpace: boolean;
  107103. }
  107104. /**
  107105. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  107106. */
  107107. export class PanoramaToCubeMapTools {
  107108. private static FACE_LEFT;
  107109. private static FACE_RIGHT;
  107110. private static FACE_FRONT;
  107111. private static FACE_BACK;
  107112. private static FACE_DOWN;
  107113. private static FACE_UP;
  107114. /**
  107115. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  107116. *
  107117. * @param float32Array The source data.
  107118. * @param inputWidth The width of the input panorama.
  107119. * @param inputHeight The height of the input panorama.
  107120. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  107121. * @return The cubemap data
  107122. */
  107123. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  107124. private static CreateCubemapTexture;
  107125. private static CalcProjectionSpherical;
  107126. }
  107127. }
  107128. declare module BABYLON {
  107129. /**
  107130. * Helper class dealing with the extraction of spherical polynomial dataArray
  107131. * from a cube map.
  107132. */
  107133. export class CubeMapToSphericalPolynomialTools {
  107134. private static FileFaces;
  107135. /**
  107136. * Converts a texture to the according Spherical Polynomial data.
  107137. * This extracts the first 3 orders only as they are the only one used in the lighting.
  107138. *
  107139. * @param texture The texture to extract the information from.
  107140. * @return The Spherical Polynomial data.
  107141. */
  107142. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  107143. /**
  107144. * Converts a cubemap to the according Spherical Polynomial data.
  107145. * This extracts the first 3 orders only as they are the only one used in the lighting.
  107146. *
  107147. * @param cubeInfo The Cube map to extract the information from.
  107148. * @return The Spherical Polynomial data.
  107149. */
  107150. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  107151. }
  107152. }
  107153. declare module BABYLON {
  107154. interface BaseTexture {
  107155. /**
  107156. * Get the polynomial representation of the texture data.
  107157. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  107158. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  107159. */
  107160. sphericalPolynomial: Nullable<SphericalPolynomial>;
  107161. }
  107162. }
  107163. declare module BABYLON {
  107164. /** @hidden */
  107165. export var pbrFragmentDeclaration: {
  107166. name: string;
  107167. shader: string;
  107168. };
  107169. }
  107170. declare module BABYLON {
  107171. /** @hidden */
  107172. export var pbrUboDeclaration: {
  107173. name: string;
  107174. shader: string;
  107175. };
  107176. }
  107177. declare module BABYLON {
  107178. /** @hidden */
  107179. export var pbrFragmentExtraDeclaration: {
  107180. name: string;
  107181. shader: string;
  107182. };
  107183. }
  107184. declare module BABYLON {
  107185. /** @hidden */
  107186. export var pbrFragmentSamplersDeclaration: {
  107187. name: string;
  107188. shader: string;
  107189. };
  107190. }
  107191. declare module BABYLON {
  107192. /** @hidden */
  107193. export var subSurfaceScatteringFunctions: {
  107194. name: string;
  107195. shader: string;
  107196. };
  107197. }
  107198. declare module BABYLON {
  107199. /** @hidden */
  107200. export var importanceSampling: {
  107201. name: string;
  107202. shader: string;
  107203. };
  107204. }
  107205. declare module BABYLON {
  107206. /** @hidden */
  107207. export var pbrHelperFunctions: {
  107208. name: string;
  107209. shader: string;
  107210. };
  107211. }
  107212. declare module BABYLON {
  107213. /** @hidden */
  107214. export var harmonicsFunctions: {
  107215. name: string;
  107216. shader: string;
  107217. };
  107218. }
  107219. declare module BABYLON {
  107220. /** @hidden */
  107221. export var pbrDirectLightingSetupFunctions: {
  107222. name: string;
  107223. shader: string;
  107224. };
  107225. }
  107226. declare module BABYLON {
  107227. /** @hidden */
  107228. export var pbrDirectLightingFalloffFunctions: {
  107229. name: string;
  107230. shader: string;
  107231. };
  107232. }
  107233. declare module BABYLON {
  107234. /** @hidden */
  107235. export var pbrBRDFFunctions: {
  107236. name: string;
  107237. shader: string;
  107238. };
  107239. }
  107240. declare module BABYLON {
  107241. /** @hidden */
  107242. export var hdrFilteringFunctions: {
  107243. name: string;
  107244. shader: string;
  107245. };
  107246. }
  107247. declare module BABYLON {
  107248. /** @hidden */
  107249. export var pbrDirectLightingFunctions: {
  107250. name: string;
  107251. shader: string;
  107252. };
  107253. }
  107254. declare module BABYLON {
  107255. /** @hidden */
  107256. export var pbrIBLFunctions: {
  107257. name: string;
  107258. shader: string;
  107259. };
  107260. }
  107261. declare module BABYLON {
  107262. /** @hidden */
  107263. export var pbrBlockAlbedoOpacity: {
  107264. name: string;
  107265. shader: string;
  107266. };
  107267. }
  107268. declare module BABYLON {
  107269. /** @hidden */
  107270. export var pbrBlockReflectivity: {
  107271. name: string;
  107272. shader: string;
  107273. };
  107274. }
  107275. declare module BABYLON {
  107276. /** @hidden */
  107277. export var pbrBlockAmbientOcclusion: {
  107278. name: string;
  107279. shader: string;
  107280. };
  107281. }
  107282. declare module BABYLON {
  107283. /** @hidden */
  107284. export var pbrBlockAlphaFresnel: {
  107285. name: string;
  107286. shader: string;
  107287. };
  107288. }
  107289. declare module BABYLON {
  107290. /** @hidden */
  107291. export var pbrBlockAnisotropic: {
  107292. name: string;
  107293. shader: string;
  107294. };
  107295. }
  107296. declare module BABYLON {
  107297. /** @hidden */
  107298. export var pbrBlockReflection: {
  107299. name: string;
  107300. shader: string;
  107301. };
  107302. }
  107303. declare module BABYLON {
  107304. /** @hidden */
  107305. export var pbrBlockSheen: {
  107306. name: string;
  107307. shader: string;
  107308. };
  107309. }
  107310. declare module BABYLON {
  107311. /** @hidden */
  107312. export var pbrBlockClearcoat: {
  107313. name: string;
  107314. shader: string;
  107315. };
  107316. }
  107317. declare module BABYLON {
  107318. /** @hidden */
  107319. export var pbrBlockSubSurface: {
  107320. name: string;
  107321. shader: string;
  107322. };
  107323. }
  107324. declare module BABYLON {
  107325. /** @hidden */
  107326. export var pbrBlockNormalGeometric: {
  107327. name: string;
  107328. shader: string;
  107329. };
  107330. }
  107331. declare module BABYLON {
  107332. /** @hidden */
  107333. export var pbrBlockNormalFinal: {
  107334. name: string;
  107335. shader: string;
  107336. };
  107337. }
  107338. declare module BABYLON {
  107339. /** @hidden */
  107340. export var pbrBlockLightmapInit: {
  107341. name: string;
  107342. shader: string;
  107343. };
  107344. }
  107345. declare module BABYLON {
  107346. /** @hidden */
  107347. export var pbrBlockGeometryInfo: {
  107348. name: string;
  107349. shader: string;
  107350. };
  107351. }
  107352. declare module BABYLON {
  107353. /** @hidden */
  107354. export var pbrBlockReflectance0: {
  107355. name: string;
  107356. shader: string;
  107357. };
  107358. }
  107359. declare module BABYLON {
  107360. /** @hidden */
  107361. export var pbrBlockReflectance: {
  107362. name: string;
  107363. shader: string;
  107364. };
  107365. }
  107366. declare module BABYLON {
  107367. /** @hidden */
  107368. export var pbrBlockDirectLighting: {
  107369. name: string;
  107370. shader: string;
  107371. };
  107372. }
  107373. declare module BABYLON {
  107374. /** @hidden */
  107375. export var pbrBlockFinalLitComponents: {
  107376. name: string;
  107377. shader: string;
  107378. };
  107379. }
  107380. declare module BABYLON {
  107381. /** @hidden */
  107382. export var pbrBlockFinalUnlitComponents: {
  107383. name: string;
  107384. shader: string;
  107385. };
  107386. }
  107387. declare module BABYLON {
  107388. /** @hidden */
  107389. export var pbrBlockFinalColorComposition: {
  107390. name: string;
  107391. shader: string;
  107392. };
  107393. }
  107394. declare module BABYLON {
  107395. /** @hidden */
  107396. export var pbrBlockImageProcessing: {
  107397. name: string;
  107398. shader: string;
  107399. };
  107400. }
  107401. declare module BABYLON {
  107402. /** @hidden */
  107403. export var pbrDebug: {
  107404. name: string;
  107405. shader: string;
  107406. };
  107407. }
  107408. declare module BABYLON {
  107409. /** @hidden */
  107410. export var pbrPixelShader: {
  107411. name: string;
  107412. shader: string;
  107413. };
  107414. }
  107415. declare module BABYLON {
  107416. /** @hidden */
  107417. export var pbrVertexDeclaration: {
  107418. name: string;
  107419. shader: string;
  107420. };
  107421. }
  107422. declare module BABYLON {
  107423. /** @hidden */
  107424. export var pbrVertexShader: {
  107425. name: string;
  107426. shader: string;
  107427. };
  107428. }
  107429. declare module BABYLON {
  107430. /**
  107431. * Manages the defines for the PBR Material.
  107432. * @hidden
  107433. */
  107434. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  107435. PBR: boolean;
  107436. NUM_SAMPLES: string;
  107437. REALTIME_FILTERING: boolean;
  107438. MAINUV1: boolean;
  107439. MAINUV2: boolean;
  107440. UV1: boolean;
  107441. UV2: boolean;
  107442. ALBEDO: boolean;
  107443. GAMMAALBEDO: boolean;
  107444. ALBEDODIRECTUV: number;
  107445. VERTEXCOLOR: boolean;
  107446. DETAIL: boolean;
  107447. DETAILDIRECTUV: number;
  107448. DETAIL_NORMALBLENDMETHOD: number;
  107449. AMBIENT: boolean;
  107450. AMBIENTDIRECTUV: number;
  107451. AMBIENTINGRAYSCALE: boolean;
  107452. OPACITY: boolean;
  107453. VERTEXALPHA: boolean;
  107454. OPACITYDIRECTUV: number;
  107455. OPACITYRGB: boolean;
  107456. ALPHATEST: boolean;
  107457. DEPTHPREPASS: boolean;
  107458. ALPHABLEND: boolean;
  107459. ALPHAFROMALBEDO: boolean;
  107460. ALPHATESTVALUE: string;
  107461. SPECULAROVERALPHA: boolean;
  107462. RADIANCEOVERALPHA: boolean;
  107463. ALPHAFRESNEL: boolean;
  107464. LINEARALPHAFRESNEL: boolean;
  107465. PREMULTIPLYALPHA: boolean;
  107466. EMISSIVE: boolean;
  107467. EMISSIVEDIRECTUV: number;
  107468. REFLECTIVITY: boolean;
  107469. REFLECTIVITYDIRECTUV: number;
  107470. SPECULARTERM: boolean;
  107471. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  107472. MICROSURFACEAUTOMATIC: boolean;
  107473. LODBASEDMICROSFURACE: boolean;
  107474. MICROSURFACEMAP: boolean;
  107475. MICROSURFACEMAPDIRECTUV: number;
  107476. METALLICWORKFLOW: boolean;
  107477. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  107478. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  107479. METALLNESSSTOREINMETALMAPBLUE: boolean;
  107480. AOSTOREINMETALMAPRED: boolean;
  107481. METALLIC_REFLECTANCE: boolean;
  107482. METALLIC_REFLECTANCEDIRECTUV: number;
  107483. ENVIRONMENTBRDF: boolean;
  107484. ENVIRONMENTBRDF_RGBD: boolean;
  107485. NORMAL: boolean;
  107486. TANGENT: boolean;
  107487. BUMP: boolean;
  107488. BUMPDIRECTUV: number;
  107489. OBJECTSPACE_NORMALMAP: boolean;
  107490. PARALLAX: boolean;
  107491. PARALLAXOCCLUSION: boolean;
  107492. NORMALXYSCALE: boolean;
  107493. LIGHTMAP: boolean;
  107494. LIGHTMAPDIRECTUV: number;
  107495. USELIGHTMAPASSHADOWMAP: boolean;
  107496. GAMMALIGHTMAP: boolean;
  107497. RGBDLIGHTMAP: boolean;
  107498. REFLECTION: boolean;
  107499. REFLECTIONMAP_3D: boolean;
  107500. REFLECTIONMAP_SPHERICAL: boolean;
  107501. REFLECTIONMAP_PLANAR: boolean;
  107502. REFLECTIONMAP_CUBIC: boolean;
  107503. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107504. REFLECTIONMAP_PROJECTION: boolean;
  107505. REFLECTIONMAP_SKYBOX: boolean;
  107506. REFLECTIONMAP_EXPLICIT: boolean;
  107507. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107508. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107509. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107510. INVERTCUBICMAP: boolean;
  107511. USESPHERICALFROMREFLECTIONMAP: boolean;
  107512. USEIRRADIANCEMAP: boolean;
  107513. SPHERICAL_HARMONICS: boolean;
  107514. USESPHERICALINVERTEX: boolean;
  107515. REFLECTIONMAP_OPPOSITEZ: boolean;
  107516. LODINREFLECTIONALPHA: boolean;
  107517. GAMMAREFLECTION: boolean;
  107518. RGBDREFLECTION: boolean;
  107519. LINEARSPECULARREFLECTION: boolean;
  107520. RADIANCEOCCLUSION: boolean;
  107521. HORIZONOCCLUSION: boolean;
  107522. INSTANCES: boolean;
  107523. THIN_INSTANCES: boolean;
  107524. PREPASS: boolean;
  107525. PREPASS_IRRADIANCE: boolean;
  107526. PREPASS_IRRADIANCE_INDEX: number;
  107527. PREPASS_ALBEDO: boolean;
  107528. PREPASS_ALBEDO_INDEX: number;
  107529. PREPASS_DEPTHNORMAL: boolean;
  107530. PREPASS_DEPTHNORMAL_INDEX: number;
  107531. PREPASS_POSITION: boolean;
  107532. PREPASS_POSITION_INDEX: number;
  107533. PREPASS_VELOCITY: boolean;
  107534. PREPASS_VELOCITY_INDEX: number;
  107535. PREPASS_REFLECTIVITY: boolean;
  107536. PREPASS_REFLECTIVITY_INDEX: number;
  107537. SCENE_MRT_COUNT: number;
  107538. NUM_BONE_INFLUENCERS: number;
  107539. BonesPerMesh: number;
  107540. BONETEXTURE: boolean;
  107541. BONES_VELOCITY_ENABLED: boolean;
  107542. NONUNIFORMSCALING: boolean;
  107543. MORPHTARGETS: boolean;
  107544. MORPHTARGETS_NORMAL: boolean;
  107545. MORPHTARGETS_TANGENT: boolean;
  107546. MORPHTARGETS_UV: boolean;
  107547. NUM_MORPH_INFLUENCERS: number;
  107548. IMAGEPROCESSING: boolean;
  107549. VIGNETTE: boolean;
  107550. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107551. VIGNETTEBLENDMODEOPAQUE: boolean;
  107552. TONEMAPPING: boolean;
  107553. TONEMAPPING_ACES: boolean;
  107554. CONTRAST: boolean;
  107555. COLORCURVES: boolean;
  107556. COLORGRADING: boolean;
  107557. COLORGRADING3D: boolean;
  107558. SAMPLER3DGREENDEPTH: boolean;
  107559. SAMPLER3DBGRMAP: boolean;
  107560. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107561. EXPOSURE: boolean;
  107562. MULTIVIEW: boolean;
  107563. USEPHYSICALLIGHTFALLOFF: boolean;
  107564. USEGLTFLIGHTFALLOFF: boolean;
  107565. TWOSIDEDLIGHTING: boolean;
  107566. SHADOWFLOAT: boolean;
  107567. CLIPPLANE: boolean;
  107568. CLIPPLANE2: boolean;
  107569. CLIPPLANE3: boolean;
  107570. CLIPPLANE4: boolean;
  107571. CLIPPLANE5: boolean;
  107572. CLIPPLANE6: boolean;
  107573. POINTSIZE: boolean;
  107574. FOG: boolean;
  107575. LOGARITHMICDEPTH: boolean;
  107576. FORCENORMALFORWARD: boolean;
  107577. SPECULARAA: boolean;
  107578. CLEARCOAT: boolean;
  107579. CLEARCOAT_DEFAULTIOR: boolean;
  107580. CLEARCOAT_TEXTURE: boolean;
  107581. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  107582. CLEARCOAT_TEXTUREDIRECTUV: number;
  107583. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  107584. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  107585. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  107586. CLEARCOAT_BUMP: boolean;
  107587. CLEARCOAT_BUMPDIRECTUV: number;
  107588. CLEARCOAT_REMAP_F0: boolean;
  107589. CLEARCOAT_TINT: boolean;
  107590. CLEARCOAT_TINT_TEXTURE: boolean;
  107591. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107592. ANISOTROPIC: boolean;
  107593. ANISOTROPIC_TEXTURE: boolean;
  107594. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107595. BRDF_V_HEIGHT_CORRELATED: boolean;
  107596. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107597. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  107598. SHEEN: boolean;
  107599. SHEEN_TEXTURE: boolean;
  107600. SHEEN_TEXTURE_ROUGHNESS: boolean;
  107601. SHEEN_TEXTUREDIRECTUV: number;
  107602. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  107603. SHEEN_LINKWITHALBEDO: boolean;
  107604. SHEEN_ROUGHNESS: boolean;
  107605. SHEEN_ALBEDOSCALING: boolean;
  107606. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  107607. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  107608. SUBSURFACE: boolean;
  107609. SS_REFRACTION: boolean;
  107610. SS_TRANSLUCENCY: boolean;
  107611. SS_SCATTERING: boolean;
  107612. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107613. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107614. SS_REFRACTIONMAP_3D: boolean;
  107615. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107616. SS_LODINREFRACTIONALPHA: boolean;
  107617. SS_GAMMAREFRACTION: boolean;
  107618. SS_RGBDREFRACTION: boolean;
  107619. SS_LINEARSPECULARREFRACTION: boolean;
  107620. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107621. SS_ALBEDOFORREFRACTIONTINT: boolean;
  107622. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107623. UNLIT: boolean;
  107624. DEBUGMODE: number;
  107625. /**
  107626. * Initializes the PBR Material defines.
  107627. */
  107628. constructor();
  107629. /**
  107630. * Resets the PBR Material defines.
  107631. */
  107632. reset(): void;
  107633. }
  107634. /**
  107635. * The Physically based material base class of BJS.
  107636. *
  107637. * This offers the main features of a standard PBR material.
  107638. * For more information, please refer to the documentation :
  107639. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107640. */
  107641. export abstract class PBRBaseMaterial extends PushMaterial {
  107642. /**
  107643. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107644. */
  107645. static readonly PBRMATERIAL_OPAQUE: number;
  107646. /**
  107647. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107648. */
  107649. static readonly PBRMATERIAL_ALPHATEST: number;
  107650. /**
  107651. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107652. */
  107653. static readonly PBRMATERIAL_ALPHABLEND: number;
  107654. /**
  107655. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107656. * They are also discarded below the alpha cutoff threshold to improve performances.
  107657. */
  107658. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107659. /**
  107660. * Defines the default value of how much AO map is occluding the analytical lights
  107661. * (point spot...).
  107662. */
  107663. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107664. /**
  107665. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  107666. */
  107667. static readonly LIGHTFALLOFF_PHYSICAL: number;
  107668. /**
  107669. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  107670. * to enhance interoperability with other engines.
  107671. */
  107672. static readonly LIGHTFALLOFF_GLTF: number;
  107673. /**
  107674. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  107675. * to enhance interoperability with other materials.
  107676. */
  107677. static readonly LIGHTFALLOFF_STANDARD: number;
  107678. /**
  107679. * Intensity of the direct lights e.g. the four lights available in your scene.
  107680. * This impacts both the direct diffuse and specular highlights.
  107681. */
  107682. protected _directIntensity: number;
  107683. /**
  107684. * Intensity of the emissive part of the material.
  107685. * This helps controlling the emissive effect without modifying the emissive color.
  107686. */
  107687. protected _emissiveIntensity: number;
  107688. /**
  107689. * Intensity of the environment e.g. how much the environment will light the object
  107690. * either through harmonics for rough material or through the refelction for shiny ones.
  107691. */
  107692. protected _environmentIntensity: number;
  107693. /**
  107694. * This is a special control allowing the reduction of the specular highlights coming from the
  107695. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107696. */
  107697. protected _specularIntensity: number;
  107698. /**
  107699. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  107700. */
  107701. private _lightingInfos;
  107702. /**
  107703. * Debug Control allowing disabling the bump map on this material.
  107704. */
  107705. protected _disableBumpMap: boolean;
  107706. /**
  107707. * AKA Diffuse Texture in standard nomenclature.
  107708. */
  107709. protected _albedoTexture: Nullable<BaseTexture>;
  107710. /**
  107711. * AKA Occlusion Texture in other nomenclature.
  107712. */
  107713. protected _ambientTexture: Nullable<BaseTexture>;
  107714. /**
  107715. * AKA Occlusion Texture Intensity in other nomenclature.
  107716. */
  107717. protected _ambientTextureStrength: number;
  107718. /**
  107719. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107720. * 1 means it completely occludes it
  107721. * 0 mean it has no impact
  107722. */
  107723. protected _ambientTextureImpactOnAnalyticalLights: number;
  107724. /**
  107725. * Stores the alpha values in a texture.
  107726. */
  107727. protected _opacityTexture: Nullable<BaseTexture>;
  107728. /**
  107729. * Stores the reflection values in a texture.
  107730. */
  107731. protected _reflectionTexture: Nullable<BaseTexture>;
  107732. /**
  107733. * Stores the emissive values in a texture.
  107734. */
  107735. protected _emissiveTexture: Nullable<BaseTexture>;
  107736. /**
  107737. * AKA Specular texture in other nomenclature.
  107738. */
  107739. protected _reflectivityTexture: Nullable<BaseTexture>;
  107740. /**
  107741. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107742. */
  107743. protected _metallicTexture: Nullable<BaseTexture>;
  107744. /**
  107745. * Specifies the metallic scalar of the metallic/roughness workflow.
  107746. * Can also be used to scale the metalness values of the metallic texture.
  107747. */
  107748. protected _metallic: Nullable<number>;
  107749. /**
  107750. * Specifies the roughness scalar of the metallic/roughness workflow.
  107751. * Can also be used to scale the roughness values of the metallic texture.
  107752. */
  107753. protected _roughness: Nullable<number>;
  107754. /**
  107755. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107756. * By default the indexOfrefraction is used to compute F0;
  107757. *
  107758. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107759. *
  107760. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107761. * F90 = metallicReflectanceColor;
  107762. */
  107763. protected _metallicF0Factor: number;
  107764. /**
  107765. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107766. * By default the F90 is always 1;
  107767. *
  107768. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107769. *
  107770. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107771. * F90 = metallicReflectanceColor;
  107772. */
  107773. protected _metallicReflectanceColor: Color3;
  107774. /**
  107775. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107776. * This is multiply against the scalar values defined in the material.
  107777. */
  107778. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  107779. /**
  107780. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107781. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107782. */
  107783. protected _microSurfaceTexture: Nullable<BaseTexture>;
  107784. /**
  107785. * Stores surface normal data used to displace a mesh in a texture.
  107786. */
  107787. protected _bumpTexture: Nullable<BaseTexture>;
  107788. /**
  107789. * Stores the pre-calculated light information of a mesh in a texture.
  107790. */
  107791. protected _lightmapTexture: Nullable<BaseTexture>;
  107792. /**
  107793. * The color of a material in ambient lighting.
  107794. */
  107795. protected _ambientColor: Color3;
  107796. /**
  107797. * AKA Diffuse Color in other nomenclature.
  107798. */
  107799. protected _albedoColor: Color3;
  107800. /**
  107801. * AKA Specular Color in other nomenclature.
  107802. */
  107803. protected _reflectivityColor: Color3;
  107804. /**
  107805. * The color applied when light is reflected from a material.
  107806. */
  107807. protected _reflectionColor: Color3;
  107808. /**
  107809. * The color applied when light is emitted from a material.
  107810. */
  107811. protected _emissiveColor: Color3;
  107812. /**
  107813. * AKA Glossiness in other nomenclature.
  107814. */
  107815. protected _microSurface: number;
  107816. /**
  107817. * Specifies that the material will use the light map as a show map.
  107818. */
  107819. protected _useLightmapAsShadowmap: boolean;
  107820. /**
  107821. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107822. * makes the reflect vector face the model (under horizon).
  107823. */
  107824. protected _useHorizonOcclusion: boolean;
  107825. /**
  107826. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107827. * too much the area relying on ambient texture to define their ambient occlusion.
  107828. */
  107829. protected _useRadianceOcclusion: boolean;
  107830. /**
  107831. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107832. */
  107833. protected _useAlphaFromAlbedoTexture: boolean;
  107834. /**
  107835. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107836. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107837. */
  107838. protected _useSpecularOverAlpha: boolean;
  107839. /**
  107840. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107841. */
  107842. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107843. /**
  107844. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107845. */
  107846. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107847. /**
  107848. * Specifies if the metallic texture contains the roughness information in its green channel.
  107849. */
  107850. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107851. /**
  107852. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107853. */
  107854. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107855. /**
  107856. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107857. */
  107858. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107859. /**
  107860. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107861. */
  107862. protected _useAmbientInGrayScale: boolean;
  107863. /**
  107864. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107865. * The material will try to infer what glossiness each pixel should be.
  107866. */
  107867. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107868. /**
  107869. * Defines the falloff type used in this material.
  107870. * It by default is Physical.
  107871. */
  107872. protected _lightFalloff: number;
  107873. /**
  107874. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107875. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107876. */
  107877. protected _useRadianceOverAlpha: boolean;
  107878. /**
  107879. * Allows using an object space normal map (instead of tangent space).
  107880. */
  107881. protected _useObjectSpaceNormalMap: boolean;
  107882. /**
  107883. * Allows using the bump map in parallax mode.
  107884. */
  107885. protected _useParallax: boolean;
  107886. /**
  107887. * Allows using the bump map in parallax occlusion mode.
  107888. */
  107889. protected _useParallaxOcclusion: boolean;
  107890. /**
  107891. * Controls the scale bias of the parallax mode.
  107892. */
  107893. protected _parallaxScaleBias: number;
  107894. /**
  107895. * If sets to true, disables all the lights affecting the material.
  107896. */
  107897. protected _disableLighting: boolean;
  107898. /**
  107899. * Number of Simultaneous lights allowed on the material.
  107900. */
  107901. protected _maxSimultaneousLights: number;
  107902. /**
  107903. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107904. */
  107905. protected _invertNormalMapX: boolean;
  107906. /**
  107907. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107908. */
  107909. protected _invertNormalMapY: boolean;
  107910. /**
  107911. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107912. */
  107913. protected _twoSidedLighting: boolean;
  107914. /**
  107915. * Defines the alpha limits in alpha test mode.
  107916. */
  107917. protected _alphaCutOff: number;
  107918. /**
  107919. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107920. */
  107921. protected _forceAlphaTest: boolean;
  107922. /**
  107923. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107924. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107925. */
  107926. protected _useAlphaFresnel: boolean;
  107927. /**
  107928. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107929. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107930. */
  107931. protected _useLinearAlphaFresnel: boolean;
  107932. /**
  107933. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107934. * from cos thetav and roughness:
  107935. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107936. */
  107937. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107938. /**
  107939. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107940. */
  107941. protected _forceIrradianceInFragment: boolean;
  107942. private _realTimeFiltering;
  107943. /**
  107944. * Enables realtime filtering on the texture.
  107945. */
  107946. get realTimeFiltering(): boolean;
  107947. set realTimeFiltering(b: boolean);
  107948. private _realTimeFilteringQuality;
  107949. /**
  107950. * Quality switch for realtime filtering
  107951. */
  107952. get realTimeFilteringQuality(): number;
  107953. set realTimeFilteringQuality(n: number);
  107954. /**
  107955. * Can this material render to several textures at once
  107956. */
  107957. get canRenderToMRT(): boolean;
  107958. /**
  107959. * Force normal to face away from face.
  107960. */
  107961. protected _forceNormalForward: boolean;
  107962. /**
  107963. * Enables specular anti aliasing in the PBR shader.
  107964. * It will both interacts on the Geometry for analytical and IBL lighting.
  107965. * It also prefilter the roughness map based on the bump values.
  107966. */
  107967. protected _enableSpecularAntiAliasing: boolean;
  107968. /**
  107969. * Default configuration related to image processing available in the PBR Material.
  107970. */
  107971. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107972. /**
  107973. * Keep track of the image processing observer to allow dispose and replace.
  107974. */
  107975. private _imageProcessingObserver;
  107976. /**
  107977. * Attaches a new image processing configuration to the PBR Material.
  107978. * @param configuration
  107979. */
  107980. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107981. /**
  107982. * Stores the available render targets.
  107983. */
  107984. private _renderTargets;
  107985. /**
  107986. * Sets the global ambient color for the material used in lighting calculations.
  107987. */
  107988. private _globalAmbientColor;
  107989. /**
  107990. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107991. */
  107992. private _useLogarithmicDepth;
  107993. /**
  107994. * If set to true, no lighting calculations will be applied.
  107995. */
  107996. private _unlit;
  107997. private _debugMode;
  107998. /**
  107999. * @hidden
  108000. * This is reserved for the inspector.
  108001. * Defines the material debug mode.
  108002. * It helps seeing only some components of the material while troubleshooting.
  108003. */
  108004. debugMode: number;
  108005. /**
  108006. * @hidden
  108007. * This is reserved for the inspector.
  108008. * Specify from where on screen the debug mode should start.
  108009. * The value goes from -1 (full screen) to 1 (not visible)
  108010. * It helps with side by side comparison against the final render
  108011. * This defaults to -1
  108012. */
  108013. private debugLimit;
  108014. /**
  108015. * @hidden
  108016. * This is reserved for the inspector.
  108017. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108018. * You can use the factor to better multiply the final value.
  108019. */
  108020. private debugFactor;
  108021. /**
  108022. * Defines the clear coat layer parameters for the material.
  108023. */
  108024. readonly clearCoat: PBRClearCoatConfiguration;
  108025. /**
  108026. * Defines the anisotropic parameters for the material.
  108027. */
  108028. readonly anisotropy: PBRAnisotropicConfiguration;
  108029. /**
  108030. * Defines the BRDF parameters for the material.
  108031. */
  108032. readonly brdf: PBRBRDFConfiguration;
  108033. /**
  108034. * Defines the Sheen parameters for the material.
  108035. */
  108036. readonly sheen: PBRSheenConfiguration;
  108037. /**
  108038. * Defines the SubSurface parameters for the material.
  108039. */
  108040. readonly subSurface: PBRSubSurfaceConfiguration;
  108041. /**
  108042. * Defines additionnal PrePass parameters for the material.
  108043. */
  108044. readonly prePassConfiguration: PrePassConfiguration;
  108045. /**
  108046. * Defines the detail map parameters for the material.
  108047. */
  108048. readonly detailMap: DetailMapConfiguration;
  108049. protected _rebuildInParallel: boolean;
  108050. /**
  108051. * Instantiates a new PBRMaterial instance.
  108052. *
  108053. * @param name The material name
  108054. * @param scene The scene the material will be use in.
  108055. */
  108056. constructor(name: string, scene: Scene);
  108057. /**
  108058. * Gets a boolean indicating that current material needs to register RTT
  108059. */
  108060. get hasRenderTargetTextures(): boolean;
  108061. /**
  108062. * Gets the name of the material class.
  108063. */
  108064. getClassName(): string;
  108065. /**
  108066. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108067. */
  108068. get useLogarithmicDepth(): boolean;
  108069. /**
  108070. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108071. */
  108072. set useLogarithmicDepth(value: boolean);
  108073. /**
  108074. * Returns true if alpha blending should be disabled.
  108075. */
  108076. protected get _disableAlphaBlending(): boolean;
  108077. /**
  108078. * Specifies whether or not this material should be rendered in alpha blend mode.
  108079. */
  108080. needAlphaBlending(): boolean;
  108081. /**
  108082. * Specifies whether or not this material should be rendered in alpha test mode.
  108083. */
  108084. needAlphaTesting(): boolean;
  108085. /**
  108086. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108087. */
  108088. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108089. /**
  108090. * Specifies whether or not there is a usable alpha channel for transparency.
  108091. */
  108092. protected _hasAlphaChannel(): boolean;
  108093. /**
  108094. * Gets the texture used for the alpha test.
  108095. */
  108096. getAlphaTestTexture(): Nullable<BaseTexture>;
  108097. /**
  108098. * Specifies that the submesh is ready to be used.
  108099. * @param mesh - BJS mesh.
  108100. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108101. * @param useInstances - Specifies that instances should be used.
  108102. * @returns - boolean indicating that the submesh is ready or not.
  108103. */
  108104. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108105. /**
  108106. * Specifies if the material uses metallic roughness workflow.
  108107. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108108. */
  108109. isMetallicWorkflow(): boolean;
  108110. private _prepareEffect;
  108111. private _prepareDefines;
  108112. /**
  108113. * Force shader compilation
  108114. */
  108115. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  108116. /**
  108117. * Initializes the uniform buffer layout for the shader.
  108118. */
  108119. buildUniformLayout(): void;
  108120. /**
  108121. * Unbinds the material from the mesh
  108122. */
  108123. unbind(): void;
  108124. /**
  108125. * Binds the submesh data.
  108126. * @param world - The world matrix.
  108127. * @param mesh - The BJS mesh.
  108128. * @param subMesh - A submesh of the BJS mesh.
  108129. */
  108130. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108131. /**
  108132. * Returns the animatable textures.
  108133. * @returns - Array of animatable textures.
  108134. */
  108135. getAnimatables(): IAnimatable[];
  108136. /**
  108137. * Returns the texture used for reflections.
  108138. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108139. */
  108140. private _getReflectionTexture;
  108141. /**
  108142. * Returns an array of the actively used textures.
  108143. * @returns - Array of BaseTextures
  108144. */
  108145. getActiveTextures(): BaseTexture[];
  108146. /**
  108147. * Checks to see if a texture is used in the material.
  108148. * @param texture - Base texture to use.
  108149. * @returns - Boolean specifying if a texture is used in the material.
  108150. */
  108151. hasTexture(texture: BaseTexture): boolean;
  108152. /**
  108153. * Sets the required values to the prepass renderer.
  108154. * @param prePassRenderer defines the prepass renderer to setup
  108155. */
  108156. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108157. /**
  108158. * Disposes the resources of the material.
  108159. * @param forceDisposeEffect - Forces the disposal of effects.
  108160. * @param forceDisposeTextures - Forces the disposal of all textures.
  108161. */
  108162. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108163. }
  108164. }
  108165. declare module BABYLON {
  108166. /**
  108167. * The Physically based material of BJS.
  108168. *
  108169. * This offers the main features of a standard PBR material.
  108170. * For more information, please refer to the documentation :
  108171. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108172. */
  108173. export class PBRMaterial extends PBRBaseMaterial {
  108174. /**
  108175. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108176. */
  108177. static readonly PBRMATERIAL_OPAQUE: number;
  108178. /**
  108179. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108180. */
  108181. static readonly PBRMATERIAL_ALPHATEST: number;
  108182. /**
  108183. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108184. */
  108185. static readonly PBRMATERIAL_ALPHABLEND: number;
  108186. /**
  108187. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108188. * They are also discarded below the alpha cutoff threshold to improve performances.
  108189. */
  108190. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108191. /**
  108192. * Defines the default value of how much AO map is occluding the analytical lights
  108193. * (point spot...).
  108194. */
  108195. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108196. /**
  108197. * Intensity of the direct lights e.g. the four lights available in your scene.
  108198. * This impacts both the direct diffuse and specular highlights.
  108199. */
  108200. directIntensity: number;
  108201. /**
  108202. * Intensity of the emissive part of the material.
  108203. * This helps controlling the emissive effect without modifying the emissive color.
  108204. */
  108205. emissiveIntensity: number;
  108206. /**
  108207. * Intensity of the environment e.g. how much the environment will light the object
  108208. * either through harmonics for rough material or through the refelction for shiny ones.
  108209. */
  108210. environmentIntensity: number;
  108211. /**
  108212. * This is a special control allowing the reduction of the specular highlights coming from the
  108213. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108214. */
  108215. specularIntensity: number;
  108216. /**
  108217. * Debug Control allowing disabling the bump map on this material.
  108218. */
  108219. disableBumpMap: boolean;
  108220. /**
  108221. * AKA Diffuse Texture in standard nomenclature.
  108222. */
  108223. albedoTexture: BaseTexture;
  108224. /**
  108225. * AKA Occlusion Texture in other nomenclature.
  108226. */
  108227. ambientTexture: BaseTexture;
  108228. /**
  108229. * AKA Occlusion Texture Intensity in other nomenclature.
  108230. */
  108231. ambientTextureStrength: number;
  108232. /**
  108233. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108234. * 1 means it completely occludes it
  108235. * 0 mean it has no impact
  108236. */
  108237. ambientTextureImpactOnAnalyticalLights: number;
  108238. /**
  108239. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  108240. */
  108241. opacityTexture: BaseTexture;
  108242. /**
  108243. * Stores the reflection values in a texture.
  108244. */
  108245. reflectionTexture: Nullable<BaseTexture>;
  108246. /**
  108247. * Stores the emissive values in a texture.
  108248. */
  108249. emissiveTexture: BaseTexture;
  108250. /**
  108251. * AKA Specular texture in other nomenclature.
  108252. */
  108253. reflectivityTexture: BaseTexture;
  108254. /**
  108255. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108256. */
  108257. metallicTexture: BaseTexture;
  108258. /**
  108259. * Specifies the metallic scalar of the metallic/roughness workflow.
  108260. * Can also be used to scale the metalness values of the metallic texture.
  108261. */
  108262. metallic: Nullable<number>;
  108263. /**
  108264. * Specifies the roughness scalar of the metallic/roughness workflow.
  108265. * Can also be used to scale the roughness values of the metallic texture.
  108266. */
  108267. roughness: Nullable<number>;
  108268. /**
  108269. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  108270. * By default the indexOfrefraction is used to compute F0;
  108271. *
  108272. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  108273. *
  108274. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  108275. * F90 = metallicReflectanceColor;
  108276. */
  108277. metallicF0Factor: number;
  108278. /**
  108279. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  108280. * By default the F90 is always 1;
  108281. *
  108282. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  108283. *
  108284. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  108285. * F90 = metallicReflectanceColor;
  108286. */
  108287. metallicReflectanceColor: Color3;
  108288. /**
  108289. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  108290. * This is multiply against the scalar values defined in the material.
  108291. */
  108292. metallicReflectanceTexture: Nullable<BaseTexture>;
  108293. /**
  108294. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108295. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108296. */
  108297. microSurfaceTexture: BaseTexture;
  108298. /**
  108299. * Stores surface normal data used to displace a mesh in a texture.
  108300. */
  108301. bumpTexture: BaseTexture;
  108302. /**
  108303. * Stores the pre-calculated light information of a mesh in a texture.
  108304. */
  108305. lightmapTexture: BaseTexture;
  108306. /**
  108307. * Stores the refracted light information in a texture.
  108308. */
  108309. get refractionTexture(): Nullable<BaseTexture>;
  108310. set refractionTexture(value: Nullable<BaseTexture>);
  108311. /**
  108312. * The color of a material in ambient lighting.
  108313. */
  108314. ambientColor: Color3;
  108315. /**
  108316. * AKA Diffuse Color in other nomenclature.
  108317. */
  108318. albedoColor: Color3;
  108319. /**
  108320. * AKA Specular Color in other nomenclature.
  108321. */
  108322. reflectivityColor: Color3;
  108323. /**
  108324. * The color reflected from the material.
  108325. */
  108326. reflectionColor: Color3;
  108327. /**
  108328. * The color emitted from the material.
  108329. */
  108330. emissiveColor: Color3;
  108331. /**
  108332. * AKA Glossiness in other nomenclature.
  108333. */
  108334. microSurface: number;
  108335. /**
  108336. * Index of refraction of the material base layer.
  108337. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  108338. *
  108339. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  108340. *
  108341. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  108342. */
  108343. get indexOfRefraction(): number;
  108344. set indexOfRefraction(value: number);
  108345. /**
  108346. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108347. */
  108348. get invertRefractionY(): boolean;
  108349. set invertRefractionY(value: boolean);
  108350. /**
  108351. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108352. * Materials half opaque for instance using refraction could benefit from this control.
  108353. */
  108354. get linkRefractionWithTransparency(): boolean;
  108355. set linkRefractionWithTransparency(value: boolean);
  108356. /**
  108357. * If true, the light map contains occlusion information instead of lighting info.
  108358. */
  108359. useLightmapAsShadowmap: boolean;
  108360. /**
  108361. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108362. */
  108363. useAlphaFromAlbedoTexture: boolean;
  108364. /**
  108365. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108366. */
  108367. forceAlphaTest: boolean;
  108368. /**
  108369. * Defines the alpha limits in alpha test mode.
  108370. */
  108371. alphaCutOff: number;
  108372. /**
  108373. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108374. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108375. */
  108376. useSpecularOverAlpha: boolean;
  108377. /**
  108378. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108379. */
  108380. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108381. /**
  108382. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108383. */
  108384. useRoughnessFromMetallicTextureAlpha: boolean;
  108385. /**
  108386. * Specifies if the metallic texture contains the roughness information in its green channel.
  108387. */
  108388. useRoughnessFromMetallicTextureGreen: boolean;
  108389. /**
  108390. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108391. */
  108392. useMetallnessFromMetallicTextureBlue: boolean;
  108393. /**
  108394. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108395. */
  108396. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108397. /**
  108398. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108399. */
  108400. useAmbientInGrayScale: boolean;
  108401. /**
  108402. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108403. * The material will try to infer what glossiness each pixel should be.
  108404. */
  108405. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108406. /**
  108407. * BJS is using an harcoded light falloff based on a manually sets up range.
  108408. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108409. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108410. */
  108411. get usePhysicalLightFalloff(): boolean;
  108412. /**
  108413. * BJS is using an harcoded light falloff based on a manually sets up range.
  108414. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108415. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108416. */
  108417. set usePhysicalLightFalloff(value: boolean);
  108418. /**
  108419. * In order to support the falloff compatibility with gltf, a special mode has been added
  108420. * to reproduce the gltf light falloff.
  108421. */
  108422. get useGLTFLightFalloff(): boolean;
  108423. /**
  108424. * In order to support the falloff compatibility with gltf, a special mode has been added
  108425. * to reproduce the gltf light falloff.
  108426. */
  108427. set useGLTFLightFalloff(value: boolean);
  108428. /**
  108429. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108430. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108431. */
  108432. useRadianceOverAlpha: boolean;
  108433. /**
  108434. * Allows using an object space normal map (instead of tangent space).
  108435. */
  108436. useObjectSpaceNormalMap: boolean;
  108437. /**
  108438. * Allows using the bump map in parallax mode.
  108439. */
  108440. useParallax: boolean;
  108441. /**
  108442. * Allows using the bump map in parallax occlusion mode.
  108443. */
  108444. useParallaxOcclusion: boolean;
  108445. /**
  108446. * Controls the scale bias of the parallax mode.
  108447. */
  108448. parallaxScaleBias: number;
  108449. /**
  108450. * If sets to true, disables all the lights affecting the material.
  108451. */
  108452. disableLighting: boolean;
  108453. /**
  108454. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108455. */
  108456. forceIrradianceInFragment: boolean;
  108457. /**
  108458. * Number of Simultaneous lights allowed on the material.
  108459. */
  108460. maxSimultaneousLights: number;
  108461. /**
  108462. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108463. */
  108464. invertNormalMapX: boolean;
  108465. /**
  108466. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108467. */
  108468. invertNormalMapY: boolean;
  108469. /**
  108470. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108471. */
  108472. twoSidedLighting: boolean;
  108473. /**
  108474. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108475. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108476. */
  108477. useAlphaFresnel: boolean;
  108478. /**
  108479. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108480. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108481. */
  108482. useLinearAlphaFresnel: boolean;
  108483. /**
  108484. * Let user defines the brdf lookup texture used for IBL.
  108485. * A default 8bit version is embedded but you could point at :
  108486. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  108487. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108488. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  108489. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108490. */
  108491. environmentBRDFTexture: Nullable<BaseTexture>;
  108492. /**
  108493. * Force normal to face away from face.
  108494. */
  108495. forceNormalForward: boolean;
  108496. /**
  108497. * Enables specular anti aliasing in the PBR shader.
  108498. * It will both interacts on the Geometry for analytical and IBL lighting.
  108499. * It also prefilter the roughness map based on the bump values.
  108500. */
  108501. enableSpecularAntiAliasing: boolean;
  108502. /**
  108503. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108504. * makes the reflect vector face the model (under horizon).
  108505. */
  108506. useHorizonOcclusion: boolean;
  108507. /**
  108508. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108509. * too much the area relying on ambient texture to define their ambient occlusion.
  108510. */
  108511. useRadianceOcclusion: boolean;
  108512. /**
  108513. * If set to true, no lighting calculations will be applied.
  108514. */
  108515. unlit: boolean;
  108516. /**
  108517. * Gets the image processing configuration used either in this material.
  108518. */
  108519. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108520. /**
  108521. * Sets the Default image processing configuration used either in the this material.
  108522. *
  108523. * If sets to null, the scene one is in use.
  108524. */
  108525. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  108526. /**
  108527. * Gets wether the color curves effect is enabled.
  108528. */
  108529. get cameraColorCurvesEnabled(): boolean;
  108530. /**
  108531. * Sets wether the color curves effect is enabled.
  108532. */
  108533. set cameraColorCurvesEnabled(value: boolean);
  108534. /**
  108535. * Gets wether the color grading effect is enabled.
  108536. */
  108537. get cameraColorGradingEnabled(): boolean;
  108538. /**
  108539. * Gets wether the color grading effect is enabled.
  108540. */
  108541. set cameraColorGradingEnabled(value: boolean);
  108542. /**
  108543. * Gets wether tonemapping is enabled or not.
  108544. */
  108545. get cameraToneMappingEnabled(): boolean;
  108546. /**
  108547. * Sets wether tonemapping is enabled or not
  108548. */
  108549. set cameraToneMappingEnabled(value: boolean);
  108550. /**
  108551. * The camera exposure used on this material.
  108552. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108553. * This corresponds to a photographic exposure.
  108554. */
  108555. get cameraExposure(): number;
  108556. /**
  108557. * The camera exposure used on this material.
  108558. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108559. * This corresponds to a photographic exposure.
  108560. */
  108561. set cameraExposure(value: number);
  108562. /**
  108563. * Gets The camera contrast used on this material.
  108564. */
  108565. get cameraContrast(): number;
  108566. /**
  108567. * Sets The camera contrast used on this material.
  108568. */
  108569. set cameraContrast(value: number);
  108570. /**
  108571. * Gets the Color Grading 2D Lookup Texture.
  108572. */
  108573. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  108574. /**
  108575. * Sets the Color Grading 2D Lookup Texture.
  108576. */
  108577. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  108578. /**
  108579. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108580. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108581. * 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;
  108582. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108583. */
  108584. get cameraColorCurves(): Nullable<ColorCurves>;
  108585. /**
  108586. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108587. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108588. * 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;
  108589. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108590. */
  108591. set cameraColorCurves(value: Nullable<ColorCurves>);
  108592. /**
  108593. * Instantiates a new PBRMaterial instance.
  108594. *
  108595. * @param name The material name
  108596. * @param scene The scene the material will be use in.
  108597. */
  108598. constructor(name: string, scene: Scene);
  108599. /**
  108600. * Returns the name of this material class.
  108601. */
  108602. getClassName(): string;
  108603. /**
  108604. * Makes a duplicate of the current material.
  108605. * @param name - name to use for the new material.
  108606. */
  108607. clone(name: string): PBRMaterial;
  108608. /**
  108609. * Serializes this PBR Material.
  108610. * @returns - An object with the serialized material.
  108611. */
  108612. serialize(): any;
  108613. /**
  108614. * Parses a PBR Material from a serialized object.
  108615. * @param source - Serialized object.
  108616. * @param scene - BJS scene instance.
  108617. * @param rootUrl - url for the scene object
  108618. * @returns - PBRMaterial
  108619. */
  108620. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  108621. }
  108622. }
  108623. declare module BABYLON {
  108624. /** @hidden */
  108625. export var mrtFragmentDeclaration: {
  108626. name: string;
  108627. shader: string;
  108628. };
  108629. }
  108630. declare module BABYLON {
  108631. /** @hidden */
  108632. export var geometryPixelShader: {
  108633. name: string;
  108634. shader: string;
  108635. };
  108636. }
  108637. declare module BABYLON {
  108638. /** @hidden */
  108639. export var geometryVertexShader: {
  108640. name: string;
  108641. shader: string;
  108642. };
  108643. }
  108644. declare module BABYLON {
  108645. /** @hidden */
  108646. interface ISavedTransformationMatrix {
  108647. world: Matrix;
  108648. viewProjection: Matrix;
  108649. }
  108650. /**
  108651. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108652. */
  108653. export class GeometryBufferRenderer {
  108654. /**
  108655. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  108656. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  108657. */
  108658. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  108659. /**
  108660. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108661. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108662. */
  108663. static readonly POSITION_TEXTURE_TYPE: number;
  108664. /**
  108665. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108666. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108667. */
  108668. static readonly VELOCITY_TEXTURE_TYPE: number;
  108669. /**
  108670. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  108671. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  108672. */
  108673. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  108674. /**
  108675. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108676. * in order to compute objects velocities when enableVelocity is set to "true"
  108677. * @hidden
  108678. */
  108679. _previousTransformationMatrices: {
  108680. [index: number]: ISavedTransformationMatrix;
  108681. };
  108682. /**
  108683. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  108684. * in order to compute objects velocities when enableVelocity is set to "true"
  108685. * @hidden
  108686. */
  108687. _previousBonesTransformationMatrices: {
  108688. [index: number]: Float32Array;
  108689. };
  108690. /**
  108691. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  108692. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  108693. */
  108694. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  108695. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  108696. renderTransparentMeshes: boolean;
  108697. private _scene;
  108698. private _resizeObserver;
  108699. private _multiRenderTarget;
  108700. private _ratio;
  108701. private _enablePosition;
  108702. private _enableVelocity;
  108703. private _enableReflectivity;
  108704. private _positionIndex;
  108705. private _velocityIndex;
  108706. private _reflectivityIndex;
  108707. private _depthNormalIndex;
  108708. private _linkedWithPrePass;
  108709. private _prePassRenderer;
  108710. private _attachments;
  108711. protected _effect: Effect;
  108712. protected _cachedDefines: string;
  108713. /**
  108714. * @hidden
  108715. * Sets up internal structures to share outputs with PrePassRenderer
  108716. * This method should only be called by the PrePassRenderer itself
  108717. */
  108718. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  108719. /**
  108720. * @hidden
  108721. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  108722. * This method should only be called by the PrePassRenderer itself
  108723. */
  108724. _unlinkPrePassRenderer(): void;
  108725. /**
  108726. * @hidden
  108727. * Resets the geometry buffer layout
  108728. */
  108729. _resetLayout(): void;
  108730. /**
  108731. * @hidden
  108732. * Replaces a texture in the geometry buffer renderer
  108733. * Useful when linking textures of the prepass renderer
  108734. */
  108735. _forceTextureType(geometryBufferType: number, index: number): void;
  108736. /**
  108737. * @hidden
  108738. * Sets texture attachments
  108739. * Useful when linking textures of the prepass renderer
  108740. */
  108741. _setAttachments(attachments: number[]): void;
  108742. /**
  108743. * @hidden
  108744. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  108745. * Useful when linking textures of the prepass renderer
  108746. */
  108747. _linkInternalTexture(internalTexture: InternalTexture): void;
  108748. /**
  108749. * Gets the render list (meshes to be rendered) used in the G buffer.
  108750. */
  108751. get renderList(): Nullable<AbstractMesh[]>;
  108752. /**
  108753. * Set the render list (meshes to be rendered) used in the G buffer.
  108754. */
  108755. set renderList(meshes: Nullable<AbstractMesh[]>);
  108756. /**
  108757. * Gets wether or not G buffer are supported by the running hardware.
  108758. * This requires draw buffer supports
  108759. */
  108760. get isSupported(): boolean;
  108761. /**
  108762. * Returns the index of the given texture type in the G-Buffer textures array
  108763. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108764. * @returns the index of the given texture type in the G-Buffer textures array
  108765. */
  108766. getTextureIndex(textureType: number): number;
  108767. /**
  108768. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108769. */
  108770. get enablePosition(): boolean;
  108771. /**
  108772. * Sets whether or not objects positions are enabled for the G buffer.
  108773. */
  108774. set enablePosition(enable: boolean);
  108775. /**
  108776. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108777. */
  108778. get enableVelocity(): boolean;
  108779. /**
  108780. * Sets wether or not objects velocities are enabled for the G buffer.
  108781. */
  108782. set enableVelocity(enable: boolean);
  108783. /**
  108784. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  108785. */
  108786. get enableReflectivity(): boolean;
  108787. /**
  108788. * Sets wether or not objects roughness are enabled for the G buffer.
  108789. */
  108790. set enableReflectivity(enable: boolean);
  108791. /**
  108792. * Gets the scene associated with the buffer.
  108793. */
  108794. get scene(): Scene;
  108795. /**
  108796. * Gets the ratio used by the buffer during its creation.
  108797. * How big is the buffer related to the main canvas.
  108798. */
  108799. get ratio(): number;
  108800. /** @hidden */
  108801. static _SceneComponentInitialization: (scene: Scene) => void;
  108802. /**
  108803. * Creates a new G Buffer for the scene
  108804. * @param scene The scene the buffer belongs to
  108805. * @param ratio How big is the buffer related to the main canvas.
  108806. */
  108807. constructor(scene: Scene, ratio?: number);
  108808. /**
  108809. * Checks wether everything is ready to render a submesh to the G buffer.
  108810. * @param subMesh the submesh to check readiness for
  108811. * @param useInstances is the mesh drawn using instance or not
  108812. * @returns true if ready otherwise false
  108813. */
  108814. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108815. /**
  108816. * Gets the current underlying G Buffer.
  108817. * @returns the buffer
  108818. */
  108819. getGBuffer(): MultiRenderTarget;
  108820. /**
  108821. * Gets the number of samples used to render the buffer (anti aliasing).
  108822. */
  108823. get samples(): number;
  108824. /**
  108825. * Sets the number of samples used to render the buffer (anti aliasing).
  108826. */
  108827. set samples(value: number);
  108828. /**
  108829. * Disposes the renderer and frees up associated resources.
  108830. */
  108831. dispose(): void;
  108832. private _assignRenderTargetIndices;
  108833. protected _createRenderTargets(): void;
  108834. private _copyBonesTransformationMatrices;
  108835. }
  108836. }
  108837. declare module BABYLON {
  108838. /**
  108839. * Renders a pre pass of the scene
  108840. * This means every mesh in the scene will be rendered to a render target texture
  108841. * And then this texture will be composited to the rendering canvas with post processes
  108842. * It is necessary for effects like subsurface scattering or deferred shading
  108843. */
  108844. export class PrePassRenderer {
  108845. /** @hidden */
  108846. static _SceneComponentInitialization: (scene: Scene) => void;
  108847. private _textureFormats;
  108848. /**
  108849. * To save performance, we can excluded skinned meshes from the prepass
  108850. */
  108851. excludedSkinnedMesh: AbstractMesh[];
  108852. /**
  108853. * Force material to be excluded from the prepass
  108854. * Can be useful when `useGeometryBufferFallback` is set to `true`
  108855. * and you don't want a material to show in the effect.
  108856. */
  108857. excludedMaterials: Material[];
  108858. private _textureIndices;
  108859. private _scene;
  108860. private _engine;
  108861. private _isDirty;
  108862. /**
  108863. * Number of textures in the multi render target texture where the scene is directly rendered
  108864. */
  108865. mrtCount: number;
  108866. /**
  108867. * The render target where the scene is directly rendered
  108868. */
  108869. prePassRT: MultiRenderTarget;
  108870. private _multiRenderAttachments;
  108871. private _defaultAttachments;
  108872. private _clearAttachments;
  108873. private _postProcesses;
  108874. private readonly _clearColor;
  108875. /**
  108876. * Image processing post process for composition
  108877. */
  108878. imageProcessingPostProcess: ImageProcessingPostProcess;
  108879. /**
  108880. * Configuration for prepass effects
  108881. */
  108882. private _effectConfigurations;
  108883. private _mrtFormats;
  108884. private _mrtLayout;
  108885. private _enabled;
  108886. /**
  108887. * Indicates if the prepass is enabled
  108888. */
  108889. get enabled(): boolean;
  108890. /**
  108891. * How many samples are used for MSAA of the scene render target
  108892. */
  108893. get samples(): number;
  108894. set samples(n: number);
  108895. private _geometryBuffer;
  108896. private _useGeometryBufferFallback;
  108897. /**
  108898. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  108899. */
  108900. get useGeometryBufferFallback(): boolean;
  108901. set useGeometryBufferFallback(value: boolean);
  108902. /**
  108903. * Instanciates a prepass renderer
  108904. * @param scene The scene
  108905. */
  108906. constructor(scene: Scene);
  108907. private _initializeAttachments;
  108908. private _createCompositionEffect;
  108909. /**
  108910. * Indicates if rendering a prepass is supported
  108911. */
  108912. get isSupported(): boolean;
  108913. /**
  108914. * Sets the proper output textures to draw in the engine.
  108915. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  108916. * @param subMesh Submesh on which the effect is applied
  108917. */
  108918. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  108919. /**
  108920. * @hidden
  108921. */
  108922. _beforeCameraDraw(): void;
  108923. /**
  108924. * @hidden
  108925. */
  108926. _afterCameraDraw(): void;
  108927. private _checkRTSize;
  108928. private _bindFrameBuffer;
  108929. /**
  108930. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  108931. */
  108932. clear(): void;
  108933. private _setState;
  108934. private _updateGeometryBufferLayout;
  108935. /**
  108936. * Adds an effect configuration to the prepass.
  108937. * If an effect has already been added, it won't add it twice and will return the configuration
  108938. * already present.
  108939. * @param cfg the effect configuration
  108940. * @return the effect configuration now used by the prepass
  108941. */
  108942. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108943. /**
  108944. * Returns the index of a texture in the multi render target texture array.
  108945. * @param type Texture type
  108946. * @return The index
  108947. */
  108948. getIndex(type: number): number;
  108949. private _enable;
  108950. private _disable;
  108951. private _resetLayout;
  108952. private _resetPostProcessChain;
  108953. private _bindPostProcessChain;
  108954. /**
  108955. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108956. */
  108957. markAsDirty(): void;
  108958. /**
  108959. * Enables a texture on the MultiRenderTarget for prepass
  108960. */
  108961. private _enableTextures;
  108962. private _update;
  108963. private _markAllMaterialsAsPrePassDirty;
  108964. /**
  108965. * Disposes the prepass renderer.
  108966. */
  108967. dispose(): void;
  108968. }
  108969. }
  108970. declare module BABYLON {
  108971. /**
  108972. * Size options for a post process
  108973. */
  108974. export type PostProcessOptions = {
  108975. width: number;
  108976. height: number;
  108977. };
  108978. /**
  108979. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108980. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108981. */
  108982. export class PostProcess {
  108983. /**
  108984. * Gets or sets the unique id of the post process
  108985. */
  108986. uniqueId: number;
  108987. /** Name of the PostProcess. */
  108988. name: string;
  108989. /**
  108990. * Width of the texture to apply the post process on
  108991. */
  108992. width: number;
  108993. /**
  108994. * Height of the texture to apply the post process on
  108995. */
  108996. height: number;
  108997. /**
  108998. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108999. */
  109000. nodeMaterialSource: Nullable<NodeMaterial>;
  109001. /**
  109002. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  109003. * @hidden
  109004. */
  109005. _outputTexture: Nullable<InternalTexture>;
  109006. /**
  109007. * Sampling mode used by the shader
  109008. * See https://doc.babylonjs.com/classes/3.1/texture
  109009. */
  109010. renderTargetSamplingMode: number;
  109011. /**
  109012. * Clear color to use when screen clearing
  109013. */
  109014. clearColor: Color4;
  109015. /**
  109016. * If the buffer needs to be cleared before applying the post process. (default: true)
  109017. * Should be set to false if shader will overwrite all previous pixels.
  109018. */
  109019. autoClear: boolean;
  109020. /**
  109021. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  109022. */
  109023. alphaMode: number;
  109024. /**
  109025. * Sets the setAlphaBlendConstants of the babylon engine
  109026. */
  109027. alphaConstants: Color4;
  109028. /**
  109029. * Animations to be used for the post processing
  109030. */
  109031. animations: Animation[];
  109032. /**
  109033. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  109034. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  109035. */
  109036. enablePixelPerfectMode: boolean;
  109037. /**
  109038. * Force the postprocess to be applied without taking in account viewport
  109039. */
  109040. forceFullscreenViewport: boolean;
  109041. /**
  109042. * List of inspectable custom properties (used by the Inspector)
  109043. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109044. */
  109045. inspectableCustomProperties: IInspectable[];
  109046. /**
  109047. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  109048. *
  109049. * | Value | Type | Description |
  109050. * | ----- | ----------------------------------- | ----------- |
  109051. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  109052. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  109053. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  109054. *
  109055. */
  109056. scaleMode: number;
  109057. /**
  109058. * Force textures to be a power of two (default: false)
  109059. */
  109060. alwaysForcePOT: boolean;
  109061. private _samples;
  109062. /**
  109063. * Number of sample textures (default: 1)
  109064. */
  109065. get samples(): number;
  109066. set samples(n: number);
  109067. /**
  109068. * Modify the scale of the post process to be the same as the viewport (default: false)
  109069. */
  109070. adaptScaleToCurrentViewport: boolean;
  109071. private _camera;
  109072. protected _scene: Scene;
  109073. private _engine;
  109074. private _options;
  109075. private _reusable;
  109076. private _textureType;
  109077. private _textureFormat;
  109078. /**
  109079. * Smart array of input and output textures for the post process.
  109080. * @hidden
  109081. */
  109082. _textures: SmartArray<InternalTexture>;
  109083. /**
  109084. * The index in _textures that corresponds to the output texture.
  109085. * @hidden
  109086. */
  109087. _currentRenderTextureInd: number;
  109088. private _effect;
  109089. private _samplers;
  109090. private _fragmentUrl;
  109091. private _vertexUrl;
  109092. private _parameters;
  109093. private _scaleRatio;
  109094. protected _indexParameters: any;
  109095. private _shareOutputWithPostProcess;
  109096. private _texelSize;
  109097. private _forcedOutputTexture;
  109098. /**
  109099. * Prepass configuration in case this post process needs a texture from prepass
  109100. * @hidden
  109101. */
  109102. _prePassEffectConfiguration: PrePassEffectConfiguration;
  109103. /**
  109104. * Returns the fragment url or shader name used in the post process.
  109105. * @returns the fragment url or name in the shader store.
  109106. */
  109107. getEffectName(): string;
  109108. /**
  109109. * An event triggered when the postprocess is activated.
  109110. */
  109111. onActivateObservable: Observable<Camera>;
  109112. private _onActivateObserver;
  109113. /**
  109114. * A function that is added to the onActivateObservable
  109115. */
  109116. set onActivate(callback: Nullable<(camera: Camera) => void>);
  109117. /**
  109118. * An event triggered when the postprocess changes its size.
  109119. */
  109120. onSizeChangedObservable: Observable<PostProcess>;
  109121. private _onSizeChangedObserver;
  109122. /**
  109123. * A function that is added to the onSizeChangedObservable
  109124. */
  109125. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  109126. /**
  109127. * An event triggered when the postprocess applies its effect.
  109128. */
  109129. onApplyObservable: Observable<Effect>;
  109130. private _onApplyObserver;
  109131. /**
  109132. * A function that is added to the onApplyObservable
  109133. */
  109134. set onApply(callback: (effect: Effect) => void);
  109135. /**
  109136. * An event triggered before rendering the postprocess
  109137. */
  109138. onBeforeRenderObservable: Observable<Effect>;
  109139. private _onBeforeRenderObserver;
  109140. /**
  109141. * A function that is added to the onBeforeRenderObservable
  109142. */
  109143. set onBeforeRender(callback: (effect: Effect) => void);
  109144. /**
  109145. * An event triggered after rendering the postprocess
  109146. */
  109147. onAfterRenderObservable: Observable<Effect>;
  109148. private _onAfterRenderObserver;
  109149. /**
  109150. * A function that is added to the onAfterRenderObservable
  109151. */
  109152. set onAfterRender(callback: (efect: Effect) => void);
  109153. /**
  109154. * 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
  109155. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  109156. */
  109157. get inputTexture(): InternalTexture;
  109158. set inputTexture(value: InternalTexture);
  109159. /**
  109160. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  109161. * the only way to unset it is to use this function to restore its internal state
  109162. */
  109163. restoreDefaultInputTexture(): void;
  109164. /**
  109165. * Gets the camera which post process is applied to.
  109166. * @returns The camera the post process is applied to.
  109167. */
  109168. getCamera(): Camera;
  109169. /**
  109170. * Gets the texel size of the postprocess.
  109171. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  109172. */
  109173. get texelSize(): Vector2;
  109174. /**
  109175. * Creates a new instance PostProcess
  109176. * @param name The name of the PostProcess.
  109177. * @param fragmentUrl The url of the fragment shader to be used.
  109178. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  109179. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  109180. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  109181. * @param camera The camera to apply the render pass to.
  109182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109183. * @param engine The engine which the post process will be applied. (default: current engine)
  109184. * @param reusable If the post process can be reused on the same frame. (default: false)
  109185. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  109186. * @param textureType Type of textures used when performing the post process. (default: 0)
  109187. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  109188. * @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
  109189. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  109190. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  109191. */
  109192. 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);
  109193. /**
  109194. * Gets a string identifying the name of the class
  109195. * @returns "PostProcess" string
  109196. */
  109197. getClassName(): string;
  109198. /**
  109199. * Gets the engine which this post process belongs to.
  109200. * @returns The engine the post process was enabled with.
  109201. */
  109202. getEngine(): Engine;
  109203. /**
  109204. * The effect that is created when initializing the post process.
  109205. * @returns The created effect corresponding the the postprocess.
  109206. */
  109207. getEffect(): Effect;
  109208. /**
  109209. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  109210. * @param postProcess The post process to share the output with.
  109211. * @returns This post process.
  109212. */
  109213. shareOutputWith(postProcess: PostProcess): PostProcess;
  109214. /**
  109215. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  109216. * This should be called if the post process that shares output with this post process is disabled/disposed.
  109217. */
  109218. useOwnOutput(): void;
  109219. /**
  109220. * Updates the effect with the current post process compile time values and recompiles the shader.
  109221. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109222. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109223. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109224. * @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
  109225. * @param onCompiled Called when the shader has been compiled.
  109226. * @param onError Called if there is an error when compiling a shader.
  109227. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  109228. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  109229. */
  109230. 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;
  109231. /**
  109232. * The post process is reusable if it can be used multiple times within one frame.
  109233. * @returns If the post process is reusable
  109234. */
  109235. isReusable(): boolean;
  109236. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  109237. markTextureDirty(): void;
  109238. /**
  109239. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  109240. * 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.
  109241. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  109242. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  109243. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  109244. * @returns The target texture that was bound to be written to.
  109245. */
  109246. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  109247. /**
  109248. * If the post process is supported.
  109249. */
  109250. get isSupported(): boolean;
  109251. /**
  109252. * The aspect ratio of the output texture.
  109253. */
  109254. get aspectRatio(): number;
  109255. /**
  109256. * Get a value indicating if the post-process is ready to be used
  109257. * @returns true if the post-process is ready (shader is compiled)
  109258. */
  109259. isReady(): boolean;
  109260. /**
  109261. * Binds all textures and uniforms to the shader, this will be run on every pass.
  109262. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  109263. */
  109264. apply(): Nullable<Effect>;
  109265. private _disposeTextures;
  109266. /**
  109267. * Sets the required values to the prepass renderer.
  109268. * @param prePassRenderer defines the prepass renderer to setup.
  109269. * @returns true if the pre pass is needed.
  109270. */
  109271. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  109272. /**
  109273. * Disposes the post process.
  109274. * @param camera The camera to dispose the post process on.
  109275. */
  109276. dispose(camera?: Camera): void;
  109277. /**
  109278. * Serializes the particle system to a JSON object
  109279. * @returns the JSON object
  109280. */
  109281. serialize(): any;
  109282. /**
  109283. * Creates a material from parsed material data
  109284. * @param parsedPostProcess defines parsed post process data
  109285. * @param scene defines the hosting scene
  109286. * @param rootUrl defines the root URL to use to load textures
  109287. * @returns a new post process
  109288. */
  109289. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  109290. }
  109291. }
  109292. declare module BABYLON {
  109293. /** @hidden */
  109294. export var kernelBlurVaryingDeclaration: {
  109295. name: string;
  109296. shader: string;
  109297. };
  109298. }
  109299. declare module BABYLON {
  109300. /** @hidden */
  109301. export var kernelBlurFragment: {
  109302. name: string;
  109303. shader: string;
  109304. };
  109305. }
  109306. declare module BABYLON {
  109307. /** @hidden */
  109308. export var kernelBlurFragment2: {
  109309. name: string;
  109310. shader: string;
  109311. };
  109312. }
  109313. declare module BABYLON {
  109314. /** @hidden */
  109315. export var kernelBlurPixelShader: {
  109316. name: string;
  109317. shader: string;
  109318. };
  109319. }
  109320. declare module BABYLON {
  109321. /** @hidden */
  109322. export var kernelBlurVertex: {
  109323. name: string;
  109324. shader: string;
  109325. };
  109326. }
  109327. declare module BABYLON {
  109328. /** @hidden */
  109329. export var kernelBlurVertexShader: {
  109330. name: string;
  109331. shader: string;
  109332. };
  109333. }
  109334. declare module BABYLON {
  109335. /**
  109336. * The Blur Post Process which blurs an image based on a kernel and direction.
  109337. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  109338. */
  109339. export class BlurPostProcess extends PostProcess {
  109340. private blockCompilation;
  109341. protected _kernel: number;
  109342. protected _idealKernel: number;
  109343. protected _packedFloat: boolean;
  109344. private _staticDefines;
  109345. /** The direction in which to blur the image. */
  109346. direction: Vector2;
  109347. /**
  109348. * Sets the length in pixels of the blur sample region
  109349. */
  109350. set kernel(v: number);
  109351. /**
  109352. * Gets the length in pixels of the blur sample region
  109353. */
  109354. get kernel(): number;
  109355. /**
  109356. * Sets wether or not the blur needs to unpack/repack floats
  109357. */
  109358. set packedFloat(v: boolean);
  109359. /**
  109360. * Gets wether or not the blur is unpacking/repacking floats
  109361. */
  109362. get packedFloat(): boolean;
  109363. /**
  109364. * Gets a string identifying the name of the class
  109365. * @returns "BlurPostProcess" string
  109366. */
  109367. getClassName(): string;
  109368. /**
  109369. * Creates a new instance BlurPostProcess
  109370. * @param name The name of the effect.
  109371. * @param direction The direction in which to blur the image.
  109372. * @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.
  109373. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  109374. * @param camera The camera to apply the render pass to.
  109375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109376. * @param engine The engine which the post process will be applied. (default: current engine)
  109377. * @param reusable If the post process can be reused on the same frame. (default: false)
  109378. * @param textureType Type of textures used when performing the post process. (default: 0)
  109379. * @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)
  109380. */
  109381. 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);
  109382. /**
  109383. * Updates the effect with the current post process compile time values and recompiles the shader.
  109384. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109385. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109386. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109387. * @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
  109388. * @param onCompiled Called when the shader has been compiled.
  109389. * @param onError Called if there is an error when compiling a shader.
  109390. */
  109391. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109392. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109393. /**
  109394. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  109395. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  109396. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  109397. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  109398. * The gaps between physical kernels are compensated for in the weighting of the samples
  109399. * @param idealKernel Ideal blur kernel.
  109400. * @return Nearest best kernel.
  109401. */
  109402. protected _nearestBestKernel(idealKernel: number): number;
  109403. /**
  109404. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  109405. * @param x The point on the Gaussian distribution to sample.
  109406. * @return the value of the Gaussian function at x.
  109407. */
  109408. protected _gaussianWeight(x: number): number;
  109409. /**
  109410. * Generates a string that can be used as a floating point number in GLSL.
  109411. * @param x Value to print.
  109412. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  109413. * @return GLSL float string.
  109414. */
  109415. protected _glslFloat(x: number, decimalFigures?: number): string;
  109416. /** @hidden */
  109417. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  109418. }
  109419. }
  109420. declare module BABYLON {
  109421. /**
  109422. * Mirror texture can be used to simulate the view from a mirror in a scene.
  109423. * It will dynamically be rendered every frame to adapt to the camera point of view.
  109424. * You can then easily use it as a reflectionTexture on a flat surface.
  109425. * In case the surface is not a plane, please consider relying on reflection probes.
  109426. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109427. */
  109428. export class MirrorTexture extends RenderTargetTexture {
  109429. private scene;
  109430. /**
  109431. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  109432. * 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.
  109433. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109434. */
  109435. mirrorPlane: Plane;
  109436. /**
  109437. * Define the blur ratio used to blur the reflection if needed.
  109438. */
  109439. set blurRatio(value: number);
  109440. get blurRatio(): number;
  109441. /**
  109442. * Define the adaptive blur kernel used to blur the reflection if needed.
  109443. * This will autocompute the closest best match for the `blurKernel`
  109444. */
  109445. set adaptiveBlurKernel(value: number);
  109446. /**
  109447. * Define the blur kernel used to blur the reflection if needed.
  109448. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109449. */
  109450. set blurKernel(value: number);
  109451. /**
  109452. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  109453. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109454. */
  109455. set blurKernelX(value: number);
  109456. get blurKernelX(): number;
  109457. /**
  109458. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  109459. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109460. */
  109461. set blurKernelY(value: number);
  109462. get blurKernelY(): number;
  109463. private _autoComputeBlurKernel;
  109464. protected _onRatioRescale(): void;
  109465. private _updateGammaSpace;
  109466. private _imageProcessingConfigChangeObserver;
  109467. private _transformMatrix;
  109468. private _mirrorMatrix;
  109469. private _savedViewMatrix;
  109470. private _blurX;
  109471. private _blurY;
  109472. private _adaptiveBlurKernel;
  109473. private _blurKernelX;
  109474. private _blurKernelY;
  109475. private _blurRatio;
  109476. /**
  109477. * Instantiates a Mirror Texture.
  109478. * Mirror texture can be used to simulate the view from a mirror in a scene.
  109479. * It will dynamically be rendered every frame to adapt to the camera point of view.
  109480. * You can then easily use it as a reflectionTexture on a flat surface.
  109481. * In case the surface is not a plane, please consider relying on reflection probes.
  109482. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109483. * @param name
  109484. * @param size
  109485. * @param scene
  109486. * @param generateMipMaps
  109487. * @param type
  109488. * @param samplingMode
  109489. * @param generateDepthBuffer
  109490. */
  109491. constructor(name: string, size: number | {
  109492. width: number;
  109493. height: number;
  109494. } | {
  109495. ratio: number;
  109496. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  109497. private _preparePostProcesses;
  109498. /**
  109499. * Clone the mirror texture.
  109500. * @returns the cloned texture
  109501. */
  109502. clone(): MirrorTexture;
  109503. /**
  109504. * Serialize the texture to a JSON representation you could use in Parse later on
  109505. * @returns the serialized JSON representation
  109506. */
  109507. serialize(): any;
  109508. /**
  109509. * Dispose the texture and release its associated resources.
  109510. */
  109511. dispose(): void;
  109512. }
  109513. }
  109514. declare module BABYLON {
  109515. /**
  109516. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  109517. * @see https://doc.babylonjs.com/babylon101/materials#texture
  109518. */
  109519. export class Texture extends BaseTexture {
  109520. /**
  109521. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  109522. */
  109523. static SerializeBuffers: boolean;
  109524. /**
  109525. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  109526. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  109527. */
  109528. static ForceSerializeBuffers: boolean;
  109529. /** @hidden */
  109530. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  109531. /** @hidden */
  109532. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  109533. /** @hidden */
  109534. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  109535. /** nearest is mag = nearest and min = nearest and mip = linear */
  109536. static readonly NEAREST_SAMPLINGMODE: number;
  109537. /** nearest is mag = nearest and min = nearest and mip = linear */
  109538. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  109539. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109540. static readonly BILINEAR_SAMPLINGMODE: number;
  109541. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109542. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  109543. /** Trilinear is mag = linear and min = linear and mip = linear */
  109544. static readonly TRILINEAR_SAMPLINGMODE: number;
  109545. /** Trilinear is mag = linear and min = linear and mip = linear */
  109546. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  109547. /** mag = nearest and min = nearest and mip = nearest */
  109548. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  109549. /** mag = nearest and min = linear and mip = nearest */
  109550. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  109551. /** mag = nearest and min = linear and mip = linear */
  109552. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  109553. /** mag = nearest and min = linear and mip = none */
  109554. static readonly NEAREST_LINEAR: number;
  109555. /** mag = nearest and min = nearest and mip = none */
  109556. static readonly NEAREST_NEAREST: number;
  109557. /** mag = linear and min = nearest and mip = nearest */
  109558. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  109559. /** mag = linear and min = nearest and mip = linear */
  109560. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  109561. /** mag = linear and min = linear and mip = none */
  109562. static readonly LINEAR_LINEAR: number;
  109563. /** mag = linear and min = nearest and mip = none */
  109564. static readonly LINEAR_NEAREST: number;
  109565. /** Explicit coordinates mode */
  109566. static readonly EXPLICIT_MODE: number;
  109567. /** Spherical coordinates mode */
  109568. static readonly SPHERICAL_MODE: number;
  109569. /** Planar coordinates mode */
  109570. static readonly PLANAR_MODE: number;
  109571. /** Cubic coordinates mode */
  109572. static readonly CUBIC_MODE: number;
  109573. /** Projection coordinates mode */
  109574. static readonly PROJECTION_MODE: number;
  109575. /** Inverse Cubic coordinates mode */
  109576. static readonly SKYBOX_MODE: number;
  109577. /** Inverse Cubic coordinates mode */
  109578. static readonly INVCUBIC_MODE: number;
  109579. /** Equirectangular coordinates mode */
  109580. static readonly EQUIRECTANGULAR_MODE: number;
  109581. /** Equirectangular Fixed coordinates mode */
  109582. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  109583. /** Equirectangular Fixed Mirrored coordinates mode */
  109584. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  109585. /** Texture is not repeating outside of 0..1 UVs */
  109586. static readonly CLAMP_ADDRESSMODE: number;
  109587. /** Texture is repeating outside of 0..1 UVs */
  109588. static readonly WRAP_ADDRESSMODE: number;
  109589. /** Texture is repeating and mirrored */
  109590. static readonly MIRROR_ADDRESSMODE: number;
  109591. /**
  109592. * 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
  109593. */
  109594. static UseSerializedUrlIfAny: boolean;
  109595. /**
  109596. * Define the url of the texture.
  109597. */
  109598. url: Nullable<string>;
  109599. /**
  109600. * Define an offset on the texture to offset the u coordinates of the UVs
  109601. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  109602. */
  109603. uOffset: number;
  109604. /**
  109605. * Define an offset on the texture to offset the v coordinates of the UVs
  109606. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  109607. */
  109608. vOffset: number;
  109609. /**
  109610. * Define an offset on the texture to scale the u coordinates of the UVs
  109611. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  109612. */
  109613. uScale: number;
  109614. /**
  109615. * Define an offset on the texture to scale the v coordinates of the UVs
  109616. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  109617. */
  109618. vScale: number;
  109619. /**
  109620. * Define an offset on the texture to rotate around the u coordinates of the UVs
  109621. * @see https://doc.babylonjs.com/how_to/more_materials
  109622. */
  109623. uAng: number;
  109624. /**
  109625. * Define an offset on the texture to rotate around the v coordinates of the UVs
  109626. * @see https://doc.babylonjs.com/how_to/more_materials
  109627. */
  109628. vAng: number;
  109629. /**
  109630. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  109631. * @see https://doc.babylonjs.com/how_to/more_materials
  109632. */
  109633. wAng: number;
  109634. /**
  109635. * Defines the center of rotation (U)
  109636. */
  109637. uRotationCenter: number;
  109638. /**
  109639. * Defines the center of rotation (V)
  109640. */
  109641. vRotationCenter: number;
  109642. /**
  109643. * Defines the center of rotation (W)
  109644. */
  109645. wRotationCenter: number;
  109646. /**
  109647. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  109648. */
  109649. homogeneousRotationInUVTransform: boolean;
  109650. /**
  109651. * Are mip maps generated for this texture or not.
  109652. */
  109653. get noMipmap(): boolean;
  109654. /**
  109655. * List of inspectable custom properties (used by the Inspector)
  109656. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109657. */
  109658. inspectableCustomProperties: Nullable<IInspectable[]>;
  109659. private _noMipmap;
  109660. /** @hidden */
  109661. _invertY: boolean;
  109662. private _rowGenerationMatrix;
  109663. private _cachedTextureMatrix;
  109664. private _projectionModeMatrix;
  109665. private _t0;
  109666. private _t1;
  109667. private _t2;
  109668. private _cachedUOffset;
  109669. private _cachedVOffset;
  109670. private _cachedUScale;
  109671. private _cachedVScale;
  109672. private _cachedUAng;
  109673. private _cachedVAng;
  109674. private _cachedWAng;
  109675. private _cachedProjectionMatrixId;
  109676. private _cachedURotationCenter;
  109677. private _cachedVRotationCenter;
  109678. private _cachedWRotationCenter;
  109679. private _cachedHomogeneousRotationInUVTransform;
  109680. private _cachedCoordinatesMode;
  109681. /** @hidden */
  109682. protected _initialSamplingMode: number;
  109683. /** @hidden */
  109684. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  109685. private _deleteBuffer;
  109686. protected _format: Nullable<number>;
  109687. private _delayedOnLoad;
  109688. private _delayedOnError;
  109689. private _mimeType?;
  109690. private _loaderOptions?;
  109691. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  109692. get mimeType(): string | undefined;
  109693. /**
  109694. * Observable triggered once the texture has been loaded.
  109695. */
  109696. onLoadObservable: Observable<Texture>;
  109697. protected _isBlocking: boolean;
  109698. /**
  109699. * Is the texture preventing material to render while loading.
  109700. * If false, a default texture will be used instead of the loading one during the preparation step.
  109701. */
  109702. set isBlocking(value: boolean);
  109703. get isBlocking(): boolean;
  109704. /**
  109705. * Get the current sampling mode associated with the texture.
  109706. */
  109707. get samplingMode(): number;
  109708. /**
  109709. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  109710. */
  109711. get invertY(): boolean;
  109712. /**
  109713. * Instantiates a new texture.
  109714. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  109715. * @see https://doc.babylonjs.com/babylon101/materials#texture
  109716. * @param url defines the url of the picture to load as a texture
  109717. * @param sceneOrEngine defines the scene or engine the texture will belong to
  109718. * @param noMipmap defines if the texture will require mip maps or not
  109719. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  109720. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109721. * @param onLoad defines a callback triggered when the texture has been loaded
  109722. * @param onError defines a callback triggered when an error occurred during the loading session
  109723. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  109724. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  109725. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109726. * @param mimeType defines an optional mime type information
  109727. * @param loaderOptions options to be passed to the loader
  109728. */
  109729. 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);
  109730. /**
  109731. * Update the url (and optional buffer) of this texture if url was null during construction.
  109732. * @param url the url of the texture
  109733. * @param buffer the buffer of the texture (defaults to null)
  109734. * @param onLoad callback called when the texture is loaded (defaults to null)
  109735. */
  109736. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  109737. /**
  109738. * Finish the loading sequence of a texture flagged as delayed load.
  109739. * @hidden
  109740. */
  109741. delayLoad(): void;
  109742. private _prepareRowForTextureGeneration;
  109743. /**
  109744. * Checks if the texture has the same transform matrix than another texture
  109745. * @param texture texture to check against
  109746. * @returns true if the transforms are the same, else false
  109747. */
  109748. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  109749. /**
  109750. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  109751. * @returns the transform matrix of the texture.
  109752. */
  109753. getTextureMatrix(uBase?: number): Matrix;
  109754. /**
  109755. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  109756. * @returns The reflection texture transform
  109757. */
  109758. getReflectionTextureMatrix(): Matrix;
  109759. /**
  109760. * Clones the texture.
  109761. * @returns the cloned texture
  109762. */
  109763. clone(): Texture;
  109764. /**
  109765. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109766. * @returns The JSON representation of the texture
  109767. */
  109768. serialize(): any;
  109769. /**
  109770. * Get the current class name of the texture useful for serialization or dynamic coding.
  109771. * @returns "Texture"
  109772. */
  109773. getClassName(): string;
  109774. /**
  109775. * Dispose the texture and release its associated resources.
  109776. */
  109777. dispose(): void;
  109778. /**
  109779. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  109780. * @param parsedTexture Define the JSON representation of the texture
  109781. * @param scene Define the scene the parsed texture should be instantiated in
  109782. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  109783. * @returns The parsed texture if successful
  109784. */
  109785. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  109786. /**
  109787. * Creates a texture from its base 64 representation.
  109788. * @param data Define the base64 payload without the data: prefix
  109789. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109790. * @param scene Define the scene the texture should belong to
  109791. * @param noMipmap Forces the texture to not create mip map information if true
  109792. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109793. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109794. * @param onLoad define a callback triggered when the texture has been loaded
  109795. * @param onError define a callback triggered when an error occurred during the loading session
  109796. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109797. * @returns the created texture
  109798. */
  109799. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  109800. /**
  109801. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  109802. * @param data Define the base64 payload without the data: prefix
  109803. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109804. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  109805. * @param scene Define the scene the texture should belong to
  109806. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  109807. * @param noMipmap Forces the texture to not create mip map information if true
  109808. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109809. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109810. * @param onLoad define a callback triggered when the texture has been loaded
  109811. * @param onError define a callback triggered when an error occurred during the loading session
  109812. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109813. * @returns the created texture
  109814. */
  109815. 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;
  109816. }
  109817. }
  109818. declare module BABYLON {
  109819. /**
  109820. * PostProcessManager is used to manage one or more post processes or post process pipelines
  109821. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109822. */
  109823. export class PostProcessManager {
  109824. private _scene;
  109825. private _indexBuffer;
  109826. private _vertexBuffers;
  109827. /**
  109828. * Creates a new instance PostProcess
  109829. * @param scene The scene that the post process is associated with.
  109830. */
  109831. constructor(scene: Scene);
  109832. private _prepareBuffers;
  109833. private _buildIndexBuffer;
  109834. /**
  109835. * Rebuilds the vertex buffers of the manager.
  109836. * @hidden
  109837. */
  109838. _rebuild(): void;
  109839. /**
  109840. * Prepares a frame to be run through a post process.
  109841. * @param sourceTexture The input texture to the post procesess. (default: null)
  109842. * @param postProcesses An array of post processes to be run. (default: null)
  109843. * @returns True if the post processes were able to be run.
  109844. * @hidden
  109845. */
  109846. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  109847. /**
  109848. * Manually render a set of post processes to a texture.
  109849. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  109850. * @param postProcesses An array of post processes to be run.
  109851. * @param targetTexture The target texture to render to.
  109852. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  109853. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  109854. * @param lodLevel defines which lod of the texture to render to
  109855. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  109856. */
  109857. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  109858. /**
  109859. * Finalize the result of the output of the postprocesses.
  109860. * @param doNotPresent If true the result will not be displayed to the screen.
  109861. * @param targetTexture The target texture to render to.
  109862. * @param faceIndex The index of the face to bind the target texture to.
  109863. * @param postProcesses The array of post processes to render.
  109864. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  109865. * @hidden
  109866. */
  109867. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  109868. /**
  109869. * Disposes of the post process manager.
  109870. */
  109871. dispose(): void;
  109872. }
  109873. }
  109874. declare module BABYLON {
  109875. /**
  109876. * This Helps creating a texture that will be created from a camera in your scene.
  109877. * It is basically a dynamic texture that could be used to create special effects for instance.
  109878. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  109879. */
  109880. export class RenderTargetTexture extends Texture {
  109881. /**
  109882. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  109883. */
  109884. static readonly REFRESHRATE_RENDER_ONCE: number;
  109885. /**
  109886. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  109887. */
  109888. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  109889. /**
  109890. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  109891. * the central point of your effect and can save a lot of performances.
  109892. */
  109893. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  109894. /**
  109895. * Use this predicate to dynamically define the list of mesh you want to render.
  109896. * If set, the renderList property will be overwritten.
  109897. */
  109898. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  109899. private _renderList;
  109900. /**
  109901. * Use this list to define the list of mesh you want to render.
  109902. */
  109903. get renderList(): Nullable<Array<AbstractMesh>>;
  109904. set renderList(value: Nullable<Array<AbstractMesh>>);
  109905. /**
  109906. * Use this function to overload the renderList array at rendering time.
  109907. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  109908. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  109909. * the cube (if the RTT is a cube, else layerOrFace=0).
  109910. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  109911. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  109912. * hold dummy elements!
  109913. */
  109914. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  109915. private _hookArray;
  109916. /**
  109917. * Define if particles should be rendered in your texture.
  109918. */
  109919. renderParticles: boolean;
  109920. /**
  109921. * Define if sprites should be rendered in your texture.
  109922. */
  109923. renderSprites: boolean;
  109924. /**
  109925. * Define the camera used to render the texture.
  109926. */
  109927. activeCamera: Nullable<Camera>;
  109928. /**
  109929. * Override the mesh isReady function with your own one.
  109930. */
  109931. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  109932. /**
  109933. * Override the render function of the texture with your own one.
  109934. */
  109935. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  109936. /**
  109937. * Define if camera post processes should be use while rendering the texture.
  109938. */
  109939. useCameraPostProcesses: boolean;
  109940. /**
  109941. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  109942. */
  109943. ignoreCameraViewport: boolean;
  109944. private _postProcessManager;
  109945. private _postProcesses;
  109946. private _resizeObserver;
  109947. /**
  109948. * An event triggered when the texture is unbind.
  109949. */
  109950. onBeforeBindObservable: Observable<RenderTargetTexture>;
  109951. /**
  109952. * An event triggered when the texture is unbind.
  109953. */
  109954. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  109955. private _onAfterUnbindObserver;
  109956. /**
  109957. * Set a after unbind callback in the texture.
  109958. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  109959. */
  109960. set onAfterUnbind(callback: () => void);
  109961. /**
  109962. * An event triggered before rendering the texture
  109963. */
  109964. onBeforeRenderObservable: Observable<number>;
  109965. private _onBeforeRenderObserver;
  109966. /**
  109967. * Set a before render callback in the texture.
  109968. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  109969. */
  109970. set onBeforeRender(callback: (faceIndex: number) => void);
  109971. /**
  109972. * An event triggered after rendering the texture
  109973. */
  109974. onAfterRenderObservable: Observable<number>;
  109975. private _onAfterRenderObserver;
  109976. /**
  109977. * Set a after render callback in the texture.
  109978. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  109979. */
  109980. set onAfterRender(callback: (faceIndex: number) => void);
  109981. /**
  109982. * An event triggered after the texture clear
  109983. */
  109984. onClearObservable: Observable<Engine>;
  109985. private _onClearObserver;
  109986. /**
  109987. * Set a clear callback in the texture.
  109988. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  109989. */
  109990. set onClear(callback: (Engine: Engine) => void);
  109991. /**
  109992. * An event triggered when the texture is resized.
  109993. */
  109994. onResizeObservable: Observable<RenderTargetTexture>;
  109995. /**
  109996. * Define the clear color of the Render Target if it should be different from the scene.
  109997. */
  109998. clearColor: Color4;
  109999. protected _size: number | {
  110000. width: number;
  110001. height: number;
  110002. layers?: number;
  110003. };
  110004. protected _initialSizeParameter: number | {
  110005. width: number;
  110006. height: number;
  110007. } | {
  110008. ratio: number;
  110009. };
  110010. protected _sizeRatio: Nullable<number>;
  110011. /** @hidden */
  110012. _generateMipMaps: boolean;
  110013. protected _renderingManager: RenderingManager;
  110014. /** @hidden */
  110015. _waitingRenderList?: string[];
  110016. protected _doNotChangeAspectRatio: boolean;
  110017. protected _currentRefreshId: number;
  110018. protected _refreshRate: number;
  110019. protected _textureMatrix: Matrix;
  110020. protected _samples: number;
  110021. protected _renderTargetOptions: RenderTargetCreationOptions;
  110022. /**
  110023. * Gets render target creation options that were used.
  110024. */
  110025. get renderTargetOptions(): RenderTargetCreationOptions;
  110026. protected _onRatioRescale(): void;
  110027. /**
  110028. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  110029. * It must define where the camera used to render the texture is set
  110030. */
  110031. boundingBoxPosition: Vector3;
  110032. private _boundingBoxSize;
  110033. /**
  110034. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  110035. * When defined, the cubemap will switch to local mode
  110036. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  110037. * @example https://www.babylonjs-playground.com/#RNASML
  110038. */
  110039. set boundingBoxSize(value: Vector3);
  110040. get boundingBoxSize(): Vector3;
  110041. /**
  110042. * In case the RTT has been created with a depth texture, get the associated
  110043. * depth texture.
  110044. * Otherwise, return null.
  110045. */
  110046. get depthStencilTexture(): Nullable<InternalTexture>;
  110047. /**
  110048. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  110049. * or used a shadow, depth texture...
  110050. * @param name The friendly name of the texture
  110051. * @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)
  110052. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  110053. * @param generateMipMaps True if mip maps need to be generated after render.
  110054. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  110055. * @param type The type of the buffer in the RTT (int, half float, float...)
  110056. * @param isCube True if a cube texture needs to be created
  110057. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  110058. * @param generateDepthBuffer True to generate a depth buffer
  110059. * @param generateStencilBuffer True to generate a stencil buffer
  110060. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  110061. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  110062. * @param delayAllocation if the texture allocation should be delayed (default: false)
  110063. */
  110064. constructor(name: string, size: number | {
  110065. width: number;
  110066. height: number;
  110067. layers?: number;
  110068. } | {
  110069. ratio: number;
  110070. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  110071. /**
  110072. * Creates a depth stencil texture.
  110073. * This is only available in WebGL 2 or with the depth texture extension available.
  110074. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  110075. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  110076. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  110077. */
  110078. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  110079. private _processSizeParameter;
  110080. /**
  110081. * Define the number of samples to use in case of MSAA.
  110082. * It defaults to one meaning no MSAA has been enabled.
  110083. */
  110084. get samples(): number;
  110085. set samples(value: number);
  110086. /**
  110087. * Resets the refresh counter of the texture and start bak from scratch.
  110088. * Could be useful to regenerate the texture if it is setup to render only once.
  110089. */
  110090. resetRefreshCounter(): void;
  110091. /**
  110092. * Define the refresh rate of the texture or the rendering frequency.
  110093. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  110094. */
  110095. get refreshRate(): number;
  110096. set refreshRate(value: number);
  110097. /**
  110098. * Adds a post process to the render target rendering passes.
  110099. * @param postProcess define the post process to add
  110100. */
  110101. addPostProcess(postProcess: PostProcess): void;
  110102. /**
  110103. * Clear all the post processes attached to the render target
  110104. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  110105. */
  110106. clearPostProcesses(dispose?: boolean): void;
  110107. /**
  110108. * Remove one of the post process from the list of attached post processes to the texture
  110109. * @param postProcess define the post process to remove from the list
  110110. */
  110111. removePostProcess(postProcess: PostProcess): void;
  110112. /** @hidden */
  110113. _shouldRender(): boolean;
  110114. /**
  110115. * Gets the actual render size of the texture.
  110116. * @returns the width of the render size
  110117. */
  110118. getRenderSize(): number;
  110119. /**
  110120. * Gets the actual render width of the texture.
  110121. * @returns the width of the render size
  110122. */
  110123. getRenderWidth(): number;
  110124. /**
  110125. * Gets the actual render height of the texture.
  110126. * @returns the height of the render size
  110127. */
  110128. getRenderHeight(): number;
  110129. /**
  110130. * Gets the actual number of layers of the texture.
  110131. * @returns the number of layers
  110132. */
  110133. getRenderLayers(): number;
  110134. /**
  110135. * Get if the texture can be rescaled or not.
  110136. */
  110137. get canRescale(): boolean;
  110138. /**
  110139. * Resize the texture using a ratio.
  110140. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  110141. */
  110142. scale(ratio: number): void;
  110143. /**
  110144. * Get the texture reflection matrix used to rotate/transform the reflection.
  110145. * @returns the reflection matrix
  110146. */
  110147. getReflectionTextureMatrix(): Matrix;
  110148. /**
  110149. * Resize the texture to a new desired size.
  110150. * Be carrefull as it will recreate all the data in the new texture.
  110151. * @param size Define the new size. It can be:
  110152. * - a number for squared texture,
  110153. * - an object containing { width: number, height: number }
  110154. * - or an object containing a ratio { ratio: number }
  110155. */
  110156. resize(size: number | {
  110157. width: number;
  110158. height: number;
  110159. } | {
  110160. ratio: number;
  110161. }): void;
  110162. private _defaultRenderListPrepared;
  110163. /**
  110164. * Renders all the objects from the render list into the texture.
  110165. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  110166. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  110167. */
  110168. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  110169. private _bestReflectionRenderTargetDimension;
  110170. private _prepareRenderingManager;
  110171. /**
  110172. * @hidden
  110173. * @param faceIndex face index to bind to if this is a cubetexture
  110174. * @param layer defines the index of the texture to bind in the array
  110175. */
  110176. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  110177. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  110178. private renderToTarget;
  110179. /**
  110180. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110181. * This allowed control for front to back rendering or reversly depending of the special needs.
  110182. *
  110183. * @param renderingGroupId The rendering group id corresponding to its index
  110184. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110185. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110186. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110187. */
  110188. 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;
  110189. /**
  110190. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110191. *
  110192. * @param renderingGroupId The rendering group id corresponding to its index
  110193. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110194. */
  110195. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  110196. /**
  110197. * Clones the texture.
  110198. * @returns the cloned texture
  110199. */
  110200. clone(): RenderTargetTexture;
  110201. /**
  110202. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  110203. * @returns The JSON representation of the texture
  110204. */
  110205. serialize(): any;
  110206. /**
  110207. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  110208. */
  110209. disposeFramebufferObjects(): void;
  110210. /**
  110211. * Dispose the texture and release its associated resources.
  110212. */
  110213. dispose(): void;
  110214. /** @hidden */
  110215. _rebuild(): void;
  110216. /**
  110217. * Clear the info related to rendering groups preventing retention point in material dispose.
  110218. */
  110219. freeRenderingGroups(): void;
  110220. /**
  110221. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  110222. * @returns the view count
  110223. */
  110224. getViewCount(): number;
  110225. }
  110226. }
  110227. declare module BABYLON {
  110228. /**
  110229. * Class used to manipulate GUIDs
  110230. */
  110231. export class GUID {
  110232. /**
  110233. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110234. * Be aware Math.random() could cause collisions, but:
  110235. * "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"
  110236. * @returns a pseudo random id
  110237. */
  110238. static RandomId(): string;
  110239. }
  110240. }
  110241. declare module BABYLON {
  110242. /**
  110243. * Options to be used when creating a shadow depth material
  110244. */
  110245. export interface IIOptionShadowDepthMaterial {
  110246. /** Variables in the vertex shader code that need to have their names remapped.
  110247. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  110248. * "var_name" should be either: worldPos or vNormalW
  110249. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  110250. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  110251. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  110252. */
  110253. remappedVariables?: string[];
  110254. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  110255. standalone?: boolean;
  110256. }
  110257. /**
  110258. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  110259. */
  110260. export class ShadowDepthWrapper {
  110261. private _scene;
  110262. private _options?;
  110263. private _baseMaterial;
  110264. private _onEffectCreatedObserver;
  110265. private _subMeshToEffect;
  110266. private _subMeshToDepthEffect;
  110267. private _meshes;
  110268. /** @hidden */
  110269. _matriceNames: any;
  110270. /** Gets the standalone status of the wrapper */
  110271. get standalone(): boolean;
  110272. /** Gets the base material the wrapper is built upon */
  110273. get baseMaterial(): Material;
  110274. /**
  110275. * Instantiate a new shadow depth wrapper.
  110276. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  110277. * generate the shadow depth map. For more information, please refer to the documentation:
  110278. * https://doc.babylonjs.com/babylon101/shadows
  110279. * @param baseMaterial Material to wrap
  110280. * @param scene Define the scene the material belongs to
  110281. * @param options Options used to create the wrapper
  110282. */
  110283. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  110284. /**
  110285. * Gets the effect to use to generate the depth map
  110286. * @param subMesh subMesh to get the effect for
  110287. * @param shadowGenerator shadow generator to get the effect for
  110288. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  110289. */
  110290. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  110291. /**
  110292. * Specifies that the submesh is ready to be used for depth rendering
  110293. * @param subMesh submesh to check
  110294. * @param defines the list of defines to take into account when checking the effect
  110295. * @param shadowGenerator combined with subMesh, it defines the effect to check
  110296. * @param useInstances specifies that instances should be used
  110297. * @returns a boolean indicating that the submesh is ready or not
  110298. */
  110299. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  110300. /**
  110301. * Disposes the resources
  110302. */
  110303. dispose(): void;
  110304. private _makeEffect;
  110305. }
  110306. }
  110307. declare module BABYLON {
  110308. /**
  110309. * Options for compiling materials.
  110310. */
  110311. export interface IMaterialCompilationOptions {
  110312. /**
  110313. * Defines whether clip planes are enabled.
  110314. */
  110315. clipPlane: boolean;
  110316. /**
  110317. * Defines whether instances are enabled.
  110318. */
  110319. useInstances: boolean;
  110320. }
  110321. /**
  110322. * Options passed when calling customShaderNameResolve
  110323. */
  110324. export interface ICustomShaderNameResolveOptions {
  110325. /**
  110326. * 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
  110327. */
  110328. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110329. }
  110330. /**
  110331. * Base class for the main features of a material in Babylon.js
  110332. */
  110333. export class Material implements IAnimatable {
  110334. /**
  110335. * Returns the triangle fill mode
  110336. */
  110337. static readonly TriangleFillMode: number;
  110338. /**
  110339. * Returns the wireframe mode
  110340. */
  110341. static readonly WireFrameFillMode: number;
  110342. /**
  110343. * Returns the point fill mode
  110344. */
  110345. static readonly PointFillMode: number;
  110346. /**
  110347. * Returns the point list draw mode
  110348. */
  110349. static readonly PointListDrawMode: number;
  110350. /**
  110351. * Returns the line list draw mode
  110352. */
  110353. static readonly LineListDrawMode: number;
  110354. /**
  110355. * Returns the line loop draw mode
  110356. */
  110357. static readonly LineLoopDrawMode: number;
  110358. /**
  110359. * Returns the line strip draw mode
  110360. */
  110361. static readonly LineStripDrawMode: number;
  110362. /**
  110363. * Returns the triangle strip draw mode
  110364. */
  110365. static readonly TriangleStripDrawMode: number;
  110366. /**
  110367. * Returns the triangle fan draw mode
  110368. */
  110369. static readonly TriangleFanDrawMode: number;
  110370. /**
  110371. * Stores the clock-wise side orientation
  110372. */
  110373. static readonly ClockWiseSideOrientation: number;
  110374. /**
  110375. * Stores the counter clock-wise side orientation
  110376. */
  110377. static readonly CounterClockWiseSideOrientation: number;
  110378. /**
  110379. * The dirty texture flag value
  110380. */
  110381. static readonly TextureDirtyFlag: number;
  110382. /**
  110383. * The dirty light flag value
  110384. */
  110385. static readonly LightDirtyFlag: number;
  110386. /**
  110387. * The dirty fresnel flag value
  110388. */
  110389. static readonly FresnelDirtyFlag: number;
  110390. /**
  110391. * The dirty attribute flag value
  110392. */
  110393. static readonly AttributesDirtyFlag: number;
  110394. /**
  110395. * The dirty misc flag value
  110396. */
  110397. static readonly MiscDirtyFlag: number;
  110398. /**
  110399. * The dirty prepass flag value
  110400. */
  110401. static readonly PrePassDirtyFlag: number;
  110402. /**
  110403. * The all dirty flag value
  110404. */
  110405. static readonly AllDirtyFlag: number;
  110406. /**
  110407. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110408. */
  110409. static readonly MATERIAL_OPAQUE: number;
  110410. /**
  110411. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110412. */
  110413. static readonly MATERIAL_ALPHATEST: number;
  110414. /**
  110415. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110416. */
  110417. static readonly MATERIAL_ALPHABLEND: number;
  110418. /**
  110419. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110420. * They are also discarded below the alpha cutoff threshold to improve performances.
  110421. */
  110422. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  110423. /**
  110424. * The Whiteout method is used to blend normals.
  110425. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110426. */
  110427. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  110428. /**
  110429. * The Reoriented Normal Mapping method is used to blend normals.
  110430. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110431. */
  110432. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  110433. /**
  110434. * Custom callback helping to override the default shader used in the material.
  110435. */
  110436. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  110437. /**
  110438. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  110439. */
  110440. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  110441. /**
  110442. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  110443. * This means that the material can keep using a previous shader while a new one is being compiled.
  110444. * This is mostly used when shader parallel compilation is supported (true by default)
  110445. */
  110446. allowShaderHotSwapping: boolean;
  110447. /**
  110448. * The ID of the material
  110449. */
  110450. id: string;
  110451. /**
  110452. * Gets or sets the unique id of the material
  110453. */
  110454. uniqueId: number;
  110455. /**
  110456. * The name of the material
  110457. */
  110458. name: string;
  110459. /**
  110460. * Gets or sets user defined metadata
  110461. */
  110462. metadata: any;
  110463. /**
  110464. * For internal use only. Please do not use.
  110465. */
  110466. reservedDataStore: any;
  110467. /**
  110468. * Specifies if the ready state should be checked on each call
  110469. */
  110470. checkReadyOnEveryCall: boolean;
  110471. /**
  110472. * Specifies if the ready state should be checked once
  110473. */
  110474. checkReadyOnlyOnce: boolean;
  110475. /**
  110476. * The state of the material
  110477. */
  110478. state: string;
  110479. /**
  110480. * If the material can be rendered to several textures with MRT extension
  110481. */
  110482. get canRenderToMRT(): boolean;
  110483. /**
  110484. * The alpha value of the material
  110485. */
  110486. protected _alpha: number;
  110487. /**
  110488. * List of inspectable custom properties (used by the Inspector)
  110489. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110490. */
  110491. inspectableCustomProperties: IInspectable[];
  110492. /**
  110493. * Sets the alpha value of the material
  110494. */
  110495. set alpha(value: number);
  110496. /**
  110497. * Gets the alpha value of the material
  110498. */
  110499. get alpha(): number;
  110500. /**
  110501. * Specifies if back face culling is enabled
  110502. */
  110503. protected _backFaceCulling: boolean;
  110504. /**
  110505. * Sets the back-face culling state
  110506. */
  110507. set backFaceCulling(value: boolean);
  110508. /**
  110509. * Gets the back-face culling state
  110510. */
  110511. get backFaceCulling(): boolean;
  110512. /**
  110513. * Stores the value for side orientation
  110514. */
  110515. sideOrientation: number;
  110516. /**
  110517. * Callback triggered when the material is compiled
  110518. */
  110519. onCompiled: Nullable<(effect: Effect) => void>;
  110520. /**
  110521. * Callback triggered when an error occurs
  110522. */
  110523. onError: Nullable<(effect: Effect, errors: string) => void>;
  110524. /**
  110525. * Callback triggered to get the render target textures
  110526. */
  110527. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  110528. /**
  110529. * Gets a boolean indicating that current material needs to register RTT
  110530. */
  110531. get hasRenderTargetTextures(): boolean;
  110532. /**
  110533. * Specifies if the material should be serialized
  110534. */
  110535. doNotSerialize: boolean;
  110536. /**
  110537. * @hidden
  110538. */
  110539. _storeEffectOnSubMeshes: boolean;
  110540. /**
  110541. * Stores the animations for the material
  110542. */
  110543. animations: Nullable<Array<Animation>>;
  110544. /**
  110545. * An event triggered when the material is disposed
  110546. */
  110547. onDisposeObservable: Observable<Material>;
  110548. /**
  110549. * An observer which watches for dispose events
  110550. */
  110551. private _onDisposeObserver;
  110552. private _onUnBindObservable;
  110553. /**
  110554. * Called during a dispose event
  110555. */
  110556. set onDispose(callback: () => void);
  110557. private _onBindObservable;
  110558. /**
  110559. * An event triggered when the material is bound
  110560. */
  110561. get onBindObservable(): Observable<AbstractMesh>;
  110562. /**
  110563. * An observer which watches for bind events
  110564. */
  110565. private _onBindObserver;
  110566. /**
  110567. * Called during a bind event
  110568. */
  110569. set onBind(callback: (Mesh: AbstractMesh) => void);
  110570. /**
  110571. * An event triggered when the material is unbound
  110572. */
  110573. get onUnBindObservable(): Observable<Material>;
  110574. protected _onEffectCreatedObservable: Nullable<Observable<{
  110575. effect: Effect;
  110576. subMesh: Nullable<SubMesh>;
  110577. }>>;
  110578. /**
  110579. * An event triggered when the effect is (re)created
  110580. */
  110581. get onEffectCreatedObservable(): Observable<{
  110582. effect: Effect;
  110583. subMesh: Nullable<SubMesh>;
  110584. }>;
  110585. /**
  110586. * Stores the value of the alpha mode
  110587. */
  110588. private _alphaMode;
  110589. /**
  110590. * Sets the value of the alpha mode.
  110591. *
  110592. * | Value | Type | Description |
  110593. * | --- | --- | --- |
  110594. * | 0 | ALPHA_DISABLE | |
  110595. * | 1 | ALPHA_ADD | |
  110596. * | 2 | ALPHA_COMBINE | |
  110597. * | 3 | ALPHA_SUBTRACT | |
  110598. * | 4 | ALPHA_MULTIPLY | |
  110599. * | 5 | ALPHA_MAXIMIZED | |
  110600. * | 6 | ALPHA_ONEONE | |
  110601. * | 7 | ALPHA_PREMULTIPLIED | |
  110602. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  110603. * | 9 | ALPHA_INTERPOLATE | |
  110604. * | 10 | ALPHA_SCREENMODE | |
  110605. *
  110606. */
  110607. set alphaMode(value: number);
  110608. /**
  110609. * Gets the value of the alpha mode
  110610. */
  110611. get alphaMode(): number;
  110612. /**
  110613. * Stores the state of the need depth pre-pass value
  110614. */
  110615. private _needDepthPrePass;
  110616. /**
  110617. * Sets the need depth pre-pass value
  110618. */
  110619. set needDepthPrePass(value: boolean);
  110620. /**
  110621. * Gets the depth pre-pass value
  110622. */
  110623. get needDepthPrePass(): boolean;
  110624. /**
  110625. * Specifies if depth writing should be disabled
  110626. */
  110627. disableDepthWrite: boolean;
  110628. /**
  110629. * Specifies if color writing should be disabled
  110630. */
  110631. disableColorWrite: boolean;
  110632. /**
  110633. * Specifies if depth writing should be forced
  110634. */
  110635. forceDepthWrite: boolean;
  110636. /**
  110637. * Specifies the depth function that should be used. 0 means the default engine function
  110638. */
  110639. depthFunction: number;
  110640. /**
  110641. * Specifies if there should be a separate pass for culling
  110642. */
  110643. separateCullingPass: boolean;
  110644. /**
  110645. * Stores the state specifing if fog should be enabled
  110646. */
  110647. private _fogEnabled;
  110648. /**
  110649. * Sets the state for enabling fog
  110650. */
  110651. set fogEnabled(value: boolean);
  110652. /**
  110653. * Gets the value of the fog enabled state
  110654. */
  110655. get fogEnabled(): boolean;
  110656. /**
  110657. * Stores the size of points
  110658. */
  110659. pointSize: number;
  110660. /**
  110661. * Stores the z offset value
  110662. */
  110663. zOffset: number;
  110664. get wireframe(): boolean;
  110665. /**
  110666. * Sets the state of wireframe mode
  110667. */
  110668. set wireframe(value: boolean);
  110669. /**
  110670. * Gets the value specifying if point clouds are enabled
  110671. */
  110672. get pointsCloud(): boolean;
  110673. /**
  110674. * Sets the state of point cloud mode
  110675. */
  110676. set pointsCloud(value: boolean);
  110677. /**
  110678. * Gets the material fill mode
  110679. */
  110680. get fillMode(): number;
  110681. /**
  110682. * Sets the material fill mode
  110683. */
  110684. set fillMode(value: number);
  110685. /**
  110686. * @hidden
  110687. * Stores the effects for the material
  110688. */
  110689. _effect: Nullable<Effect>;
  110690. /**
  110691. * Specifies if uniform buffers should be used
  110692. */
  110693. private _useUBO;
  110694. /**
  110695. * Stores a reference to the scene
  110696. */
  110697. private _scene;
  110698. /**
  110699. * Stores the fill mode state
  110700. */
  110701. private _fillMode;
  110702. /**
  110703. * Specifies if the depth write state should be cached
  110704. */
  110705. private _cachedDepthWriteState;
  110706. /**
  110707. * Specifies if the color write state should be cached
  110708. */
  110709. private _cachedColorWriteState;
  110710. /**
  110711. * Specifies if the depth function state should be cached
  110712. */
  110713. private _cachedDepthFunctionState;
  110714. /**
  110715. * Stores the uniform buffer
  110716. */
  110717. protected _uniformBuffer: UniformBuffer;
  110718. /** @hidden */
  110719. _indexInSceneMaterialArray: number;
  110720. /** @hidden */
  110721. meshMap: Nullable<{
  110722. [id: string]: AbstractMesh | undefined;
  110723. }>;
  110724. /**
  110725. * Creates a material instance
  110726. * @param name defines the name of the material
  110727. * @param scene defines the scene to reference
  110728. * @param doNotAdd specifies if the material should be added to the scene
  110729. */
  110730. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  110731. /**
  110732. * Returns a string representation of the current material
  110733. * @param fullDetails defines a boolean indicating which levels of logging is desired
  110734. * @returns a string with material information
  110735. */
  110736. toString(fullDetails?: boolean): string;
  110737. /**
  110738. * Gets the class name of the material
  110739. * @returns a string with the class name of the material
  110740. */
  110741. getClassName(): string;
  110742. /**
  110743. * Specifies if updates for the material been locked
  110744. */
  110745. get isFrozen(): boolean;
  110746. /**
  110747. * Locks updates for the material
  110748. */
  110749. freeze(): void;
  110750. /**
  110751. * Unlocks updates for the material
  110752. */
  110753. unfreeze(): void;
  110754. /**
  110755. * Specifies if the material is ready to be used
  110756. * @param mesh defines the mesh to check
  110757. * @param useInstances specifies if instances should be used
  110758. * @returns a boolean indicating if the material is ready to be used
  110759. */
  110760. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  110761. /**
  110762. * Specifies that the submesh is ready to be used
  110763. * @param mesh defines the mesh to check
  110764. * @param subMesh defines which submesh to check
  110765. * @param useInstances specifies that instances should be used
  110766. * @returns a boolean indicating that the submesh is ready or not
  110767. */
  110768. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110769. /**
  110770. * Returns the material effect
  110771. * @returns the effect associated with the material
  110772. */
  110773. getEffect(): Nullable<Effect>;
  110774. /**
  110775. * Returns the current scene
  110776. * @returns a Scene
  110777. */
  110778. getScene(): Scene;
  110779. /**
  110780. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110781. */
  110782. protected _forceAlphaTest: boolean;
  110783. /**
  110784. * The transparency mode of the material.
  110785. */
  110786. protected _transparencyMode: Nullable<number>;
  110787. /**
  110788. * Gets the current transparency mode.
  110789. */
  110790. get transparencyMode(): Nullable<number>;
  110791. /**
  110792. * Sets the transparency mode of the material.
  110793. *
  110794. * | Value | Type | Description |
  110795. * | ----- | ----------------------------------- | ----------- |
  110796. * | 0 | OPAQUE | |
  110797. * | 1 | ALPHATEST | |
  110798. * | 2 | ALPHABLEND | |
  110799. * | 3 | ALPHATESTANDBLEND | |
  110800. *
  110801. */
  110802. set transparencyMode(value: Nullable<number>);
  110803. /**
  110804. * Returns true if alpha blending should be disabled.
  110805. */
  110806. protected get _disableAlphaBlending(): boolean;
  110807. /**
  110808. * Specifies whether or not this material should be rendered in alpha blend mode.
  110809. * @returns a boolean specifying if alpha blending is needed
  110810. */
  110811. needAlphaBlending(): boolean;
  110812. /**
  110813. * Specifies if the mesh will require alpha blending
  110814. * @param mesh defines the mesh to check
  110815. * @returns a boolean specifying if alpha blending is needed for the mesh
  110816. */
  110817. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110818. /**
  110819. * Specifies whether or not this material should be rendered in alpha test mode.
  110820. * @returns a boolean specifying if an alpha test is needed.
  110821. */
  110822. needAlphaTesting(): boolean;
  110823. /**
  110824. * Specifies if material alpha testing should be turned on for the mesh
  110825. * @param mesh defines the mesh to check
  110826. */
  110827. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  110828. /**
  110829. * Gets the texture used for the alpha test
  110830. * @returns the texture to use for alpha testing
  110831. */
  110832. getAlphaTestTexture(): Nullable<BaseTexture>;
  110833. /**
  110834. * Marks the material to indicate that it needs to be re-calculated
  110835. */
  110836. markDirty(): void;
  110837. /** @hidden */
  110838. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  110839. /**
  110840. * Binds the material to the mesh
  110841. * @param world defines the world transformation matrix
  110842. * @param mesh defines the mesh to bind the material to
  110843. */
  110844. bind(world: Matrix, mesh?: Mesh): void;
  110845. /**
  110846. * Binds the submesh to the material
  110847. * @param world defines the world transformation matrix
  110848. * @param mesh defines the mesh containing the submesh
  110849. * @param subMesh defines the submesh to bind the material to
  110850. */
  110851. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110852. /**
  110853. * Binds the world matrix to the material
  110854. * @param world defines the world transformation matrix
  110855. */
  110856. bindOnlyWorldMatrix(world: Matrix): void;
  110857. /**
  110858. * Binds the scene's uniform buffer to the effect.
  110859. * @param effect defines the effect to bind to the scene uniform buffer
  110860. * @param sceneUbo defines the uniform buffer storing scene data
  110861. */
  110862. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  110863. /**
  110864. * Binds the view matrix to the effect
  110865. * @param effect defines the effect to bind the view matrix to
  110866. */
  110867. bindView(effect: Effect): void;
  110868. /**
  110869. * Binds the view projection matrix to the effect
  110870. * @param effect defines the effect to bind the view projection matrix to
  110871. */
  110872. bindViewProjection(effect: Effect): void;
  110873. /**
  110874. * Processes to execute after binding the material to a mesh
  110875. * @param mesh defines the rendered mesh
  110876. */
  110877. protected _afterBind(mesh?: Mesh): void;
  110878. /**
  110879. * Unbinds the material from the mesh
  110880. */
  110881. unbind(): void;
  110882. /**
  110883. * Gets the active textures from the material
  110884. * @returns an array of textures
  110885. */
  110886. getActiveTextures(): BaseTexture[];
  110887. /**
  110888. * Specifies if the material uses a texture
  110889. * @param texture defines the texture to check against the material
  110890. * @returns a boolean specifying if the material uses the texture
  110891. */
  110892. hasTexture(texture: BaseTexture): boolean;
  110893. /**
  110894. * Makes a duplicate of the material, and gives it a new name
  110895. * @param name defines the new name for the duplicated material
  110896. * @returns the cloned material
  110897. */
  110898. clone(name: string): Nullable<Material>;
  110899. /**
  110900. * Gets the meshes bound to the material
  110901. * @returns an array of meshes bound to the material
  110902. */
  110903. getBindedMeshes(): AbstractMesh[];
  110904. /**
  110905. * Force shader compilation
  110906. * @param mesh defines the mesh associated with this material
  110907. * @param onCompiled defines a function to execute once the material is compiled
  110908. * @param options defines the options to configure the compilation
  110909. * @param onError defines a function to execute if the material fails compiling
  110910. */
  110911. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  110912. /**
  110913. * Force shader compilation
  110914. * @param mesh defines the mesh that will use this material
  110915. * @param options defines additional options for compiling the shaders
  110916. * @returns a promise that resolves when the compilation completes
  110917. */
  110918. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  110919. private static readonly _AllDirtyCallBack;
  110920. private static readonly _ImageProcessingDirtyCallBack;
  110921. private static readonly _TextureDirtyCallBack;
  110922. private static readonly _FresnelDirtyCallBack;
  110923. private static readonly _MiscDirtyCallBack;
  110924. private static readonly _PrePassDirtyCallBack;
  110925. private static readonly _LightsDirtyCallBack;
  110926. private static readonly _AttributeDirtyCallBack;
  110927. private static _FresnelAndMiscDirtyCallBack;
  110928. private static _TextureAndMiscDirtyCallBack;
  110929. private static readonly _DirtyCallbackArray;
  110930. private static readonly _RunDirtyCallBacks;
  110931. /**
  110932. * Marks a define in the material to indicate that it needs to be re-computed
  110933. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  110934. */
  110935. markAsDirty(flag: number): void;
  110936. /**
  110937. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  110938. * @param func defines a function which checks material defines against the submeshes
  110939. */
  110940. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  110941. /**
  110942. * Indicates that the scene should check if the rendering now needs a prepass
  110943. */
  110944. protected _markScenePrePassDirty(): void;
  110945. /**
  110946. * Indicates that we need to re-calculated for all submeshes
  110947. */
  110948. protected _markAllSubMeshesAsAllDirty(): void;
  110949. /**
  110950. * Indicates that image processing needs to be re-calculated for all submeshes
  110951. */
  110952. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  110953. /**
  110954. * Indicates that textures need to be re-calculated for all submeshes
  110955. */
  110956. protected _markAllSubMeshesAsTexturesDirty(): void;
  110957. /**
  110958. * Indicates that fresnel needs to be re-calculated for all submeshes
  110959. */
  110960. protected _markAllSubMeshesAsFresnelDirty(): void;
  110961. /**
  110962. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  110963. */
  110964. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  110965. /**
  110966. * Indicates that lights need to be re-calculated for all submeshes
  110967. */
  110968. protected _markAllSubMeshesAsLightsDirty(): void;
  110969. /**
  110970. * Indicates that attributes need to be re-calculated for all submeshes
  110971. */
  110972. protected _markAllSubMeshesAsAttributesDirty(): void;
  110973. /**
  110974. * Indicates that misc needs to be re-calculated for all submeshes
  110975. */
  110976. protected _markAllSubMeshesAsMiscDirty(): void;
  110977. /**
  110978. * Indicates that prepass needs to be re-calculated for all submeshes
  110979. */
  110980. protected _markAllSubMeshesAsPrePassDirty(): void;
  110981. /**
  110982. * Indicates that textures and misc need to be re-calculated for all submeshes
  110983. */
  110984. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  110985. /**
  110986. * Sets the required values to the prepass renderer.
  110987. * @param prePassRenderer defines the prepass renderer to setup.
  110988. * @returns true if the pre pass is needed.
  110989. */
  110990. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  110991. /**
  110992. * Disposes the material
  110993. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110994. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110995. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  110996. */
  110997. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  110998. /** @hidden */
  110999. private releaseVertexArrayObject;
  111000. /**
  111001. * Serializes this material
  111002. * @returns the serialized material object
  111003. */
  111004. serialize(): any;
  111005. /**
  111006. * Creates a material from parsed material data
  111007. * @param parsedMaterial defines parsed material data
  111008. * @param scene defines the hosting scene
  111009. * @param rootUrl defines the root URL to use to load textures
  111010. * @returns a new material
  111011. */
  111012. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  111013. }
  111014. }
  111015. declare module BABYLON {
  111016. /**
  111017. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111018. * separate meshes. This can be use to improve performances.
  111019. * @see https://doc.babylonjs.com/how_to/multi_materials
  111020. */
  111021. export class MultiMaterial extends Material {
  111022. private _subMaterials;
  111023. /**
  111024. * Gets or Sets the list of Materials used within the multi material.
  111025. * They need to be ordered according to the submeshes order in the associated mesh
  111026. */
  111027. get subMaterials(): Nullable<Material>[];
  111028. set subMaterials(value: Nullable<Material>[]);
  111029. /**
  111030. * Function used to align with Node.getChildren()
  111031. * @returns the list of Materials used within the multi material
  111032. */
  111033. getChildren(): Nullable<Material>[];
  111034. /**
  111035. * Instantiates a new Multi Material
  111036. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111037. * separate meshes. This can be use to improve performances.
  111038. * @see https://doc.babylonjs.com/how_to/multi_materials
  111039. * @param name Define the name in the scene
  111040. * @param scene Define the scene the material belongs to
  111041. */
  111042. constructor(name: string, scene: Scene);
  111043. private _hookArray;
  111044. /**
  111045. * Get one of the submaterial by its index in the submaterials array
  111046. * @param index The index to look the sub material at
  111047. * @returns The Material if the index has been defined
  111048. */
  111049. getSubMaterial(index: number): Nullable<Material>;
  111050. /**
  111051. * Get the list of active textures for the whole sub materials list.
  111052. * @returns All the textures that will be used during the rendering
  111053. */
  111054. getActiveTextures(): BaseTexture[];
  111055. /**
  111056. * Gets the current class name of the material e.g. "MultiMaterial"
  111057. * Mainly use in serialization.
  111058. * @returns the class name
  111059. */
  111060. getClassName(): string;
  111061. /**
  111062. * Checks if the material is ready to render the requested sub mesh
  111063. * @param mesh Define the mesh the submesh belongs to
  111064. * @param subMesh Define the sub mesh to look readyness for
  111065. * @param useInstances Define whether or not the material is used with instances
  111066. * @returns true if ready, otherwise false
  111067. */
  111068. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111069. /**
  111070. * Clones the current material and its related sub materials
  111071. * @param name Define the name of the newly cloned material
  111072. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  111073. * @returns the cloned material
  111074. */
  111075. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  111076. /**
  111077. * Serializes the materials into a JSON representation.
  111078. * @returns the JSON representation
  111079. */
  111080. serialize(): any;
  111081. /**
  111082. * Dispose the material and release its associated resources
  111083. * @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)
  111084. * @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)
  111085. * @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)
  111086. */
  111087. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  111088. /**
  111089. * Creates a MultiMaterial from parsed MultiMaterial data.
  111090. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  111091. * @param scene defines the hosting scene
  111092. * @returns a new MultiMaterial
  111093. */
  111094. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  111095. }
  111096. }
  111097. declare module BABYLON {
  111098. /**
  111099. * Defines a subdivision inside a mesh
  111100. */
  111101. export class SubMesh implements ICullable {
  111102. /** the material index to use */
  111103. materialIndex: number;
  111104. /** vertex index start */
  111105. verticesStart: number;
  111106. /** vertices count */
  111107. verticesCount: number;
  111108. /** index start */
  111109. indexStart: number;
  111110. /** indices count */
  111111. indexCount: number;
  111112. /** @hidden */
  111113. _materialDefines: Nullable<MaterialDefines>;
  111114. /** @hidden */
  111115. _materialEffect: Nullable<Effect>;
  111116. /** @hidden */
  111117. _effectOverride: Nullable<Effect>;
  111118. /**
  111119. * Gets material defines used by the effect associated to the sub mesh
  111120. */
  111121. get materialDefines(): Nullable<MaterialDefines>;
  111122. /**
  111123. * Sets material defines used by the effect associated to the sub mesh
  111124. */
  111125. set materialDefines(defines: Nullable<MaterialDefines>);
  111126. /**
  111127. * Gets associated effect
  111128. */
  111129. get effect(): Nullable<Effect>;
  111130. /**
  111131. * Sets associated effect (effect used to render this submesh)
  111132. * @param effect defines the effect to associate with
  111133. * @param defines defines the set of defines used to compile this effect
  111134. */
  111135. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  111136. /** @hidden */
  111137. _linesIndexCount: number;
  111138. private _mesh;
  111139. private _renderingMesh;
  111140. private _boundingInfo;
  111141. private _linesIndexBuffer;
  111142. /** @hidden */
  111143. _lastColliderWorldVertices: Nullable<Vector3[]>;
  111144. /** @hidden */
  111145. _trianglePlanes: Plane[];
  111146. /** @hidden */
  111147. _lastColliderTransformMatrix: Nullable<Matrix>;
  111148. /** @hidden */
  111149. _renderId: number;
  111150. /** @hidden */
  111151. _alphaIndex: number;
  111152. /** @hidden */
  111153. _distanceToCamera: number;
  111154. /** @hidden */
  111155. _id: number;
  111156. private _currentMaterial;
  111157. /**
  111158. * Add a new submesh to a mesh
  111159. * @param materialIndex defines the material index to use
  111160. * @param verticesStart defines vertex index start
  111161. * @param verticesCount defines vertices count
  111162. * @param indexStart defines index start
  111163. * @param indexCount defines indices count
  111164. * @param mesh defines the parent mesh
  111165. * @param renderingMesh defines an optional rendering mesh
  111166. * @param createBoundingBox defines if bounding box should be created for this submesh
  111167. * @returns the new submesh
  111168. */
  111169. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  111170. /**
  111171. * Creates a new submesh
  111172. * @param materialIndex defines the material index to use
  111173. * @param verticesStart defines vertex index start
  111174. * @param verticesCount defines vertices count
  111175. * @param indexStart defines index start
  111176. * @param indexCount defines indices count
  111177. * @param mesh defines the parent mesh
  111178. * @param renderingMesh defines an optional rendering mesh
  111179. * @param createBoundingBox defines if bounding box should be created for this submesh
  111180. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  111181. */
  111182. constructor(
  111183. /** the material index to use */
  111184. materialIndex: number,
  111185. /** vertex index start */
  111186. verticesStart: number,
  111187. /** vertices count */
  111188. verticesCount: number,
  111189. /** index start */
  111190. indexStart: number,
  111191. /** indices count */
  111192. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  111193. /**
  111194. * Returns true if this submesh covers the entire parent mesh
  111195. * @ignorenaming
  111196. */
  111197. get IsGlobal(): boolean;
  111198. /**
  111199. * Returns the submesh BoudingInfo object
  111200. * @returns current bounding info (or mesh's one if the submesh is global)
  111201. */
  111202. getBoundingInfo(): BoundingInfo;
  111203. /**
  111204. * Sets the submesh BoundingInfo
  111205. * @param boundingInfo defines the new bounding info to use
  111206. * @returns the SubMesh
  111207. */
  111208. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  111209. /**
  111210. * Returns the mesh of the current submesh
  111211. * @return the parent mesh
  111212. */
  111213. getMesh(): AbstractMesh;
  111214. /**
  111215. * Returns the rendering mesh of the submesh
  111216. * @returns the rendering mesh (could be different from parent mesh)
  111217. */
  111218. getRenderingMesh(): Mesh;
  111219. /**
  111220. * Returns the replacement mesh of the submesh
  111221. * @returns the replacement mesh (could be different from parent mesh)
  111222. */
  111223. getReplacementMesh(): Nullable<AbstractMesh>;
  111224. /**
  111225. * Returns the effective mesh of the submesh
  111226. * @returns the effective mesh (could be different from parent mesh)
  111227. */
  111228. getEffectiveMesh(): AbstractMesh;
  111229. /**
  111230. * Returns the submesh material
  111231. * @returns null or the current material
  111232. */
  111233. getMaterial(): Nullable<Material>;
  111234. private _IsMultiMaterial;
  111235. /**
  111236. * Sets a new updated BoundingInfo object to the submesh
  111237. * @param data defines an optional position array to use to determine the bounding info
  111238. * @returns the SubMesh
  111239. */
  111240. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  111241. /** @hidden */
  111242. _checkCollision(collider: Collider): boolean;
  111243. /**
  111244. * Updates the submesh BoundingInfo
  111245. * @param world defines the world matrix to use to update the bounding info
  111246. * @returns the submesh
  111247. */
  111248. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  111249. /**
  111250. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  111251. * @param frustumPlanes defines the frustum planes
  111252. * @returns true if the submesh is intersecting with the frustum
  111253. */
  111254. isInFrustum(frustumPlanes: Plane[]): boolean;
  111255. /**
  111256. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  111257. * @param frustumPlanes defines the frustum planes
  111258. * @returns true if the submesh is inside the frustum
  111259. */
  111260. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111261. /**
  111262. * Renders the submesh
  111263. * @param enableAlphaMode defines if alpha needs to be used
  111264. * @returns the submesh
  111265. */
  111266. render(enableAlphaMode: boolean): SubMesh;
  111267. /**
  111268. * @hidden
  111269. */
  111270. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  111271. /**
  111272. * Checks if the submesh intersects with a ray
  111273. * @param ray defines the ray to test
  111274. * @returns true is the passed ray intersects the submesh bounding box
  111275. */
  111276. canIntersects(ray: Ray): boolean;
  111277. /**
  111278. * Intersects current submesh with a ray
  111279. * @param ray defines the ray to test
  111280. * @param positions defines mesh's positions array
  111281. * @param indices defines mesh's indices array
  111282. * @param fastCheck defines if the first intersection will be used (and not the closest)
  111283. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111284. * @returns intersection info or null if no intersection
  111285. */
  111286. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  111287. /** @hidden */
  111288. private _intersectLines;
  111289. /** @hidden */
  111290. private _intersectUnIndexedLines;
  111291. /** @hidden */
  111292. private _intersectTriangles;
  111293. /** @hidden */
  111294. private _intersectUnIndexedTriangles;
  111295. /** @hidden */
  111296. _rebuild(): void;
  111297. /**
  111298. * Creates a new submesh from the passed mesh
  111299. * @param newMesh defines the new hosting mesh
  111300. * @param newRenderingMesh defines an optional rendering mesh
  111301. * @returns the new submesh
  111302. */
  111303. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  111304. /**
  111305. * Release associated resources
  111306. */
  111307. dispose(): void;
  111308. /**
  111309. * Gets the class name
  111310. * @returns the string "SubMesh".
  111311. */
  111312. getClassName(): string;
  111313. /**
  111314. * Creates a new submesh from indices data
  111315. * @param materialIndex the index of the main mesh material
  111316. * @param startIndex the index where to start the copy in the mesh indices array
  111317. * @param indexCount the number of indices to copy then from the startIndex
  111318. * @param mesh the main mesh to create the submesh from
  111319. * @param renderingMesh the optional rendering mesh
  111320. * @returns a new submesh
  111321. */
  111322. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  111323. }
  111324. }
  111325. declare module BABYLON {
  111326. /**
  111327. * Class used to represent data loading progression
  111328. */
  111329. export class SceneLoaderFlags {
  111330. private static _ForceFullSceneLoadingForIncremental;
  111331. private static _ShowLoadingScreen;
  111332. private static _CleanBoneMatrixWeights;
  111333. private static _loggingLevel;
  111334. /**
  111335. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111336. */
  111337. static get ForceFullSceneLoadingForIncremental(): boolean;
  111338. static set ForceFullSceneLoadingForIncremental(value: boolean);
  111339. /**
  111340. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111341. */
  111342. static get ShowLoadingScreen(): boolean;
  111343. static set ShowLoadingScreen(value: boolean);
  111344. /**
  111345. * Defines the current logging level (while loading the scene)
  111346. * @ignorenaming
  111347. */
  111348. static get loggingLevel(): number;
  111349. static set loggingLevel(value: number);
  111350. /**
  111351. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111352. */
  111353. static get CleanBoneMatrixWeights(): boolean;
  111354. static set CleanBoneMatrixWeights(value: boolean);
  111355. }
  111356. }
  111357. declare module BABYLON {
  111358. /**
  111359. * Class used to store geometry data (vertex buffers + index buffer)
  111360. */
  111361. export class Geometry implements IGetSetVerticesData {
  111362. /**
  111363. * Gets or sets the ID of the geometry
  111364. */
  111365. id: string;
  111366. /**
  111367. * Gets or sets the unique ID of the geometry
  111368. */
  111369. uniqueId: number;
  111370. /**
  111371. * Gets the delay loading state of the geometry (none by default which means not delayed)
  111372. */
  111373. delayLoadState: number;
  111374. /**
  111375. * Gets the file containing the data to load when running in delay load state
  111376. */
  111377. delayLoadingFile: Nullable<string>;
  111378. /**
  111379. * Callback called when the geometry is updated
  111380. */
  111381. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  111382. private _scene;
  111383. private _engine;
  111384. private _meshes;
  111385. private _totalVertices;
  111386. /** @hidden */
  111387. _indices: IndicesArray;
  111388. /** @hidden */
  111389. _vertexBuffers: {
  111390. [key: string]: VertexBuffer;
  111391. };
  111392. private _isDisposed;
  111393. private _extend;
  111394. private _boundingBias;
  111395. /** @hidden */
  111396. _delayInfo: Array<string>;
  111397. private _indexBuffer;
  111398. private _indexBufferIsUpdatable;
  111399. /** @hidden */
  111400. _boundingInfo: Nullable<BoundingInfo>;
  111401. /** @hidden */
  111402. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  111403. /** @hidden */
  111404. _softwareSkinningFrameId: number;
  111405. private _vertexArrayObjects;
  111406. private _updatable;
  111407. /** @hidden */
  111408. _positions: Nullable<Vector3[]>;
  111409. private _positionsCache;
  111410. /**
  111411. * 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
  111412. */
  111413. get boundingBias(): Vector2;
  111414. /**
  111415. * 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
  111416. */
  111417. set boundingBias(value: Vector2);
  111418. /**
  111419. * Static function used to attach a new empty geometry to a mesh
  111420. * @param mesh defines the mesh to attach the geometry to
  111421. * @returns the new Geometry
  111422. */
  111423. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  111424. /** Get the list of meshes using this geometry */
  111425. get meshes(): Mesh[];
  111426. /**
  111427. * 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
  111428. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  111429. */
  111430. useBoundingInfoFromGeometry: boolean;
  111431. /**
  111432. * Creates a new geometry
  111433. * @param id defines the unique ID
  111434. * @param scene defines the hosting scene
  111435. * @param vertexData defines the VertexData used to get geometry data
  111436. * @param updatable defines if geometry must be updatable (false by default)
  111437. * @param mesh defines the mesh that will be associated with the geometry
  111438. */
  111439. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  111440. /**
  111441. * Gets the current extend of the geometry
  111442. */
  111443. get extend(): {
  111444. minimum: Vector3;
  111445. maximum: Vector3;
  111446. };
  111447. /**
  111448. * Gets the hosting scene
  111449. * @returns the hosting Scene
  111450. */
  111451. getScene(): Scene;
  111452. /**
  111453. * Gets the hosting engine
  111454. * @returns the hosting Engine
  111455. */
  111456. getEngine(): Engine;
  111457. /**
  111458. * Defines if the geometry is ready to use
  111459. * @returns true if the geometry is ready to be used
  111460. */
  111461. isReady(): boolean;
  111462. /**
  111463. * Gets a value indicating that the geometry should not be serialized
  111464. */
  111465. get doNotSerialize(): boolean;
  111466. /** @hidden */
  111467. _rebuild(): void;
  111468. /**
  111469. * Affects all geometry data in one call
  111470. * @param vertexData defines the geometry data
  111471. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  111472. */
  111473. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  111474. /**
  111475. * Set specific vertex data
  111476. * @param kind defines the data kind (Position, normal, etc...)
  111477. * @param data defines the vertex data to use
  111478. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  111479. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  111480. */
  111481. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  111482. /**
  111483. * Removes a specific vertex data
  111484. * @param kind defines the data kind (Position, normal, etc...)
  111485. */
  111486. removeVerticesData(kind: string): void;
  111487. /**
  111488. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  111489. * @param buffer defines the vertex buffer to use
  111490. * @param totalVertices defines the total number of vertices for position kind (could be null)
  111491. */
  111492. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  111493. /**
  111494. * Update a specific vertex buffer
  111495. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  111496. * It will do nothing if the buffer is not updatable
  111497. * @param kind defines the data kind (Position, normal, etc...)
  111498. * @param data defines the data to use
  111499. * @param offset defines the offset in the target buffer where to store the data
  111500. * @param useBytes set to true if the offset is in bytes
  111501. */
  111502. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  111503. /**
  111504. * Update a specific vertex buffer
  111505. * This function will create a new buffer if the current one is not updatable
  111506. * @param kind defines the data kind (Position, normal, etc...)
  111507. * @param data defines the data to use
  111508. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  111509. */
  111510. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  111511. private _updateBoundingInfo;
  111512. /** @hidden */
  111513. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  111514. /**
  111515. * Gets total number of vertices
  111516. * @returns the total number of vertices
  111517. */
  111518. getTotalVertices(): number;
  111519. /**
  111520. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  111521. * @param kind defines the data kind (Position, normal, etc...)
  111522. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111523. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111524. * @returns a float array containing vertex data
  111525. */
  111526. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  111527. /**
  111528. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  111529. * @param kind defines the data kind (Position, normal, etc...)
  111530. * @returns true if the vertex buffer with the specified kind is updatable
  111531. */
  111532. isVertexBufferUpdatable(kind: string): boolean;
  111533. /**
  111534. * Gets a specific vertex buffer
  111535. * @param kind defines the data kind (Position, normal, etc...)
  111536. * @returns a VertexBuffer
  111537. */
  111538. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  111539. /**
  111540. * Returns all vertex buffers
  111541. * @return an object holding all vertex buffers indexed by kind
  111542. */
  111543. getVertexBuffers(): Nullable<{
  111544. [key: string]: VertexBuffer;
  111545. }>;
  111546. /**
  111547. * Gets a boolean indicating if specific vertex buffer is present
  111548. * @param kind defines the data kind (Position, normal, etc...)
  111549. * @returns true if data is present
  111550. */
  111551. isVerticesDataPresent(kind: string): boolean;
  111552. /**
  111553. * Gets a list of all attached data kinds (Position, normal, etc...)
  111554. * @returns a list of string containing all kinds
  111555. */
  111556. getVerticesDataKinds(): string[];
  111557. /**
  111558. * Update index buffer
  111559. * @param indices defines the indices to store in the index buffer
  111560. * @param offset defines the offset in the target buffer where to store the data
  111561. * @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)
  111562. */
  111563. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  111564. /**
  111565. * Creates a new index buffer
  111566. * @param indices defines the indices to store in the index buffer
  111567. * @param totalVertices defines the total number of vertices (could be null)
  111568. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111569. */
  111570. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  111571. /**
  111572. * Return the total number of indices
  111573. * @returns the total number of indices
  111574. */
  111575. getTotalIndices(): number;
  111576. /**
  111577. * Gets the index buffer array
  111578. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111580. * @returns the index buffer array
  111581. */
  111582. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  111583. /**
  111584. * Gets the index buffer
  111585. * @return the index buffer
  111586. */
  111587. getIndexBuffer(): Nullable<DataBuffer>;
  111588. /** @hidden */
  111589. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  111590. /**
  111591. * Release the associated resources for a specific mesh
  111592. * @param mesh defines the source mesh
  111593. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  111594. */
  111595. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  111596. /**
  111597. * Apply current geometry to a given mesh
  111598. * @param mesh defines the mesh to apply geometry to
  111599. */
  111600. applyToMesh(mesh: Mesh): void;
  111601. private _updateExtend;
  111602. private _applyToMesh;
  111603. private notifyUpdate;
  111604. /**
  111605. * Load the geometry if it was flagged as delay loaded
  111606. * @param scene defines the hosting scene
  111607. * @param onLoaded defines a callback called when the geometry is loaded
  111608. */
  111609. load(scene: Scene, onLoaded?: () => void): void;
  111610. private _queueLoad;
  111611. /**
  111612. * Invert the geometry to move from a right handed system to a left handed one.
  111613. */
  111614. toLeftHanded(): void;
  111615. /** @hidden */
  111616. _resetPointsArrayCache(): void;
  111617. /** @hidden */
  111618. _generatePointsArray(): boolean;
  111619. /**
  111620. * Gets a value indicating if the geometry is disposed
  111621. * @returns true if the geometry was disposed
  111622. */
  111623. isDisposed(): boolean;
  111624. private _disposeVertexArrayObjects;
  111625. /**
  111626. * Free all associated resources
  111627. */
  111628. dispose(): void;
  111629. /**
  111630. * Clone the current geometry into a new geometry
  111631. * @param id defines the unique ID of the new geometry
  111632. * @returns a new geometry object
  111633. */
  111634. copy(id: string): Geometry;
  111635. /**
  111636. * Serialize the current geometry info (and not the vertices data) into a JSON object
  111637. * @return a JSON representation of the current geometry data (without the vertices data)
  111638. */
  111639. serialize(): any;
  111640. private toNumberArray;
  111641. /**
  111642. * Serialize all vertices data into a JSON oject
  111643. * @returns a JSON representation of the current geometry data
  111644. */
  111645. serializeVerticeData(): any;
  111646. /**
  111647. * Extracts a clone of a mesh geometry
  111648. * @param mesh defines the source mesh
  111649. * @param id defines the unique ID of the new geometry object
  111650. * @returns the new geometry object
  111651. */
  111652. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  111653. /**
  111654. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  111655. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  111656. * Be aware Math.random() could cause collisions, but:
  111657. * "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"
  111658. * @returns a string containing a new GUID
  111659. */
  111660. static RandomId(): string;
  111661. /** @hidden */
  111662. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  111663. private static _CleanMatricesWeights;
  111664. /**
  111665. * Create a new geometry from persisted data (Using .babylon file format)
  111666. * @param parsedVertexData defines the persisted data
  111667. * @param scene defines the hosting scene
  111668. * @param rootUrl defines the root url to use to load assets (like delayed data)
  111669. * @returns the new geometry object
  111670. */
  111671. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  111672. }
  111673. }
  111674. declare module BABYLON {
  111675. /**
  111676. * Define an interface for all classes that will get and set the data on vertices
  111677. */
  111678. export interface IGetSetVerticesData {
  111679. /**
  111680. * Gets a boolean indicating if specific vertex data is present
  111681. * @param kind defines the vertex data kind to use
  111682. * @returns true is data kind is present
  111683. */
  111684. isVerticesDataPresent(kind: string): boolean;
  111685. /**
  111686. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  111687. * @param kind defines the data kind (Position, normal, etc...)
  111688. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111689. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111690. * @returns a float array containing vertex data
  111691. */
  111692. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  111693. /**
  111694. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  111695. * @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.
  111696. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111697. * @returns the indices array or an empty array if the mesh has no geometry
  111698. */
  111699. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  111700. /**
  111701. * Set specific vertex data
  111702. * @param kind defines the data kind (Position, normal, etc...)
  111703. * @param data defines the vertex data to use
  111704. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  111705. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  111706. */
  111707. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  111708. /**
  111709. * Update a specific associated vertex buffer
  111710. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  111711. * - VertexBuffer.PositionKind
  111712. * - VertexBuffer.UVKind
  111713. * - VertexBuffer.UV2Kind
  111714. * - VertexBuffer.UV3Kind
  111715. * - VertexBuffer.UV4Kind
  111716. * - VertexBuffer.UV5Kind
  111717. * - VertexBuffer.UV6Kind
  111718. * - VertexBuffer.ColorKind
  111719. * - VertexBuffer.MatricesIndicesKind
  111720. * - VertexBuffer.MatricesIndicesExtraKind
  111721. * - VertexBuffer.MatricesWeightsKind
  111722. * - VertexBuffer.MatricesWeightsExtraKind
  111723. * @param data defines the data source
  111724. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  111725. * @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)
  111726. */
  111727. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  111728. /**
  111729. * Creates a new index buffer
  111730. * @param indices defines the indices to store in the index buffer
  111731. * @param totalVertices defines the total number of vertices (could be null)
  111732. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111733. */
  111734. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  111735. }
  111736. /**
  111737. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  111738. */
  111739. export class VertexData {
  111740. /**
  111741. * Mesh side orientation : usually the external or front surface
  111742. */
  111743. static readonly FRONTSIDE: number;
  111744. /**
  111745. * Mesh side orientation : usually the internal or back surface
  111746. */
  111747. static readonly BACKSIDE: number;
  111748. /**
  111749. * Mesh side orientation : both internal and external or front and back surfaces
  111750. */
  111751. static readonly DOUBLESIDE: number;
  111752. /**
  111753. * Mesh side orientation : by default, `FRONTSIDE`
  111754. */
  111755. static readonly DEFAULTSIDE: number;
  111756. /**
  111757. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  111758. */
  111759. positions: Nullable<FloatArray>;
  111760. /**
  111761. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  111762. */
  111763. normals: Nullable<FloatArray>;
  111764. /**
  111765. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  111766. */
  111767. tangents: Nullable<FloatArray>;
  111768. /**
  111769. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111770. */
  111771. uvs: Nullable<FloatArray>;
  111772. /**
  111773. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111774. */
  111775. uvs2: Nullable<FloatArray>;
  111776. /**
  111777. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111778. */
  111779. uvs3: Nullable<FloatArray>;
  111780. /**
  111781. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111782. */
  111783. uvs4: Nullable<FloatArray>;
  111784. /**
  111785. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111786. */
  111787. uvs5: Nullable<FloatArray>;
  111788. /**
  111789. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111790. */
  111791. uvs6: Nullable<FloatArray>;
  111792. /**
  111793. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  111794. */
  111795. colors: Nullable<FloatArray>;
  111796. /**
  111797. * 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).
  111798. */
  111799. matricesIndices: Nullable<FloatArray>;
  111800. /**
  111801. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  111802. */
  111803. matricesWeights: Nullable<FloatArray>;
  111804. /**
  111805. * An array extending the number of possible indices
  111806. */
  111807. matricesIndicesExtra: Nullable<FloatArray>;
  111808. /**
  111809. * An array extending the number of possible weights when the number of indices is extended
  111810. */
  111811. matricesWeightsExtra: Nullable<FloatArray>;
  111812. /**
  111813. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  111814. */
  111815. indices: Nullable<IndicesArray>;
  111816. /**
  111817. * Uses the passed data array to set the set the values for the specified kind of data
  111818. * @param data a linear array of floating numbers
  111819. * @param kind the type of data that is being set, eg positions, colors etc
  111820. */
  111821. set(data: FloatArray, kind: string): void;
  111822. /**
  111823. * Associates the vertexData to the passed Mesh.
  111824. * Sets it as updatable or not (default `false`)
  111825. * @param mesh the mesh the vertexData is applied to
  111826. * @param updatable when used and having the value true allows new data to update the vertexData
  111827. * @returns the VertexData
  111828. */
  111829. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  111830. /**
  111831. * Associates the vertexData to the passed Geometry.
  111832. * Sets it as updatable or not (default `false`)
  111833. * @param geometry the geometry the vertexData is applied to
  111834. * @param updatable when used and having the value true allows new data to update the vertexData
  111835. * @returns VertexData
  111836. */
  111837. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  111838. /**
  111839. * Updates the associated mesh
  111840. * @param mesh the mesh to be updated
  111841. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111842. * @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
  111843. * @returns VertexData
  111844. */
  111845. updateMesh(mesh: Mesh): VertexData;
  111846. /**
  111847. * Updates the associated geometry
  111848. * @param geometry the geometry to be updated
  111849. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111850. * @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
  111851. * @returns VertexData.
  111852. */
  111853. updateGeometry(geometry: Geometry): VertexData;
  111854. private _applyTo;
  111855. private _update;
  111856. /**
  111857. * Transforms each position and each normal of the vertexData according to the passed Matrix
  111858. * @param matrix the transforming matrix
  111859. * @returns the VertexData
  111860. */
  111861. transform(matrix: Matrix): VertexData;
  111862. /**
  111863. * Merges the passed VertexData into the current one
  111864. * @param other the VertexData to be merged into the current one
  111865. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  111866. * @returns the modified VertexData
  111867. */
  111868. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  111869. private _mergeElement;
  111870. private _validate;
  111871. /**
  111872. * Serializes the VertexData
  111873. * @returns a serialized object
  111874. */
  111875. serialize(): any;
  111876. /**
  111877. * Extracts the vertexData from a mesh
  111878. * @param mesh the mesh from which to extract the VertexData
  111879. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  111880. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111881. * @returns the object VertexData associated to the passed mesh
  111882. */
  111883. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111884. /**
  111885. * Extracts the vertexData from the geometry
  111886. * @param geometry the geometry from which to extract the VertexData
  111887. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  111888. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111889. * @returns the object VertexData associated to the passed mesh
  111890. */
  111891. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111892. private static _ExtractFrom;
  111893. /**
  111894. * Creates the VertexData for a Ribbon
  111895. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  111896. * * pathArray array of paths, each of which an array of successive Vector3
  111897. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  111898. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  111899. * * 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
  111900. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111901. * * 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)
  111902. * * 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)
  111903. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  111904. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  111905. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  111906. * @returns the VertexData of the ribbon
  111907. */
  111908. static CreateRibbon(options: {
  111909. pathArray: Vector3[][];
  111910. closeArray?: boolean;
  111911. closePath?: boolean;
  111912. offset?: number;
  111913. sideOrientation?: number;
  111914. frontUVs?: Vector4;
  111915. backUVs?: Vector4;
  111916. invertUV?: boolean;
  111917. uvs?: Vector2[];
  111918. colors?: Color4[];
  111919. }): VertexData;
  111920. /**
  111921. * Creates the VertexData for a box
  111922. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111923. * * size sets the width, height and depth of the box to the value of size, optional default 1
  111924. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  111925. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  111926. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  111927. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111928. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111929. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111930. * * 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)
  111931. * * 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)
  111932. * @returns the VertexData of the box
  111933. */
  111934. static CreateBox(options: {
  111935. size?: number;
  111936. width?: number;
  111937. height?: number;
  111938. depth?: number;
  111939. faceUV?: Vector4[];
  111940. faceColors?: Color4[];
  111941. sideOrientation?: number;
  111942. frontUVs?: Vector4;
  111943. backUVs?: Vector4;
  111944. }): VertexData;
  111945. /**
  111946. * Creates the VertexData for a tiled box
  111947. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111948. * * faceTiles sets the pattern, tile size and number of tiles for a face
  111949. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111950. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111952. * @returns the VertexData of the box
  111953. */
  111954. static CreateTiledBox(options: {
  111955. pattern?: number;
  111956. width?: number;
  111957. height?: number;
  111958. depth?: number;
  111959. tileSize?: number;
  111960. tileWidth?: number;
  111961. tileHeight?: number;
  111962. alignHorizontal?: number;
  111963. alignVertical?: number;
  111964. faceUV?: Vector4[];
  111965. faceColors?: Color4[];
  111966. sideOrientation?: number;
  111967. }): VertexData;
  111968. /**
  111969. * Creates the VertexData for a tiled plane
  111970. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111971. * * pattern a limited pattern arrangement depending on the number
  111972. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  111973. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  111974. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  111975. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111976. * * 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)
  111977. * * 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)
  111978. * @returns the VertexData of the tiled plane
  111979. */
  111980. static CreateTiledPlane(options: {
  111981. pattern?: number;
  111982. tileSize?: number;
  111983. tileWidth?: number;
  111984. tileHeight?: number;
  111985. size?: number;
  111986. width?: number;
  111987. height?: number;
  111988. alignHorizontal?: number;
  111989. alignVertical?: number;
  111990. sideOrientation?: number;
  111991. frontUVs?: Vector4;
  111992. backUVs?: Vector4;
  111993. }): VertexData;
  111994. /**
  111995. * Creates the VertexData for an ellipsoid, defaults to a sphere
  111996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111997. * * segments sets the number of horizontal strips optional, default 32
  111998. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  111999. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  112000. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  112001. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  112002. * * 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
  112003. * * 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
  112004. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112005. * * 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)
  112006. * * 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)
  112007. * @returns the VertexData of the ellipsoid
  112008. */
  112009. static CreateSphere(options: {
  112010. segments?: number;
  112011. diameter?: number;
  112012. diameterX?: number;
  112013. diameterY?: number;
  112014. diameterZ?: number;
  112015. arc?: number;
  112016. slice?: number;
  112017. sideOrientation?: number;
  112018. frontUVs?: Vector4;
  112019. backUVs?: Vector4;
  112020. }): VertexData;
  112021. /**
  112022. * Creates the VertexData for a cylinder, cone or prism
  112023. * @param options an object used to set the following optional parameters for the box, required but can be empty
  112024. * * height sets the height (y direction) of the cylinder, optional, default 2
  112025. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  112026. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  112027. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  112028. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  112029. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  112030. * * 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
  112031. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  112032. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  112033. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  112034. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  112035. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112036. * * 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)
  112037. * * 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)
  112038. * @returns the VertexData of the cylinder, cone or prism
  112039. */
  112040. static CreateCylinder(options: {
  112041. height?: number;
  112042. diameterTop?: number;
  112043. diameterBottom?: number;
  112044. diameter?: number;
  112045. tessellation?: number;
  112046. subdivisions?: number;
  112047. arc?: number;
  112048. faceColors?: Color4[];
  112049. faceUV?: Vector4[];
  112050. hasRings?: boolean;
  112051. enclose?: boolean;
  112052. sideOrientation?: number;
  112053. frontUVs?: Vector4;
  112054. backUVs?: Vector4;
  112055. }): VertexData;
  112056. /**
  112057. * Creates the VertexData for a torus
  112058. * @param options an object used to set the following optional parameters for the box, required but can be empty
  112059. * * diameter the diameter of the torus, optional default 1
  112060. * * thickness the diameter of the tube forming the torus, optional default 0.5
  112061. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  112062. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112063. * * 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)
  112064. * * 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)
  112065. * @returns the VertexData of the torus
  112066. */
  112067. static CreateTorus(options: {
  112068. diameter?: number;
  112069. thickness?: number;
  112070. tessellation?: number;
  112071. sideOrientation?: number;
  112072. frontUVs?: Vector4;
  112073. backUVs?: Vector4;
  112074. }): VertexData;
  112075. /**
  112076. * Creates the VertexData of the LineSystem
  112077. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  112078. * - lines an array of lines, each line being an array of successive Vector3
  112079. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  112080. * @returns the VertexData of the LineSystem
  112081. */
  112082. static CreateLineSystem(options: {
  112083. lines: Vector3[][];
  112084. colors?: Nullable<Color4[][]>;
  112085. }): VertexData;
  112086. /**
  112087. * Create the VertexData for a DashedLines
  112088. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  112089. * - points an array successive Vector3
  112090. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  112091. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  112092. * - dashNb the intended total number of dashes, optional, default 200
  112093. * @returns the VertexData for the DashedLines
  112094. */
  112095. static CreateDashedLines(options: {
  112096. points: Vector3[];
  112097. dashSize?: number;
  112098. gapSize?: number;
  112099. dashNb?: number;
  112100. }): VertexData;
  112101. /**
  112102. * Creates the VertexData for a Ground
  112103. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  112104. * - width the width (x direction) of the ground, optional, default 1
  112105. * - height the height (z direction) of the ground, optional, default 1
  112106. * - subdivisions the number of subdivisions per side, optional, default 1
  112107. * @returns the VertexData of the Ground
  112108. */
  112109. static CreateGround(options: {
  112110. width?: number;
  112111. height?: number;
  112112. subdivisions?: number;
  112113. subdivisionsX?: number;
  112114. subdivisionsY?: number;
  112115. }): VertexData;
  112116. /**
  112117. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  112118. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  112119. * * xmin the ground minimum X coordinate, optional, default -1
  112120. * * zmin the ground minimum Z coordinate, optional, default -1
  112121. * * xmax the ground maximum X coordinate, optional, default 1
  112122. * * zmax the ground maximum Z coordinate, optional, default 1
  112123. * * 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}
  112124. * * 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}
  112125. * @returns the VertexData of the TiledGround
  112126. */
  112127. static CreateTiledGround(options: {
  112128. xmin: number;
  112129. zmin: number;
  112130. xmax: number;
  112131. zmax: number;
  112132. subdivisions?: {
  112133. w: number;
  112134. h: number;
  112135. };
  112136. precision?: {
  112137. w: number;
  112138. h: number;
  112139. };
  112140. }): VertexData;
  112141. /**
  112142. * Creates the VertexData of the Ground designed from a heightmap
  112143. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  112144. * * width the width (x direction) of the ground
  112145. * * height the height (z direction) of the ground
  112146. * * subdivisions the number of subdivisions per side
  112147. * * minHeight the minimum altitude on the ground, optional, default 0
  112148. * * maxHeight the maximum altitude on the ground, optional default 1
  112149. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  112150. * * buffer the array holding the image color data
  112151. * * bufferWidth the width of image
  112152. * * bufferHeight the height of image
  112153. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  112154. * @returns the VertexData of the Ground designed from a heightmap
  112155. */
  112156. static CreateGroundFromHeightMap(options: {
  112157. width: number;
  112158. height: number;
  112159. subdivisions: number;
  112160. minHeight: number;
  112161. maxHeight: number;
  112162. colorFilter: Color3;
  112163. buffer: Uint8Array;
  112164. bufferWidth: number;
  112165. bufferHeight: number;
  112166. alphaFilter: number;
  112167. }): VertexData;
  112168. /**
  112169. * Creates the VertexData for a Plane
  112170. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  112171. * * size sets the width and height of the plane to the value of size, optional default 1
  112172. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  112173. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  112174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112175. * * 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)
  112176. * * 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)
  112177. * @returns the VertexData of the box
  112178. */
  112179. static CreatePlane(options: {
  112180. size?: number;
  112181. width?: number;
  112182. height?: number;
  112183. sideOrientation?: number;
  112184. frontUVs?: Vector4;
  112185. backUVs?: Vector4;
  112186. }): VertexData;
  112187. /**
  112188. * Creates the VertexData of the Disc or regular Polygon
  112189. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  112190. * * radius the radius of the disc, optional default 0.5
  112191. * * tessellation the number of polygon sides, optional, default 64
  112192. * * 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
  112193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112194. * * 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)
  112195. * * 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)
  112196. * @returns the VertexData of the box
  112197. */
  112198. static CreateDisc(options: {
  112199. radius?: number;
  112200. tessellation?: number;
  112201. arc?: number;
  112202. sideOrientation?: number;
  112203. frontUVs?: Vector4;
  112204. backUVs?: Vector4;
  112205. }): VertexData;
  112206. /**
  112207. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  112208. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  112209. * @param polygon a mesh built from polygonTriangulation.build()
  112210. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112211. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  112212. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  112213. * @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)
  112214. * @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)
  112215. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  112216. * @returns the VertexData of the Polygon
  112217. */
  112218. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  112219. /**
  112220. * Creates the VertexData of the IcoSphere
  112221. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  112222. * * radius the radius of the IcoSphere, optional default 1
  112223. * * radiusX allows stretching in the x direction, optional, default radius
  112224. * * radiusY allows stretching in the y direction, optional, default radius
  112225. * * radiusZ allows stretching in the z direction, optional, default radius
  112226. * * flat when true creates a flat shaded mesh, optional, default true
  112227. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  112228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112229. * * 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)
  112230. * * 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)
  112231. * @returns the VertexData of the IcoSphere
  112232. */
  112233. static CreateIcoSphere(options: {
  112234. radius?: number;
  112235. radiusX?: number;
  112236. radiusY?: number;
  112237. radiusZ?: number;
  112238. flat?: boolean;
  112239. subdivisions?: number;
  112240. sideOrientation?: number;
  112241. frontUVs?: Vector4;
  112242. backUVs?: Vector4;
  112243. }): VertexData;
  112244. /**
  112245. * Creates the VertexData for a Polyhedron
  112246. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  112247. * * type provided types are:
  112248. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  112249. * * 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)
  112250. * * size the size of the IcoSphere, optional default 1
  112251. * * sizeX allows stretching in the x direction, optional, default size
  112252. * * sizeY allows stretching in the y direction, optional, default size
  112253. * * sizeZ allows stretching in the z direction, optional, default size
  112254. * * 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
  112255. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  112256. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  112257. * * flat when true creates a flat shaded mesh, optional, default true
  112258. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  112259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112260. * * 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)
  112261. * * 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)
  112262. * @returns the VertexData of the Polyhedron
  112263. */
  112264. static CreatePolyhedron(options: {
  112265. type?: number;
  112266. size?: number;
  112267. sizeX?: number;
  112268. sizeY?: number;
  112269. sizeZ?: number;
  112270. custom?: any;
  112271. faceUV?: Vector4[];
  112272. faceColors?: Color4[];
  112273. flat?: boolean;
  112274. sideOrientation?: number;
  112275. frontUVs?: Vector4;
  112276. backUVs?: Vector4;
  112277. }): VertexData;
  112278. /**
  112279. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  112280. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  112281. * @returns the VertexData of the Capsule
  112282. */
  112283. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  112284. /**
  112285. * Creates the VertexData for a TorusKnot
  112286. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  112287. * * radius the radius of the torus knot, optional, default 2
  112288. * * tube the thickness of the tube, optional, default 0.5
  112289. * * radialSegments the number of sides on each tube segments, optional, default 32
  112290. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  112291. * * p the number of windings around the z axis, optional, default 2
  112292. * * q the number of windings around the x axis, optional, default 3
  112293. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112294. * * 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)
  112295. * * 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)
  112296. * @returns the VertexData of the Torus Knot
  112297. */
  112298. static CreateTorusKnot(options: {
  112299. radius?: number;
  112300. tube?: number;
  112301. radialSegments?: number;
  112302. tubularSegments?: number;
  112303. p?: number;
  112304. q?: number;
  112305. sideOrientation?: number;
  112306. frontUVs?: Vector4;
  112307. backUVs?: Vector4;
  112308. }): VertexData;
  112309. /**
  112310. * Compute normals for given positions and indices
  112311. * @param positions an array of vertex positions, [...., x, y, z, ......]
  112312. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  112313. * @param normals an array of vertex normals, [...., x, y, z, ......]
  112314. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  112315. * * facetNormals : optional array of facet normals (vector3)
  112316. * * facetPositions : optional array of facet positions (vector3)
  112317. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  112318. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  112319. * * bInfo : optional bounding info, required for facetPartitioning computation
  112320. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  112321. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  112322. * * useRightHandedSystem: optional boolean to for right handed system computation
  112323. * * depthSort : optional boolean to enable the facet depth sort computation
  112324. * * distanceTo : optional Vector3 to compute the facet depth from this location
  112325. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  112326. */
  112327. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  112328. facetNormals?: any;
  112329. facetPositions?: any;
  112330. facetPartitioning?: any;
  112331. ratio?: number;
  112332. bInfo?: any;
  112333. bbSize?: Vector3;
  112334. subDiv?: any;
  112335. useRightHandedSystem?: boolean;
  112336. depthSort?: boolean;
  112337. distanceTo?: Vector3;
  112338. depthSortedFacets?: any;
  112339. }): void;
  112340. /** @hidden */
  112341. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  112342. /**
  112343. * Applies VertexData created from the imported parameters to the geometry
  112344. * @param parsedVertexData the parsed data from an imported file
  112345. * @param geometry the geometry to apply the VertexData to
  112346. */
  112347. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  112348. }
  112349. }
  112350. declare module BABYLON {
  112351. /**
  112352. * Defines a target to use with MorphTargetManager
  112353. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112354. */
  112355. export class MorphTarget implements IAnimatable {
  112356. /** defines the name of the target */
  112357. name: string;
  112358. /**
  112359. * Gets or sets the list of animations
  112360. */
  112361. animations: Animation[];
  112362. private _scene;
  112363. private _positions;
  112364. private _normals;
  112365. private _tangents;
  112366. private _uvs;
  112367. private _influence;
  112368. private _uniqueId;
  112369. /**
  112370. * Observable raised when the influence changes
  112371. */
  112372. onInfluenceChanged: Observable<boolean>;
  112373. /** @hidden */
  112374. _onDataLayoutChanged: Observable<void>;
  112375. /**
  112376. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  112377. */
  112378. get influence(): number;
  112379. set influence(influence: number);
  112380. /**
  112381. * Gets or sets the id of the morph Target
  112382. */
  112383. id: string;
  112384. private _animationPropertiesOverride;
  112385. /**
  112386. * Gets or sets the animation properties override
  112387. */
  112388. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112389. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112390. /**
  112391. * Creates a new MorphTarget
  112392. * @param name defines the name of the target
  112393. * @param influence defines the influence to use
  112394. * @param scene defines the scene the morphtarget belongs to
  112395. */
  112396. constructor(
  112397. /** defines the name of the target */
  112398. name: string, influence?: number, scene?: Nullable<Scene>);
  112399. /**
  112400. * Gets the unique ID of this manager
  112401. */
  112402. get uniqueId(): number;
  112403. /**
  112404. * Gets a boolean defining if the target contains position data
  112405. */
  112406. get hasPositions(): boolean;
  112407. /**
  112408. * Gets a boolean defining if the target contains normal data
  112409. */
  112410. get hasNormals(): boolean;
  112411. /**
  112412. * Gets a boolean defining if the target contains tangent data
  112413. */
  112414. get hasTangents(): boolean;
  112415. /**
  112416. * Gets a boolean defining if the target contains texture coordinates data
  112417. */
  112418. get hasUVs(): boolean;
  112419. /**
  112420. * Affects position data to this target
  112421. * @param data defines the position data to use
  112422. */
  112423. setPositions(data: Nullable<FloatArray>): void;
  112424. /**
  112425. * Gets the position data stored in this target
  112426. * @returns a FloatArray containing the position data (or null if not present)
  112427. */
  112428. getPositions(): Nullable<FloatArray>;
  112429. /**
  112430. * Affects normal data to this target
  112431. * @param data defines the normal data to use
  112432. */
  112433. setNormals(data: Nullable<FloatArray>): void;
  112434. /**
  112435. * Gets the normal data stored in this target
  112436. * @returns a FloatArray containing the normal data (or null if not present)
  112437. */
  112438. getNormals(): Nullable<FloatArray>;
  112439. /**
  112440. * Affects tangent data to this target
  112441. * @param data defines the tangent data to use
  112442. */
  112443. setTangents(data: Nullable<FloatArray>): void;
  112444. /**
  112445. * Gets the tangent data stored in this target
  112446. * @returns a FloatArray containing the tangent data (or null if not present)
  112447. */
  112448. getTangents(): Nullable<FloatArray>;
  112449. /**
  112450. * Affects texture coordinates data to this target
  112451. * @param data defines the texture coordinates data to use
  112452. */
  112453. setUVs(data: Nullable<FloatArray>): void;
  112454. /**
  112455. * Gets the texture coordinates data stored in this target
  112456. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  112457. */
  112458. getUVs(): Nullable<FloatArray>;
  112459. /**
  112460. * Clone the current target
  112461. * @returns a new MorphTarget
  112462. */
  112463. clone(): MorphTarget;
  112464. /**
  112465. * Serializes the current target into a Serialization object
  112466. * @returns the serialized object
  112467. */
  112468. serialize(): any;
  112469. /**
  112470. * Returns the string "MorphTarget"
  112471. * @returns "MorphTarget"
  112472. */
  112473. getClassName(): string;
  112474. /**
  112475. * Creates a new target from serialized data
  112476. * @param serializationObject defines the serialized data to use
  112477. * @returns a new MorphTarget
  112478. */
  112479. static Parse(serializationObject: any): MorphTarget;
  112480. /**
  112481. * Creates a MorphTarget from mesh data
  112482. * @param mesh defines the source mesh
  112483. * @param name defines the name to use for the new target
  112484. * @param influence defines the influence to attach to the target
  112485. * @returns a new MorphTarget
  112486. */
  112487. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  112488. }
  112489. }
  112490. declare module BABYLON {
  112491. /**
  112492. * This class is used to deform meshes using morphing between different targets
  112493. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112494. */
  112495. export class MorphTargetManager {
  112496. private _targets;
  112497. private _targetInfluenceChangedObservers;
  112498. private _targetDataLayoutChangedObservers;
  112499. private _activeTargets;
  112500. private _scene;
  112501. private _influences;
  112502. private _supportsNormals;
  112503. private _supportsTangents;
  112504. private _supportsUVs;
  112505. private _vertexCount;
  112506. private _uniqueId;
  112507. private _tempInfluences;
  112508. /**
  112509. * Gets or sets a boolean indicating if normals must be morphed
  112510. */
  112511. enableNormalMorphing: boolean;
  112512. /**
  112513. * Gets or sets a boolean indicating if tangents must be morphed
  112514. */
  112515. enableTangentMorphing: boolean;
  112516. /**
  112517. * Gets or sets a boolean indicating if UV must be morphed
  112518. */
  112519. enableUVMorphing: boolean;
  112520. /**
  112521. * Creates a new MorphTargetManager
  112522. * @param scene defines the current scene
  112523. */
  112524. constructor(scene?: Nullable<Scene>);
  112525. /**
  112526. * Gets the unique ID of this manager
  112527. */
  112528. get uniqueId(): number;
  112529. /**
  112530. * Gets the number of vertices handled by this manager
  112531. */
  112532. get vertexCount(): number;
  112533. /**
  112534. * Gets a boolean indicating if this manager supports morphing of normals
  112535. */
  112536. get supportsNormals(): boolean;
  112537. /**
  112538. * Gets a boolean indicating if this manager supports morphing of tangents
  112539. */
  112540. get supportsTangents(): boolean;
  112541. /**
  112542. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  112543. */
  112544. get supportsUVs(): boolean;
  112545. /**
  112546. * Gets the number of targets stored in this manager
  112547. */
  112548. get numTargets(): number;
  112549. /**
  112550. * Gets the number of influencers (ie. the number of targets with influences > 0)
  112551. */
  112552. get numInfluencers(): number;
  112553. /**
  112554. * Gets the list of influences (one per target)
  112555. */
  112556. get influences(): Float32Array;
  112557. /**
  112558. * Gets the active target at specified index. An active target is a target with an influence > 0
  112559. * @param index defines the index to check
  112560. * @returns the requested target
  112561. */
  112562. getActiveTarget(index: number): MorphTarget;
  112563. /**
  112564. * Gets the target at specified index
  112565. * @param index defines the index to check
  112566. * @returns the requested target
  112567. */
  112568. getTarget(index: number): MorphTarget;
  112569. /**
  112570. * Add a new target to this manager
  112571. * @param target defines the target to add
  112572. */
  112573. addTarget(target: MorphTarget): void;
  112574. /**
  112575. * Removes a target from the manager
  112576. * @param target defines the target to remove
  112577. */
  112578. removeTarget(target: MorphTarget): void;
  112579. /**
  112580. * Clone the current manager
  112581. * @returns a new MorphTargetManager
  112582. */
  112583. clone(): MorphTargetManager;
  112584. /**
  112585. * Serializes the current manager into a Serialization object
  112586. * @returns the serialized object
  112587. */
  112588. serialize(): any;
  112589. private _syncActiveTargets;
  112590. /**
  112591. * Syncrhonize the targets with all the meshes using this morph target manager
  112592. */
  112593. synchronize(): void;
  112594. /**
  112595. * Creates a new MorphTargetManager from serialized data
  112596. * @param serializationObject defines the serialized data
  112597. * @param scene defines the hosting scene
  112598. * @returns the new MorphTargetManager
  112599. */
  112600. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  112601. }
  112602. }
  112603. declare module BABYLON {
  112604. /**
  112605. * Class used to represent a specific level of detail of a mesh
  112606. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  112607. */
  112608. export class MeshLODLevel {
  112609. /** Defines the distance where this level should start being displayed */
  112610. distance: number;
  112611. /** Defines the mesh to use to render this level */
  112612. mesh: Nullable<Mesh>;
  112613. /**
  112614. * Creates a new LOD level
  112615. * @param distance defines the distance where this level should star being displayed
  112616. * @param mesh defines the mesh to use to render this level
  112617. */
  112618. constructor(
  112619. /** Defines the distance where this level should start being displayed */
  112620. distance: number,
  112621. /** Defines the mesh to use to render this level */
  112622. mesh: Nullable<Mesh>);
  112623. }
  112624. }
  112625. declare module BABYLON {
  112626. /**
  112627. * Helper class used to generate a canvas to manipulate images
  112628. */
  112629. export class CanvasGenerator {
  112630. /**
  112631. * Create a new canvas (or offscreen canvas depending on the context)
  112632. * @param width defines the expected width
  112633. * @param height defines the expected height
  112634. * @return a new canvas or offscreen canvas
  112635. */
  112636. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  112637. }
  112638. }
  112639. declare module BABYLON {
  112640. /**
  112641. * Mesh representing the gorund
  112642. */
  112643. export class GroundMesh extends Mesh {
  112644. /** If octree should be generated */
  112645. generateOctree: boolean;
  112646. private _heightQuads;
  112647. /** @hidden */
  112648. _subdivisionsX: number;
  112649. /** @hidden */
  112650. _subdivisionsY: number;
  112651. /** @hidden */
  112652. _width: number;
  112653. /** @hidden */
  112654. _height: number;
  112655. /** @hidden */
  112656. _minX: number;
  112657. /** @hidden */
  112658. _maxX: number;
  112659. /** @hidden */
  112660. _minZ: number;
  112661. /** @hidden */
  112662. _maxZ: number;
  112663. constructor(name: string, scene: Scene);
  112664. /**
  112665. * "GroundMesh"
  112666. * @returns "GroundMesh"
  112667. */
  112668. getClassName(): string;
  112669. /**
  112670. * The minimum of x and y subdivisions
  112671. */
  112672. get subdivisions(): number;
  112673. /**
  112674. * X subdivisions
  112675. */
  112676. get subdivisionsX(): number;
  112677. /**
  112678. * Y subdivisions
  112679. */
  112680. get subdivisionsY(): number;
  112681. /**
  112682. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  112683. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112684. * @param chunksCount the number of subdivisions for x and y
  112685. * @param octreeBlocksSize (Default: 32)
  112686. */
  112687. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  112688. /**
  112689. * Returns a height (y) value in the Worl system :
  112690. * the ground altitude at the coordinates (x, z) expressed in the World system.
  112691. * @param x x coordinate
  112692. * @param z z coordinate
  112693. * @returns the ground y position if (x, z) are outside the ground surface.
  112694. */
  112695. getHeightAtCoordinates(x: number, z: number): number;
  112696. /**
  112697. * Returns a normalized vector (Vector3) orthogonal to the ground
  112698. * at the ground coordinates (x, z) expressed in the World system.
  112699. * @param x x coordinate
  112700. * @param z z coordinate
  112701. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  112702. */
  112703. getNormalAtCoordinates(x: number, z: number): Vector3;
  112704. /**
  112705. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  112706. * at the ground coordinates (x, z) expressed in the World system.
  112707. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  112708. * @param x x coordinate
  112709. * @param z z coordinate
  112710. * @param ref vector to store the result
  112711. * @returns the GroundMesh.
  112712. */
  112713. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  112714. /**
  112715. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  112716. * if the ground has been updated.
  112717. * This can be used in the render loop.
  112718. * @returns the GroundMesh.
  112719. */
  112720. updateCoordinateHeights(): GroundMesh;
  112721. private _getFacetAt;
  112722. private _initHeightQuads;
  112723. private _computeHeightQuads;
  112724. /**
  112725. * Serializes this ground mesh
  112726. * @param serializationObject object to write serialization to
  112727. */
  112728. serialize(serializationObject: any): void;
  112729. /**
  112730. * Parses a serialized ground mesh
  112731. * @param parsedMesh the serialized mesh
  112732. * @param scene the scene to create the ground mesh in
  112733. * @returns the created ground mesh
  112734. */
  112735. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112736. }
  112737. }
  112738. declare module BABYLON {
  112739. /**
  112740. * Interface for Physics-Joint data
  112741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112742. */
  112743. export interface PhysicsJointData {
  112744. /**
  112745. * The main pivot of the joint
  112746. */
  112747. mainPivot?: Vector3;
  112748. /**
  112749. * The connected pivot of the joint
  112750. */
  112751. connectedPivot?: Vector3;
  112752. /**
  112753. * The main axis of the joint
  112754. */
  112755. mainAxis?: Vector3;
  112756. /**
  112757. * The connected axis of the joint
  112758. */
  112759. connectedAxis?: Vector3;
  112760. /**
  112761. * The collision of the joint
  112762. */
  112763. collision?: boolean;
  112764. /**
  112765. * Native Oimo/Cannon/Energy data
  112766. */
  112767. nativeParams?: any;
  112768. }
  112769. /**
  112770. * This is a holder class for the physics joint created by the physics plugin
  112771. * It holds a set of functions to control the underlying joint
  112772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112773. */
  112774. export class PhysicsJoint {
  112775. /**
  112776. * The type of the physics joint
  112777. */
  112778. type: number;
  112779. /**
  112780. * The data for the physics joint
  112781. */
  112782. jointData: PhysicsJointData;
  112783. private _physicsJoint;
  112784. protected _physicsPlugin: IPhysicsEnginePlugin;
  112785. /**
  112786. * Initializes the physics joint
  112787. * @param type The type of the physics joint
  112788. * @param jointData The data for the physics joint
  112789. */
  112790. constructor(
  112791. /**
  112792. * The type of the physics joint
  112793. */
  112794. type: number,
  112795. /**
  112796. * The data for the physics joint
  112797. */
  112798. jointData: PhysicsJointData);
  112799. /**
  112800. * Gets the physics joint
  112801. */
  112802. get physicsJoint(): any;
  112803. /**
  112804. * Sets the physics joint
  112805. */
  112806. set physicsJoint(newJoint: any);
  112807. /**
  112808. * Sets the physics plugin
  112809. */
  112810. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112811. /**
  112812. * Execute a function that is physics-plugin specific.
  112813. * @param {Function} func the function that will be executed.
  112814. * It accepts two parameters: the physics world and the physics joint
  112815. */
  112816. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112817. /**
  112818. * Distance-Joint type
  112819. */
  112820. static DistanceJoint: number;
  112821. /**
  112822. * Hinge-Joint type
  112823. */
  112824. static HingeJoint: number;
  112825. /**
  112826. * Ball-and-Socket joint type
  112827. */
  112828. static BallAndSocketJoint: number;
  112829. /**
  112830. * Wheel-Joint type
  112831. */
  112832. static WheelJoint: number;
  112833. /**
  112834. * Slider-Joint type
  112835. */
  112836. static SliderJoint: number;
  112837. /**
  112838. * Prismatic-Joint type
  112839. */
  112840. static PrismaticJoint: number;
  112841. /**
  112842. * Universal-Joint type
  112843. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112844. */
  112845. static UniversalJoint: number;
  112846. /**
  112847. * Hinge-Joint 2 type
  112848. */
  112849. static Hinge2Joint: number;
  112850. /**
  112851. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112852. */
  112853. static PointToPointJoint: number;
  112854. /**
  112855. * Spring-Joint type
  112856. */
  112857. static SpringJoint: number;
  112858. /**
  112859. * Lock-Joint type
  112860. */
  112861. static LockJoint: number;
  112862. }
  112863. /**
  112864. * A class representing a physics distance joint
  112865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112866. */
  112867. export class DistanceJoint extends PhysicsJoint {
  112868. /**
  112869. *
  112870. * @param jointData The data for the Distance-Joint
  112871. */
  112872. constructor(jointData: DistanceJointData);
  112873. /**
  112874. * Update the predefined distance.
  112875. * @param maxDistance The maximum preferred distance
  112876. * @param minDistance The minimum preferred distance
  112877. */
  112878. updateDistance(maxDistance: number, minDistance?: number): void;
  112879. }
  112880. /**
  112881. * Represents a Motor-Enabled Joint
  112882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112883. */
  112884. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112885. /**
  112886. * Initializes the Motor-Enabled Joint
  112887. * @param type The type of the joint
  112888. * @param jointData The physica joint data for the joint
  112889. */
  112890. constructor(type: number, jointData: PhysicsJointData);
  112891. /**
  112892. * Set the motor values.
  112893. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112894. * @param force the force to apply
  112895. * @param maxForce max force for this motor.
  112896. */
  112897. setMotor(force?: number, maxForce?: number): void;
  112898. /**
  112899. * Set the motor's limits.
  112900. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112901. * @param upperLimit The upper limit of the motor
  112902. * @param lowerLimit The lower limit of the motor
  112903. */
  112904. setLimit(upperLimit: number, lowerLimit?: number): void;
  112905. }
  112906. /**
  112907. * This class represents a single physics Hinge-Joint
  112908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112909. */
  112910. export class HingeJoint extends MotorEnabledJoint {
  112911. /**
  112912. * Initializes the Hinge-Joint
  112913. * @param jointData The joint data for the Hinge-Joint
  112914. */
  112915. constructor(jointData: PhysicsJointData);
  112916. /**
  112917. * Set the motor values.
  112918. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112919. * @param {number} force the force to apply
  112920. * @param {number} maxForce max force for this motor.
  112921. */
  112922. setMotor(force?: number, maxForce?: number): void;
  112923. /**
  112924. * Set the motor's limits.
  112925. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112926. * @param upperLimit The upper limit of the motor
  112927. * @param lowerLimit The lower limit of the motor
  112928. */
  112929. setLimit(upperLimit: number, lowerLimit?: number): void;
  112930. }
  112931. /**
  112932. * This class represents a dual hinge physics joint (same as wheel joint)
  112933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112934. */
  112935. export class Hinge2Joint extends MotorEnabledJoint {
  112936. /**
  112937. * Initializes the Hinge2-Joint
  112938. * @param jointData The joint data for the Hinge2-Joint
  112939. */
  112940. constructor(jointData: PhysicsJointData);
  112941. /**
  112942. * Set the motor values.
  112943. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112944. * @param {number} targetSpeed the speed the motor is to reach
  112945. * @param {number} maxForce max force for this motor.
  112946. * @param {motorIndex} the motor's index, 0 or 1.
  112947. */
  112948. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112949. /**
  112950. * Set the motor limits.
  112951. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112952. * @param {number} upperLimit the upper limit
  112953. * @param {number} lowerLimit lower limit
  112954. * @param {motorIndex} the motor's index, 0 or 1.
  112955. */
  112956. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112957. }
  112958. /**
  112959. * Interface for a motor enabled joint
  112960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112961. */
  112962. export interface IMotorEnabledJoint {
  112963. /**
  112964. * Physics joint
  112965. */
  112966. physicsJoint: any;
  112967. /**
  112968. * Sets the motor of the motor-enabled joint
  112969. * @param force The force of the motor
  112970. * @param maxForce The maximum force of the motor
  112971. * @param motorIndex The index of the motor
  112972. */
  112973. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112974. /**
  112975. * Sets the limit of the motor
  112976. * @param upperLimit The upper limit of the motor
  112977. * @param lowerLimit The lower limit of the motor
  112978. * @param motorIndex The index of the motor
  112979. */
  112980. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112981. }
  112982. /**
  112983. * Joint data for a Distance-Joint
  112984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112985. */
  112986. export interface DistanceJointData extends PhysicsJointData {
  112987. /**
  112988. * Max distance the 2 joint objects can be apart
  112989. */
  112990. maxDistance: number;
  112991. }
  112992. /**
  112993. * Joint data from a spring joint
  112994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112995. */
  112996. export interface SpringJointData extends PhysicsJointData {
  112997. /**
  112998. * Length of the spring
  112999. */
  113000. length: number;
  113001. /**
  113002. * Stiffness of the spring
  113003. */
  113004. stiffness: number;
  113005. /**
  113006. * Damping of the spring
  113007. */
  113008. damping: number;
  113009. /** this callback will be called when applying the force to the impostors. */
  113010. forceApplicationCallback: () => void;
  113011. }
  113012. }
  113013. declare module BABYLON {
  113014. /**
  113015. * Holds the data for the raycast result
  113016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113017. */
  113018. export class PhysicsRaycastResult {
  113019. private _hasHit;
  113020. private _hitDistance;
  113021. private _hitNormalWorld;
  113022. private _hitPointWorld;
  113023. private _rayFromWorld;
  113024. private _rayToWorld;
  113025. /**
  113026. * Gets if there was a hit
  113027. */
  113028. get hasHit(): boolean;
  113029. /**
  113030. * Gets the distance from the hit
  113031. */
  113032. get hitDistance(): number;
  113033. /**
  113034. * Gets the hit normal/direction in the world
  113035. */
  113036. get hitNormalWorld(): Vector3;
  113037. /**
  113038. * Gets the hit point in the world
  113039. */
  113040. get hitPointWorld(): Vector3;
  113041. /**
  113042. * Gets the ray "start point" of the ray in the world
  113043. */
  113044. get rayFromWorld(): Vector3;
  113045. /**
  113046. * Gets the ray "end point" of the ray in the world
  113047. */
  113048. get rayToWorld(): Vector3;
  113049. /**
  113050. * Sets the hit data (normal & point in world space)
  113051. * @param hitNormalWorld defines the normal in world space
  113052. * @param hitPointWorld defines the point in world space
  113053. */
  113054. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  113055. /**
  113056. * Sets the distance from the start point to the hit point
  113057. * @param distance
  113058. */
  113059. setHitDistance(distance: number): void;
  113060. /**
  113061. * Calculates the distance manually
  113062. */
  113063. calculateHitDistance(): void;
  113064. /**
  113065. * Resets all the values to default
  113066. * @param from The from point on world space
  113067. * @param to The to point on world space
  113068. */
  113069. reset(from?: Vector3, to?: Vector3): void;
  113070. }
  113071. /**
  113072. * Interface for the size containing width and height
  113073. */
  113074. interface IXYZ {
  113075. /**
  113076. * X
  113077. */
  113078. x: number;
  113079. /**
  113080. * Y
  113081. */
  113082. y: number;
  113083. /**
  113084. * Z
  113085. */
  113086. z: number;
  113087. }
  113088. }
  113089. declare module BABYLON {
  113090. /**
  113091. * Interface used to describe a physics joint
  113092. */
  113093. export interface PhysicsImpostorJoint {
  113094. /** Defines the main impostor to which the joint is linked */
  113095. mainImpostor: PhysicsImpostor;
  113096. /** Defines the impostor that is connected to the main impostor using this joint */
  113097. connectedImpostor: PhysicsImpostor;
  113098. /** Defines the joint itself */
  113099. joint: PhysicsJoint;
  113100. }
  113101. /** @hidden */
  113102. export interface IPhysicsEnginePlugin {
  113103. world: any;
  113104. name: string;
  113105. setGravity(gravity: Vector3): void;
  113106. setTimeStep(timeStep: number): void;
  113107. getTimeStep(): number;
  113108. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113109. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113110. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113111. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113112. removePhysicsBody(impostor: PhysicsImpostor): void;
  113113. generateJoint(joint: PhysicsImpostorJoint): void;
  113114. removeJoint(joint: PhysicsImpostorJoint): void;
  113115. isSupported(): boolean;
  113116. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113117. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113118. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113119. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113120. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113121. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113122. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113123. getBodyMass(impostor: PhysicsImpostor): number;
  113124. getBodyFriction(impostor: PhysicsImpostor): number;
  113125. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113126. getBodyRestitution(impostor: PhysicsImpostor): number;
  113127. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113128. getBodyPressure?(impostor: PhysicsImpostor): number;
  113129. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  113130. getBodyStiffness?(impostor: PhysicsImpostor): number;
  113131. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  113132. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  113133. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  113134. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  113135. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  113136. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113137. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113138. sleepBody(impostor: PhysicsImpostor): void;
  113139. wakeUpBody(impostor: PhysicsImpostor): void;
  113140. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113141. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113142. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  113143. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  113144. getRadius(impostor: PhysicsImpostor): number;
  113145. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113146. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113147. dispose(): void;
  113148. }
  113149. /**
  113150. * Interface used to define a physics engine
  113151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113152. */
  113153. export interface IPhysicsEngine {
  113154. /**
  113155. * Gets the gravity vector used by the simulation
  113156. */
  113157. gravity: Vector3;
  113158. /**
  113159. * Sets the gravity vector used by the simulation
  113160. * @param gravity defines the gravity vector to use
  113161. */
  113162. setGravity(gravity: Vector3): void;
  113163. /**
  113164. * Set the time step of the physics engine.
  113165. * Default is 1/60.
  113166. * To slow it down, enter 1/600 for example.
  113167. * To speed it up, 1/30
  113168. * @param newTimeStep the new timestep to apply to this world.
  113169. */
  113170. setTimeStep(newTimeStep: number): void;
  113171. /**
  113172. * Get the time step of the physics engine.
  113173. * @returns the current time step
  113174. */
  113175. getTimeStep(): number;
  113176. /**
  113177. * Set the sub time step of the physics engine.
  113178. * Default is 0 meaning there is no sub steps
  113179. * To increase physics resolution precision, set a small value (like 1 ms)
  113180. * @param subTimeStep defines the new sub timestep used for physics resolution.
  113181. */
  113182. setSubTimeStep(subTimeStep: number): void;
  113183. /**
  113184. * Get the sub time step of the physics engine.
  113185. * @returns the current sub time step
  113186. */
  113187. getSubTimeStep(): number;
  113188. /**
  113189. * Release all resources
  113190. */
  113191. dispose(): void;
  113192. /**
  113193. * Gets the name of the current physics plugin
  113194. * @returns the name of the plugin
  113195. */
  113196. getPhysicsPluginName(): string;
  113197. /**
  113198. * Adding a new impostor for the impostor tracking.
  113199. * This will be done by the impostor itself.
  113200. * @param impostor the impostor to add
  113201. */
  113202. addImpostor(impostor: PhysicsImpostor): void;
  113203. /**
  113204. * Remove an impostor from the engine.
  113205. * This impostor and its mesh will not longer be updated by the physics engine.
  113206. * @param impostor the impostor to remove
  113207. */
  113208. removeImpostor(impostor: PhysicsImpostor): void;
  113209. /**
  113210. * Add a joint to the physics engine
  113211. * @param mainImpostor defines the main impostor to which the joint is added.
  113212. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113213. * @param joint defines the joint that will connect both impostors.
  113214. */
  113215. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113216. /**
  113217. * Removes a joint from the simulation
  113218. * @param mainImpostor defines the impostor used with the joint
  113219. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113220. * @param joint defines the joint to remove
  113221. */
  113222. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113223. /**
  113224. * Gets the current plugin used to run the simulation
  113225. * @returns current plugin
  113226. */
  113227. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113228. /**
  113229. * Gets the list of physic impostors
  113230. * @returns an array of PhysicsImpostor
  113231. */
  113232. getImpostors(): Array<PhysicsImpostor>;
  113233. /**
  113234. * Gets the impostor for a physics enabled object
  113235. * @param object defines the object impersonated by the impostor
  113236. * @returns the PhysicsImpostor or null if not found
  113237. */
  113238. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113239. /**
  113240. * Gets the impostor for a physics body object
  113241. * @param body defines physics body used by the impostor
  113242. * @returns the PhysicsImpostor or null if not found
  113243. */
  113244. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113245. /**
  113246. * Does a raycast in the physics world
  113247. * @param from when should the ray start?
  113248. * @param to when should the ray end?
  113249. * @returns PhysicsRaycastResult
  113250. */
  113251. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113252. /**
  113253. * Called by the scene. No need to call it.
  113254. * @param delta defines the timespam between frames
  113255. */
  113256. _step(delta: number): void;
  113257. }
  113258. }
  113259. declare module BABYLON {
  113260. /**
  113261. * The interface for the physics imposter parameters
  113262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113263. */
  113264. export interface PhysicsImpostorParameters {
  113265. /**
  113266. * The mass of the physics imposter
  113267. */
  113268. mass: number;
  113269. /**
  113270. * The friction of the physics imposter
  113271. */
  113272. friction?: number;
  113273. /**
  113274. * The coefficient of restitution of the physics imposter
  113275. */
  113276. restitution?: number;
  113277. /**
  113278. * The native options of the physics imposter
  113279. */
  113280. nativeOptions?: any;
  113281. /**
  113282. * Specifies if the parent should be ignored
  113283. */
  113284. ignoreParent?: boolean;
  113285. /**
  113286. * Specifies if bi-directional transformations should be disabled
  113287. */
  113288. disableBidirectionalTransformation?: boolean;
  113289. /**
  113290. * The pressure inside the physics imposter, soft object only
  113291. */
  113292. pressure?: number;
  113293. /**
  113294. * The stiffness the physics imposter, soft object only
  113295. */
  113296. stiffness?: number;
  113297. /**
  113298. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  113299. */
  113300. velocityIterations?: number;
  113301. /**
  113302. * The number of iterations used in maintaining consistent vertex positions, soft object only
  113303. */
  113304. positionIterations?: number;
  113305. /**
  113306. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  113307. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  113308. * Add to fix multiple points
  113309. */
  113310. fixedPoints?: number;
  113311. /**
  113312. * The collision margin around a soft object
  113313. */
  113314. margin?: number;
  113315. /**
  113316. * The collision margin around a soft object
  113317. */
  113318. damping?: number;
  113319. /**
  113320. * The path for a rope based on an extrusion
  113321. */
  113322. path?: any;
  113323. /**
  113324. * The shape of an extrusion used for a rope based on an extrusion
  113325. */
  113326. shape?: any;
  113327. }
  113328. /**
  113329. * Interface for a physics-enabled object
  113330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113331. */
  113332. export interface IPhysicsEnabledObject {
  113333. /**
  113334. * The position of the physics-enabled object
  113335. */
  113336. position: Vector3;
  113337. /**
  113338. * The rotation of the physics-enabled object
  113339. */
  113340. rotationQuaternion: Nullable<Quaternion>;
  113341. /**
  113342. * The scale of the physics-enabled object
  113343. */
  113344. scaling: Vector3;
  113345. /**
  113346. * The rotation of the physics-enabled object
  113347. */
  113348. rotation?: Vector3;
  113349. /**
  113350. * The parent of the physics-enabled object
  113351. */
  113352. parent?: any;
  113353. /**
  113354. * The bounding info of the physics-enabled object
  113355. * @returns The bounding info of the physics-enabled object
  113356. */
  113357. getBoundingInfo(): BoundingInfo;
  113358. /**
  113359. * Computes the world matrix
  113360. * @param force Specifies if the world matrix should be computed by force
  113361. * @returns A world matrix
  113362. */
  113363. computeWorldMatrix(force: boolean): Matrix;
  113364. /**
  113365. * Gets the world matrix
  113366. * @returns A world matrix
  113367. */
  113368. getWorldMatrix?(): Matrix;
  113369. /**
  113370. * Gets the child meshes
  113371. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  113372. * @returns An array of abstract meshes
  113373. */
  113374. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  113375. /**
  113376. * Gets the vertex data
  113377. * @param kind The type of vertex data
  113378. * @returns A nullable array of numbers, or a float32 array
  113379. */
  113380. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  113381. /**
  113382. * Gets the indices from the mesh
  113383. * @returns A nullable array of index arrays
  113384. */
  113385. getIndices?(): Nullable<IndicesArray>;
  113386. /**
  113387. * Gets the scene from the mesh
  113388. * @returns the indices array or null
  113389. */
  113390. getScene?(): Scene;
  113391. /**
  113392. * Gets the absolute position from the mesh
  113393. * @returns the absolute position
  113394. */
  113395. getAbsolutePosition(): Vector3;
  113396. /**
  113397. * Gets the absolute pivot point from the mesh
  113398. * @returns the absolute pivot point
  113399. */
  113400. getAbsolutePivotPoint(): Vector3;
  113401. /**
  113402. * Rotates the mesh
  113403. * @param axis The axis of rotation
  113404. * @param amount The amount of rotation
  113405. * @param space The space of the rotation
  113406. * @returns The rotation transform node
  113407. */
  113408. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  113409. /**
  113410. * Translates the mesh
  113411. * @param axis The axis of translation
  113412. * @param distance The distance of translation
  113413. * @param space The space of the translation
  113414. * @returns The transform node
  113415. */
  113416. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  113417. /**
  113418. * Sets the absolute position of the mesh
  113419. * @param absolutePosition The absolute position of the mesh
  113420. * @returns The transform node
  113421. */
  113422. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  113423. /**
  113424. * Gets the class name of the mesh
  113425. * @returns The class name
  113426. */
  113427. getClassName(): string;
  113428. }
  113429. /**
  113430. * Represents a physics imposter
  113431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113432. */
  113433. export class PhysicsImpostor {
  113434. /**
  113435. * The physics-enabled object used as the physics imposter
  113436. */
  113437. object: IPhysicsEnabledObject;
  113438. /**
  113439. * The type of the physics imposter
  113440. */
  113441. type: number;
  113442. private _options;
  113443. private _scene?;
  113444. /**
  113445. * The default object size of the imposter
  113446. */
  113447. static DEFAULT_OBJECT_SIZE: Vector3;
  113448. /**
  113449. * The identity quaternion of the imposter
  113450. */
  113451. static IDENTITY_QUATERNION: Quaternion;
  113452. /** @hidden */
  113453. _pluginData: any;
  113454. private _physicsEngine;
  113455. private _physicsBody;
  113456. private _bodyUpdateRequired;
  113457. private _onBeforePhysicsStepCallbacks;
  113458. private _onAfterPhysicsStepCallbacks;
  113459. /** @hidden */
  113460. _onPhysicsCollideCallbacks: Array<{
  113461. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  113462. otherImpostors: Array<PhysicsImpostor>;
  113463. }>;
  113464. private _deltaPosition;
  113465. private _deltaRotation;
  113466. private _deltaRotationConjugated;
  113467. /** @hidden */
  113468. _isFromLine: boolean;
  113469. private _parent;
  113470. private _isDisposed;
  113471. private static _tmpVecs;
  113472. private static _tmpQuat;
  113473. /**
  113474. * Specifies if the physics imposter is disposed
  113475. */
  113476. get isDisposed(): boolean;
  113477. /**
  113478. * Gets the mass of the physics imposter
  113479. */
  113480. get mass(): number;
  113481. set mass(value: number);
  113482. /**
  113483. * Gets the coefficient of friction
  113484. */
  113485. get friction(): number;
  113486. /**
  113487. * Sets the coefficient of friction
  113488. */
  113489. set friction(value: number);
  113490. /**
  113491. * Gets the coefficient of restitution
  113492. */
  113493. get restitution(): number;
  113494. /**
  113495. * Sets the coefficient of restitution
  113496. */
  113497. set restitution(value: number);
  113498. /**
  113499. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  113500. */
  113501. get pressure(): number;
  113502. /**
  113503. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  113504. */
  113505. set pressure(value: number);
  113506. /**
  113507. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113508. */
  113509. get stiffness(): number;
  113510. /**
  113511. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113512. */
  113513. set stiffness(value: number);
  113514. /**
  113515. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113516. */
  113517. get velocityIterations(): number;
  113518. /**
  113519. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113520. */
  113521. set velocityIterations(value: number);
  113522. /**
  113523. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113524. */
  113525. get positionIterations(): number;
  113526. /**
  113527. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113528. */
  113529. set positionIterations(value: number);
  113530. /**
  113531. * The unique id of the physics imposter
  113532. * set by the physics engine when adding this impostor to the array
  113533. */
  113534. uniqueId: number;
  113535. /**
  113536. * @hidden
  113537. */
  113538. soft: boolean;
  113539. /**
  113540. * @hidden
  113541. */
  113542. segments: number;
  113543. private _joints;
  113544. /**
  113545. * Initializes the physics imposter
  113546. * @param object The physics-enabled object used as the physics imposter
  113547. * @param type The type of the physics imposter
  113548. * @param _options The options for the physics imposter
  113549. * @param _scene The Babylon scene
  113550. */
  113551. constructor(
  113552. /**
  113553. * The physics-enabled object used as the physics imposter
  113554. */
  113555. object: IPhysicsEnabledObject,
  113556. /**
  113557. * The type of the physics imposter
  113558. */
  113559. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  113560. /**
  113561. * This function will completly initialize this impostor.
  113562. * It will create a new body - but only if this mesh has no parent.
  113563. * If it has, this impostor will not be used other than to define the impostor
  113564. * of the child mesh.
  113565. * @hidden
  113566. */
  113567. _init(): void;
  113568. private _getPhysicsParent;
  113569. /**
  113570. * Should a new body be generated.
  113571. * @returns boolean specifying if body initialization is required
  113572. */
  113573. isBodyInitRequired(): boolean;
  113574. /**
  113575. * Sets the updated scaling
  113576. * @param updated Specifies if the scaling is updated
  113577. */
  113578. setScalingUpdated(): void;
  113579. /**
  113580. * Force a regeneration of this or the parent's impostor's body.
  113581. * Use under cautious - This will remove all joints already implemented.
  113582. */
  113583. forceUpdate(): void;
  113584. /**
  113585. * Gets the body that holds this impostor. Either its own, or its parent.
  113586. */
  113587. get physicsBody(): any;
  113588. /**
  113589. * Get the parent of the physics imposter
  113590. * @returns Physics imposter or null
  113591. */
  113592. get parent(): Nullable<PhysicsImpostor>;
  113593. /**
  113594. * Sets the parent of the physics imposter
  113595. */
  113596. set parent(value: Nullable<PhysicsImpostor>);
  113597. /**
  113598. * Set the physics body. Used mainly by the physics engine/plugin
  113599. */
  113600. set physicsBody(physicsBody: any);
  113601. /**
  113602. * Resets the update flags
  113603. */
  113604. resetUpdateFlags(): void;
  113605. /**
  113606. * Gets the object extend size
  113607. * @returns the object extend size
  113608. */
  113609. getObjectExtendSize(): Vector3;
  113610. /**
  113611. * Gets the object center
  113612. * @returns The object center
  113613. */
  113614. getObjectCenter(): Vector3;
  113615. /**
  113616. * Get a specific parameter from the options parameters
  113617. * @param paramName The object parameter name
  113618. * @returns The object parameter
  113619. */
  113620. getParam(paramName: string): any;
  113621. /**
  113622. * Sets a specific parameter in the options given to the physics plugin
  113623. * @param paramName The parameter name
  113624. * @param value The value of the parameter
  113625. */
  113626. setParam(paramName: string, value: number): void;
  113627. /**
  113628. * Specifically change the body's mass option. Won't recreate the physics body object
  113629. * @param mass The mass of the physics imposter
  113630. */
  113631. setMass(mass: number): void;
  113632. /**
  113633. * Gets the linear velocity
  113634. * @returns linear velocity or null
  113635. */
  113636. getLinearVelocity(): Nullable<Vector3>;
  113637. /**
  113638. * Sets the linear velocity
  113639. * @param velocity linear velocity or null
  113640. */
  113641. setLinearVelocity(velocity: Nullable<Vector3>): void;
  113642. /**
  113643. * Gets the angular velocity
  113644. * @returns angular velocity or null
  113645. */
  113646. getAngularVelocity(): Nullable<Vector3>;
  113647. /**
  113648. * Sets the angular velocity
  113649. * @param velocity The velocity or null
  113650. */
  113651. setAngularVelocity(velocity: Nullable<Vector3>): void;
  113652. /**
  113653. * Execute a function with the physics plugin native code
  113654. * Provide a function the will have two variables - the world object and the physics body object
  113655. * @param func The function to execute with the physics plugin native code
  113656. */
  113657. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  113658. /**
  113659. * Register a function that will be executed before the physics world is stepping forward
  113660. * @param func The function to execute before the physics world is stepped forward
  113661. */
  113662. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113663. /**
  113664. * Unregister a function that will be executed before the physics world is stepping forward
  113665. * @param func The function to execute before the physics world is stepped forward
  113666. */
  113667. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113668. /**
  113669. * Register a function that will be executed after the physics step
  113670. * @param func The function to execute after physics step
  113671. */
  113672. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113673. /**
  113674. * Unregisters a function that will be executed after the physics step
  113675. * @param func The function to execute after physics step
  113676. */
  113677. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113678. /**
  113679. * register a function that will be executed when this impostor collides against a different body
  113680. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113681. * @param func Callback that is executed on collision
  113682. */
  113683. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  113684. /**
  113685. * Unregisters the physics imposter on contact
  113686. * @param collideAgainst The physics object to collide against
  113687. * @param func Callback to execute on collision
  113688. */
  113689. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  113690. private _tmpQuat;
  113691. private _tmpQuat2;
  113692. /**
  113693. * Get the parent rotation
  113694. * @returns The parent rotation
  113695. */
  113696. getParentsRotation(): Quaternion;
  113697. /**
  113698. * this function is executed by the physics engine.
  113699. */
  113700. beforeStep: () => void;
  113701. /**
  113702. * this function is executed by the physics engine
  113703. */
  113704. afterStep: () => void;
  113705. /**
  113706. * Legacy collision detection event support
  113707. */
  113708. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  113709. /**
  113710. * event and body object due to cannon's event-based architecture.
  113711. */
  113712. onCollide: (e: {
  113713. body: any;
  113714. point: Nullable<Vector3>;
  113715. }) => void;
  113716. /**
  113717. * Apply a force
  113718. * @param force The force to apply
  113719. * @param contactPoint The contact point for the force
  113720. * @returns The physics imposter
  113721. */
  113722. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113723. /**
  113724. * Apply an impulse
  113725. * @param force The impulse force
  113726. * @param contactPoint The contact point for the impulse force
  113727. * @returns The physics imposter
  113728. */
  113729. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113730. /**
  113731. * A help function to create a joint
  113732. * @param otherImpostor A physics imposter used to create a joint
  113733. * @param jointType The type of joint
  113734. * @param jointData The data for the joint
  113735. * @returns The physics imposter
  113736. */
  113737. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113738. /**
  113739. * Add a joint to this impostor with a different impostor
  113740. * @param otherImpostor A physics imposter used to add a joint
  113741. * @param joint The joint to add
  113742. * @returns The physics imposter
  113743. */
  113744. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113745. /**
  113746. * Add an anchor to a cloth impostor
  113747. * @param otherImpostor rigid impostor to anchor to
  113748. * @param width ratio across width from 0 to 1
  113749. * @param height ratio up height from 0 to 1
  113750. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113751. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113752. * @returns impostor the soft imposter
  113753. */
  113754. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113755. /**
  113756. * Add a hook to a rope impostor
  113757. * @param otherImpostor rigid impostor to anchor to
  113758. * @param length ratio across rope from 0 to 1
  113759. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113760. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113761. * @returns impostor the rope imposter
  113762. */
  113763. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113764. /**
  113765. * Will keep this body still, in a sleep mode.
  113766. * @returns the physics imposter
  113767. */
  113768. sleep(): PhysicsImpostor;
  113769. /**
  113770. * Wake the body up.
  113771. * @returns The physics imposter
  113772. */
  113773. wakeUp(): PhysicsImpostor;
  113774. /**
  113775. * Clones the physics imposter
  113776. * @param newObject The physics imposter clones to this physics-enabled object
  113777. * @returns A nullable physics imposter
  113778. */
  113779. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113780. /**
  113781. * Disposes the physics imposter
  113782. */
  113783. dispose(): void;
  113784. /**
  113785. * Sets the delta position
  113786. * @param position The delta position amount
  113787. */
  113788. setDeltaPosition(position: Vector3): void;
  113789. /**
  113790. * Sets the delta rotation
  113791. * @param rotation The delta rotation amount
  113792. */
  113793. setDeltaRotation(rotation: Quaternion): void;
  113794. /**
  113795. * Gets the box size of the physics imposter and stores the result in the input parameter
  113796. * @param result Stores the box size
  113797. * @returns The physics imposter
  113798. */
  113799. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113800. /**
  113801. * Gets the radius of the physics imposter
  113802. * @returns Radius of the physics imposter
  113803. */
  113804. getRadius(): number;
  113805. /**
  113806. * Sync a bone with this impostor
  113807. * @param bone The bone to sync to the impostor.
  113808. * @param boneMesh The mesh that the bone is influencing.
  113809. * @param jointPivot The pivot of the joint / bone in local space.
  113810. * @param distToJoint Optional distance from the impostor to the joint.
  113811. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113812. */
  113813. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113814. /**
  113815. * Sync impostor to a bone
  113816. * @param bone The bone that the impostor will be synced to.
  113817. * @param boneMesh The mesh that the bone is influencing.
  113818. * @param jointPivot The pivot of the joint / bone in local space.
  113819. * @param distToJoint Optional distance from the impostor to the joint.
  113820. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113821. * @param boneAxis Optional vector3 axis the bone is aligned with
  113822. */
  113823. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113824. /**
  113825. * No-Imposter type
  113826. */
  113827. static NoImpostor: number;
  113828. /**
  113829. * Sphere-Imposter type
  113830. */
  113831. static SphereImpostor: number;
  113832. /**
  113833. * Box-Imposter type
  113834. */
  113835. static BoxImpostor: number;
  113836. /**
  113837. * Plane-Imposter type
  113838. */
  113839. static PlaneImpostor: number;
  113840. /**
  113841. * Mesh-imposter type
  113842. */
  113843. static MeshImpostor: number;
  113844. /**
  113845. * Capsule-Impostor type (Ammo.js plugin only)
  113846. */
  113847. static CapsuleImpostor: number;
  113848. /**
  113849. * Cylinder-Imposter type
  113850. */
  113851. static CylinderImpostor: number;
  113852. /**
  113853. * Particle-Imposter type
  113854. */
  113855. static ParticleImpostor: number;
  113856. /**
  113857. * Heightmap-Imposter type
  113858. */
  113859. static HeightmapImpostor: number;
  113860. /**
  113861. * ConvexHull-Impostor type (Ammo.js plugin only)
  113862. */
  113863. static ConvexHullImpostor: number;
  113864. /**
  113865. * Custom-Imposter type (Ammo.js plugin only)
  113866. */
  113867. static CustomImpostor: number;
  113868. /**
  113869. * Rope-Imposter type
  113870. */
  113871. static RopeImpostor: number;
  113872. /**
  113873. * Cloth-Imposter type
  113874. */
  113875. static ClothImpostor: number;
  113876. /**
  113877. * Softbody-Imposter type
  113878. */
  113879. static SoftbodyImpostor: number;
  113880. }
  113881. }
  113882. declare module BABYLON {
  113883. /**
  113884. * @hidden
  113885. **/
  113886. export class _CreationDataStorage {
  113887. closePath?: boolean;
  113888. closeArray?: boolean;
  113889. idx: number[];
  113890. dashSize: number;
  113891. gapSize: number;
  113892. path3D: Path3D;
  113893. pathArray: Vector3[][];
  113894. arc: number;
  113895. radius: number;
  113896. cap: number;
  113897. tessellation: number;
  113898. }
  113899. /**
  113900. * @hidden
  113901. **/
  113902. class _InstanceDataStorage {
  113903. visibleInstances: any;
  113904. batchCache: _InstancesBatch;
  113905. instancesBufferSize: number;
  113906. instancesBuffer: Nullable<Buffer>;
  113907. instancesData: Float32Array;
  113908. overridenInstanceCount: number;
  113909. isFrozen: boolean;
  113910. previousBatch: Nullable<_InstancesBatch>;
  113911. hardwareInstancedRendering: boolean;
  113912. sideOrientation: number;
  113913. manualUpdate: boolean;
  113914. previousRenderId: number;
  113915. }
  113916. /**
  113917. * @hidden
  113918. **/
  113919. export class _InstancesBatch {
  113920. mustReturn: boolean;
  113921. visibleInstances: Nullable<InstancedMesh[]>[];
  113922. renderSelf: boolean[];
  113923. hardwareInstancedRendering: boolean[];
  113924. }
  113925. /**
  113926. * @hidden
  113927. **/
  113928. class _ThinInstanceDataStorage {
  113929. instancesCount: number;
  113930. matrixBuffer: Nullable<Buffer>;
  113931. matrixBufferSize: number;
  113932. matrixData: Nullable<Float32Array>;
  113933. boundingVectors: Array<Vector3>;
  113934. worldMatrices: Nullable<Matrix[]>;
  113935. }
  113936. /**
  113937. * Class used to represent renderable models
  113938. */
  113939. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113940. /**
  113941. * Mesh side orientation : usually the external or front surface
  113942. */
  113943. static readonly FRONTSIDE: number;
  113944. /**
  113945. * Mesh side orientation : usually the internal or back surface
  113946. */
  113947. static readonly BACKSIDE: number;
  113948. /**
  113949. * Mesh side orientation : both internal and external or front and back surfaces
  113950. */
  113951. static readonly DOUBLESIDE: number;
  113952. /**
  113953. * Mesh side orientation : by default, `FRONTSIDE`
  113954. */
  113955. static readonly DEFAULTSIDE: number;
  113956. /**
  113957. * Mesh cap setting : no cap
  113958. */
  113959. static readonly NO_CAP: number;
  113960. /**
  113961. * Mesh cap setting : one cap at the beginning of the mesh
  113962. */
  113963. static readonly CAP_START: number;
  113964. /**
  113965. * Mesh cap setting : one cap at the end of the mesh
  113966. */
  113967. static readonly CAP_END: number;
  113968. /**
  113969. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113970. */
  113971. static readonly CAP_ALL: number;
  113972. /**
  113973. * Mesh pattern setting : no flip or rotate
  113974. */
  113975. static readonly NO_FLIP: number;
  113976. /**
  113977. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113978. */
  113979. static readonly FLIP_TILE: number;
  113980. /**
  113981. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113982. */
  113983. static readonly ROTATE_TILE: number;
  113984. /**
  113985. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113986. */
  113987. static readonly FLIP_ROW: number;
  113988. /**
  113989. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113990. */
  113991. static readonly ROTATE_ROW: number;
  113992. /**
  113993. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113994. */
  113995. static readonly FLIP_N_ROTATE_TILE: number;
  113996. /**
  113997. * Mesh pattern setting : rotate pattern and rotate
  113998. */
  113999. static readonly FLIP_N_ROTATE_ROW: number;
  114000. /**
  114001. * Mesh tile positioning : part tiles same on left/right or top/bottom
  114002. */
  114003. static readonly CENTER: number;
  114004. /**
  114005. * Mesh tile positioning : part tiles on left
  114006. */
  114007. static readonly LEFT: number;
  114008. /**
  114009. * Mesh tile positioning : part tiles on right
  114010. */
  114011. static readonly RIGHT: number;
  114012. /**
  114013. * Mesh tile positioning : part tiles on top
  114014. */
  114015. static readonly TOP: number;
  114016. /**
  114017. * Mesh tile positioning : part tiles on bottom
  114018. */
  114019. static readonly BOTTOM: number;
  114020. /**
  114021. * Gets the default side orientation.
  114022. * @param orientation the orientation to value to attempt to get
  114023. * @returns the default orientation
  114024. * @hidden
  114025. */
  114026. static _GetDefaultSideOrientation(orientation?: number): number;
  114027. private _internalMeshDataInfo;
  114028. get computeBonesUsingShaders(): boolean;
  114029. set computeBonesUsingShaders(value: boolean);
  114030. /**
  114031. * An event triggered before rendering the mesh
  114032. */
  114033. get onBeforeRenderObservable(): Observable<Mesh>;
  114034. /**
  114035. * An event triggered before binding the mesh
  114036. */
  114037. get onBeforeBindObservable(): Observable<Mesh>;
  114038. /**
  114039. * An event triggered after rendering the mesh
  114040. */
  114041. get onAfterRenderObservable(): Observable<Mesh>;
  114042. /**
  114043. * An event triggered before drawing the mesh
  114044. */
  114045. get onBeforeDrawObservable(): Observable<Mesh>;
  114046. private _onBeforeDrawObserver;
  114047. /**
  114048. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  114049. */
  114050. set onBeforeDraw(callback: () => void);
  114051. get hasInstances(): boolean;
  114052. get hasThinInstances(): boolean;
  114053. /**
  114054. * Gets the delay loading state of the mesh (when delay loading is turned on)
  114055. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  114056. */
  114057. delayLoadState: number;
  114058. /**
  114059. * Gets the list of instances created from this mesh
  114060. * it is not supposed to be modified manually.
  114061. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  114062. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114063. */
  114064. instances: InstancedMesh[];
  114065. /**
  114066. * Gets the file containing delay loading data for this mesh
  114067. */
  114068. delayLoadingFile: string;
  114069. /** @hidden */
  114070. _binaryInfo: any;
  114071. /**
  114072. * User defined function used to change how LOD level selection is done
  114073. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114074. */
  114075. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  114076. /**
  114077. * Gets or sets the morph target manager
  114078. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  114079. */
  114080. get morphTargetManager(): Nullable<MorphTargetManager>;
  114081. set morphTargetManager(value: Nullable<MorphTargetManager>);
  114082. /** @hidden */
  114083. _creationDataStorage: Nullable<_CreationDataStorage>;
  114084. /** @hidden */
  114085. _geometry: Nullable<Geometry>;
  114086. /** @hidden */
  114087. _delayInfo: Array<string>;
  114088. /** @hidden */
  114089. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  114090. /** @hidden */
  114091. _instanceDataStorage: _InstanceDataStorage;
  114092. /** @hidden */
  114093. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  114094. private _effectiveMaterial;
  114095. /** @hidden */
  114096. _shouldGenerateFlatShading: boolean;
  114097. /** @hidden */
  114098. _originalBuilderSideOrientation: number;
  114099. /**
  114100. * Use this property to change the original side orientation defined at construction time
  114101. */
  114102. overrideMaterialSideOrientation: Nullable<number>;
  114103. /**
  114104. * Gets the source mesh (the one used to clone this one from)
  114105. */
  114106. get source(): Nullable<Mesh>;
  114107. /**
  114108. * Gets the list of clones of this mesh
  114109. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  114110. * Note that useClonedMeshMap=true is the default setting
  114111. */
  114112. get cloneMeshMap(): Nullable<{
  114113. [id: string]: Mesh | undefined;
  114114. }>;
  114115. /**
  114116. * Gets or sets a boolean indicating that this mesh does not use index buffer
  114117. */
  114118. get isUnIndexed(): boolean;
  114119. set isUnIndexed(value: boolean);
  114120. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  114121. get worldMatrixInstancedBuffer(): Float32Array;
  114122. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  114123. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  114124. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  114125. /**
  114126. * @constructor
  114127. * @param name The value used by scene.getMeshByName() to do a lookup.
  114128. * @param scene The scene to add this mesh to.
  114129. * @param parent The parent of this mesh, if it has one
  114130. * @param source An optional Mesh from which geometry is shared, cloned.
  114131. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  114132. * When false, achieved by calling a clone(), also passing False.
  114133. * This will make creation of children, recursive.
  114134. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  114135. */
  114136. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  114137. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  114138. doNotInstantiate: boolean;
  114139. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  114140. /**
  114141. * Gets the class name
  114142. * @returns the string "Mesh".
  114143. */
  114144. getClassName(): string;
  114145. /** @hidden */
  114146. get _isMesh(): boolean;
  114147. /**
  114148. * Returns a description of this mesh
  114149. * @param fullDetails define if full details about this mesh must be used
  114150. * @returns a descriptive string representing this mesh
  114151. */
  114152. toString(fullDetails?: boolean): string;
  114153. /** @hidden */
  114154. _unBindEffect(): void;
  114155. /**
  114156. * Gets a boolean indicating if this mesh has LOD
  114157. */
  114158. get hasLODLevels(): boolean;
  114159. /**
  114160. * Gets the list of MeshLODLevel associated with the current mesh
  114161. * @returns an array of MeshLODLevel
  114162. */
  114163. getLODLevels(): MeshLODLevel[];
  114164. private _sortLODLevels;
  114165. /**
  114166. * Add a mesh as LOD level triggered at the given distance.
  114167. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114168. * @param distance The distance from the center of the object to show this level
  114169. * @param mesh The mesh to be added as LOD level (can be null)
  114170. * @return This mesh (for chaining)
  114171. */
  114172. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  114173. /**
  114174. * Returns the LOD level mesh at the passed distance or null if not found.
  114175. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114176. * @param distance The distance from the center of the object to show this level
  114177. * @returns a Mesh or `null`
  114178. */
  114179. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  114180. /**
  114181. * Remove a mesh from the LOD array
  114182. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114183. * @param mesh defines the mesh to be removed
  114184. * @return This mesh (for chaining)
  114185. */
  114186. removeLODLevel(mesh: Mesh): Mesh;
  114187. /**
  114188. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  114189. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114190. * @param camera defines the camera to use to compute distance
  114191. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  114192. * @return This mesh (for chaining)
  114193. */
  114194. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  114195. /**
  114196. * Gets the mesh internal Geometry object
  114197. */
  114198. get geometry(): Nullable<Geometry>;
  114199. /**
  114200. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  114201. * @returns the total number of vertices
  114202. */
  114203. getTotalVertices(): number;
  114204. /**
  114205. * Returns the content of an associated vertex buffer
  114206. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114207. * - VertexBuffer.PositionKind
  114208. * - VertexBuffer.UVKind
  114209. * - VertexBuffer.UV2Kind
  114210. * - VertexBuffer.UV3Kind
  114211. * - VertexBuffer.UV4Kind
  114212. * - VertexBuffer.UV5Kind
  114213. * - VertexBuffer.UV6Kind
  114214. * - VertexBuffer.ColorKind
  114215. * - VertexBuffer.MatricesIndicesKind
  114216. * - VertexBuffer.MatricesIndicesExtraKind
  114217. * - VertexBuffer.MatricesWeightsKind
  114218. * - VertexBuffer.MatricesWeightsExtraKind
  114219. * @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
  114220. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  114221. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  114222. */
  114223. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  114224. /**
  114225. * Returns the mesh VertexBuffer object from the requested `kind`
  114226. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114227. * - VertexBuffer.PositionKind
  114228. * - VertexBuffer.NormalKind
  114229. * - VertexBuffer.UVKind
  114230. * - VertexBuffer.UV2Kind
  114231. * - VertexBuffer.UV3Kind
  114232. * - VertexBuffer.UV4Kind
  114233. * - VertexBuffer.UV5Kind
  114234. * - VertexBuffer.UV6Kind
  114235. * - VertexBuffer.ColorKind
  114236. * - VertexBuffer.MatricesIndicesKind
  114237. * - VertexBuffer.MatricesIndicesExtraKind
  114238. * - VertexBuffer.MatricesWeightsKind
  114239. * - VertexBuffer.MatricesWeightsExtraKind
  114240. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  114241. */
  114242. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  114243. /**
  114244. * Tests if a specific vertex buffer is associated with this mesh
  114245. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114246. * - VertexBuffer.PositionKind
  114247. * - VertexBuffer.NormalKind
  114248. * - VertexBuffer.UVKind
  114249. * - VertexBuffer.UV2Kind
  114250. * - VertexBuffer.UV3Kind
  114251. * - VertexBuffer.UV4Kind
  114252. * - VertexBuffer.UV5Kind
  114253. * - VertexBuffer.UV6Kind
  114254. * - VertexBuffer.ColorKind
  114255. * - VertexBuffer.MatricesIndicesKind
  114256. * - VertexBuffer.MatricesIndicesExtraKind
  114257. * - VertexBuffer.MatricesWeightsKind
  114258. * - VertexBuffer.MatricesWeightsExtraKind
  114259. * @returns a boolean
  114260. */
  114261. isVerticesDataPresent(kind: string): boolean;
  114262. /**
  114263. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  114264. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114265. * - VertexBuffer.PositionKind
  114266. * - VertexBuffer.UVKind
  114267. * - VertexBuffer.UV2Kind
  114268. * - VertexBuffer.UV3Kind
  114269. * - VertexBuffer.UV4Kind
  114270. * - VertexBuffer.UV5Kind
  114271. * - VertexBuffer.UV6Kind
  114272. * - VertexBuffer.ColorKind
  114273. * - VertexBuffer.MatricesIndicesKind
  114274. * - VertexBuffer.MatricesIndicesExtraKind
  114275. * - VertexBuffer.MatricesWeightsKind
  114276. * - VertexBuffer.MatricesWeightsExtraKind
  114277. * @returns a boolean
  114278. */
  114279. isVertexBufferUpdatable(kind: string): boolean;
  114280. /**
  114281. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  114282. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114283. * - VertexBuffer.PositionKind
  114284. * - VertexBuffer.NormalKind
  114285. * - VertexBuffer.UVKind
  114286. * - VertexBuffer.UV2Kind
  114287. * - VertexBuffer.UV3Kind
  114288. * - VertexBuffer.UV4Kind
  114289. * - VertexBuffer.UV5Kind
  114290. * - VertexBuffer.UV6Kind
  114291. * - VertexBuffer.ColorKind
  114292. * - VertexBuffer.MatricesIndicesKind
  114293. * - VertexBuffer.MatricesIndicesExtraKind
  114294. * - VertexBuffer.MatricesWeightsKind
  114295. * - VertexBuffer.MatricesWeightsExtraKind
  114296. * @returns an array of strings
  114297. */
  114298. getVerticesDataKinds(): string[];
  114299. /**
  114300. * Returns a positive integer : the total number of indices in this mesh geometry.
  114301. * @returns the numner of indices or zero if the mesh has no geometry.
  114302. */
  114303. getTotalIndices(): number;
  114304. /**
  114305. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  114306. * @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.
  114307. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114308. * @returns the indices array or an empty array if the mesh has no geometry
  114309. */
  114310. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  114311. get isBlocked(): boolean;
  114312. /**
  114313. * Determine if the current mesh is ready to be rendered
  114314. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  114315. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  114316. * @returns true if all associated assets are ready (material, textures, shaders)
  114317. */
  114318. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  114319. /**
  114320. * 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.
  114321. */
  114322. get areNormalsFrozen(): boolean;
  114323. /**
  114324. * 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.
  114325. * @returns the current mesh
  114326. */
  114327. freezeNormals(): Mesh;
  114328. /**
  114329. * 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
  114330. * @returns the current mesh
  114331. */
  114332. unfreezeNormals(): Mesh;
  114333. /**
  114334. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  114335. */
  114336. set overridenInstanceCount(count: number);
  114337. /** @hidden */
  114338. _preActivate(): Mesh;
  114339. /** @hidden */
  114340. _preActivateForIntermediateRendering(renderId: number): Mesh;
  114341. /** @hidden */
  114342. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  114343. protected _afterComputeWorldMatrix(): void;
  114344. /** @hidden */
  114345. _postActivate(): void;
  114346. /**
  114347. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  114348. * This means the mesh underlying bounding box and sphere are recomputed.
  114349. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  114350. * @returns the current mesh
  114351. */
  114352. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  114353. /** @hidden */
  114354. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  114355. /**
  114356. * This function will subdivide the mesh into multiple submeshes
  114357. * @param count defines the expected number of submeshes
  114358. */
  114359. subdivide(count: number): void;
  114360. /**
  114361. * Copy a FloatArray into a specific associated vertex buffer
  114362. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114363. * - VertexBuffer.PositionKind
  114364. * - VertexBuffer.UVKind
  114365. * - VertexBuffer.UV2Kind
  114366. * - VertexBuffer.UV3Kind
  114367. * - VertexBuffer.UV4Kind
  114368. * - VertexBuffer.UV5Kind
  114369. * - VertexBuffer.UV6Kind
  114370. * - VertexBuffer.ColorKind
  114371. * - VertexBuffer.MatricesIndicesKind
  114372. * - VertexBuffer.MatricesIndicesExtraKind
  114373. * - VertexBuffer.MatricesWeightsKind
  114374. * - VertexBuffer.MatricesWeightsExtraKind
  114375. * @param data defines the data source
  114376. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114377. * @param stride defines the data stride size (can be null)
  114378. * @returns the current mesh
  114379. */
  114380. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  114381. /**
  114382. * Delete a vertex buffer associated with this mesh
  114383. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  114384. * - VertexBuffer.PositionKind
  114385. * - VertexBuffer.UVKind
  114386. * - VertexBuffer.UV2Kind
  114387. * - VertexBuffer.UV3Kind
  114388. * - VertexBuffer.UV4Kind
  114389. * - VertexBuffer.UV5Kind
  114390. * - VertexBuffer.UV6Kind
  114391. * - VertexBuffer.ColorKind
  114392. * - VertexBuffer.MatricesIndicesKind
  114393. * - VertexBuffer.MatricesIndicesExtraKind
  114394. * - VertexBuffer.MatricesWeightsKind
  114395. * - VertexBuffer.MatricesWeightsExtraKind
  114396. */
  114397. removeVerticesData(kind: string): void;
  114398. /**
  114399. * Flags an associated vertex buffer as updatable
  114400. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  114401. * - VertexBuffer.PositionKind
  114402. * - VertexBuffer.UVKind
  114403. * - VertexBuffer.UV2Kind
  114404. * - VertexBuffer.UV3Kind
  114405. * - VertexBuffer.UV4Kind
  114406. * - VertexBuffer.UV5Kind
  114407. * - VertexBuffer.UV6Kind
  114408. * - VertexBuffer.ColorKind
  114409. * - VertexBuffer.MatricesIndicesKind
  114410. * - VertexBuffer.MatricesIndicesExtraKind
  114411. * - VertexBuffer.MatricesWeightsKind
  114412. * - VertexBuffer.MatricesWeightsExtraKind
  114413. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114414. */
  114415. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  114416. /**
  114417. * Sets the mesh global Vertex Buffer
  114418. * @param buffer defines the buffer to use
  114419. * @returns the current mesh
  114420. */
  114421. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  114422. /**
  114423. * Update a specific associated vertex buffer
  114424. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114425. * - VertexBuffer.PositionKind
  114426. * - VertexBuffer.UVKind
  114427. * - VertexBuffer.UV2Kind
  114428. * - VertexBuffer.UV3Kind
  114429. * - VertexBuffer.UV4Kind
  114430. * - VertexBuffer.UV5Kind
  114431. * - VertexBuffer.UV6Kind
  114432. * - VertexBuffer.ColorKind
  114433. * - VertexBuffer.MatricesIndicesKind
  114434. * - VertexBuffer.MatricesIndicesExtraKind
  114435. * - VertexBuffer.MatricesWeightsKind
  114436. * - VertexBuffer.MatricesWeightsExtraKind
  114437. * @param data defines the data source
  114438. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  114439. * @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)
  114440. * @returns the current mesh
  114441. */
  114442. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  114443. /**
  114444. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  114445. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  114446. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  114447. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  114448. * @returns the current mesh
  114449. */
  114450. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  114451. /**
  114452. * Creates a un-shared specific occurence of the geometry for the mesh.
  114453. * @returns the current mesh
  114454. */
  114455. makeGeometryUnique(): Mesh;
  114456. /**
  114457. * Set the index buffer of this mesh
  114458. * @param indices defines the source data
  114459. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  114460. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  114461. * @returns the current mesh
  114462. */
  114463. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  114464. /**
  114465. * Update the current index buffer
  114466. * @param indices defines the source data
  114467. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  114468. * @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)
  114469. * @returns the current mesh
  114470. */
  114471. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  114472. /**
  114473. * Invert the geometry to move from a right handed system to a left handed one.
  114474. * @returns the current mesh
  114475. */
  114476. toLeftHanded(): Mesh;
  114477. /** @hidden */
  114478. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  114479. /** @hidden */
  114480. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  114481. /**
  114482. * Registers for this mesh a javascript function called just before the rendering process
  114483. * @param func defines the function to call before rendering this mesh
  114484. * @returns the current mesh
  114485. */
  114486. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114487. /**
  114488. * Disposes a previously registered javascript function called before the rendering
  114489. * @param func defines the function to remove
  114490. * @returns the current mesh
  114491. */
  114492. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114493. /**
  114494. * Registers for this mesh a javascript function called just after the rendering is complete
  114495. * @param func defines the function to call after rendering this mesh
  114496. * @returns the current mesh
  114497. */
  114498. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114499. /**
  114500. * Disposes a previously registered javascript function called after the rendering.
  114501. * @param func defines the function to remove
  114502. * @returns the current mesh
  114503. */
  114504. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114505. /** @hidden */
  114506. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  114507. /** @hidden */
  114508. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  114509. /** @hidden */
  114510. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  114511. /** @hidden */
  114512. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  114513. /** @hidden */
  114514. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  114515. /** @hidden */
  114516. _rebuild(): void;
  114517. /** @hidden */
  114518. _freeze(): void;
  114519. /** @hidden */
  114520. _unFreeze(): void;
  114521. /**
  114522. * 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
  114523. * @param subMesh defines the subMesh to render
  114524. * @param enableAlphaMode defines if alpha mode can be changed
  114525. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  114526. * @returns the current mesh
  114527. */
  114528. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  114529. private _onBeforeDraw;
  114530. /**
  114531. * Renormalize the mesh and patch it up if there are no weights
  114532. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  114533. * However in the case of zero weights then we set just a single influence to 1.
  114534. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  114535. */
  114536. cleanMatrixWeights(): void;
  114537. private normalizeSkinFourWeights;
  114538. private normalizeSkinWeightsAndExtra;
  114539. /**
  114540. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  114541. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  114542. * the user know there was an issue with importing the mesh
  114543. * @returns a validation object with skinned, valid and report string
  114544. */
  114545. validateSkinning(): {
  114546. skinned: boolean;
  114547. valid: boolean;
  114548. report: string;
  114549. };
  114550. /** @hidden */
  114551. _checkDelayState(): Mesh;
  114552. private _queueLoad;
  114553. /**
  114554. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  114555. * A mesh is in the frustum if its bounding box intersects the frustum
  114556. * @param frustumPlanes defines the frustum to test
  114557. * @returns true if the mesh is in the frustum planes
  114558. */
  114559. isInFrustum(frustumPlanes: Plane[]): boolean;
  114560. /**
  114561. * Sets the mesh material by the material or multiMaterial `id` property
  114562. * @param id is a string identifying the material or the multiMaterial
  114563. * @returns the current mesh
  114564. */
  114565. setMaterialByID(id: string): Mesh;
  114566. /**
  114567. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  114568. * @returns an array of IAnimatable
  114569. */
  114570. getAnimatables(): IAnimatable[];
  114571. /**
  114572. * Modifies the mesh geometry according to the passed transformation matrix.
  114573. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  114574. * The mesh normals are modified using the same transformation.
  114575. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114576. * @param transform defines the transform matrix to use
  114577. * @see https://doc.babylonjs.com/resources/baking_transformations
  114578. * @returns the current mesh
  114579. */
  114580. bakeTransformIntoVertices(transform: Matrix): Mesh;
  114581. /**
  114582. * Modifies the mesh geometry according to its own current World Matrix.
  114583. * The mesh World Matrix is then reset.
  114584. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  114585. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114586. * @see https://doc.babylonjs.com/resources/baking_transformations
  114587. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  114588. * @returns the current mesh
  114589. */
  114590. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  114591. /** @hidden */
  114592. get _positions(): Nullable<Vector3[]>;
  114593. /** @hidden */
  114594. _resetPointsArrayCache(): Mesh;
  114595. /** @hidden */
  114596. _generatePointsArray(): boolean;
  114597. /**
  114598. * Returns a new Mesh object generated from the current mesh properties.
  114599. * This method must not get confused with createInstance()
  114600. * @param name is a string, the name given to the new mesh
  114601. * @param newParent can be any Node object (default `null`)
  114602. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  114603. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  114604. * @returns a new mesh
  114605. */
  114606. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  114607. /**
  114608. * Releases resources associated with this mesh.
  114609. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114610. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114611. */
  114612. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114613. /** @hidden */
  114614. _disposeInstanceSpecificData(): void;
  114615. /** @hidden */
  114616. _disposeThinInstanceSpecificData(): void;
  114617. /**
  114618. * Modifies the mesh geometry according to a displacement map.
  114619. * 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.
  114620. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114621. * @param url is a string, the URL from the image file is to be downloaded.
  114622. * @param minHeight is the lower limit of the displacement.
  114623. * @param maxHeight is the upper limit of the displacement.
  114624. * @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.
  114625. * @param uvOffset is an optional vector2 used to offset UV.
  114626. * @param uvScale is an optional vector2 used to scale UV.
  114627. * @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.
  114628. * @returns the Mesh.
  114629. */
  114630. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114631. /**
  114632. * Modifies the mesh geometry according to a displacementMap buffer.
  114633. * 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.
  114634. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114635. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  114636. * @param heightMapWidth is the width of the buffer image.
  114637. * @param heightMapHeight is the height of the buffer image.
  114638. * @param minHeight is the lower limit of the displacement.
  114639. * @param maxHeight is the upper limit of the displacement.
  114640. * @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.
  114641. * @param uvOffset is an optional vector2 used to offset UV.
  114642. * @param uvScale is an optional vector2 used to scale UV.
  114643. * @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.
  114644. * @returns the Mesh.
  114645. */
  114646. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114647. /**
  114648. * Modify the mesh to get a flat shading rendering.
  114649. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  114650. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  114651. * @returns current mesh
  114652. */
  114653. convertToFlatShadedMesh(): Mesh;
  114654. /**
  114655. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  114656. * In other words, more vertices, no more indices and a single bigger VBO.
  114657. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  114658. * @returns current mesh
  114659. */
  114660. convertToUnIndexedMesh(): Mesh;
  114661. /**
  114662. * Inverses facet orientations.
  114663. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114664. * @param flipNormals will also inverts the normals
  114665. * @returns current mesh
  114666. */
  114667. flipFaces(flipNormals?: boolean): Mesh;
  114668. /**
  114669. * Increase the number of facets and hence vertices in a mesh
  114670. * Vertex normals are interpolated from existing vertex normals
  114671. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114672. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  114673. */
  114674. increaseVertices(numberPerEdge: number): void;
  114675. /**
  114676. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  114677. * This will undo any application of covertToFlatShadedMesh
  114678. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114679. */
  114680. forceSharedVertices(): void;
  114681. /** @hidden */
  114682. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  114683. /** @hidden */
  114684. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  114685. /**
  114686. * Creates a new InstancedMesh object from the mesh model.
  114687. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114688. * @param name defines the name of the new instance
  114689. * @returns a new InstancedMesh
  114690. */
  114691. createInstance(name: string): InstancedMesh;
  114692. /**
  114693. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  114694. * After this call, all the mesh instances have the same submeshes than the current mesh.
  114695. * @returns the current mesh
  114696. */
  114697. synchronizeInstances(): Mesh;
  114698. /**
  114699. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  114700. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  114701. * This should be used together with the simplification to avoid disappearing triangles.
  114702. * @param successCallback an optional success callback to be called after the optimization finished.
  114703. * @returns the current mesh
  114704. */
  114705. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  114706. /**
  114707. * Serialize current mesh
  114708. * @param serializationObject defines the object which will receive the serialization data
  114709. */
  114710. serialize(serializationObject: any): void;
  114711. /** @hidden */
  114712. _syncGeometryWithMorphTargetManager(): void;
  114713. /** @hidden */
  114714. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  114715. /**
  114716. * Returns a new Mesh object parsed from the source provided.
  114717. * @param parsedMesh is the source
  114718. * @param scene defines the hosting scene
  114719. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  114720. * @returns a new Mesh
  114721. */
  114722. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  114723. /**
  114724. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  114725. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114726. * @param name defines the name of the mesh to create
  114727. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114728. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114729. * @param closePath creates a seam between the first and the last points of each path of the path array
  114730. * @param offset is taken in account only if the `pathArray` is containing a single path
  114731. * @param scene defines the hosting scene
  114732. * @param updatable defines if the mesh must be flagged as updatable
  114733. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114734. * @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)
  114735. * @returns a new Mesh
  114736. */
  114737. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114738. /**
  114739. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114740. * @param name defines the name of the mesh to create
  114741. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114742. * @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
  114743. * @param scene defines the hosting scene
  114744. * @param updatable defines if the mesh must be flagged as updatable
  114745. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114746. * @returns a new Mesh
  114747. */
  114748. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114749. /**
  114750. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114751. * @param name defines the name of the mesh to create
  114752. * @param size sets the size (float) of each box side (default 1)
  114753. * @param scene defines the hosting scene
  114754. * @param updatable defines if the mesh must be flagged as updatable
  114755. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114756. * @returns a new Mesh
  114757. */
  114758. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114759. /**
  114760. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114761. * @param name defines the name of the mesh to create
  114762. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114763. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114764. * @param scene defines the hosting scene
  114765. * @param updatable defines if the mesh must be flagged as updatable
  114766. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114767. * @returns a new Mesh
  114768. */
  114769. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114770. /**
  114771. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114772. * @param name defines the name of the mesh to create
  114773. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114774. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114775. * @param scene defines the hosting scene
  114776. * @returns a new Mesh
  114777. */
  114778. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114779. /**
  114780. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114781. * @param name defines the name of the mesh to create
  114782. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114783. * @param diameterTop set the top cap diameter (floats, default 1)
  114784. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114785. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114786. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114787. * @param scene defines the hosting scene
  114788. * @param updatable defines if the mesh must be flagged as updatable
  114789. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114790. * @returns a new Mesh
  114791. */
  114792. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114793. /**
  114794. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114795. * @param name defines the name of the mesh to create
  114796. * @param diameter sets the diameter size (float) of the torus (default 1)
  114797. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114798. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114799. * @param scene defines the hosting scene
  114800. * @param updatable defines if the mesh must be flagged as updatable
  114801. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114802. * @returns a new Mesh
  114803. */
  114804. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114805. /**
  114806. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114807. * @param name defines the name of the mesh to create
  114808. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114809. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114810. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114811. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114812. * @param p the number of windings on X axis (positive integers, default 2)
  114813. * @param q the number of windings on Y axis (positive integers, default 3)
  114814. * @param scene defines the hosting scene
  114815. * @param updatable defines if the mesh must be flagged as updatable
  114816. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114817. * @returns a new Mesh
  114818. */
  114819. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114820. /**
  114821. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114822. * @param name defines the name of the mesh to create
  114823. * @param points is an array successive Vector3
  114824. * @param scene defines the hosting scene
  114825. * @param updatable defines if the mesh must be flagged as updatable
  114826. * @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).
  114827. * @returns a new Mesh
  114828. */
  114829. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114830. /**
  114831. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114832. * @param name defines the name of the mesh to create
  114833. * @param points is an array successive Vector3
  114834. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114835. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114836. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114837. * @param scene defines the hosting scene
  114838. * @param updatable defines if the mesh must be flagged as updatable
  114839. * @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)
  114840. * @returns a new Mesh
  114841. */
  114842. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114843. /**
  114844. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114845. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114846. * 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.
  114847. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114848. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114849. * Remember you can only change the shape positions, not their number when updating a polygon.
  114850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114851. * @param name defines the name of the mesh to create
  114852. * @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
  114853. * @param scene defines the hosting scene
  114854. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114855. * @param updatable defines if the mesh must be flagged as updatable
  114856. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114857. * @param earcutInjection can be used to inject your own earcut reference
  114858. * @returns a new Mesh
  114859. */
  114860. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114861. /**
  114862. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114864. * @param name defines the name of the mesh to create
  114865. * @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
  114866. * @param depth defines the height of extrusion
  114867. * @param scene defines the hosting scene
  114868. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114869. * @param updatable defines if the mesh must be flagged as updatable
  114870. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114871. * @param earcutInjection can be used to inject your own earcut reference
  114872. * @returns a new Mesh
  114873. */
  114874. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114875. /**
  114876. * Creates an extruded shape mesh.
  114877. * 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
  114878. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114880. * @param name defines the name of the mesh to create
  114881. * @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
  114882. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114883. * @param scale is the value to scale the shape
  114884. * @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
  114885. * @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
  114886. * @param scene defines the hosting scene
  114887. * @param updatable defines if the mesh must be flagged as updatable
  114888. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114889. * @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)
  114890. * @returns a new Mesh
  114891. */
  114892. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114893. /**
  114894. * Creates an custom extruded shape mesh.
  114895. * The custom extrusion is a parametric shape.
  114896. * It has no predefined shape. Its final shape will depend on the input parameters.
  114897. * Please consider using the same method from the MeshBuilder class instead
  114898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114899. * @param name defines the name of the mesh to create
  114900. * @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
  114901. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114902. * @param scaleFunction is a custom Javascript function called on each path point
  114903. * @param rotationFunction is a custom Javascript function called on each path point
  114904. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114905. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114906. * @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
  114907. * @param scene defines the hosting scene
  114908. * @param updatable defines if the mesh must be flagged as updatable
  114909. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114910. * @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)
  114911. * @returns a new Mesh
  114912. */
  114913. 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;
  114914. /**
  114915. * Creates lathe mesh.
  114916. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114917. * Please consider using the same method from the MeshBuilder class instead
  114918. * @param name defines the name of the mesh to create
  114919. * @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
  114920. * @param radius is the radius value of the lathe
  114921. * @param tessellation is the side number of the lathe.
  114922. * @param scene defines the hosting scene
  114923. * @param updatable defines if the mesh must be flagged as updatable
  114924. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114925. * @returns a new Mesh
  114926. */
  114927. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114928. /**
  114929. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114930. * @param name defines the name of the mesh to create
  114931. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114932. * @param scene defines the hosting scene
  114933. * @param updatable defines if the mesh must be flagged as updatable
  114934. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114935. * @returns a new Mesh
  114936. */
  114937. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114938. /**
  114939. * Creates a ground mesh.
  114940. * Please consider using the same method from the MeshBuilder class instead
  114941. * @param name defines the name of the mesh to create
  114942. * @param width set the width of the ground
  114943. * @param height set the height of the ground
  114944. * @param subdivisions sets the number of subdivisions per side
  114945. * @param scene defines the hosting scene
  114946. * @param updatable defines if the mesh must be flagged as updatable
  114947. * @returns a new Mesh
  114948. */
  114949. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114950. /**
  114951. * Creates a tiled ground mesh.
  114952. * Please consider using the same method from the MeshBuilder class instead
  114953. * @param name defines the name of the mesh to create
  114954. * @param xmin set the ground minimum X coordinate
  114955. * @param zmin set the ground minimum Y coordinate
  114956. * @param xmax set the ground maximum X coordinate
  114957. * @param zmax set the ground maximum Z coordinate
  114958. * @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
  114959. * @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
  114960. * @param scene defines the hosting scene
  114961. * @param updatable defines if the mesh must be flagged as updatable
  114962. * @returns a new Mesh
  114963. */
  114964. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114965. w: number;
  114966. h: number;
  114967. }, precision: {
  114968. w: number;
  114969. h: number;
  114970. }, scene: Scene, updatable?: boolean): Mesh;
  114971. /**
  114972. * Creates a ground mesh from a height map.
  114973. * Please consider using the same method from the MeshBuilder class instead
  114974. * @see https://doc.babylonjs.com/babylon101/height_map
  114975. * @param name defines the name of the mesh to create
  114976. * @param url sets the URL of the height map image resource
  114977. * @param width set the ground width size
  114978. * @param height set the ground height size
  114979. * @param subdivisions sets the number of subdivision per side
  114980. * @param minHeight is the minimum altitude on the ground
  114981. * @param maxHeight is the maximum altitude on the ground
  114982. * @param scene defines the hosting scene
  114983. * @param updatable defines if the mesh must be flagged as updatable
  114984. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114985. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114986. * @returns a new Mesh
  114987. */
  114988. 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;
  114989. /**
  114990. * Creates a tube mesh.
  114991. * The tube is a parametric shape.
  114992. * It has no predefined shape. Its final shape will depend on the input parameters.
  114993. * Please consider using the same method from the MeshBuilder class instead
  114994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114995. * @param name defines the name of the mesh to create
  114996. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114997. * @param radius sets the tube radius size
  114998. * @param tessellation is the number of sides on the tubular surface
  114999. * @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
  115000. * @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
  115001. * @param scene defines the hosting scene
  115002. * @param updatable defines if the mesh must be flagged as updatable
  115003. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  115004. * @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)
  115005. * @returns a new Mesh
  115006. */
  115007. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  115008. (i: number, distance: number): number;
  115009. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  115010. /**
  115011. * Creates a polyhedron mesh.
  115012. * Please consider using the same method from the MeshBuilder class instead.
  115013. * * 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
  115014. * * The parameter `size` (positive float, default 1) sets the polygon size
  115015. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115016. * * 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`
  115017. * * 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
  115018. * * 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)`)
  115019. * * 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
  115020. * * 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
  115021. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115024. * @param name defines the name of the mesh to create
  115025. * @param options defines the options used to create the mesh
  115026. * @param scene defines the hosting scene
  115027. * @returns a new Mesh
  115028. */
  115029. static CreatePolyhedron(name: string, options: {
  115030. type?: number;
  115031. size?: number;
  115032. sizeX?: number;
  115033. sizeY?: number;
  115034. sizeZ?: number;
  115035. custom?: any;
  115036. faceUV?: Vector4[];
  115037. faceColors?: Color4[];
  115038. updatable?: boolean;
  115039. sideOrientation?: number;
  115040. }, scene: Scene): Mesh;
  115041. /**
  115042. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115043. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115044. * * 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`)
  115045. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115046. * * 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
  115047. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115050. * @param name defines the name of the mesh
  115051. * @param options defines the options used to create the mesh
  115052. * @param scene defines the hosting scene
  115053. * @returns a new Mesh
  115054. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115055. */
  115056. static CreateIcoSphere(name: string, options: {
  115057. radius?: number;
  115058. flat?: boolean;
  115059. subdivisions?: number;
  115060. sideOrientation?: number;
  115061. updatable?: boolean;
  115062. }, scene: Scene): Mesh;
  115063. /**
  115064. * Creates a decal mesh.
  115065. * Please consider using the same method from the MeshBuilder class instead.
  115066. * A decal is a mesh usually applied as a model onto the surface of another mesh
  115067. * @param name defines the name of the mesh
  115068. * @param sourceMesh defines the mesh receiving the decal
  115069. * @param position sets the position of the decal in world coordinates
  115070. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  115071. * @param size sets the decal scaling
  115072. * @param angle sets the angle to rotate the decal
  115073. * @returns a new Mesh
  115074. */
  115075. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  115076. /** Creates a Capsule Mesh
  115077. * @param name defines the name of the mesh.
  115078. * @param options the constructors options used to shape the mesh.
  115079. * @param scene defines the scene the mesh is scoped to.
  115080. * @returns the capsule mesh
  115081. * @see https://doc.babylonjs.com/how_to/capsule_shape
  115082. */
  115083. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  115084. /**
  115085. * Prepare internal position array for software CPU skinning
  115086. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  115087. */
  115088. setPositionsForCPUSkinning(): Float32Array;
  115089. /**
  115090. * Prepare internal normal array for software CPU skinning
  115091. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  115092. */
  115093. setNormalsForCPUSkinning(): Float32Array;
  115094. /**
  115095. * Updates the vertex buffer by applying transformation from the bones
  115096. * @param skeleton defines the skeleton to apply to current mesh
  115097. * @returns the current mesh
  115098. */
  115099. applySkeleton(skeleton: Skeleton): Mesh;
  115100. /**
  115101. * 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
  115102. * @param meshes defines the list of meshes to scan
  115103. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  115104. */
  115105. static MinMax(meshes: AbstractMesh[]): {
  115106. min: Vector3;
  115107. max: Vector3;
  115108. };
  115109. /**
  115110. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  115111. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  115112. * @returns a vector3
  115113. */
  115114. static Center(meshesOrMinMaxVector: {
  115115. min: Vector3;
  115116. max: Vector3;
  115117. } | AbstractMesh[]): Vector3;
  115118. /**
  115119. * Merge the array of meshes into a single mesh for performance reasons.
  115120. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  115121. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  115122. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  115123. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  115124. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  115125. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  115126. * @returns a new mesh
  115127. */
  115128. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  115129. /** @hidden */
  115130. addInstance(instance: InstancedMesh): void;
  115131. /** @hidden */
  115132. removeInstance(instance: InstancedMesh): void;
  115133. }
  115134. }
  115135. declare module BABYLON {
  115136. /**
  115137. * This is the base class of all the camera used in the application.
  115138. * @see https://doc.babylonjs.com/features/cameras
  115139. */
  115140. export class Camera extends Node {
  115141. /** @hidden */
  115142. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  115143. /**
  115144. * This is the default projection mode used by the cameras.
  115145. * It helps recreating a feeling of perspective and better appreciate depth.
  115146. * This is the best way to simulate real life cameras.
  115147. */
  115148. static readonly PERSPECTIVE_CAMERA: number;
  115149. /**
  115150. * This helps creating camera with an orthographic mode.
  115151. * 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.
  115152. */
  115153. static readonly ORTHOGRAPHIC_CAMERA: number;
  115154. /**
  115155. * This is the default FOV mode for perspective cameras.
  115156. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  115157. */
  115158. static readonly FOVMODE_VERTICAL_FIXED: number;
  115159. /**
  115160. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  115161. */
  115162. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  115163. /**
  115164. * This specifies ther is no need for a camera rig.
  115165. * Basically only one eye is rendered corresponding to the camera.
  115166. */
  115167. static readonly RIG_MODE_NONE: number;
  115168. /**
  115169. * Simulates a camera Rig with one blue eye and one red eye.
  115170. * This can be use with 3d blue and red glasses.
  115171. */
  115172. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  115173. /**
  115174. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  115175. */
  115176. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  115177. /**
  115178. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  115179. */
  115180. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  115181. /**
  115182. * Defines that both eyes of the camera will be rendered over under each other.
  115183. */
  115184. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  115185. /**
  115186. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  115187. */
  115188. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  115189. /**
  115190. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  115191. */
  115192. static readonly RIG_MODE_VR: number;
  115193. /**
  115194. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  115195. */
  115196. static readonly RIG_MODE_WEBVR: number;
  115197. /**
  115198. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  115199. */
  115200. static readonly RIG_MODE_CUSTOM: number;
  115201. /**
  115202. * Defines if by default attaching controls should prevent the default javascript event to continue.
  115203. */
  115204. static ForceAttachControlToAlwaysPreventDefault: boolean;
  115205. /**
  115206. * Define the input manager associated with the camera.
  115207. */
  115208. inputs: CameraInputsManager<Camera>;
  115209. /** @hidden */
  115210. _position: Vector3;
  115211. /**
  115212. * Define the current local position of the camera in the scene
  115213. */
  115214. get position(): Vector3;
  115215. set position(newPosition: Vector3);
  115216. protected _upVector: Vector3;
  115217. /**
  115218. * The vector the camera should consider as up.
  115219. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  115220. */
  115221. set upVector(vec: Vector3);
  115222. get upVector(): Vector3;
  115223. /**
  115224. * Define the current limit on the left side for an orthographic camera
  115225. * In scene unit
  115226. */
  115227. orthoLeft: Nullable<number>;
  115228. /**
  115229. * Define the current limit on the right side for an orthographic camera
  115230. * In scene unit
  115231. */
  115232. orthoRight: Nullable<number>;
  115233. /**
  115234. * Define the current limit on the bottom side for an orthographic camera
  115235. * In scene unit
  115236. */
  115237. orthoBottom: Nullable<number>;
  115238. /**
  115239. * Define the current limit on the top side for an orthographic camera
  115240. * In scene unit
  115241. */
  115242. orthoTop: Nullable<number>;
  115243. /**
  115244. * Field Of View is set in Radians. (default is 0.8)
  115245. */
  115246. fov: number;
  115247. /**
  115248. * Define the minimum distance the camera can see from.
  115249. * This is important to note that the depth buffer are not infinite and the closer it starts
  115250. * the more your scene might encounter depth fighting issue.
  115251. */
  115252. minZ: number;
  115253. /**
  115254. * Define the maximum distance the camera can see to.
  115255. * This is important to note that the depth buffer are not infinite and the further it end
  115256. * the more your scene might encounter depth fighting issue.
  115257. */
  115258. maxZ: number;
  115259. /**
  115260. * Define the default inertia of the camera.
  115261. * This helps giving a smooth feeling to the camera movement.
  115262. */
  115263. inertia: number;
  115264. /**
  115265. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  115266. */
  115267. mode: number;
  115268. /**
  115269. * Define whether the camera is intermediate.
  115270. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  115271. */
  115272. isIntermediate: boolean;
  115273. /**
  115274. * Define the viewport of the camera.
  115275. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  115276. */
  115277. viewport: Viewport;
  115278. /**
  115279. * Restricts the camera to viewing objects with the same layerMask.
  115280. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  115281. */
  115282. layerMask: number;
  115283. /**
  115284. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  115285. */
  115286. fovMode: number;
  115287. /**
  115288. * Rig mode of the camera.
  115289. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  115290. * This is normally controlled byt the camera themselves as internal use.
  115291. */
  115292. cameraRigMode: number;
  115293. /**
  115294. * Defines the distance between both "eyes" in case of a RIG
  115295. */
  115296. interaxialDistance: number;
  115297. /**
  115298. * Defines if stereoscopic rendering is done side by side or over under.
  115299. */
  115300. isStereoscopicSideBySide: boolean;
  115301. /**
  115302. * 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
  115303. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  115304. * else in the scene. (Eg. security camera)
  115305. *
  115306. * 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)
  115307. */
  115308. customRenderTargets: RenderTargetTexture[];
  115309. /**
  115310. * When set, the camera will render to this render target instead of the default canvas
  115311. *
  115312. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  115313. */
  115314. outputRenderTarget: Nullable<RenderTargetTexture>;
  115315. /**
  115316. * Observable triggered when the camera view matrix has changed.
  115317. */
  115318. onViewMatrixChangedObservable: Observable<Camera>;
  115319. /**
  115320. * Observable triggered when the camera Projection matrix has changed.
  115321. */
  115322. onProjectionMatrixChangedObservable: Observable<Camera>;
  115323. /**
  115324. * Observable triggered when the inputs have been processed.
  115325. */
  115326. onAfterCheckInputsObservable: Observable<Camera>;
  115327. /**
  115328. * Observable triggered when reset has been called and applied to the camera.
  115329. */
  115330. onRestoreStateObservable: Observable<Camera>;
  115331. /**
  115332. * Is this camera a part of a rig system?
  115333. */
  115334. isRigCamera: boolean;
  115335. /**
  115336. * If isRigCamera set to true this will be set with the parent camera.
  115337. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  115338. */
  115339. rigParent?: Camera;
  115340. /** @hidden */
  115341. _cameraRigParams: any;
  115342. /** @hidden */
  115343. _rigCameras: Camera[];
  115344. /** @hidden */
  115345. _rigPostProcess: Nullable<PostProcess>;
  115346. protected _webvrViewMatrix: Matrix;
  115347. /** @hidden */
  115348. _skipRendering: boolean;
  115349. /** @hidden */
  115350. _projectionMatrix: Matrix;
  115351. /** @hidden */
  115352. _postProcesses: Nullable<PostProcess>[];
  115353. /** @hidden */
  115354. _activeMeshes: SmartArray<AbstractMesh>;
  115355. protected _globalPosition: Vector3;
  115356. /** @hidden */
  115357. _computedViewMatrix: Matrix;
  115358. private _doNotComputeProjectionMatrix;
  115359. private _transformMatrix;
  115360. private _frustumPlanes;
  115361. private _refreshFrustumPlanes;
  115362. private _storedFov;
  115363. private _stateStored;
  115364. /**
  115365. * Instantiates a new camera object.
  115366. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  115367. * @see https://doc.babylonjs.com/features/cameras
  115368. * @param name Defines the name of the camera in the scene
  115369. * @param position Defines the position of the camera
  115370. * @param scene Defines the scene the camera belongs too
  115371. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  115372. */
  115373. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  115374. /**
  115375. * Store current camera state (fov, position, etc..)
  115376. * @returns the camera
  115377. */
  115378. storeState(): Camera;
  115379. /**
  115380. * Restores the camera state values if it has been stored. You must call storeState() first
  115381. */
  115382. protected _restoreStateValues(): boolean;
  115383. /**
  115384. * Restored camera state. You must call storeState() first.
  115385. * @returns true if restored and false otherwise
  115386. */
  115387. restoreState(): boolean;
  115388. /**
  115389. * Gets the class name of the camera.
  115390. * @returns the class name
  115391. */
  115392. getClassName(): string;
  115393. /** @hidden */
  115394. readonly _isCamera: boolean;
  115395. /**
  115396. * Gets a string representation of the camera useful for debug purpose.
  115397. * @param fullDetails Defines that a more verboe level of logging is required
  115398. * @returns the string representation
  115399. */
  115400. toString(fullDetails?: boolean): string;
  115401. /**
  115402. * Gets the current world space position of the camera.
  115403. */
  115404. get globalPosition(): Vector3;
  115405. /**
  115406. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  115407. * @returns the active meshe list
  115408. */
  115409. getActiveMeshes(): SmartArray<AbstractMesh>;
  115410. /**
  115411. * Check whether a mesh is part of the current active mesh list of the camera
  115412. * @param mesh Defines the mesh to check
  115413. * @returns true if active, false otherwise
  115414. */
  115415. isActiveMesh(mesh: Mesh): boolean;
  115416. /**
  115417. * Is this camera ready to be used/rendered
  115418. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  115419. * @return true if the camera is ready
  115420. */
  115421. isReady(completeCheck?: boolean): boolean;
  115422. /** @hidden */
  115423. _initCache(): void;
  115424. /** @hidden */
  115425. _updateCache(ignoreParentClass?: boolean): void;
  115426. /** @hidden */
  115427. _isSynchronized(): boolean;
  115428. /** @hidden */
  115429. _isSynchronizedViewMatrix(): boolean;
  115430. /** @hidden */
  115431. _isSynchronizedProjectionMatrix(): boolean;
  115432. /**
  115433. * Attach the input controls to a specific dom element to get the input from.
  115434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115435. */
  115436. attachControl(noPreventDefault?: boolean): void;
  115437. /**
  115438. * Detach the current controls from the specified dom element.
  115439. */
  115440. detachControl(): void;
  115441. /**
  115442. * Update the camera state according to the different inputs gathered during the frame.
  115443. */
  115444. update(): void;
  115445. /** @hidden */
  115446. _checkInputs(): void;
  115447. /** @hidden */
  115448. get rigCameras(): Camera[];
  115449. /**
  115450. * Gets the post process used by the rig cameras
  115451. */
  115452. get rigPostProcess(): Nullable<PostProcess>;
  115453. /**
  115454. * Internal, gets the first post proces.
  115455. * @returns the first post process to be run on this camera.
  115456. */
  115457. _getFirstPostProcess(): Nullable<PostProcess>;
  115458. private _cascadePostProcessesToRigCams;
  115459. /**
  115460. * Attach a post process to the camera.
  115461. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  115462. * @param postProcess The post process to attach to the camera
  115463. * @param insertAt The position of the post process in case several of them are in use in the scene
  115464. * @returns the position the post process has been inserted at
  115465. */
  115466. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  115467. /**
  115468. * Detach a post process to the camera.
  115469. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  115470. * @param postProcess The post process to detach from the camera
  115471. */
  115472. detachPostProcess(postProcess: PostProcess): void;
  115473. /**
  115474. * Gets the current world matrix of the camera
  115475. */
  115476. getWorldMatrix(): Matrix;
  115477. /** @hidden */
  115478. _getViewMatrix(): Matrix;
  115479. /**
  115480. * Gets the current view matrix of the camera.
  115481. * @param force forces the camera to recompute the matrix without looking at the cached state
  115482. * @returns the view matrix
  115483. */
  115484. getViewMatrix(force?: boolean): Matrix;
  115485. /**
  115486. * Freeze the projection matrix.
  115487. * It will prevent the cache check of the camera projection compute and can speed up perf
  115488. * if no parameter of the camera are meant to change
  115489. * @param projection Defines manually a projection if necessary
  115490. */
  115491. freezeProjectionMatrix(projection?: Matrix): void;
  115492. /**
  115493. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  115494. */
  115495. unfreezeProjectionMatrix(): void;
  115496. /**
  115497. * Gets the current projection matrix of the camera.
  115498. * @param force forces the camera to recompute the matrix without looking at the cached state
  115499. * @returns the projection matrix
  115500. */
  115501. getProjectionMatrix(force?: boolean): Matrix;
  115502. /**
  115503. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  115504. * @returns a Matrix
  115505. */
  115506. getTransformationMatrix(): Matrix;
  115507. private _updateFrustumPlanes;
  115508. /**
  115509. * Checks if a cullable object (mesh...) is in the camera frustum
  115510. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  115511. * @param target The object to check
  115512. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  115513. * @returns true if the object is in frustum otherwise false
  115514. */
  115515. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  115516. /**
  115517. * Checks if a cullable object (mesh...) is in the camera frustum
  115518. * Unlike isInFrustum this cheks the full bounding box
  115519. * @param target The object to check
  115520. * @returns true if the object is in frustum otherwise false
  115521. */
  115522. isCompletelyInFrustum(target: ICullable): boolean;
  115523. /**
  115524. * Gets a ray in the forward direction from the camera.
  115525. * @param length Defines the length of the ray to create
  115526. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  115527. * @param origin Defines the start point of the ray which defaults to the camera position
  115528. * @returns the forward ray
  115529. */
  115530. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  115531. /**
  115532. * Gets a ray in the forward direction from the camera.
  115533. * @param refRay the ray to (re)use when setting the values
  115534. * @param length Defines the length of the ray to create
  115535. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  115536. * @param origin Defines the start point of the ray which defaults to the camera position
  115537. * @returns the forward ray
  115538. */
  115539. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  115540. /**
  115541. * Releases resources associated with this node.
  115542. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115543. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115544. */
  115545. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115546. /** @hidden */
  115547. _isLeftCamera: boolean;
  115548. /**
  115549. * Gets the left camera of a rig setup in case of Rigged Camera
  115550. */
  115551. get isLeftCamera(): boolean;
  115552. /** @hidden */
  115553. _isRightCamera: boolean;
  115554. /**
  115555. * Gets the right camera of a rig setup in case of Rigged Camera
  115556. */
  115557. get isRightCamera(): boolean;
  115558. /**
  115559. * Gets the left camera of a rig setup in case of Rigged Camera
  115560. */
  115561. get leftCamera(): Nullable<FreeCamera>;
  115562. /**
  115563. * Gets the right camera of a rig setup in case of Rigged Camera
  115564. */
  115565. get rightCamera(): Nullable<FreeCamera>;
  115566. /**
  115567. * Gets the left camera target of a rig setup in case of Rigged Camera
  115568. * @returns the target position
  115569. */
  115570. getLeftTarget(): Nullable<Vector3>;
  115571. /**
  115572. * Gets the right camera target of a rig setup in case of Rigged Camera
  115573. * @returns the target position
  115574. */
  115575. getRightTarget(): Nullable<Vector3>;
  115576. /**
  115577. * @hidden
  115578. */
  115579. setCameraRigMode(mode: number, rigParams: any): void;
  115580. /** @hidden */
  115581. static _setStereoscopicRigMode(camera: Camera): void;
  115582. /** @hidden */
  115583. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  115584. /** @hidden */
  115585. static _setVRRigMode(camera: Camera, rigParams: any): void;
  115586. /** @hidden */
  115587. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  115588. /** @hidden */
  115589. _getVRProjectionMatrix(): Matrix;
  115590. protected _updateCameraRotationMatrix(): void;
  115591. protected _updateWebVRCameraRotationMatrix(): void;
  115592. /**
  115593. * This function MUST be overwritten by the different WebVR cameras available.
  115594. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  115595. * @hidden
  115596. */
  115597. _getWebVRProjectionMatrix(): Matrix;
  115598. /**
  115599. * This function MUST be overwritten by the different WebVR cameras available.
  115600. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  115601. * @hidden
  115602. */
  115603. _getWebVRViewMatrix(): Matrix;
  115604. /** @hidden */
  115605. setCameraRigParameter(name: string, value: any): void;
  115606. /**
  115607. * needs to be overridden by children so sub has required properties to be copied
  115608. * @hidden
  115609. */
  115610. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  115611. /**
  115612. * May need to be overridden by children
  115613. * @hidden
  115614. */
  115615. _updateRigCameras(): void;
  115616. /** @hidden */
  115617. _setupInputs(): void;
  115618. /**
  115619. * Serialiaze the camera setup to a json represention
  115620. * @returns the JSON representation
  115621. */
  115622. serialize(): any;
  115623. /**
  115624. * Clones the current camera.
  115625. * @param name The cloned camera name
  115626. * @returns the cloned camera
  115627. */
  115628. clone(name: string): Camera;
  115629. /**
  115630. * Gets the direction of the camera relative to a given local axis.
  115631. * @param localAxis Defines the reference axis to provide a relative direction.
  115632. * @return the direction
  115633. */
  115634. getDirection(localAxis: Vector3): Vector3;
  115635. /**
  115636. * Returns the current camera absolute rotation
  115637. */
  115638. get absoluteRotation(): Quaternion;
  115639. /**
  115640. * Gets the direction of the camera relative to a given local axis into a passed vector.
  115641. * @param localAxis Defines the reference axis to provide a relative direction.
  115642. * @param result Defines the vector to store the result in
  115643. */
  115644. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  115645. /**
  115646. * Gets a camera constructor for a given camera type
  115647. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  115648. * @param name The name of the camera the result will be able to instantiate
  115649. * @param scene The scene the result will construct the camera in
  115650. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  115651. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  115652. * @returns a factory method to construc the camera
  115653. */
  115654. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  115655. /**
  115656. * Compute the world matrix of the camera.
  115657. * @returns the camera world matrix
  115658. */
  115659. computeWorldMatrix(): Matrix;
  115660. /**
  115661. * Parse a JSON and creates the camera from the parsed information
  115662. * @param parsedCamera The JSON to parse
  115663. * @param scene The scene to instantiate the camera in
  115664. * @returns the newly constructed camera
  115665. */
  115666. static Parse(parsedCamera: any, scene: Scene): Camera;
  115667. }
  115668. }
  115669. declare module BABYLON {
  115670. /**
  115671. * Class containing static functions to help procedurally build meshes
  115672. */
  115673. export class DiscBuilder {
  115674. /**
  115675. * Creates a plane polygonal mesh. By default, this is a disc
  115676. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115677. * * 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
  115678. * * 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
  115679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115682. * @param name defines the name of the mesh
  115683. * @param options defines the options used to create the mesh
  115684. * @param scene defines the hosting scene
  115685. * @returns the plane polygonal mesh
  115686. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115687. */
  115688. static CreateDisc(name: string, options: {
  115689. radius?: number;
  115690. tessellation?: number;
  115691. arc?: number;
  115692. updatable?: boolean;
  115693. sideOrientation?: number;
  115694. frontUVs?: Vector4;
  115695. backUVs?: Vector4;
  115696. }, scene?: Nullable<Scene>): Mesh;
  115697. }
  115698. }
  115699. declare module BABYLON {
  115700. /**
  115701. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  115702. *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.
  115703. * The SPS is also a particle system. It provides some methods to manage the particles.
  115704. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  115705. *
  115706. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  115707. */
  115708. export class SolidParticleSystem implements IDisposable {
  115709. /**
  115710. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  115711. * Example : var p = SPS.particles[i];
  115712. */
  115713. particles: SolidParticle[];
  115714. /**
  115715. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  115716. */
  115717. nbParticles: number;
  115718. /**
  115719. * If the particles must ever face the camera (default false). Useful for planar particles.
  115720. */
  115721. billboard: boolean;
  115722. /**
  115723. * Recompute normals when adding a shape
  115724. */
  115725. recomputeNormals: boolean;
  115726. /**
  115727. * This a counter ofr your own usage. It's not set by any SPS functions.
  115728. */
  115729. counter: number;
  115730. /**
  115731. * The SPS name. This name is also given to the underlying mesh.
  115732. */
  115733. name: string;
  115734. /**
  115735. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115736. */
  115737. mesh: Mesh;
  115738. /**
  115739. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115740. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115741. */
  115742. vars: any;
  115743. /**
  115744. * This array is populated when the SPS is set as 'pickable'.
  115745. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115746. * Each element of this array is an object `{idx: int, faceId: int}`.
  115747. * `idx` is the picked particle index in the `SPS.particles` array
  115748. * `faceId` is the picked face index counted within this particle.
  115749. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115750. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115751. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115752. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115753. */
  115754. pickedParticles: {
  115755. idx: number;
  115756. faceId: number;
  115757. }[];
  115758. /**
  115759. * This array is populated when the SPS is set as 'pickable'
  115760. * Each key of this array is a submesh index.
  115761. * Each element of this array is a second array defined like this :
  115762. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115763. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115764. * `idx` is the picked particle index in the `SPS.particles` array
  115765. * `faceId` is the picked face index counted within this particle.
  115766. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115767. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115768. */
  115769. pickedBySubMesh: {
  115770. idx: number;
  115771. faceId: number;
  115772. }[][];
  115773. /**
  115774. * This array is populated when `enableDepthSort` is set to true.
  115775. * Each element of this array is an instance of the class DepthSortedParticle.
  115776. */
  115777. depthSortedParticles: DepthSortedParticle[];
  115778. /**
  115779. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115780. * @hidden
  115781. */
  115782. _bSphereOnly: boolean;
  115783. /**
  115784. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115785. * @hidden
  115786. */
  115787. _bSphereRadiusFactor: number;
  115788. private _scene;
  115789. private _positions;
  115790. private _indices;
  115791. private _normals;
  115792. private _colors;
  115793. private _uvs;
  115794. private _indices32;
  115795. private _positions32;
  115796. private _normals32;
  115797. private _fixedNormal32;
  115798. private _colors32;
  115799. private _uvs32;
  115800. private _index;
  115801. private _updatable;
  115802. private _pickable;
  115803. private _isVisibilityBoxLocked;
  115804. private _alwaysVisible;
  115805. private _depthSort;
  115806. private _expandable;
  115807. private _shapeCounter;
  115808. private _copy;
  115809. private _color;
  115810. private _computeParticleColor;
  115811. private _computeParticleTexture;
  115812. private _computeParticleRotation;
  115813. private _computeParticleVertex;
  115814. private _computeBoundingBox;
  115815. private _depthSortParticles;
  115816. private _camera;
  115817. private _mustUnrotateFixedNormals;
  115818. private _particlesIntersect;
  115819. private _needs32Bits;
  115820. private _isNotBuilt;
  115821. private _lastParticleId;
  115822. private _idxOfId;
  115823. private _multimaterialEnabled;
  115824. private _useModelMaterial;
  115825. private _indicesByMaterial;
  115826. private _materialIndexes;
  115827. private _depthSortFunction;
  115828. private _materialSortFunction;
  115829. private _materials;
  115830. private _multimaterial;
  115831. private _materialIndexesById;
  115832. private _defaultMaterial;
  115833. private _autoUpdateSubMeshes;
  115834. private _tmpVertex;
  115835. /**
  115836. * Creates a SPS (Solid Particle System) object.
  115837. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115838. * @param scene (Scene) is the scene in which the SPS is added.
  115839. * @param options defines the options of the sps e.g.
  115840. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115841. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115842. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115843. * * 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.
  115844. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115845. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115846. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115847. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115848. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115849. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115850. */
  115851. constructor(name: string, scene: Scene, options?: {
  115852. updatable?: boolean;
  115853. isPickable?: boolean;
  115854. enableDepthSort?: boolean;
  115855. particleIntersection?: boolean;
  115856. boundingSphereOnly?: boolean;
  115857. bSphereRadiusFactor?: number;
  115858. expandable?: boolean;
  115859. useModelMaterial?: boolean;
  115860. enableMultiMaterial?: boolean;
  115861. });
  115862. /**
  115863. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115864. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115865. * @returns the created mesh
  115866. */
  115867. buildMesh(): Mesh;
  115868. /**
  115869. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115870. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115871. * Thus the particles generated from `digest()` have their property `position` set yet.
  115872. * @param mesh ( Mesh ) is the mesh to be digested
  115873. * @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
  115874. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115875. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115876. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115877. * @returns the current SPS
  115878. */
  115879. digest(mesh: Mesh, options?: {
  115880. facetNb?: number;
  115881. number?: number;
  115882. delta?: number;
  115883. storage?: [];
  115884. }): SolidParticleSystem;
  115885. /**
  115886. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115887. * @hidden
  115888. */
  115889. private _unrotateFixedNormals;
  115890. /**
  115891. * Resets the temporary working copy particle
  115892. * @hidden
  115893. */
  115894. private _resetCopy;
  115895. /**
  115896. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115897. * @param p the current index in the positions array to be updated
  115898. * @param ind the current index in the indices array
  115899. * @param shape a Vector3 array, the shape geometry
  115900. * @param positions the positions array to be updated
  115901. * @param meshInd the shape indices array
  115902. * @param indices the indices array to be updated
  115903. * @param meshUV the shape uv array
  115904. * @param uvs the uv array to be updated
  115905. * @param meshCol the shape color array
  115906. * @param colors the color array to be updated
  115907. * @param meshNor the shape normals array
  115908. * @param normals the normals array to be updated
  115909. * @param idx the particle index
  115910. * @param idxInShape the particle index in its shape
  115911. * @param options the addShape() method passed options
  115912. * @model the particle model
  115913. * @hidden
  115914. */
  115915. private _meshBuilder;
  115916. /**
  115917. * Returns a shape Vector3 array from positions float array
  115918. * @param positions float array
  115919. * @returns a vector3 array
  115920. * @hidden
  115921. */
  115922. private _posToShape;
  115923. /**
  115924. * Returns a shapeUV array from a float uvs (array deep copy)
  115925. * @param uvs as a float array
  115926. * @returns a shapeUV array
  115927. * @hidden
  115928. */
  115929. private _uvsToShapeUV;
  115930. /**
  115931. * Adds a new particle object in the particles array
  115932. * @param idx particle index in particles array
  115933. * @param id particle id
  115934. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115935. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115936. * @param model particle ModelShape object
  115937. * @param shapeId model shape identifier
  115938. * @param idxInShape index of the particle in the current model
  115939. * @param bInfo model bounding info object
  115940. * @param storage target storage array, if any
  115941. * @hidden
  115942. */
  115943. private _addParticle;
  115944. /**
  115945. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115946. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115947. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115948. * @param nb (positive integer) the number of particles to be created from this model
  115949. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115950. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115951. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115952. * @returns the number of shapes in the system
  115953. */
  115954. addShape(mesh: Mesh, nb: number, options?: {
  115955. positionFunction?: any;
  115956. vertexFunction?: any;
  115957. storage?: [];
  115958. }): number;
  115959. /**
  115960. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115961. * @hidden
  115962. */
  115963. private _rebuildParticle;
  115964. /**
  115965. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115966. * @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.
  115967. * @returns the SPS.
  115968. */
  115969. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115970. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115971. * Returns an array with the removed particles.
  115972. * 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.
  115973. * The SPS can't be empty so at least one particle needs to remain in place.
  115974. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115975. * @param start index of the first particle to remove
  115976. * @param end index of the last particle to remove (included)
  115977. * @returns an array populated with the removed particles
  115978. */
  115979. removeParticles(start: number, end: number): SolidParticle[];
  115980. /**
  115981. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115982. * @param solidParticleArray an array populated with Solid Particles objects
  115983. * @returns the SPS
  115984. */
  115985. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115986. /**
  115987. * Creates a new particle and modifies the SPS mesh geometry :
  115988. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115989. * - calls _addParticle() to populate the particle array
  115990. * factorized code from addShape() and insertParticlesFromArray()
  115991. * @param idx particle index in the particles array
  115992. * @param i particle index in its shape
  115993. * @param modelShape particle ModelShape object
  115994. * @param shape shape vertex array
  115995. * @param meshInd shape indices array
  115996. * @param meshUV shape uv array
  115997. * @param meshCol shape color array
  115998. * @param meshNor shape normals array
  115999. * @param bbInfo shape bounding info
  116000. * @param storage target particle storage
  116001. * @options addShape() passed options
  116002. * @hidden
  116003. */
  116004. private _insertNewParticle;
  116005. /**
  116006. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  116007. * This method calls `updateParticle()` for each particle of the SPS.
  116008. * For an animated SPS, it is usually called within the render loop.
  116009. * 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.
  116010. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  116011. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  116012. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  116013. * @returns the SPS.
  116014. */
  116015. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  116016. /**
  116017. * Disposes the SPS.
  116018. */
  116019. dispose(): void;
  116020. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  116021. * idx is the particle index in the SPS
  116022. * faceId is the picked face index counted within this particle.
  116023. * Returns null if the pickInfo can't identify a picked particle.
  116024. * @param pickingInfo (PickingInfo object)
  116025. * @returns {idx: number, faceId: number} or null
  116026. */
  116027. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  116028. idx: number;
  116029. faceId: number;
  116030. }>;
  116031. /**
  116032. * Returns a SolidParticle object from its identifier : particle.id
  116033. * @param id (integer) the particle Id
  116034. * @returns the searched particle or null if not found in the SPS.
  116035. */
  116036. getParticleById(id: number): Nullable<SolidParticle>;
  116037. /**
  116038. * Returns a new array populated with the particles having the passed shapeId.
  116039. * @param shapeId (integer) the shape identifier
  116040. * @returns a new solid particle array
  116041. */
  116042. getParticlesByShapeId(shapeId: number): SolidParticle[];
  116043. /**
  116044. * Populates the passed array "ref" with the particles having the passed shapeId.
  116045. * @param shapeId the shape identifier
  116046. * @returns the SPS
  116047. * @param ref
  116048. */
  116049. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  116050. /**
  116051. * Computes the required SubMeshes according the materials assigned to the particles.
  116052. * @returns the solid particle system.
  116053. * Does nothing if called before the SPS mesh is built.
  116054. */
  116055. computeSubMeshes(): SolidParticleSystem;
  116056. /**
  116057. * Sorts the solid particles by material when MultiMaterial is enabled.
  116058. * Updates the indices32 array.
  116059. * Updates the indicesByMaterial array.
  116060. * Updates the mesh indices array.
  116061. * @returns the SPS
  116062. * @hidden
  116063. */
  116064. private _sortParticlesByMaterial;
  116065. /**
  116066. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  116067. * @hidden
  116068. */
  116069. private _setMaterialIndexesById;
  116070. /**
  116071. * Returns an array with unique values of Materials from the passed array
  116072. * @param array the material array to be checked and filtered
  116073. * @hidden
  116074. */
  116075. private _filterUniqueMaterialId;
  116076. /**
  116077. * Sets a new Standard Material as _defaultMaterial if not already set.
  116078. * @hidden
  116079. */
  116080. private _setDefaultMaterial;
  116081. /**
  116082. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  116083. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116084. * @returns the SPS.
  116085. */
  116086. refreshVisibleSize(): SolidParticleSystem;
  116087. /**
  116088. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  116089. * @param size the size (float) of the visibility box
  116090. * note : this doesn't lock the SPS mesh bounding box.
  116091. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116092. */
  116093. setVisibilityBox(size: number): void;
  116094. /**
  116095. * Gets whether the SPS as always visible or not
  116096. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116097. */
  116098. get isAlwaysVisible(): boolean;
  116099. /**
  116100. * Sets the SPS as always visible or not
  116101. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116102. */
  116103. set isAlwaysVisible(val: boolean);
  116104. /**
  116105. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116106. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116107. */
  116108. set isVisibilityBoxLocked(val: boolean);
  116109. /**
  116110. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116111. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116112. */
  116113. get isVisibilityBoxLocked(): boolean;
  116114. /**
  116115. * Tells to `setParticles()` to compute the particle rotations or not.
  116116. * Default value : true. The SPS is faster when it's set to false.
  116117. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116118. */
  116119. set computeParticleRotation(val: boolean);
  116120. /**
  116121. * Tells to `setParticles()` to compute the particle colors or not.
  116122. * Default value : true. The SPS is faster when it's set to false.
  116123. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116124. */
  116125. set computeParticleColor(val: boolean);
  116126. set computeParticleTexture(val: boolean);
  116127. /**
  116128. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  116129. * Default value : false. The SPS is faster when it's set to false.
  116130. * Note : the particle custom vertex positions aren't stored values.
  116131. */
  116132. set computeParticleVertex(val: boolean);
  116133. /**
  116134. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  116135. */
  116136. set computeBoundingBox(val: boolean);
  116137. /**
  116138. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  116139. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116140. * Default : `true`
  116141. */
  116142. set depthSortParticles(val: boolean);
  116143. /**
  116144. * Gets if `setParticles()` computes the particle rotations or not.
  116145. * Default value : true. The SPS is faster when it's set to false.
  116146. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116147. */
  116148. get computeParticleRotation(): boolean;
  116149. /**
  116150. * Gets if `setParticles()` computes the particle colors or not.
  116151. * Default value : true. The SPS is faster when it's set to false.
  116152. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116153. */
  116154. get computeParticleColor(): boolean;
  116155. /**
  116156. * Gets if `setParticles()` computes the particle textures or not.
  116157. * Default value : true. The SPS is faster when it's set to false.
  116158. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  116159. */
  116160. get computeParticleTexture(): boolean;
  116161. /**
  116162. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  116163. * Default value : false. The SPS is faster when it's set to false.
  116164. * Note : the particle custom vertex positions aren't stored values.
  116165. */
  116166. get computeParticleVertex(): boolean;
  116167. /**
  116168. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  116169. */
  116170. get computeBoundingBox(): boolean;
  116171. /**
  116172. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  116173. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116174. * Default : `true`
  116175. */
  116176. get depthSortParticles(): boolean;
  116177. /**
  116178. * Gets if the SPS is created as expandable at construction time.
  116179. * Default : `false`
  116180. */
  116181. get expandable(): boolean;
  116182. /**
  116183. * Gets if the SPS supports the Multi Materials
  116184. */
  116185. get multimaterialEnabled(): boolean;
  116186. /**
  116187. * Gets if the SPS uses the model materials for its own multimaterial.
  116188. */
  116189. get useModelMaterial(): boolean;
  116190. /**
  116191. * The SPS used material array.
  116192. */
  116193. get materials(): Material[];
  116194. /**
  116195. * Sets the SPS MultiMaterial from the passed materials.
  116196. * Note : the passed array is internally copied and not used then by reference.
  116197. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  116198. */
  116199. setMultiMaterial(materials: Material[]): void;
  116200. /**
  116201. * The SPS computed multimaterial object
  116202. */
  116203. get multimaterial(): MultiMaterial;
  116204. set multimaterial(mm: MultiMaterial);
  116205. /**
  116206. * If the subMeshes must be updated on the next call to setParticles()
  116207. */
  116208. get autoUpdateSubMeshes(): boolean;
  116209. set autoUpdateSubMeshes(val: boolean);
  116210. /**
  116211. * This function does nothing. It may be overwritten to set all the particle first values.
  116212. * The SPS doesn't call this function, you may have to call it by your own.
  116213. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116214. */
  116215. initParticles(): void;
  116216. /**
  116217. * This function does nothing. It may be overwritten to recycle a particle.
  116218. * The SPS doesn't call this function, you may have to call it by your own.
  116219. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116220. * @param particle The particle to recycle
  116221. * @returns the recycled particle
  116222. */
  116223. recycleParticle(particle: SolidParticle): SolidParticle;
  116224. /**
  116225. * Updates a particle : this function should be overwritten by the user.
  116226. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  116227. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116228. * @example : just set a particle position or velocity and recycle conditions
  116229. * @param particle The particle to update
  116230. * @returns the updated particle
  116231. */
  116232. updateParticle(particle: SolidParticle): SolidParticle;
  116233. /**
  116234. * Updates a vertex of a particle : it can be overwritten by the user.
  116235. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  116236. * @param particle the current particle
  116237. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  116238. * @param pt the index of the current vertex in the particle shape
  116239. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  116240. * @example : just set a vertex particle position or color
  116241. * @returns the sps
  116242. */
  116243. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  116244. /**
  116245. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  116246. * This does nothing and may be overwritten by the user.
  116247. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116248. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116249. * @param update the boolean update value actually passed to setParticles()
  116250. */
  116251. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116252. /**
  116253. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  116254. * This will be passed three parameters.
  116255. * This does nothing and may be overwritten by the user.
  116256. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116257. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116258. * @param update the boolean update value actually passed to setParticles()
  116259. */
  116260. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116261. }
  116262. }
  116263. declare module BABYLON {
  116264. /**
  116265. * Represents one particle of a solid particle system.
  116266. */
  116267. export class SolidParticle {
  116268. /**
  116269. * particle global index
  116270. */
  116271. idx: number;
  116272. /**
  116273. * particle identifier
  116274. */
  116275. id: number;
  116276. /**
  116277. * The color of the particle
  116278. */
  116279. color: Nullable<Color4>;
  116280. /**
  116281. * The world space position of the particle.
  116282. */
  116283. position: Vector3;
  116284. /**
  116285. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  116286. */
  116287. rotation: Vector3;
  116288. /**
  116289. * The world space rotation quaternion of the particle.
  116290. */
  116291. rotationQuaternion: Nullable<Quaternion>;
  116292. /**
  116293. * The scaling of the particle.
  116294. */
  116295. scaling: Vector3;
  116296. /**
  116297. * The uvs of the particle.
  116298. */
  116299. uvs: Vector4;
  116300. /**
  116301. * The current speed of the particle.
  116302. */
  116303. velocity: Vector3;
  116304. /**
  116305. * The pivot point in the particle local space.
  116306. */
  116307. pivot: Vector3;
  116308. /**
  116309. * Must the particle be translated from its pivot point in its local space ?
  116310. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  116311. * Default : false
  116312. */
  116313. translateFromPivot: boolean;
  116314. /**
  116315. * Is the particle active or not ?
  116316. */
  116317. alive: boolean;
  116318. /**
  116319. * Is the particle visible or not ?
  116320. */
  116321. isVisible: boolean;
  116322. /**
  116323. * Index of this particle in the global "positions" array (Internal use)
  116324. * @hidden
  116325. */
  116326. _pos: number;
  116327. /**
  116328. * @hidden Index of this particle in the global "indices" array (Internal use)
  116329. */
  116330. _ind: number;
  116331. /**
  116332. * @hidden ModelShape of this particle (Internal use)
  116333. */
  116334. _model: ModelShape;
  116335. /**
  116336. * ModelShape id of this particle
  116337. */
  116338. shapeId: number;
  116339. /**
  116340. * Index of the particle in its shape id
  116341. */
  116342. idxInShape: number;
  116343. /**
  116344. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  116345. */
  116346. _modelBoundingInfo: BoundingInfo;
  116347. /**
  116348. * @hidden Particle BoundingInfo object (Internal use)
  116349. */
  116350. _boundingInfo: BoundingInfo;
  116351. /**
  116352. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  116353. */
  116354. _sps: SolidParticleSystem;
  116355. /**
  116356. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  116357. */
  116358. _stillInvisible: boolean;
  116359. /**
  116360. * @hidden Last computed particle rotation matrix
  116361. */
  116362. _rotationMatrix: number[];
  116363. /**
  116364. * Parent particle Id, if any.
  116365. * Default null.
  116366. */
  116367. parentId: Nullable<number>;
  116368. /**
  116369. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  116370. */
  116371. materialIndex: Nullable<number>;
  116372. /**
  116373. * Custom object or properties.
  116374. */
  116375. props: Nullable<any>;
  116376. /**
  116377. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  116378. * The possible values are :
  116379. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116380. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116381. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116382. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116383. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116384. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  116385. * */
  116386. cullingStrategy: number;
  116387. /**
  116388. * @hidden Internal global position in the SPS.
  116389. */
  116390. _globalPosition: Vector3;
  116391. /**
  116392. * Creates a Solid Particle object.
  116393. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  116394. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  116395. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  116396. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  116397. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  116398. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  116399. * @param shapeId (integer) is the model shape identifier in the SPS.
  116400. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  116401. * @param sps defines the sps it is associated to
  116402. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  116403. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  116404. */
  116405. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  116406. /**
  116407. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  116408. * @param target the particle target
  116409. * @returns the current particle
  116410. */
  116411. copyToRef(target: SolidParticle): SolidParticle;
  116412. /**
  116413. * Legacy support, changed scale to scaling
  116414. */
  116415. get scale(): Vector3;
  116416. /**
  116417. * Legacy support, changed scale to scaling
  116418. */
  116419. set scale(scale: Vector3);
  116420. /**
  116421. * Legacy support, changed quaternion to rotationQuaternion
  116422. */
  116423. get quaternion(): Nullable<Quaternion>;
  116424. /**
  116425. * Legacy support, changed quaternion to rotationQuaternion
  116426. */
  116427. set quaternion(q: Nullable<Quaternion>);
  116428. /**
  116429. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  116430. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  116431. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  116432. * @returns true if it intersects
  116433. */
  116434. intersectsMesh(target: Mesh | SolidParticle): boolean;
  116435. /**
  116436. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  116437. * A particle is in the frustum if its bounding box intersects the frustum
  116438. * @param frustumPlanes defines the frustum to test
  116439. * @returns true if the particle is in the frustum planes
  116440. */
  116441. isInFrustum(frustumPlanes: Plane[]): boolean;
  116442. /**
  116443. * get the rotation matrix of the particle
  116444. * @hidden
  116445. */
  116446. getRotationMatrix(m: Matrix): void;
  116447. }
  116448. /**
  116449. * Represents the shape of the model used by one particle of a solid particle system.
  116450. * SPS internal tool, don't use it manually.
  116451. */
  116452. export class ModelShape {
  116453. /**
  116454. * The shape id
  116455. * @hidden
  116456. */
  116457. shapeID: number;
  116458. /**
  116459. * flat array of model positions (internal use)
  116460. * @hidden
  116461. */
  116462. _shape: Vector3[];
  116463. /**
  116464. * flat array of model UVs (internal use)
  116465. * @hidden
  116466. */
  116467. _shapeUV: number[];
  116468. /**
  116469. * color array of the model
  116470. * @hidden
  116471. */
  116472. _shapeColors: number[];
  116473. /**
  116474. * indices array of the model
  116475. * @hidden
  116476. */
  116477. _indices: number[];
  116478. /**
  116479. * normals array of the model
  116480. * @hidden
  116481. */
  116482. _normals: number[];
  116483. /**
  116484. * length of the shape in the model indices array (internal use)
  116485. * @hidden
  116486. */
  116487. _indicesLength: number;
  116488. /**
  116489. * Custom position function (internal use)
  116490. * @hidden
  116491. */
  116492. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  116493. /**
  116494. * Custom vertex function (internal use)
  116495. * @hidden
  116496. */
  116497. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  116498. /**
  116499. * Model material (internal use)
  116500. * @hidden
  116501. */
  116502. _material: Nullable<Material>;
  116503. /**
  116504. * 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.
  116505. * SPS internal tool, don't use it manually.
  116506. * @hidden
  116507. */
  116508. 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>);
  116509. }
  116510. /**
  116511. * Represents a Depth Sorted Particle in the solid particle system.
  116512. * @hidden
  116513. */
  116514. export class DepthSortedParticle {
  116515. /**
  116516. * Particle index
  116517. */
  116518. idx: number;
  116519. /**
  116520. * Index of the particle in the "indices" array
  116521. */
  116522. ind: number;
  116523. /**
  116524. * Length of the particle shape in the "indices" array
  116525. */
  116526. indicesLength: number;
  116527. /**
  116528. * Squared distance from the particle to the camera
  116529. */
  116530. sqDistance: number;
  116531. /**
  116532. * Material index when used with MultiMaterials
  116533. */
  116534. materialIndex: number;
  116535. /**
  116536. * Creates a new sorted particle
  116537. * @param materialIndex
  116538. */
  116539. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  116540. }
  116541. /**
  116542. * Represents a solid particle vertex
  116543. */
  116544. export class SolidParticleVertex {
  116545. /**
  116546. * Vertex position
  116547. */
  116548. position: Vector3;
  116549. /**
  116550. * Vertex color
  116551. */
  116552. color: Color4;
  116553. /**
  116554. * Vertex UV
  116555. */
  116556. uv: Vector2;
  116557. /**
  116558. * Creates a new solid particle vertex
  116559. */
  116560. constructor();
  116561. /** Vertex x coordinate */
  116562. get x(): number;
  116563. set x(val: number);
  116564. /** Vertex y coordinate */
  116565. get y(): number;
  116566. set y(val: number);
  116567. /** Vertex z coordinate */
  116568. get z(): number;
  116569. set z(val: number);
  116570. }
  116571. }
  116572. declare module BABYLON {
  116573. /**
  116574. * @hidden
  116575. */
  116576. export class _MeshCollisionData {
  116577. _checkCollisions: boolean;
  116578. _collisionMask: number;
  116579. _collisionGroup: number;
  116580. _surroundingMeshes: Nullable<AbstractMesh[]>;
  116581. _collider: Nullable<Collider>;
  116582. _oldPositionForCollisions: Vector3;
  116583. _diffPositionForCollisions: Vector3;
  116584. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  116585. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  116586. _collisionResponse: boolean;
  116587. }
  116588. }
  116589. declare module BABYLON {
  116590. /** @hidden */
  116591. class _FacetDataStorage {
  116592. facetPositions: Vector3[];
  116593. facetNormals: Vector3[];
  116594. facetPartitioning: number[][];
  116595. facetNb: number;
  116596. partitioningSubdivisions: number;
  116597. partitioningBBoxRatio: number;
  116598. facetDataEnabled: boolean;
  116599. facetParameters: any;
  116600. bbSize: Vector3;
  116601. subDiv: {
  116602. max: number;
  116603. X: number;
  116604. Y: number;
  116605. Z: number;
  116606. };
  116607. facetDepthSort: boolean;
  116608. facetDepthSortEnabled: boolean;
  116609. depthSortedIndices: IndicesArray;
  116610. depthSortedFacets: {
  116611. ind: number;
  116612. sqDistance: number;
  116613. }[];
  116614. facetDepthSortFunction: (f1: {
  116615. ind: number;
  116616. sqDistance: number;
  116617. }, f2: {
  116618. ind: number;
  116619. sqDistance: number;
  116620. }) => number;
  116621. facetDepthSortFrom: Vector3;
  116622. facetDepthSortOrigin: Vector3;
  116623. invertedMatrix: Matrix;
  116624. }
  116625. /**
  116626. * @hidden
  116627. **/
  116628. class _InternalAbstractMeshDataInfo {
  116629. _hasVertexAlpha: boolean;
  116630. _useVertexColors: boolean;
  116631. _numBoneInfluencers: number;
  116632. _applyFog: boolean;
  116633. _receiveShadows: boolean;
  116634. _facetData: _FacetDataStorage;
  116635. _visibility: number;
  116636. _skeleton: Nullable<Skeleton>;
  116637. _layerMask: number;
  116638. _computeBonesUsingShaders: boolean;
  116639. _isActive: boolean;
  116640. _onlyForInstances: boolean;
  116641. _isActiveIntermediate: boolean;
  116642. _onlyForInstancesIntermediate: boolean;
  116643. _actAsRegularMesh: boolean;
  116644. _currentLOD: Nullable<AbstractMesh>;
  116645. }
  116646. /**
  116647. * Class used to store all common mesh properties
  116648. */
  116649. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  116650. /** No occlusion */
  116651. static OCCLUSION_TYPE_NONE: number;
  116652. /** Occlusion set to optimisitic */
  116653. static OCCLUSION_TYPE_OPTIMISTIC: number;
  116654. /** Occlusion set to strict */
  116655. static OCCLUSION_TYPE_STRICT: number;
  116656. /** Use an accurante occlusion algorithm */
  116657. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  116658. /** Use a conservative occlusion algorithm */
  116659. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  116660. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  116661. * Test order :
  116662. * Is the bounding sphere outside the frustum ?
  116663. * If not, are the bounding box vertices outside the frustum ?
  116664. * It not, then the cullable object is in the frustum.
  116665. */
  116666. static readonly CULLINGSTRATEGY_STANDARD: number;
  116667. /** Culling strategy : Bounding Sphere Only.
  116668. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  116669. * It's also less accurate than the standard because some not visible objects can still be selected.
  116670. * Test : is the bounding sphere outside the frustum ?
  116671. * If not, then the cullable object is in the frustum.
  116672. */
  116673. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  116674. /** Culling strategy : Optimistic Inclusion.
  116675. * This in an inclusion test first, then the standard exclusion test.
  116676. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  116677. * 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.
  116678. * Anyway, it's as accurate as the standard strategy.
  116679. * Test :
  116680. * Is the cullable object bounding sphere center in the frustum ?
  116681. * If not, apply the default culling strategy.
  116682. */
  116683. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  116684. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  116685. * This in an inclusion test first, then the bounding sphere only exclusion test.
  116686. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  116687. * 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.
  116688. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  116689. * Test :
  116690. * Is the cullable object bounding sphere center in the frustum ?
  116691. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  116692. */
  116693. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  116694. /**
  116695. * No billboard
  116696. */
  116697. static get BILLBOARDMODE_NONE(): number;
  116698. /** Billboard on X axis */
  116699. static get BILLBOARDMODE_X(): number;
  116700. /** Billboard on Y axis */
  116701. static get BILLBOARDMODE_Y(): number;
  116702. /** Billboard on Z axis */
  116703. static get BILLBOARDMODE_Z(): number;
  116704. /** Billboard on all axes */
  116705. static get BILLBOARDMODE_ALL(): number;
  116706. /** Billboard on using position instead of orientation */
  116707. static get BILLBOARDMODE_USE_POSITION(): number;
  116708. /** @hidden */
  116709. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  116710. /**
  116711. * The culling strategy to use to check whether the mesh must be rendered or not.
  116712. * This value can be changed at any time and will be used on the next render mesh selection.
  116713. * The possible values are :
  116714. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116715. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116716. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116717. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116718. * Please read each static variable documentation to get details about the culling process.
  116719. * */
  116720. cullingStrategy: number;
  116721. /**
  116722. * Gets the number of facets in the mesh
  116723. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116724. */
  116725. get facetNb(): number;
  116726. /**
  116727. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116728. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116729. */
  116730. get partitioningSubdivisions(): number;
  116731. set partitioningSubdivisions(nb: number);
  116732. /**
  116733. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116734. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116735. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116736. */
  116737. get partitioningBBoxRatio(): number;
  116738. set partitioningBBoxRatio(ratio: number);
  116739. /**
  116740. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116741. * Works only for updatable meshes.
  116742. * Doesn't work with multi-materials
  116743. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116744. */
  116745. get mustDepthSortFacets(): boolean;
  116746. set mustDepthSortFacets(sort: boolean);
  116747. /**
  116748. * The location (Vector3) where the facet depth sort must be computed from.
  116749. * By default, the active camera position.
  116750. * Used only when facet depth sort is enabled
  116751. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116752. */
  116753. get facetDepthSortFrom(): Vector3;
  116754. set facetDepthSortFrom(location: Vector3);
  116755. /**
  116756. * gets a boolean indicating if facetData is enabled
  116757. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116758. */
  116759. get isFacetDataEnabled(): boolean;
  116760. /** @hidden */
  116761. _updateNonUniformScalingState(value: boolean): boolean;
  116762. /**
  116763. * An event triggered when this mesh collides with another one
  116764. */
  116765. onCollideObservable: Observable<AbstractMesh>;
  116766. /** Set a function to call when this mesh collides with another one */
  116767. set onCollide(callback: () => void);
  116768. /**
  116769. * An event triggered when the collision's position changes
  116770. */
  116771. onCollisionPositionChangeObservable: Observable<Vector3>;
  116772. /** Set a function to call when the collision's position changes */
  116773. set onCollisionPositionChange(callback: () => void);
  116774. /**
  116775. * An event triggered when material is changed
  116776. */
  116777. onMaterialChangedObservable: Observable<AbstractMesh>;
  116778. /**
  116779. * Gets or sets the orientation for POV movement & rotation
  116780. */
  116781. definedFacingForward: boolean;
  116782. /** @hidden */
  116783. _occlusionQuery: Nullable<WebGLQuery>;
  116784. /** @hidden */
  116785. _renderingGroup: Nullable<RenderingGroup>;
  116786. /**
  116787. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116788. */
  116789. get visibility(): number;
  116790. /**
  116791. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116792. */
  116793. set visibility(value: number);
  116794. /** Gets or sets the alpha index used to sort transparent meshes
  116795. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116796. */
  116797. alphaIndex: number;
  116798. /**
  116799. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116800. */
  116801. isVisible: boolean;
  116802. /**
  116803. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116804. */
  116805. isPickable: boolean;
  116806. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116807. showSubMeshesBoundingBox: boolean;
  116808. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116809. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116810. */
  116811. isBlocker: boolean;
  116812. /**
  116813. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116814. */
  116815. enablePointerMoveEvents: boolean;
  116816. private _renderingGroupId;
  116817. /**
  116818. * Specifies the rendering group id for this mesh (0 by default)
  116819. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116820. */
  116821. get renderingGroupId(): number;
  116822. set renderingGroupId(value: number);
  116823. private _material;
  116824. /** Gets or sets current material */
  116825. get material(): Nullable<Material>;
  116826. set material(value: Nullable<Material>);
  116827. /**
  116828. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116829. * @see https://doc.babylonjs.com/babylon101/shadows
  116830. */
  116831. get receiveShadows(): boolean;
  116832. set receiveShadows(value: boolean);
  116833. /** Defines color to use when rendering outline */
  116834. outlineColor: Color3;
  116835. /** Define width to use when rendering outline */
  116836. outlineWidth: number;
  116837. /** Defines color to use when rendering overlay */
  116838. overlayColor: Color3;
  116839. /** Defines alpha to use when rendering overlay */
  116840. overlayAlpha: number;
  116841. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116842. get hasVertexAlpha(): boolean;
  116843. set hasVertexAlpha(value: boolean);
  116844. /** 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) */
  116845. get useVertexColors(): boolean;
  116846. set useVertexColors(value: boolean);
  116847. /**
  116848. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116849. */
  116850. get computeBonesUsingShaders(): boolean;
  116851. set computeBonesUsingShaders(value: boolean);
  116852. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116853. get numBoneInfluencers(): number;
  116854. set numBoneInfluencers(value: number);
  116855. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116856. get applyFog(): boolean;
  116857. set applyFog(value: boolean);
  116858. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116859. useOctreeForRenderingSelection: boolean;
  116860. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116861. useOctreeForPicking: boolean;
  116862. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116863. useOctreeForCollisions: boolean;
  116864. /**
  116865. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116866. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116867. */
  116868. get layerMask(): number;
  116869. set layerMask(value: number);
  116870. /**
  116871. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116872. */
  116873. alwaysSelectAsActiveMesh: boolean;
  116874. /**
  116875. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116876. */
  116877. doNotSyncBoundingInfo: boolean;
  116878. /**
  116879. * Gets or sets the current action manager
  116880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116881. */
  116882. actionManager: Nullable<AbstractActionManager>;
  116883. private _meshCollisionData;
  116884. /**
  116885. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116886. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116887. */
  116888. ellipsoid: Vector3;
  116889. /**
  116890. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116891. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116892. */
  116893. ellipsoidOffset: Vector3;
  116894. /**
  116895. * Gets or sets a collision mask used to mask collisions (default is -1).
  116896. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116897. */
  116898. get collisionMask(): number;
  116899. set collisionMask(mask: number);
  116900. /**
  116901. * Gets or sets a collision response flag (default is true).
  116902. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116903. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116904. * to respond to the collision.
  116905. */
  116906. get collisionResponse(): boolean;
  116907. set collisionResponse(response: boolean);
  116908. /**
  116909. * Gets or sets the current collision group mask (-1 by default).
  116910. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116911. */
  116912. get collisionGroup(): number;
  116913. set collisionGroup(mask: number);
  116914. /**
  116915. * Gets or sets current surrounding meshes (null by default).
  116916. *
  116917. * By default collision detection is tested against every mesh in the scene.
  116918. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  116919. * meshes will be tested for the collision.
  116920. *
  116921. * Note: if set to an empty array no collision will happen when this mesh is moved.
  116922. */
  116923. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  116924. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  116925. /**
  116926. * Defines edge width used when edgesRenderer is enabled
  116927. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116928. */
  116929. edgesWidth: number;
  116930. /**
  116931. * Defines edge color used when edgesRenderer is enabled
  116932. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116933. */
  116934. edgesColor: Color4;
  116935. /** @hidden */
  116936. _edgesRenderer: Nullable<IEdgesRenderer>;
  116937. /** @hidden */
  116938. _masterMesh: Nullable<AbstractMesh>;
  116939. /** @hidden */
  116940. _boundingInfo: Nullable<BoundingInfo>;
  116941. /** @hidden */
  116942. _renderId: number;
  116943. /**
  116944. * Gets or sets the list of subMeshes
  116945. * @see https://doc.babylonjs.com/how_to/multi_materials
  116946. */
  116947. subMeshes: SubMesh[];
  116948. /** @hidden */
  116949. _intersectionsInProgress: AbstractMesh[];
  116950. /** @hidden */
  116951. _unIndexed: boolean;
  116952. /** @hidden */
  116953. _lightSources: Light[];
  116954. /** Gets the list of lights affecting that mesh */
  116955. get lightSources(): Light[];
  116956. /** @hidden */
  116957. get _positions(): Nullable<Vector3[]>;
  116958. /** @hidden */
  116959. _waitingData: {
  116960. lods: Nullable<any>;
  116961. actions: Nullable<any>;
  116962. freezeWorldMatrix: Nullable<boolean>;
  116963. };
  116964. /** @hidden */
  116965. _bonesTransformMatrices: Nullable<Float32Array>;
  116966. /** @hidden */
  116967. _transformMatrixTexture: Nullable<RawTexture>;
  116968. /**
  116969. * Gets or sets a skeleton to apply skining transformations
  116970. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116971. */
  116972. set skeleton(value: Nullable<Skeleton>);
  116973. get skeleton(): Nullable<Skeleton>;
  116974. /**
  116975. * An event triggered when the mesh is rebuilt.
  116976. */
  116977. onRebuildObservable: Observable<AbstractMesh>;
  116978. /**
  116979. * Creates a new AbstractMesh
  116980. * @param name defines the name of the mesh
  116981. * @param scene defines the hosting scene
  116982. */
  116983. constructor(name: string, scene?: Nullable<Scene>);
  116984. /**
  116985. * Returns the string "AbstractMesh"
  116986. * @returns "AbstractMesh"
  116987. */
  116988. getClassName(): string;
  116989. /**
  116990. * Gets a string representation of the current mesh
  116991. * @param fullDetails defines a boolean indicating if full details must be included
  116992. * @returns a string representation of the current mesh
  116993. */
  116994. toString(fullDetails?: boolean): string;
  116995. /**
  116996. * @hidden
  116997. */
  116998. protected _getEffectiveParent(): Nullable<Node>;
  116999. /** @hidden */
  117000. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117001. /** @hidden */
  117002. _rebuild(): void;
  117003. /** @hidden */
  117004. _resyncLightSources(): void;
  117005. /** @hidden */
  117006. _resyncLightSource(light: Light): void;
  117007. /** @hidden */
  117008. _unBindEffect(): void;
  117009. /** @hidden */
  117010. _removeLightSource(light: Light, dispose: boolean): void;
  117011. private _markSubMeshesAsDirty;
  117012. /** @hidden */
  117013. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  117014. /** @hidden */
  117015. _markSubMeshesAsAttributesDirty(): void;
  117016. /** @hidden */
  117017. _markSubMeshesAsMiscDirty(): void;
  117018. /**
  117019. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  117020. */
  117021. get scaling(): Vector3;
  117022. set scaling(newScaling: Vector3);
  117023. /**
  117024. * Returns true if the mesh is blocked. Implemented by child classes
  117025. */
  117026. get isBlocked(): boolean;
  117027. /**
  117028. * Returns the mesh itself by default. Implemented by child classes
  117029. * @param camera defines the camera to use to pick the right LOD level
  117030. * @returns the currentAbstractMesh
  117031. */
  117032. getLOD(camera: Camera): Nullable<AbstractMesh>;
  117033. /**
  117034. * Returns 0 by default. Implemented by child classes
  117035. * @returns an integer
  117036. */
  117037. getTotalVertices(): number;
  117038. /**
  117039. * Returns a positive integer : the total number of indices in this mesh geometry.
  117040. * @returns the numner of indices or zero if the mesh has no geometry.
  117041. */
  117042. getTotalIndices(): number;
  117043. /**
  117044. * Returns null by default. Implemented by child classes
  117045. * @returns null
  117046. */
  117047. getIndices(): Nullable<IndicesArray>;
  117048. /**
  117049. * Returns the array of the requested vertex data kind. Implemented by child classes
  117050. * @param kind defines the vertex data kind to use
  117051. * @returns null
  117052. */
  117053. getVerticesData(kind: string): Nullable<FloatArray>;
  117054. /**
  117055. * Sets the vertex data of the mesh geometry for the requested `kind`.
  117056. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  117057. * Note that a new underlying VertexBuffer object is created each call.
  117058. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  117059. * @param kind defines vertex data kind:
  117060. * * VertexBuffer.PositionKind
  117061. * * VertexBuffer.UVKind
  117062. * * VertexBuffer.UV2Kind
  117063. * * VertexBuffer.UV3Kind
  117064. * * VertexBuffer.UV4Kind
  117065. * * VertexBuffer.UV5Kind
  117066. * * VertexBuffer.UV6Kind
  117067. * * VertexBuffer.ColorKind
  117068. * * VertexBuffer.MatricesIndicesKind
  117069. * * VertexBuffer.MatricesIndicesExtraKind
  117070. * * VertexBuffer.MatricesWeightsKind
  117071. * * VertexBuffer.MatricesWeightsExtraKind
  117072. * @param data defines the data source
  117073. * @param updatable defines if the data must be flagged as updatable (or static)
  117074. * @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
  117075. * @returns the current mesh
  117076. */
  117077. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  117078. /**
  117079. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  117080. * If the mesh has no geometry, it is simply returned as it is.
  117081. * @param kind defines vertex data kind:
  117082. * * VertexBuffer.PositionKind
  117083. * * VertexBuffer.UVKind
  117084. * * VertexBuffer.UV2Kind
  117085. * * VertexBuffer.UV3Kind
  117086. * * VertexBuffer.UV4Kind
  117087. * * VertexBuffer.UV5Kind
  117088. * * VertexBuffer.UV6Kind
  117089. * * VertexBuffer.ColorKind
  117090. * * VertexBuffer.MatricesIndicesKind
  117091. * * VertexBuffer.MatricesIndicesExtraKind
  117092. * * VertexBuffer.MatricesWeightsKind
  117093. * * VertexBuffer.MatricesWeightsExtraKind
  117094. * @param data defines the data source
  117095. * @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
  117096. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  117097. * @returns the current mesh
  117098. */
  117099. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  117100. /**
  117101. * Sets the mesh indices,
  117102. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  117103. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  117104. * @param totalVertices Defines the total number of vertices
  117105. * @returns the current mesh
  117106. */
  117107. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  117108. /**
  117109. * Gets a boolean indicating if specific vertex data is present
  117110. * @param kind defines the vertex data kind to use
  117111. * @returns true is data kind is present
  117112. */
  117113. isVerticesDataPresent(kind: string): boolean;
  117114. /**
  117115. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  117116. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  117117. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  117118. * @returns a BoundingInfo
  117119. */
  117120. getBoundingInfo(): BoundingInfo;
  117121. /**
  117122. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  117123. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  117124. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  117125. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  117126. * @returns the current mesh
  117127. */
  117128. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  117129. /**
  117130. * Overwrite the current bounding info
  117131. * @param boundingInfo defines the new bounding info
  117132. * @returns the current mesh
  117133. */
  117134. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  117135. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  117136. get useBones(): boolean;
  117137. /** @hidden */
  117138. _preActivate(): void;
  117139. /** @hidden */
  117140. _preActivateForIntermediateRendering(renderId: number): void;
  117141. /** @hidden */
  117142. _activate(renderId: number, intermediateRendering: boolean): boolean;
  117143. /** @hidden */
  117144. _postActivate(): void;
  117145. /** @hidden */
  117146. _freeze(): void;
  117147. /** @hidden */
  117148. _unFreeze(): void;
  117149. /**
  117150. * Gets the current world matrix
  117151. * @returns a Matrix
  117152. */
  117153. getWorldMatrix(): Matrix;
  117154. /** @hidden */
  117155. _getWorldMatrixDeterminant(): number;
  117156. /**
  117157. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  117158. */
  117159. get isAnInstance(): boolean;
  117160. /**
  117161. * Gets a boolean indicating if this mesh has instances
  117162. */
  117163. get hasInstances(): boolean;
  117164. /**
  117165. * Gets a boolean indicating if this mesh has thin instances
  117166. */
  117167. get hasThinInstances(): boolean;
  117168. /**
  117169. * Perform relative position change from the point of view of behind the front of the mesh.
  117170. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117171. * Supports definition of mesh facing forward or backward
  117172. * @param amountRight defines the distance on the right axis
  117173. * @param amountUp defines the distance on the up axis
  117174. * @param amountForward defines the distance on the forward axis
  117175. * @returns the current mesh
  117176. */
  117177. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  117178. /**
  117179. * Calculate relative position change from the point of view of behind the front of the mesh.
  117180. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117181. * Supports definition of mesh facing forward or backward
  117182. * @param amountRight defines the distance on the right axis
  117183. * @param amountUp defines the distance on the up axis
  117184. * @param amountForward defines the distance on the forward axis
  117185. * @returns the new displacement vector
  117186. */
  117187. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  117188. /**
  117189. * Perform relative rotation change from the point of view of behind the front of the mesh.
  117190. * Supports definition of mesh facing forward or backward
  117191. * @param flipBack defines the flip
  117192. * @param twirlClockwise defines the twirl
  117193. * @param tiltRight defines the tilt
  117194. * @returns the current mesh
  117195. */
  117196. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  117197. /**
  117198. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  117199. * Supports definition of mesh facing forward or backward.
  117200. * @param flipBack defines the flip
  117201. * @param twirlClockwise defines the twirl
  117202. * @param tiltRight defines the tilt
  117203. * @returns the new rotation vector
  117204. */
  117205. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  117206. /**
  117207. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  117208. * This means the mesh underlying bounding box and sphere are recomputed.
  117209. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  117210. * @returns the current mesh
  117211. */
  117212. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  117213. /** @hidden */
  117214. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  117215. /** @hidden */
  117216. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  117217. /** @hidden */
  117218. _updateBoundingInfo(): AbstractMesh;
  117219. /** @hidden */
  117220. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  117221. /** @hidden */
  117222. protected _afterComputeWorldMatrix(): void;
  117223. /** @hidden */
  117224. get _effectiveMesh(): AbstractMesh;
  117225. /**
  117226. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  117227. * A mesh is in the frustum if its bounding box intersects the frustum
  117228. * @param frustumPlanes defines the frustum to test
  117229. * @returns true if the mesh is in the frustum planes
  117230. */
  117231. isInFrustum(frustumPlanes: Plane[]): boolean;
  117232. /**
  117233. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  117234. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  117235. * @param frustumPlanes defines the frustum to test
  117236. * @returns true if the mesh is completely in the frustum planes
  117237. */
  117238. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  117239. /**
  117240. * True if the mesh intersects another mesh or a SolidParticle object
  117241. * @param mesh defines a target mesh or SolidParticle to test
  117242. * @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)
  117243. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  117244. * @returns true if there is an intersection
  117245. */
  117246. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  117247. /**
  117248. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  117249. * @param point defines the point to test
  117250. * @returns true if there is an intersection
  117251. */
  117252. intersectsPoint(point: Vector3): boolean;
  117253. /**
  117254. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  117255. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117256. */
  117257. get checkCollisions(): boolean;
  117258. set checkCollisions(collisionEnabled: boolean);
  117259. /**
  117260. * Gets Collider object used to compute collisions (not physics)
  117261. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117262. */
  117263. get collider(): Nullable<Collider>;
  117264. /**
  117265. * Move the mesh using collision engine
  117266. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117267. * @param displacement defines the requested displacement vector
  117268. * @returns the current mesh
  117269. */
  117270. moveWithCollisions(displacement: Vector3): AbstractMesh;
  117271. private _onCollisionPositionChange;
  117272. /** @hidden */
  117273. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  117274. /** @hidden */
  117275. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  117276. /** @hidden */
  117277. _checkCollision(collider: Collider): AbstractMesh;
  117278. /** @hidden */
  117279. _generatePointsArray(): boolean;
  117280. /**
  117281. * Checks if the passed Ray intersects with the mesh
  117282. * @param ray defines the ray to use
  117283. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  117284. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117285. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  117286. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  117287. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  117288. * @returns the picking info
  117289. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  117290. */
  117291. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  117292. /**
  117293. * Clones the current mesh
  117294. * @param name defines the mesh name
  117295. * @param newParent defines the new mesh parent
  117296. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  117297. * @returns the new mesh
  117298. */
  117299. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  117300. /**
  117301. * Disposes all the submeshes of the current meshnp
  117302. * @returns the current mesh
  117303. */
  117304. releaseSubMeshes(): AbstractMesh;
  117305. /**
  117306. * Releases resources associated with this abstract mesh.
  117307. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117308. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117309. */
  117310. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117311. /**
  117312. * Adds the passed mesh as a child to the current mesh
  117313. * @param mesh defines the child mesh
  117314. * @returns the current mesh
  117315. */
  117316. addChild(mesh: AbstractMesh): AbstractMesh;
  117317. /**
  117318. * Removes the passed mesh from the current mesh children list
  117319. * @param mesh defines the child mesh
  117320. * @returns the current mesh
  117321. */
  117322. removeChild(mesh: AbstractMesh): AbstractMesh;
  117323. /** @hidden */
  117324. private _initFacetData;
  117325. /**
  117326. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  117327. * This method can be called within the render loop.
  117328. * 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
  117329. * @returns the current mesh
  117330. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117331. */
  117332. updateFacetData(): AbstractMesh;
  117333. /**
  117334. * Returns the facetLocalNormals array.
  117335. * The normals are expressed in the mesh local spac
  117336. * @returns an array of Vector3
  117337. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117338. */
  117339. getFacetLocalNormals(): Vector3[];
  117340. /**
  117341. * Returns the facetLocalPositions array.
  117342. * The facet positions are expressed in the mesh local space
  117343. * @returns an array of Vector3
  117344. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117345. */
  117346. getFacetLocalPositions(): Vector3[];
  117347. /**
  117348. * Returns the facetLocalPartioning array
  117349. * @returns an array of array of numbers
  117350. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117351. */
  117352. getFacetLocalPartitioning(): number[][];
  117353. /**
  117354. * Returns the i-th facet position in the world system.
  117355. * This method allocates a new Vector3 per call
  117356. * @param i defines the facet index
  117357. * @returns a new Vector3
  117358. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117359. */
  117360. getFacetPosition(i: number): Vector3;
  117361. /**
  117362. * Sets the reference Vector3 with the i-th facet position in the world system
  117363. * @param i defines the facet index
  117364. * @param ref defines the target vector
  117365. * @returns the current mesh
  117366. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117367. */
  117368. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  117369. /**
  117370. * Returns the i-th facet normal in the world system.
  117371. * This method allocates a new Vector3 per call
  117372. * @param i defines the facet index
  117373. * @returns a new Vector3
  117374. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117375. */
  117376. getFacetNormal(i: number): Vector3;
  117377. /**
  117378. * Sets the reference Vector3 with the i-th facet normal in the world system
  117379. * @param i defines the facet index
  117380. * @param ref defines the target vector
  117381. * @returns the current mesh
  117382. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117383. */
  117384. getFacetNormalToRef(i: number, ref: Vector3): this;
  117385. /**
  117386. * 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)
  117387. * @param x defines x coordinate
  117388. * @param y defines y coordinate
  117389. * @param z defines z coordinate
  117390. * @returns the array of facet indexes
  117391. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117392. */
  117393. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  117394. /**
  117395. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  117396. * @param projected sets as the (x,y,z) world projection on the facet
  117397. * @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
  117398. * @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
  117399. * @param x defines x coordinate
  117400. * @param y defines y coordinate
  117401. * @param z defines z coordinate
  117402. * @returns the face index if found (or null instead)
  117403. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117404. */
  117405. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117406. /**
  117407. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  117408. * @param projected sets as the (x,y,z) local projection on the facet
  117409. * @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
  117410. * @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
  117411. * @param x defines x coordinate
  117412. * @param y defines y coordinate
  117413. * @param z defines z coordinate
  117414. * @returns the face index if found (or null instead)
  117415. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117416. */
  117417. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117418. /**
  117419. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  117420. * @returns the parameters
  117421. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117422. */
  117423. getFacetDataParameters(): any;
  117424. /**
  117425. * Disables the feature FacetData and frees the related memory
  117426. * @returns the current mesh
  117427. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117428. */
  117429. disableFacetData(): AbstractMesh;
  117430. /**
  117431. * Updates the AbstractMesh indices array
  117432. * @param indices defines the data source
  117433. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  117434. * @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)
  117435. * @returns the current mesh
  117436. */
  117437. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  117438. /**
  117439. * Creates new normals data for the mesh
  117440. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  117441. * @returns the current mesh
  117442. */
  117443. createNormals(updatable: boolean): AbstractMesh;
  117444. /**
  117445. * Align the mesh with a normal
  117446. * @param normal defines the normal to use
  117447. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  117448. * @returns the current mesh
  117449. */
  117450. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  117451. /** @hidden */
  117452. _checkOcclusionQuery(): boolean;
  117453. /**
  117454. * Disables the mesh edge rendering mode
  117455. * @returns the currentAbstractMesh
  117456. */
  117457. disableEdgesRendering(): AbstractMesh;
  117458. /**
  117459. * Enables the edge rendering mode on the mesh.
  117460. * This mode makes the mesh edges visible
  117461. * @param epsilon defines the maximal distance between two angles to detect a face
  117462. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  117463. * @returns the currentAbstractMesh
  117464. * @see https://www.babylonjs-playground.com/#19O9TU#0
  117465. */
  117466. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  117467. /**
  117468. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  117469. * @returns an array of particle systems in the scene that use the mesh as an emitter
  117470. */
  117471. getConnectedParticleSystems(): IParticleSystem[];
  117472. }
  117473. }
  117474. declare module BABYLON {
  117475. /**
  117476. * Interface used to define ActionEvent
  117477. */
  117478. export interface IActionEvent {
  117479. /** The mesh or sprite that triggered the action */
  117480. source: any;
  117481. /** The X mouse cursor position at the time of the event */
  117482. pointerX: number;
  117483. /** The Y mouse cursor position at the time of the event */
  117484. pointerY: number;
  117485. /** The mesh that is currently pointed at (can be null) */
  117486. meshUnderPointer: Nullable<AbstractMesh>;
  117487. /** the original (browser) event that triggered the ActionEvent */
  117488. sourceEvent?: any;
  117489. /** additional data for the event */
  117490. additionalData?: any;
  117491. }
  117492. /**
  117493. * ActionEvent is the event being sent when an action is triggered.
  117494. */
  117495. export class ActionEvent implements IActionEvent {
  117496. /** The mesh or sprite that triggered the action */
  117497. source: any;
  117498. /** The X mouse cursor position at the time of the event */
  117499. pointerX: number;
  117500. /** The Y mouse cursor position at the time of the event */
  117501. pointerY: number;
  117502. /** The mesh that is currently pointed at (can be null) */
  117503. meshUnderPointer: Nullable<AbstractMesh>;
  117504. /** the original (browser) event that triggered the ActionEvent */
  117505. sourceEvent?: any;
  117506. /** additional data for the event */
  117507. additionalData?: any;
  117508. /**
  117509. * Creates a new ActionEvent
  117510. * @param source The mesh or sprite that triggered the action
  117511. * @param pointerX The X mouse cursor position at the time of the event
  117512. * @param pointerY The Y mouse cursor position at the time of the event
  117513. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  117514. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  117515. * @param additionalData additional data for the event
  117516. */
  117517. constructor(
  117518. /** The mesh or sprite that triggered the action */
  117519. source: any,
  117520. /** The X mouse cursor position at the time of the event */
  117521. pointerX: number,
  117522. /** The Y mouse cursor position at the time of the event */
  117523. pointerY: number,
  117524. /** The mesh that is currently pointed at (can be null) */
  117525. meshUnderPointer: Nullable<AbstractMesh>,
  117526. /** the original (browser) event that triggered the ActionEvent */
  117527. sourceEvent?: any,
  117528. /** additional data for the event */
  117529. additionalData?: any);
  117530. /**
  117531. * Helper function to auto-create an ActionEvent from a source mesh.
  117532. * @param source The source mesh that triggered the event
  117533. * @param evt The original (browser) event
  117534. * @param additionalData additional data for the event
  117535. * @returns the new ActionEvent
  117536. */
  117537. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  117538. /**
  117539. * Helper function to auto-create an ActionEvent from a source sprite
  117540. * @param source The source sprite that triggered the event
  117541. * @param scene Scene associated with the sprite
  117542. * @param evt The original (browser) event
  117543. * @param additionalData additional data for the event
  117544. * @returns the new ActionEvent
  117545. */
  117546. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  117547. /**
  117548. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  117549. * @param scene the scene where the event occurred
  117550. * @param evt The original (browser) event
  117551. * @returns the new ActionEvent
  117552. */
  117553. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  117554. /**
  117555. * Helper function to auto-create an ActionEvent from a primitive
  117556. * @param prim defines the target primitive
  117557. * @param pointerPos defines the pointer position
  117558. * @param evt The original (browser) event
  117559. * @param additionalData additional data for the event
  117560. * @returns the new ActionEvent
  117561. */
  117562. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  117563. }
  117564. }
  117565. declare module BABYLON {
  117566. /**
  117567. * Abstract class used to decouple action Manager from scene and meshes.
  117568. * Do not instantiate.
  117569. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117570. */
  117571. export abstract class AbstractActionManager implements IDisposable {
  117572. /** Gets the list of active triggers */
  117573. static Triggers: {
  117574. [key: string]: number;
  117575. };
  117576. /** Gets the cursor to use when hovering items */
  117577. hoverCursor: string;
  117578. /** Gets the list of actions */
  117579. actions: IAction[];
  117580. /**
  117581. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  117582. */
  117583. isRecursive: boolean;
  117584. /**
  117585. * Releases all associated resources
  117586. */
  117587. abstract dispose(): void;
  117588. /**
  117589. * Does this action manager has pointer triggers
  117590. */
  117591. abstract get hasPointerTriggers(): boolean;
  117592. /**
  117593. * Does this action manager has pick triggers
  117594. */
  117595. abstract get hasPickTriggers(): boolean;
  117596. /**
  117597. * Process a specific trigger
  117598. * @param trigger defines the trigger to process
  117599. * @param evt defines the event details to be processed
  117600. */
  117601. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  117602. /**
  117603. * Does this action manager handles actions of any of the given triggers
  117604. * @param triggers defines the triggers to be tested
  117605. * @return a boolean indicating whether one (or more) of the triggers is handled
  117606. */
  117607. abstract hasSpecificTriggers(triggers: number[]): boolean;
  117608. /**
  117609. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  117610. * speed.
  117611. * @param triggerA defines the trigger to be tested
  117612. * @param triggerB defines the trigger to be tested
  117613. * @return a boolean indicating whether one (or more) of the triggers is handled
  117614. */
  117615. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  117616. /**
  117617. * Does this action manager handles actions of a given trigger
  117618. * @param trigger defines the trigger to be tested
  117619. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  117620. * @return whether the trigger is handled
  117621. */
  117622. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  117623. /**
  117624. * Serialize this manager to a JSON object
  117625. * @param name defines the property name to store this manager
  117626. * @returns a JSON representation of this manager
  117627. */
  117628. abstract serialize(name: string): any;
  117629. /**
  117630. * Registers an action to this action manager
  117631. * @param action defines the action to be registered
  117632. * @return the action amended (prepared) after registration
  117633. */
  117634. abstract registerAction(action: IAction): Nullable<IAction>;
  117635. /**
  117636. * Unregisters an action to this action manager
  117637. * @param action defines the action to be unregistered
  117638. * @return a boolean indicating whether the action has been unregistered
  117639. */
  117640. abstract unregisterAction(action: IAction): Boolean;
  117641. /**
  117642. * Does exist one action manager with at least one trigger
  117643. **/
  117644. static get HasTriggers(): boolean;
  117645. /**
  117646. * Does exist one action manager with at least one pick trigger
  117647. **/
  117648. static get HasPickTriggers(): boolean;
  117649. /**
  117650. * Does exist one action manager that handles actions of a given trigger
  117651. * @param trigger defines the trigger to be tested
  117652. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  117653. **/
  117654. static HasSpecificTrigger(trigger: number): boolean;
  117655. }
  117656. }
  117657. declare module BABYLON {
  117658. /**
  117659. * Defines how a node can be built from a string name.
  117660. */
  117661. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  117662. /**
  117663. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  117664. */
  117665. export class Node implements IBehaviorAware<Node> {
  117666. /** @hidden */
  117667. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  117668. private static _NodeConstructors;
  117669. /**
  117670. * Add a new node constructor
  117671. * @param type defines the type name of the node to construct
  117672. * @param constructorFunc defines the constructor function
  117673. */
  117674. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  117675. /**
  117676. * Returns a node constructor based on type name
  117677. * @param type defines the type name
  117678. * @param name defines the new node name
  117679. * @param scene defines the hosting scene
  117680. * @param options defines optional options to transmit to constructors
  117681. * @returns the new constructor or null
  117682. */
  117683. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  117684. /**
  117685. * Gets or sets the name of the node
  117686. */
  117687. name: string;
  117688. /**
  117689. * Gets or sets the id of the node
  117690. */
  117691. id: string;
  117692. /**
  117693. * Gets or sets the unique id of the node
  117694. */
  117695. uniqueId: number;
  117696. /**
  117697. * Gets or sets a string used to store user defined state for the node
  117698. */
  117699. state: string;
  117700. /**
  117701. * Gets or sets an object used to store user defined information for the node
  117702. */
  117703. metadata: any;
  117704. /**
  117705. * For internal use only. Please do not use.
  117706. */
  117707. reservedDataStore: any;
  117708. /**
  117709. * List of inspectable custom properties (used by the Inspector)
  117710. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117711. */
  117712. inspectableCustomProperties: IInspectable[];
  117713. private _doNotSerialize;
  117714. /**
  117715. * Gets or sets a boolean used to define if the node must be serialized
  117716. */
  117717. get doNotSerialize(): boolean;
  117718. set doNotSerialize(value: boolean);
  117719. /** @hidden */
  117720. _isDisposed: boolean;
  117721. /**
  117722. * Gets a list of Animations associated with the node
  117723. */
  117724. animations: Animation[];
  117725. protected _ranges: {
  117726. [name: string]: Nullable<AnimationRange>;
  117727. };
  117728. /**
  117729. * Callback raised when the node is ready to be used
  117730. */
  117731. onReady: Nullable<(node: Node) => void>;
  117732. private _isEnabled;
  117733. private _isParentEnabled;
  117734. private _isReady;
  117735. /** @hidden */
  117736. _currentRenderId: number;
  117737. private _parentUpdateId;
  117738. /** @hidden */
  117739. _childUpdateId: number;
  117740. /** @hidden */
  117741. _waitingParentId: Nullable<string>;
  117742. /** @hidden */
  117743. _scene: Scene;
  117744. /** @hidden */
  117745. _cache: any;
  117746. private _parentNode;
  117747. private _children;
  117748. /** @hidden */
  117749. _worldMatrix: Matrix;
  117750. /** @hidden */
  117751. _worldMatrixDeterminant: number;
  117752. /** @hidden */
  117753. _worldMatrixDeterminantIsDirty: boolean;
  117754. /** @hidden */
  117755. private _sceneRootNodesIndex;
  117756. /**
  117757. * Gets a boolean indicating if the node has been disposed
  117758. * @returns true if the node was disposed
  117759. */
  117760. isDisposed(): boolean;
  117761. /**
  117762. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117763. * @see https://doc.babylonjs.com/how_to/parenting
  117764. */
  117765. set parent(parent: Nullable<Node>);
  117766. get parent(): Nullable<Node>;
  117767. /** @hidden */
  117768. _addToSceneRootNodes(): void;
  117769. /** @hidden */
  117770. _removeFromSceneRootNodes(): void;
  117771. private _animationPropertiesOverride;
  117772. /**
  117773. * Gets or sets the animation properties override
  117774. */
  117775. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117776. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117777. /**
  117778. * Gets a string identifying the name of the class
  117779. * @returns "Node" string
  117780. */
  117781. getClassName(): string;
  117782. /** @hidden */
  117783. readonly _isNode: boolean;
  117784. /**
  117785. * An event triggered when the mesh is disposed
  117786. */
  117787. onDisposeObservable: Observable<Node>;
  117788. private _onDisposeObserver;
  117789. /**
  117790. * Sets a callback that will be raised when the node will be disposed
  117791. */
  117792. set onDispose(callback: () => void);
  117793. /**
  117794. * Creates a new Node
  117795. * @param name the name and id to be given to this node
  117796. * @param scene the scene this node will be added to
  117797. */
  117798. constructor(name: string, scene?: Nullable<Scene>);
  117799. /**
  117800. * Gets the scene of the node
  117801. * @returns a scene
  117802. */
  117803. getScene(): Scene;
  117804. /**
  117805. * Gets the engine of the node
  117806. * @returns a Engine
  117807. */
  117808. getEngine(): Engine;
  117809. private _behaviors;
  117810. /**
  117811. * Attach a behavior to the node
  117812. * @see https://doc.babylonjs.com/features/behaviour
  117813. * @param behavior defines the behavior to attach
  117814. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117815. * @returns the current Node
  117816. */
  117817. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117818. /**
  117819. * Remove an attached behavior
  117820. * @see https://doc.babylonjs.com/features/behaviour
  117821. * @param behavior defines the behavior to attach
  117822. * @returns the current Node
  117823. */
  117824. removeBehavior(behavior: Behavior<Node>): Node;
  117825. /**
  117826. * Gets the list of attached behaviors
  117827. * @see https://doc.babylonjs.com/features/behaviour
  117828. */
  117829. get behaviors(): Behavior<Node>[];
  117830. /**
  117831. * Gets an attached behavior by name
  117832. * @param name defines the name of the behavior to look for
  117833. * @see https://doc.babylonjs.com/features/behaviour
  117834. * @returns null if behavior was not found else the requested behavior
  117835. */
  117836. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117837. /**
  117838. * Returns the latest update of the World matrix
  117839. * @returns a Matrix
  117840. */
  117841. getWorldMatrix(): Matrix;
  117842. /** @hidden */
  117843. _getWorldMatrixDeterminant(): number;
  117844. /**
  117845. * Returns directly the latest state of the mesh World matrix.
  117846. * A Matrix is returned.
  117847. */
  117848. get worldMatrixFromCache(): Matrix;
  117849. /** @hidden */
  117850. _initCache(): void;
  117851. /** @hidden */
  117852. updateCache(force?: boolean): void;
  117853. /** @hidden */
  117854. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117855. /** @hidden */
  117856. _updateCache(ignoreParentClass?: boolean): void;
  117857. /** @hidden */
  117858. _isSynchronized(): boolean;
  117859. /** @hidden */
  117860. _markSyncedWithParent(): void;
  117861. /** @hidden */
  117862. isSynchronizedWithParent(): boolean;
  117863. /** @hidden */
  117864. isSynchronized(): boolean;
  117865. /**
  117866. * Is this node ready to be used/rendered
  117867. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117868. * @return true if the node is ready
  117869. */
  117870. isReady(completeCheck?: boolean): boolean;
  117871. /**
  117872. * Is this node enabled?
  117873. * 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
  117874. * @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
  117875. * @return whether this node (and its parent) is enabled
  117876. */
  117877. isEnabled(checkAncestors?: boolean): boolean;
  117878. /** @hidden */
  117879. protected _syncParentEnabledState(): void;
  117880. /**
  117881. * Set the enabled state of this node
  117882. * @param value defines the new enabled state
  117883. */
  117884. setEnabled(value: boolean): void;
  117885. /**
  117886. * Is this node a descendant of the given node?
  117887. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117888. * @param ancestor defines the parent node to inspect
  117889. * @returns a boolean indicating if this node is a descendant of the given node
  117890. */
  117891. isDescendantOf(ancestor: Node): boolean;
  117892. /** @hidden */
  117893. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117894. /**
  117895. * Will return all nodes that have this node as ascendant
  117896. * @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
  117897. * @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
  117898. * @return all children nodes of all types
  117899. */
  117900. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117901. /**
  117902. * Get all child-meshes of this node
  117903. * @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)
  117904. * @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
  117905. * @returns an array of AbstractMesh
  117906. */
  117907. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  117908. /**
  117909. * Get all direct children of this node
  117910. * @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
  117911. * @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)
  117912. * @returns an array of Node
  117913. */
  117914. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  117915. /** @hidden */
  117916. _setReady(state: boolean): void;
  117917. /**
  117918. * Get an animation by name
  117919. * @param name defines the name of the animation to look for
  117920. * @returns null if not found else the requested animation
  117921. */
  117922. getAnimationByName(name: string): Nullable<Animation>;
  117923. /**
  117924. * Creates an animation range for this node
  117925. * @param name defines the name of the range
  117926. * @param from defines the starting key
  117927. * @param to defines the end key
  117928. */
  117929. createAnimationRange(name: string, from: number, to: number): void;
  117930. /**
  117931. * Delete a specific animation range
  117932. * @param name defines the name of the range to delete
  117933. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117934. */
  117935. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117936. /**
  117937. * Get an animation range by name
  117938. * @param name defines the name of the animation range to look for
  117939. * @returns null if not found else the requested animation range
  117940. */
  117941. getAnimationRange(name: string): Nullable<AnimationRange>;
  117942. /**
  117943. * Gets the list of all animation ranges defined on this node
  117944. * @returns an array
  117945. */
  117946. getAnimationRanges(): Nullable<AnimationRange>[];
  117947. /**
  117948. * Will start the animation sequence
  117949. * @param name defines the range frames for animation sequence
  117950. * @param loop defines if the animation should loop (false by default)
  117951. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117952. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117953. * @returns the object created for this animation. If range does not exist, it will return null
  117954. */
  117955. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117956. /**
  117957. * Serialize animation ranges into a JSON compatible object
  117958. * @returns serialization object
  117959. */
  117960. serializeAnimationRanges(): any;
  117961. /**
  117962. * Computes the world matrix of the node
  117963. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117964. * @returns the world matrix
  117965. */
  117966. computeWorldMatrix(force?: boolean): Matrix;
  117967. /**
  117968. * Releases resources associated with this node.
  117969. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117970. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117971. */
  117972. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117973. /**
  117974. * Parse animation range data from a serialization object and store them into a given node
  117975. * @param node defines where to store the animation ranges
  117976. * @param parsedNode defines the serialization object to read data from
  117977. * @param scene defines the hosting scene
  117978. */
  117979. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117980. /**
  117981. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117982. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117983. * @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
  117984. * @returns the new bounding vectors
  117985. */
  117986. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117987. min: Vector3;
  117988. max: Vector3;
  117989. };
  117990. }
  117991. }
  117992. declare module BABYLON {
  117993. /**
  117994. * @hidden
  117995. */
  117996. export class _IAnimationState {
  117997. key: number;
  117998. repeatCount: number;
  117999. workValue?: any;
  118000. loopMode?: number;
  118001. offsetValue?: any;
  118002. highLimitValue?: any;
  118003. }
  118004. /**
  118005. * Class used to store any kind of animation
  118006. */
  118007. export class Animation {
  118008. /**Name of the animation */
  118009. name: string;
  118010. /**Property to animate */
  118011. targetProperty: string;
  118012. /**The frames per second of the animation */
  118013. framePerSecond: number;
  118014. /**The data type of the animation */
  118015. dataType: number;
  118016. /**The loop mode of the animation */
  118017. loopMode?: number | undefined;
  118018. /**Specifies if blending should be enabled */
  118019. enableBlending?: boolean | undefined;
  118020. /**
  118021. * Use matrix interpolation instead of using direct key value when animating matrices
  118022. */
  118023. static AllowMatricesInterpolation: boolean;
  118024. /**
  118025. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  118026. */
  118027. static AllowMatrixDecomposeForInterpolation: boolean;
  118028. /** Define the Url to load snippets */
  118029. static SnippetUrl: string;
  118030. /** Snippet ID if the animation was created from the snippet server */
  118031. snippetId: string;
  118032. /**
  118033. * Stores the key frames of the animation
  118034. */
  118035. private _keys;
  118036. /**
  118037. * Stores the easing function of the animation
  118038. */
  118039. private _easingFunction;
  118040. /**
  118041. * @hidden Internal use only
  118042. */
  118043. _runtimeAnimations: RuntimeAnimation[];
  118044. /**
  118045. * The set of event that will be linked to this animation
  118046. */
  118047. private _events;
  118048. /**
  118049. * Stores an array of target property paths
  118050. */
  118051. targetPropertyPath: string[];
  118052. /**
  118053. * Stores the blending speed of the animation
  118054. */
  118055. blendingSpeed: number;
  118056. /**
  118057. * Stores the animation ranges for the animation
  118058. */
  118059. private _ranges;
  118060. /**
  118061. * @hidden Internal use
  118062. */
  118063. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  118064. /**
  118065. * Sets up an animation
  118066. * @param property The property to animate
  118067. * @param animationType The animation type to apply
  118068. * @param framePerSecond The frames per second of the animation
  118069. * @param easingFunction The easing function used in the animation
  118070. * @returns The created animation
  118071. */
  118072. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  118073. /**
  118074. * Create and start an animation on a node
  118075. * @param name defines the name of the global animation that will be run on all nodes
  118076. * @param node defines the root node where the animation will take place
  118077. * @param targetProperty defines property to animate
  118078. * @param framePerSecond defines the number of frame per second yo use
  118079. * @param totalFrame defines the number of frames in total
  118080. * @param from defines the initial value
  118081. * @param to defines the final value
  118082. * @param loopMode defines which loop mode you want to use (off by default)
  118083. * @param easingFunction defines the easing function to use (linear by default)
  118084. * @param onAnimationEnd defines the callback to call when animation end
  118085. * @returns the animatable created for this animation
  118086. */
  118087. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118088. /**
  118089. * Create and start an animation on a node and its descendants
  118090. * @param name defines the name of the global animation that will be run on all nodes
  118091. * @param node defines the root node where the animation will take place
  118092. * @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
  118093. * @param targetProperty defines property to animate
  118094. * @param framePerSecond defines the number of frame per second to use
  118095. * @param totalFrame defines the number of frames in total
  118096. * @param from defines the initial value
  118097. * @param to defines the final value
  118098. * @param loopMode defines which loop mode you want to use (off by default)
  118099. * @param easingFunction defines the easing function to use (linear by default)
  118100. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  118101. * @returns the list of animatables created for all nodes
  118102. * @example https://www.babylonjs-playground.com/#MH0VLI
  118103. */
  118104. 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[]>;
  118105. /**
  118106. * Creates a new animation, merges it with the existing animations and starts it
  118107. * @param name Name of the animation
  118108. * @param node Node which contains the scene that begins the animations
  118109. * @param targetProperty Specifies which property to animate
  118110. * @param framePerSecond The frames per second of the animation
  118111. * @param totalFrame The total number of frames
  118112. * @param from The frame at the beginning of the animation
  118113. * @param to The frame at the end of the animation
  118114. * @param loopMode Specifies the loop mode of the animation
  118115. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  118116. * @param onAnimationEnd Callback to run once the animation is complete
  118117. * @returns Nullable animation
  118118. */
  118119. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118120. /**
  118121. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118122. * @param sourceAnimation defines the Animation containing keyframes to convert
  118123. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118124. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  118125. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  118126. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  118127. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  118128. */
  118129. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  118130. /**
  118131. * Transition property of an host to the target Value
  118132. * @param property The property to transition
  118133. * @param targetValue The target Value of the property
  118134. * @param host The object where the property to animate belongs
  118135. * @param scene Scene used to run the animation
  118136. * @param frameRate Framerate (in frame/s) to use
  118137. * @param transition The transition type we want to use
  118138. * @param duration The duration of the animation, in milliseconds
  118139. * @param onAnimationEnd Callback trigger at the end of the animation
  118140. * @returns Nullable animation
  118141. */
  118142. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  118143. /**
  118144. * Return the array of runtime animations currently using this animation
  118145. */
  118146. get runtimeAnimations(): RuntimeAnimation[];
  118147. /**
  118148. * Specifies if any of the runtime animations are currently running
  118149. */
  118150. get hasRunningRuntimeAnimations(): boolean;
  118151. /**
  118152. * Initializes the animation
  118153. * @param name Name of the animation
  118154. * @param targetProperty Property to animate
  118155. * @param framePerSecond The frames per second of the animation
  118156. * @param dataType The data type of the animation
  118157. * @param loopMode The loop mode of the animation
  118158. * @param enableBlending Specifies if blending should be enabled
  118159. */
  118160. constructor(
  118161. /**Name of the animation */
  118162. name: string,
  118163. /**Property to animate */
  118164. targetProperty: string,
  118165. /**The frames per second of the animation */
  118166. framePerSecond: number,
  118167. /**The data type of the animation */
  118168. dataType: number,
  118169. /**The loop mode of the animation */
  118170. loopMode?: number | undefined,
  118171. /**Specifies if blending should be enabled */
  118172. enableBlending?: boolean | undefined);
  118173. /**
  118174. * Converts the animation to a string
  118175. * @param fullDetails support for multiple levels of logging within scene loading
  118176. * @returns String form of the animation
  118177. */
  118178. toString(fullDetails?: boolean): string;
  118179. /**
  118180. * Add an event to this animation
  118181. * @param event Event to add
  118182. */
  118183. addEvent(event: AnimationEvent): void;
  118184. /**
  118185. * Remove all events found at the given frame
  118186. * @param frame The frame to remove events from
  118187. */
  118188. removeEvents(frame: number): void;
  118189. /**
  118190. * Retrieves all the events from the animation
  118191. * @returns Events from the animation
  118192. */
  118193. getEvents(): AnimationEvent[];
  118194. /**
  118195. * Creates an animation range
  118196. * @param name Name of the animation range
  118197. * @param from Starting frame of the animation range
  118198. * @param to Ending frame of the animation
  118199. */
  118200. createRange(name: string, from: number, to: number): void;
  118201. /**
  118202. * Deletes an animation range by name
  118203. * @param name Name of the animation range to delete
  118204. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  118205. */
  118206. deleteRange(name: string, deleteFrames?: boolean): void;
  118207. /**
  118208. * Gets the animation range by name, or null if not defined
  118209. * @param name Name of the animation range
  118210. * @returns Nullable animation range
  118211. */
  118212. getRange(name: string): Nullable<AnimationRange>;
  118213. /**
  118214. * Gets the key frames from the animation
  118215. * @returns The key frames of the animation
  118216. */
  118217. getKeys(): Array<IAnimationKey>;
  118218. /**
  118219. * Gets the highest frame rate of the animation
  118220. * @returns Highest frame rate of the animation
  118221. */
  118222. getHighestFrame(): number;
  118223. /**
  118224. * Gets the easing function of the animation
  118225. * @returns Easing function of the animation
  118226. */
  118227. getEasingFunction(): IEasingFunction;
  118228. /**
  118229. * Sets the easing function of the animation
  118230. * @param easingFunction A custom mathematical formula for animation
  118231. */
  118232. setEasingFunction(easingFunction: EasingFunction): void;
  118233. /**
  118234. * Interpolates a scalar linearly
  118235. * @param startValue Start value of the animation curve
  118236. * @param endValue End value of the animation curve
  118237. * @param gradient Scalar amount to interpolate
  118238. * @returns Interpolated scalar value
  118239. */
  118240. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  118241. /**
  118242. * Interpolates a scalar cubically
  118243. * @param startValue Start value of the animation curve
  118244. * @param outTangent End tangent of the animation
  118245. * @param endValue End value of the animation curve
  118246. * @param inTangent Start tangent of the animation curve
  118247. * @param gradient Scalar amount to interpolate
  118248. * @returns Interpolated scalar value
  118249. */
  118250. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  118251. /**
  118252. * Interpolates a quaternion using a spherical linear interpolation
  118253. * @param startValue Start value of the animation curve
  118254. * @param endValue End value of the animation curve
  118255. * @param gradient Scalar amount to interpolate
  118256. * @returns Interpolated quaternion value
  118257. */
  118258. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  118259. /**
  118260. * Interpolates a quaternion cubically
  118261. * @param startValue Start value of the animation curve
  118262. * @param outTangent End tangent of the animation curve
  118263. * @param endValue End value of the animation curve
  118264. * @param inTangent Start tangent of the animation curve
  118265. * @param gradient Scalar amount to interpolate
  118266. * @returns Interpolated quaternion value
  118267. */
  118268. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  118269. /**
  118270. * Interpolates a Vector3 linearl
  118271. * @param startValue Start value of the animation curve
  118272. * @param endValue End value of the animation curve
  118273. * @param gradient Scalar amount to interpolate
  118274. * @returns Interpolated scalar value
  118275. */
  118276. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  118277. /**
  118278. * Interpolates a Vector3 cubically
  118279. * @param startValue Start value of the animation curve
  118280. * @param outTangent End tangent of the animation
  118281. * @param endValue End value of the animation curve
  118282. * @param inTangent Start tangent of the animation curve
  118283. * @param gradient Scalar amount to interpolate
  118284. * @returns InterpolatedVector3 value
  118285. */
  118286. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  118287. /**
  118288. * Interpolates a Vector2 linearly
  118289. * @param startValue Start value of the animation curve
  118290. * @param endValue End value of the animation curve
  118291. * @param gradient Scalar amount to interpolate
  118292. * @returns Interpolated Vector2 value
  118293. */
  118294. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  118295. /**
  118296. * Interpolates a Vector2 cubically
  118297. * @param startValue Start value of the animation curve
  118298. * @param outTangent End tangent of the animation
  118299. * @param endValue End value of the animation curve
  118300. * @param inTangent Start tangent of the animation curve
  118301. * @param gradient Scalar amount to interpolate
  118302. * @returns Interpolated Vector2 value
  118303. */
  118304. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  118305. /**
  118306. * Interpolates a size linearly
  118307. * @param startValue Start value of the animation curve
  118308. * @param endValue End value of the animation curve
  118309. * @param gradient Scalar amount to interpolate
  118310. * @returns Interpolated Size value
  118311. */
  118312. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  118313. /**
  118314. * Interpolates a Color3 linearly
  118315. * @param startValue Start value of the animation curve
  118316. * @param endValue End value of the animation curve
  118317. * @param gradient Scalar amount to interpolate
  118318. * @returns Interpolated Color3 value
  118319. */
  118320. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  118321. /**
  118322. * Interpolates a Color4 linearly
  118323. * @param startValue Start value of the animation curve
  118324. * @param endValue End value of the animation curve
  118325. * @param gradient Scalar amount to interpolate
  118326. * @returns Interpolated Color3 value
  118327. */
  118328. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  118329. /**
  118330. * @hidden Internal use only
  118331. */
  118332. _getKeyValue(value: any): any;
  118333. /**
  118334. * @hidden Internal use only
  118335. */
  118336. _interpolate(currentFrame: number, state: _IAnimationState): any;
  118337. /**
  118338. * Defines the function to use to interpolate matrices
  118339. * @param startValue defines the start matrix
  118340. * @param endValue defines the end matrix
  118341. * @param gradient defines the gradient between both matrices
  118342. * @param result defines an optional target matrix where to store the interpolation
  118343. * @returns the interpolated matrix
  118344. */
  118345. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  118346. /**
  118347. * Makes a copy of the animation
  118348. * @returns Cloned animation
  118349. */
  118350. clone(): Animation;
  118351. /**
  118352. * Sets the key frames of the animation
  118353. * @param values The animation key frames to set
  118354. */
  118355. setKeys(values: Array<IAnimationKey>): void;
  118356. /**
  118357. * Serializes the animation to an object
  118358. * @returns Serialized object
  118359. */
  118360. serialize(): any;
  118361. /**
  118362. * Float animation type
  118363. */
  118364. static readonly ANIMATIONTYPE_FLOAT: number;
  118365. /**
  118366. * Vector3 animation type
  118367. */
  118368. static readonly ANIMATIONTYPE_VECTOR3: number;
  118369. /**
  118370. * Quaternion animation type
  118371. */
  118372. static readonly ANIMATIONTYPE_QUATERNION: number;
  118373. /**
  118374. * Matrix animation type
  118375. */
  118376. static readonly ANIMATIONTYPE_MATRIX: number;
  118377. /**
  118378. * Color3 animation type
  118379. */
  118380. static readonly ANIMATIONTYPE_COLOR3: number;
  118381. /**
  118382. * Color3 animation type
  118383. */
  118384. static readonly ANIMATIONTYPE_COLOR4: number;
  118385. /**
  118386. * Vector2 animation type
  118387. */
  118388. static readonly ANIMATIONTYPE_VECTOR2: number;
  118389. /**
  118390. * Size animation type
  118391. */
  118392. static readonly ANIMATIONTYPE_SIZE: number;
  118393. /**
  118394. * Relative Loop Mode
  118395. */
  118396. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  118397. /**
  118398. * Cycle Loop Mode
  118399. */
  118400. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  118401. /**
  118402. * Constant Loop Mode
  118403. */
  118404. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  118405. /** @hidden */
  118406. static _UniversalLerp(left: any, right: any, amount: number): any;
  118407. /**
  118408. * Parses an animation object and creates an animation
  118409. * @param parsedAnimation Parsed animation object
  118410. * @returns Animation object
  118411. */
  118412. static Parse(parsedAnimation: any): Animation;
  118413. /**
  118414. * Appends the serialized animations from the source animations
  118415. * @param source Source containing the animations
  118416. * @param destination Target to store the animations
  118417. */
  118418. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118419. /**
  118420. * Creates a new animation or an array of animations from a snippet saved in a remote file
  118421. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  118422. * @param url defines the url to load from
  118423. * @returns a promise that will resolve to the new animation or an array of animations
  118424. */
  118425. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  118426. /**
  118427. * Creates an animation or an array of animations from a snippet saved by the Inspector
  118428. * @param snippetId defines the snippet to load
  118429. * @returns a promise that will resolve to the new animation or a new array of animations
  118430. */
  118431. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  118432. }
  118433. }
  118434. declare module BABYLON {
  118435. /**
  118436. * Interface containing an array of animations
  118437. */
  118438. export interface IAnimatable {
  118439. /**
  118440. * Array of animations
  118441. */
  118442. animations: Nullable<Array<Animation>>;
  118443. }
  118444. }
  118445. declare module BABYLON {
  118446. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  118447. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118448. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118449. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118450. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118451. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118452. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118453. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118454. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118455. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118456. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118457. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118458. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118459. /**
  118460. * Decorator used to define property that can be serialized as reference to a camera
  118461. * @param sourceName defines the name of the property to decorate
  118462. */
  118463. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118464. /**
  118465. * Class used to help serialization objects
  118466. */
  118467. export class SerializationHelper {
  118468. /** @hidden */
  118469. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  118470. /** @hidden */
  118471. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  118472. /** @hidden */
  118473. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  118474. /** @hidden */
  118475. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  118476. /**
  118477. * Appends the serialized animations from the source animations
  118478. * @param source Source containing the animations
  118479. * @param destination Target to store the animations
  118480. */
  118481. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118482. /**
  118483. * Static function used to serialized a specific entity
  118484. * @param entity defines the entity to serialize
  118485. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  118486. * @returns a JSON compatible object representing the serialization of the entity
  118487. */
  118488. static Serialize<T>(entity: T, serializationObject?: any): any;
  118489. /**
  118490. * Creates a new entity from a serialization data object
  118491. * @param creationFunction defines a function used to instanciated the new entity
  118492. * @param source defines the source serialization data
  118493. * @param scene defines the hosting scene
  118494. * @param rootUrl defines the root url for resources
  118495. * @returns a new entity
  118496. */
  118497. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  118498. /**
  118499. * Clones an object
  118500. * @param creationFunction defines the function used to instanciate the new object
  118501. * @param source defines the source object
  118502. * @returns the cloned object
  118503. */
  118504. static Clone<T>(creationFunction: () => T, source: T): T;
  118505. /**
  118506. * Instanciates a new object based on a source one (some data will be shared between both object)
  118507. * @param creationFunction defines the function used to instanciate the new object
  118508. * @param source defines the source object
  118509. * @returns the new object
  118510. */
  118511. static Instanciate<T>(creationFunction: () => T, source: T): T;
  118512. }
  118513. }
  118514. declare module BABYLON {
  118515. /**
  118516. * Base class of all the textures in babylon.
  118517. * It groups all the common properties the materials, post process, lights... might need
  118518. * in order to make a correct use of the texture.
  118519. */
  118520. export class BaseTexture implements IAnimatable {
  118521. /**
  118522. * Default anisotropic filtering level for the application.
  118523. * It is set to 4 as a good tradeoff between perf and quality.
  118524. */
  118525. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  118526. /**
  118527. * Gets or sets the unique id of the texture
  118528. */
  118529. uniqueId: number;
  118530. /**
  118531. * Define the name of the texture.
  118532. */
  118533. name: string;
  118534. /**
  118535. * Gets or sets an object used to store user defined information.
  118536. */
  118537. metadata: any;
  118538. /**
  118539. * For internal use only. Please do not use.
  118540. */
  118541. reservedDataStore: any;
  118542. private _hasAlpha;
  118543. /**
  118544. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  118545. */
  118546. set hasAlpha(value: boolean);
  118547. get hasAlpha(): boolean;
  118548. /**
  118549. * Defines if the alpha value should be determined via the rgb values.
  118550. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  118551. */
  118552. getAlphaFromRGB: boolean;
  118553. /**
  118554. * Intensity or strength of the texture.
  118555. * It is commonly used by materials to fine tune the intensity of the texture
  118556. */
  118557. level: number;
  118558. /**
  118559. * Define the UV chanel to use starting from 0 and defaulting to 0.
  118560. * This is part of the texture as textures usually maps to one uv set.
  118561. */
  118562. coordinatesIndex: number;
  118563. protected _coordinatesMode: number;
  118564. /**
  118565. * How a texture is mapped.
  118566. *
  118567. * | Value | Type | Description |
  118568. * | ----- | ----------------------------------- | ----------- |
  118569. * | 0 | EXPLICIT_MODE | |
  118570. * | 1 | SPHERICAL_MODE | |
  118571. * | 2 | PLANAR_MODE | |
  118572. * | 3 | CUBIC_MODE | |
  118573. * | 4 | PROJECTION_MODE | |
  118574. * | 5 | SKYBOX_MODE | |
  118575. * | 6 | INVCUBIC_MODE | |
  118576. * | 7 | EQUIRECTANGULAR_MODE | |
  118577. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  118578. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  118579. */
  118580. set coordinatesMode(value: number);
  118581. get coordinatesMode(): number;
  118582. private _wrapU;
  118583. /**
  118584. * | Value | Type | Description |
  118585. * | ----- | ------------------ | ----------- |
  118586. * | 0 | CLAMP_ADDRESSMODE | |
  118587. * | 1 | WRAP_ADDRESSMODE | |
  118588. * | 2 | MIRROR_ADDRESSMODE | |
  118589. */
  118590. get wrapU(): number;
  118591. set wrapU(value: number);
  118592. private _wrapV;
  118593. /**
  118594. * | Value | Type | Description |
  118595. * | ----- | ------------------ | ----------- |
  118596. * | 0 | CLAMP_ADDRESSMODE | |
  118597. * | 1 | WRAP_ADDRESSMODE | |
  118598. * | 2 | MIRROR_ADDRESSMODE | |
  118599. */
  118600. get wrapV(): number;
  118601. set wrapV(value: number);
  118602. /**
  118603. * | Value | Type | Description |
  118604. * | ----- | ------------------ | ----------- |
  118605. * | 0 | CLAMP_ADDRESSMODE | |
  118606. * | 1 | WRAP_ADDRESSMODE | |
  118607. * | 2 | MIRROR_ADDRESSMODE | |
  118608. */
  118609. wrapR: number;
  118610. /**
  118611. * With compliant hardware and browser (supporting anisotropic filtering)
  118612. * this defines the level of anisotropic filtering in the texture.
  118613. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  118614. */
  118615. anisotropicFilteringLevel: number;
  118616. /**
  118617. * Define if the texture is a cube texture or if false a 2d texture.
  118618. */
  118619. get isCube(): boolean;
  118620. set isCube(value: boolean);
  118621. /**
  118622. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  118623. */
  118624. get is3D(): boolean;
  118625. set is3D(value: boolean);
  118626. /**
  118627. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  118628. */
  118629. get is2DArray(): boolean;
  118630. set is2DArray(value: boolean);
  118631. private _gammaSpace;
  118632. /**
  118633. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  118634. * HDR texture are usually stored in linear space.
  118635. * This only impacts the PBR and Background materials
  118636. */
  118637. get gammaSpace(): boolean;
  118638. set gammaSpace(gamma: boolean);
  118639. /**
  118640. * Gets or sets whether or not the texture contains RGBD data.
  118641. */
  118642. get isRGBD(): boolean;
  118643. set isRGBD(value: boolean);
  118644. /**
  118645. * Is Z inverted in the texture (useful in a cube texture).
  118646. */
  118647. invertZ: boolean;
  118648. /**
  118649. * Are mip maps generated for this texture or not.
  118650. */
  118651. get noMipmap(): boolean;
  118652. /**
  118653. * @hidden
  118654. */
  118655. lodLevelInAlpha: boolean;
  118656. /**
  118657. * With prefiltered texture, defined the offset used during the prefiltering steps.
  118658. */
  118659. get lodGenerationOffset(): number;
  118660. set lodGenerationOffset(value: number);
  118661. /**
  118662. * With prefiltered texture, defined the scale used during the prefiltering steps.
  118663. */
  118664. get lodGenerationScale(): number;
  118665. set lodGenerationScale(value: number);
  118666. /**
  118667. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  118668. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  118669. * average roughness values.
  118670. */
  118671. get linearSpecularLOD(): boolean;
  118672. set linearSpecularLOD(value: boolean);
  118673. /**
  118674. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  118675. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  118676. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  118677. */
  118678. get irradianceTexture(): Nullable<BaseTexture>;
  118679. set irradianceTexture(value: Nullable<BaseTexture>);
  118680. /**
  118681. * Define if the texture is a render target.
  118682. */
  118683. isRenderTarget: boolean;
  118684. /**
  118685. * Define the unique id of the texture in the scene.
  118686. */
  118687. get uid(): string;
  118688. /** @hidden */
  118689. _prefiltered: boolean;
  118690. /**
  118691. * Return a string representation of the texture.
  118692. * @returns the texture as a string
  118693. */
  118694. toString(): string;
  118695. /**
  118696. * Get the class name of the texture.
  118697. * @returns "BaseTexture"
  118698. */
  118699. getClassName(): string;
  118700. /**
  118701. * Define the list of animation attached to the texture.
  118702. */
  118703. animations: Animation[];
  118704. /**
  118705. * An event triggered when the texture is disposed.
  118706. */
  118707. onDisposeObservable: Observable<BaseTexture>;
  118708. private _onDisposeObserver;
  118709. /**
  118710. * Callback triggered when the texture has been disposed.
  118711. * Kept for back compatibility, you can use the onDisposeObservable instead.
  118712. */
  118713. set onDispose(callback: () => void);
  118714. /**
  118715. * Define the current state of the loading sequence when in delayed load mode.
  118716. */
  118717. delayLoadState: number;
  118718. protected _scene: Nullable<Scene>;
  118719. protected _engine: Nullable<ThinEngine>;
  118720. /** @hidden */
  118721. _texture: Nullable<InternalTexture>;
  118722. private _uid;
  118723. /**
  118724. * Define if the texture is preventinga material to render or not.
  118725. * If not and the texture is not ready, the engine will use a default black texture instead.
  118726. */
  118727. get isBlocking(): boolean;
  118728. /**
  118729. * Instantiates a new BaseTexture.
  118730. * Base class of all the textures in babylon.
  118731. * It groups all the common properties the materials, post process, lights... might need
  118732. * in order to make a correct use of the texture.
  118733. * @param sceneOrEngine Define the scene or engine the texture blongs to
  118734. */
  118735. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  118736. /**
  118737. * Get the scene the texture belongs to.
  118738. * @returns the scene or null if undefined
  118739. */
  118740. getScene(): Nullable<Scene>;
  118741. /** @hidden */
  118742. protected _getEngine(): Nullable<ThinEngine>;
  118743. /**
  118744. * Checks if the texture has the same transform matrix than another texture
  118745. * @param texture texture to check against
  118746. * @returns true if the transforms are the same, else false
  118747. */
  118748. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  118749. /**
  118750. * Get the texture transform matrix used to offset tile the texture for istance.
  118751. * @returns the transformation matrix
  118752. */
  118753. getTextureMatrix(): Matrix;
  118754. /**
  118755. * Get the texture reflection matrix used to rotate/transform the reflection.
  118756. * @returns the reflection matrix
  118757. */
  118758. getReflectionTextureMatrix(): Matrix;
  118759. /**
  118760. * Get the underlying lower level texture from Babylon.
  118761. * @returns the insternal texture
  118762. */
  118763. getInternalTexture(): Nullable<InternalTexture>;
  118764. /**
  118765. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  118766. * @returns true if ready or not blocking
  118767. */
  118768. isReadyOrNotBlocking(): boolean;
  118769. /**
  118770. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  118771. * @returns true if fully ready
  118772. */
  118773. isReady(): boolean;
  118774. private _cachedSize;
  118775. /**
  118776. * Get the size of the texture.
  118777. * @returns the texture size.
  118778. */
  118779. getSize(): ISize;
  118780. /**
  118781. * Get the base size of the texture.
  118782. * It can be different from the size if the texture has been resized for POT for instance
  118783. * @returns the base size
  118784. */
  118785. getBaseSize(): ISize;
  118786. /**
  118787. * Update the sampling mode of the texture.
  118788. * Default is Trilinear mode.
  118789. *
  118790. * | Value | Type | Description |
  118791. * | ----- | ------------------ | ----------- |
  118792. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  118793. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  118794. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  118795. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  118796. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  118797. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  118798. * | 7 | NEAREST_LINEAR | |
  118799. * | 8 | NEAREST_NEAREST | |
  118800. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  118801. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  118802. * | 11 | LINEAR_LINEAR | |
  118803. * | 12 | LINEAR_NEAREST | |
  118804. *
  118805. * > _mag_: magnification filter (close to the viewer)
  118806. * > _min_: minification filter (far from the viewer)
  118807. * > _mip_: filter used between mip map levels
  118808. *@param samplingMode Define the new sampling mode of the texture
  118809. */
  118810. updateSamplingMode(samplingMode: number): void;
  118811. /**
  118812. * Scales the texture if is `canRescale()`
  118813. * @param ratio the resize factor we want to use to rescale
  118814. */
  118815. scale(ratio: number): void;
  118816. /**
  118817. * Get if the texture can rescale.
  118818. */
  118819. get canRescale(): boolean;
  118820. /** @hidden */
  118821. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  118822. /** @hidden */
  118823. _rebuild(): void;
  118824. /**
  118825. * Triggers the load sequence in delayed load mode.
  118826. */
  118827. delayLoad(): void;
  118828. /**
  118829. * Clones the texture.
  118830. * @returns the cloned texture
  118831. */
  118832. clone(): Nullable<BaseTexture>;
  118833. /**
  118834. * Get the texture underlying type (INT, FLOAT...)
  118835. */
  118836. get textureType(): number;
  118837. /**
  118838. * Get the texture underlying format (RGB, RGBA...)
  118839. */
  118840. get textureFormat(): number;
  118841. /**
  118842. * Indicates that textures need to be re-calculated for all materials
  118843. */
  118844. protected _markAllSubMeshesAsTexturesDirty(): void;
  118845. /**
  118846. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  118847. * This will returns an RGBA array buffer containing either in values (0-255) or
  118848. * float values (0-1) depending of the underlying buffer type.
  118849. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  118850. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  118851. * @param buffer defines a user defined buffer to fill with data (can be null)
  118852. * @returns The Array buffer containing the pixels data.
  118853. */
  118854. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  118855. /**
  118856. * Release and destroy the underlying lower level texture aka internalTexture.
  118857. */
  118858. releaseInternalTexture(): void;
  118859. /** @hidden */
  118860. get _lodTextureHigh(): Nullable<BaseTexture>;
  118861. /** @hidden */
  118862. get _lodTextureMid(): Nullable<BaseTexture>;
  118863. /** @hidden */
  118864. get _lodTextureLow(): Nullable<BaseTexture>;
  118865. /**
  118866. * Dispose the texture and release its associated resources.
  118867. */
  118868. dispose(): void;
  118869. /**
  118870. * Serialize the texture into a JSON representation that can be parsed later on.
  118871. * @returns the JSON representation of the texture
  118872. */
  118873. serialize(): any;
  118874. /**
  118875. * Helper function to be called back once a list of texture contains only ready textures.
  118876. * @param textures Define the list of textures to wait for
  118877. * @param callback Define the callback triggered once the entire list will be ready
  118878. */
  118879. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  118880. private static _isScene;
  118881. }
  118882. }
  118883. declare module BABYLON {
  118884. /**
  118885. * Options to be used when creating an effect.
  118886. */
  118887. export interface IEffectCreationOptions {
  118888. /**
  118889. * Atrributes that will be used in the shader.
  118890. */
  118891. attributes: string[];
  118892. /**
  118893. * Uniform varible names that will be set in the shader.
  118894. */
  118895. uniformsNames: string[];
  118896. /**
  118897. * Uniform buffer variable names that will be set in the shader.
  118898. */
  118899. uniformBuffersNames: string[];
  118900. /**
  118901. * Sampler texture variable names that will be set in the shader.
  118902. */
  118903. samplers: string[];
  118904. /**
  118905. * Define statements that will be set in the shader.
  118906. */
  118907. defines: any;
  118908. /**
  118909. * Possible fallbacks for this effect to improve performance when needed.
  118910. */
  118911. fallbacks: Nullable<IEffectFallbacks>;
  118912. /**
  118913. * Callback that will be called when the shader is compiled.
  118914. */
  118915. onCompiled: Nullable<(effect: Effect) => void>;
  118916. /**
  118917. * Callback that will be called if an error occurs during shader compilation.
  118918. */
  118919. onError: Nullable<(effect: Effect, errors: string) => void>;
  118920. /**
  118921. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118922. */
  118923. indexParameters?: any;
  118924. /**
  118925. * Max number of lights that can be used in the shader.
  118926. */
  118927. maxSimultaneousLights?: number;
  118928. /**
  118929. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  118930. */
  118931. transformFeedbackVaryings?: Nullable<string[]>;
  118932. /**
  118933. * 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
  118934. */
  118935. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  118936. /**
  118937. * Is this effect rendering to several color attachments ?
  118938. */
  118939. multiTarget?: boolean;
  118940. }
  118941. /**
  118942. * Effect containing vertex and fragment shader that can be executed on an object.
  118943. */
  118944. export class Effect implements IDisposable {
  118945. /**
  118946. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  118947. */
  118948. static ShadersRepository: string;
  118949. /**
  118950. * Enable logging of the shader code when a compilation error occurs
  118951. */
  118952. static LogShaderCodeOnCompilationError: boolean;
  118953. /**
  118954. * Name of the effect.
  118955. */
  118956. name: any;
  118957. /**
  118958. * String container all the define statements that should be set on the shader.
  118959. */
  118960. defines: string;
  118961. /**
  118962. * Callback that will be called when the shader is compiled.
  118963. */
  118964. onCompiled: Nullable<(effect: Effect) => void>;
  118965. /**
  118966. * Callback that will be called if an error occurs during shader compilation.
  118967. */
  118968. onError: Nullable<(effect: Effect, errors: string) => void>;
  118969. /**
  118970. * Callback that will be called when effect is bound.
  118971. */
  118972. onBind: Nullable<(effect: Effect) => void>;
  118973. /**
  118974. * Unique ID of the effect.
  118975. */
  118976. uniqueId: number;
  118977. /**
  118978. * Observable that will be called when the shader is compiled.
  118979. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  118980. */
  118981. onCompileObservable: Observable<Effect>;
  118982. /**
  118983. * Observable that will be called if an error occurs during shader compilation.
  118984. */
  118985. onErrorObservable: Observable<Effect>;
  118986. /** @hidden */
  118987. _onBindObservable: Nullable<Observable<Effect>>;
  118988. /**
  118989. * @hidden
  118990. * Specifies if the effect was previously ready
  118991. */
  118992. _wasPreviouslyReady: boolean;
  118993. /**
  118994. * Observable that will be called when effect is bound.
  118995. */
  118996. get onBindObservable(): Observable<Effect>;
  118997. /** @hidden */
  118998. _bonesComputationForcedToCPU: boolean;
  118999. /** @hidden */
  119000. _multiTarget: boolean;
  119001. private static _uniqueIdSeed;
  119002. private _engine;
  119003. private _uniformBuffersNames;
  119004. private _uniformBuffersNamesList;
  119005. private _uniformsNames;
  119006. private _samplerList;
  119007. private _samplers;
  119008. private _isReady;
  119009. private _compilationError;
  119010. private _allFallbacksProcessed;
  119011. private _attributesNames;
  119012. private _attributes;
  119013. private _attributeLocationByName;
  119014. private _uniforms;
  119015. /**
  119016. * Key for the effect.
  119017. * @hidden
  119018. */
  119019. _key: string;
  119020. private _indexParameters;
  119021. private _fallbacks;
  119022. private _vertexSourceCode;
  119023. private _fragmentSourceCode;
  119024. private _vertexSourceCodeOverride;
  119025. private _fragmentSourceCodeOverride;
  119026. private _transformFeedbackVaryings;
  119027. private _rawVertexSourceCode;
  119028. private _rawFragmentSourceCode;
  119029. /**
  119030. * Compiled shader to webGL program.
  119031. * @hidden
  119032. */
  119033. _pipelineContext: Nullable<IPipelineContext>;
  119034. private _valueCache;
  119035. private static _baseCache;
  119036. /**
  119037. * Instantiates an effect.
  119038. * An effect can be used to create/manage/execute vertex and fragment shaders.
  119039. * @param baseName Name of the effect.
  119040. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  119041. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  119042. * @param samplers List of sampler variables that will be passed to the shader.
  119043. * @param engine Engine to be used to render the effect
  119044. * @param defines Define statements to be added to the shader.
  119045. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  119046. * @param onCompiled Callback that will be called when the shader is compiled.
  119047. * @param onError Callback that will be called if an error occurs during shader compilation.
  119048. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119049. */
  119050. 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);
  119051. private _useFinalCode;
  119052. /**
  119053. * Unique key for this effect
  119054. */
  119055. get key(): string;
  119056. /**
  119057. * If the effect has been compiled and prepared.
  119058. * @returns if the effect is compiled and prepared.
  119059. */
  119060. isReady(): boolean;
  119061. private _isReadyInternal;
  119062. /**
  119063. * The engine the effect was initialized with.
  119064. * @returns the engine.
  119065. */
  119066. getEngine(): Engine;
  119067. /**
  119068. * The pipeline context for this effect
  119069. * @returns the associated pipeline context
  119070. */
  119071. getPipelineContext(): Nullable<IPipelineContext>;
  119072. /**
  119073. * The set of names of attribute variables for the shader.
  119074. * @returns An array of attribute names.
  119075. */
  119076. getAttributesNames(): string[];
  119077. /**
  119078. * Returns the attribute at the given index.
  119079. * @param index The index of the attribute.
  119080. * @returns The location of the attribute.
  119081. */
  119082. getAttributeLocation(index: number): number;
  119083. /**
  119084. * Returns the attribute based on the name of the variable.
  119085. * @param name of the attribute to look up.
  119086. * @returns the attribute location.
  119087. */
  119088. getAttributeLocationByName(name: string): number;
  119089. /**
  119090. * The number of attributes.
  119091. * @returns the numnber of attributes.
  119092. */
  119093. getAttributesCount(): number;
  119094. /**
  119095. * Gets the index of a uniform variable.
  119096. * @param uniformName of the uniform to look up.
  119097. * @returns the index.
  119098. */
  119099. getUniformIndex(uniformName: string): number;
  119100. /**
  119101. * Returns the attribute based on the name of the variable.
  119102. * @param uniformName of the uniform to look up.
  119103. * @returns the location of the uniform.
  119104. */
  119105. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  119106. /**
  119107. * Returns an array of sampler variable names
  119108. * @returns The array of sampler variable names.
  119109. */
  119110. getSamplers(): string[];
  119111. /**
  119112. * Returns an array of uniform variable names
  119113. * @returns The array of uniform variable names.
  119114. */
  119115. getUniformNames(): string[];
  119116. /**
  119117. * Returns an array of uniform buffer variable names
  119118. * @returns The array of uniform buffer variable names.
  119119. */
  119120. getUniformBuffersNames(): string[];
  119121. /**
  119122. * Returns the index parameters used to create the effect
  119123. * @returns The index parameters object
  119124. */
  119125. getIndexParameters(): any;
  119126. /**
  119127. * The error from the last compilation.
  119128. * @returns the error string.
  119129. */
  119130. getCompilationError(): string;
  119131. /**
  119132. * Gets a boolean indicating that all fallbacks were used during compilation
  119133. * @returns true if all fallbacks were used
  119134. */
  119135. allFallbacksProcessed(): boolean;
  119136. /**
  119137. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  119138. * @param func The callback to be used.
  119139. */
  119140. executeWhenCompiled(func: (effect: Effect) => void): void;
  119141. private _checkIsReady;
  119142. private _loadShader;
  119143. /**
  119144. * Gets the vertex shader source code of this effect
  119145. */
  119146. get vertexSourceCode(): string;
  119147. /**
  119148. * Gets the fragment shader source code of this effect
  119149. */
  119150. get fragmentSourceCode(): string;
  119151. /**
  119152. * Gets the vertex shader source code before it has been processed by the preprocessor
  119153. */
  119154. get rawVertexSourceCode(): string;
  119155. /**
  119156. * Gets the fragment shader source code before it has been processed by the preprocessor
  119157. */
  119158. get rawFragmentSourceCode(): string;
  119159. /**
  119160. * Recompiles the webGL program
  119161. * @param vertexSourceCode The source code for the vertex shader.
  119162. * @param fragmentSourceCode The source code for the fragment shader.
  119163. * @param onCompiled Callback called when completed.
  119164. * @param onError Callback called on error.
  119165. * @hidden
  119166. */
  119167. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  119168. /**
  119169. * Prepares the effect
  119170. * @hidden
  119171. */
  119172. _prepareEffect(): void;
  119173. private _getShaderCodeAndErrorLine;
  119174. private _processCompilationErrors;
  119175. /**
  119176. * Checks if the effect is supported. (Must be called after compilation)
  119177. */
  119178. get isSupported(): boolean;
  119179. /**
  119180. * Binds a texture to the engine to be used as output of the shader.
  119181. * @param channel Name of the output variable.
  119182. * @param texture Texture to bind.
  119183. * @hidden
  119184. */
  119185. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  119186. /**
  119187. * Sets a texture on the engine to be used in the shader.
  119188. * @param channel Name of the sampler variable.
  119189. * @param texture Texture to set.
  119190. */
  119191. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  119192. /**
  119193. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  119194. * @param channel Name of the sampler variable.
  119195. * @param texture Texture to set.
  119196. */
  119197. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  119198. /**
  119199. * Sets an array of textures on the engine to be used in the shader.
  119200. * @param channel Name of the variable.
  119201. * @param textures Textures to set.
  119202. */
  119203. setTextureArray(channel: string, textures: BaseTexture[]): void;
  119204. /**
  119205. * 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)
  119206. * @param channel Name of the sampler variable.
  119207. * @param postProcess Post process to get the input texture from.
  119208. */
  119209. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  119210. /**
  119211. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  119212. * 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)
  119213. * @param channel Name of the sampler variable.
  119214. * @param postProcess Post process to get the output texture from.
  119215. */
  119216. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  119217. /** @hidden */
  119218. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  119219. /** @hidden */
  119220. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  119221. /** @hidden */
  119222. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  119223. /** @hidden */
  119224. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  119225. /**
  119226. * Binds a buffer to a uniform.
  119227. * @param buffer Buffer to bind.
  119228. * @param name Name of the uniform variable to bind to.
  119229. */
  119230. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  119231. /**
  119232. * Binds block to a uniform.
  119233. * @param blockName Name of the block to bind.
  119234. * @param index Index to bind.
  119235. */
  119236. bindUniformBlock(blockName: string, index: number): void;
  119237. /**
  119238. * Sets an interger value on a uniform variable.
  119239. * @param uniformName Name of the variable.
  119240. * @param value Value to be set.
  119241. * @returns this effect.
  119242. */
  119243. setInt(uniformName: string, value: number): Effect;
  119244. /**
  119245. * Sets an int array on a uniform variable.
  119246. * @param uniformName Name of the variable.
  119247. * @param array array to be set.
  119248. * @returns this effect.
  119249. */
  119250. setIntArray(uniformName: string, array: Int32Array): Effect;
  119251. /**
  119252. * 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)
  119253. * @param uniformName Name of the variable.
  119254. * @param array array to be set.
  119255. * @returns this effect.
  119256. */
  119257. setIntArray2(uniformName: string, array: Int32Array): Effect;
  119258. /**
  119259. * 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)
  119260. * @param uniformName Name of the variable.
  119261. * @param array array to be set.
  119262. * @returns this effect.
  119263. */
  119264. setIntArray3(uniformName: string, array: Int32Array): Effect;
  119265. /**
  119266. * 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)
  119267. * @param uniformName Name of the variable.
  119268. * @param array array to be set.
  119269. * @returns this effect.
  119270. */
  119271. setIntArray4(uniformName: string, array: Int32Array): Effect;
  119272. /**
  119273. * Sets an float array on a uniform variable.
  119274. * @param uniformName Name of the variable.
  119275. * @param array array to be set.
  119276. * @returns this effect.
  119277. */
  119278. setFloatArray(uniformName: string, array: Float32Array): Effect;
  119279. /**
  119280. * 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)
  119281. * @param uniformName Name of the variable.
  119282. * @param array array to be set.
  119283. * @returns this effect.
  119284. */
  119285. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  119286. /**
  119287. * 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)
  119288. * @param uniformName Name of the variable.
  119289. * @param array array to be set.
  119290. * @returns this effect.
  119291. */
  119292. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  119293. /**
  119294. * 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)
  119295. * @param uniformName Name of the variable.
  119296. * @param array array to be set.
  119297. * @returns this effect.
  119298. */
  119299. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  119300. /**
  119301. * Sets an array on a uniform variable.
  119302. * @param uniformName Name of the variable.
  119303. * @param array array to be set.
  119304. * @returns this effect.
  119305. */
  119306. setArray(uniformName: string, array: number[]): Effect;
  119307. /**
  119308. * 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)
  119309. * @param uniformName Name of the variable.
  119310. * @param array array to be set.
  119311. * @returns this effect.
  119312. */
  119313. setArray2(uniformName: string, array: number[]): Effect;
  119314. /**
  119315. * 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)
  119316. * @param uniformName Name of the variable.
  119317. * @param array array to be set.
  119318. * @returns this effect.
  119319. */
  119320. setArray3(uniformName: string, array: number[]): Effect;
  119321. /**
  119322. * 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)
  119323. * @param uniformName Name of the variable.
  119324. * @param array array to be set.
  119325. * @returns this effect.
  119326. */
  119327. setArray4(uniformName: string, array: number[]): Effect;
  119328. /**
  119329. * Sets matrices on a uniform variable.
  119330. * @param uniformName Name of the variable.
  119331. * @param matrices matrices to be set.
  119332. * @returns this effect.
  119333. */
  119334. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  119335. /**
  119336. * Sets matrix on a uniform variable.
  119337. * @param uniformName Name of the variable.
  119338. * @param matrix matrix to be set.
  119339. * @returns this effect.
  119340. */
  119341. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  119342. /**
  119343. * 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)
  119344. * @param uniformName Name of the variable.
  119345. * @param matrix matrix to be set.
  119346. * @returns this effect.
  119347. */
  119348. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119349. /**
  119350. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  119351. * @param uniformName Name of the variable.
  119352. * @param matrix matrix to be set.
  119353. * @returns this effect.
  119354. */
  119355. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119356. /**
  119357. * Sets a float on a uniform variable.
  119358. * @param uniformName Name of the variable.
  119359. * @param value value to be set.
  119360. * @returns this effect.
  119361. */
  119362. setFloat(uniformName: string, value: number): Effect;
  119363. /**
  119364. * Sets a boolean on a uniform variable.
  119365. * @param uniformName Name of the variable.
  119366. * @param bool value to be set.
  119367. * @returns this effect.
  119368. */
  119369. setBool(uniformName: string, bool: boolean): Effect;
  119370. /**
  119371. * Sets a Vector2 on a uniform variable.
  119372. * @param uniformName Name of the variable.
  119373. * @param vector2 vector2 to be set.
  119374. * @returns this effect.
  119375. */
  119376. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  119377. /**
  119378. * Sets a float2 on a uniform variable.
  119379. * @param uniformName Name of the variable.
  119380. * @param x First float in float2.
  119381. * @param y Second float in float2.
  119382. * @returns this effect.
  119383. */
  119384. setFloat2(uniformName: string, x: number, y: number): Effect;
  119385. /**
  119386. * Sets a Vector3 on a uniform variable.
  119387. * @param uniformName Name of the variable.
  119388. * @param vector3 Value to be set.
  119389. * @returns this effect.
  119390. */
  119391. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  119392. /**
  119393. * Sets a float3 on a uniform variable.
  119394. * @param uniformName Name of the variable.
  119395. * @param x First float in float3.
  119396. * @param y Second float in float3.
  119397. * @param z Third float in float3.
  119398. * @returns this effect.
  119399. */
  119400. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  119401. /**
  119402. * Sets a Vector4 on a uniform variable.
  119403. * @param uniformName Name of the variable.
  119404. * @param vector4 Value to be set.
  119405. * @returns this effect.
  119406. */
  119407. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  119408. /**
  119409. * Sets a float4 on a uniform variable.
  119410. * @param uniformName Name of the variable.
  119411. * @param x First float in float4.
  119412. * @param y Second float in float4.
  119413. * @param z Third float in float4.
  119414. * @param w Fourth float in float4.
  119415. * @returns this effect.
  119416. */
  119417. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  119418. /**
  119419. * Sets a Color3 on a uniform variable.
  119420. * @param uniformName Name of the variable.
  119421. * @param color3 Value to be set.
  119422. * @returns this effect.
  119423. */
  119424. setColor3(uniformName: string, color3: IColor3Like): Effect;
  119425. /**
  119426. * Sets a Color4 on a uniform variable.
  119427. * @param uniformName Name of the variable.
  119428. * @param color3 Value to be set.
  119429. * @param alpha Alpha value to be set.
  119430. * @returns this effect.
  119431. */
  119432. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  119433. /**
  119434. * Sets a Color4 on a uniform variable
  119435. * @param uniformName defines the name of the variable
  119436. * @param color4 defines the value to be set
  119437. * @returns this effect.
  119438. */
  119439. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  119440. /** Release all associated resources */
  119441. dispose(): void;
  119442. /**
  119443. * This function will add a new shader to the shader store
  119444. * @param name the name of the shader
  119445. * @param pixelShader optional pixel shader content
  119446. * @param vertexShader optional vertex shader content
  119447. */
  119448. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  119449. /**
  119450. * Store of each shader (The can be looked up using effect.key)
  119451. */
  119452. static ShadersStore: {
  119453. [key: string]: string;
  119454. };
  119455. /**
  119456. * Store of each included file for a shader (The can be looked up using effect.key)
  119457. */
  119458. static IncludesShadersStore: {
  119459. [key: string]: string;
  119460. };
  119461. /**
  119462. * Resets the cache of effects.
  119463. */
  119464. static ResetCache(): void;
  119465. }
  119466. }
  119467. declare module BABYLON {
  119468. /**
  119469. * Interface used to describe the capabilities of the engine relatively to the current browser
  119470. */
  119471. export interface EngineCapabilities {
  119472. /** Maximum textures units per fragment shader */
  119473. maxTexturesImageUnits: number;
  119474. /** Maximum texture units per vertex shader */
  119475. maxVertexTextureImageUnits: number;
  119476. /** Maximum textures units in the entire pipeline */
  119477. maxCombinedTexturesImageUnits: number;
  119478. /** Maximum texture size */
  119479. maxTextureSize: number;
  119480. /** Maximum texture samples */
  119481. maxSamples?: number;
  119482. /** Maximum cube texture size */
  119483. maxCubemapTextureSize: number;
  119484. /** Maximum render texture size */
  119485. maxRenderTextureSize: number;
  119486. /** Maximum number of vertex attributes */
  119487. maxVertexAttribs: number;
  119488. /** Maximum number of varyings */
  119489. maxVaryingVectors: number;
  119490. /** Maximum number of uniforms per vertex shader */
  119491. maxVertexUniformVectors: number;
  119492. /** Maximum number of uniforms per fragment shader */
  119493. maxFragmentUniformVectors: number;
  119494. /** Defines if standard derivates (dx/dy) are supported */
  119495. standardDerivatives: boolean;
  119496. /** Defines if s3tc texture compression is supported */
  119497. s3tc?: WEBGL_compressed_texture_s3tc;
  119498. /** Defines if pvrtc texture compression is supported */
  119499. pvrtc: any;
  119500. /** Defines if etc1 texture compression is supported */
  119501. etc1: any;
  119502. /** Defines if etc2 texture compression is supported */
  119503. etc2: any;
  119504. /** Defines if astc texture compression is supported */
  119505. astc: any;
  119506. /** Defines if bptc texture compression is supported */
  119507. bptc: any;
  119508. /** Defines if float textures are supported */
  119509. textureFloat: boolean;
  119510. /** Defines if vertex array objects are supported */
  119511. vertexArrayObject: boolean;
  119512. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  119513. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  119514. /** Gets the maximum level of anisotropy supported */
  119515. maxAnisotropy: number;
  119516. /** Defines if instancing is supported */
  119517. instancedArrays: boolean;
  119518. /** Defines if 32 bits indices are supported */
  119519. uintIndices: boolean;
  119520. /** Defines if high precision shaders are supported */
  119521. highPrecisionShaderSupported: boolean;
  119522. /** Defines if depth reading in the fragment shader is supported */
  119523. fragmentDepthSupported: boolean;
  119524. /** Defines if float texture linear filtering is supported*/
  119525. textureFloatLinearFiltering: boolean;
  119526. /** Defines if rendering to float textures is supported */
  119527. textureFloatRender: boolean;
  119528. /** Defines if half float textures are supported*/
  119529. textureHalfFloat: boolean;
  119530. /** Defines if half float texture linear filtering is supported*/
  119531. textureHalfFloatLinearFiltering: boolean;
  119532. /** Defines if rendering to half float textures is supported */
  119533. textureHalfFloatRender: boolean;
  119534. /** Defines if textureLOD shader command is supported */
  119535. textureLOD: boolean;
  119536. /** Defines if draw buffers extension is supported */
  119537. drawBuffersExtension: boolean;
  119538. /** Defines if depth textures are supported */
  119539. depthTextureExtension: boolean;
  119540. /** Defines if float color buffer are supported */
  119541. colorBufferFloat: boolean;
  119542. /** Gets disjoint timer query extension (null if not supported) */
  119543. timerQuery?: EXT_disjoint_timer_query;
  119544. /** Defines if timestamp can be used with timer query */
  119545. canUseTimestampForTimerQuery: boolean;
  119546. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  119547. multiview?: any;
  119548. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  119549. oculusMultiview?: any;
  119550. /** Function used to let the system compiles shaders in background */
  119551. parallelShaderCompile?: {
  119552. COMPLETION_STATUS_KHR: number;
  119553. };
  119554. /** Max number of texture samples for MSAA */
  119555. maxMSAASamples: number;
  119556. /** Defines if the blend min max extension is supported */
  119557. blendMinMax: boolean;
  119558. }
  119559. }
  119560. declare module BABYLON {
  119561. /**
  119562. * @hidden
  119563. **/
  119564. export class DepthCullingState {
  119565. private _isDepthTestDirty;
  119566. private _isDepthMaskDirty;
  119567. private _isDepthFuncDirty;
  119568. private _isCullFaceDirty;
  119569. private _isCullDirty;
  119570. private _isZOffsetDirty;
  119571. private _isFrontFaceDirty;
  119572. private _depthTest;
  119573. private _depthMask;
  119574. private _depthFunc;
  119575. private _cull;
  119576. private _cullFace;
  119577. private _zOffset;
  119578. private _frontFace;
  119579. /**
  119580. * Initializes the state.
  119581. */
  119582. constructor();
  119583. get isDirty(): boolean;
  119584. get zOffset(): number;
  119585. set zOffset(value: number);
  119586. get cullFace(): Nullable<number>;
  119587. set cullFace(value: Nullable<number>);
  119588. get cull(): Nullable<boolean>;
  119589. set cull(value: Nullable<boolean>);
  119590. get depthFunc(): Nullable<number>;
  119591. set depthFunc(value: Nullable<number>);
  119592. get depthMask(): boolean;
  119593. set depthMask(value: boolean);
  119594. get depthTest(): boolean;
  119595. set depthTest(value: boolean);
  119596. get frontFace(): Nullable<number>;
  119597. set frontFace(value: Nullable<number>);
  119598. reset(): void;
  119599. apply(gl: WebGLRenderingContext): void;
  119600. }
  119601. }
  119602. declare module BABYLON {
  119603. /**
  119604. * @hidden
  119605. **/
  119606. export class StencilState {
  119607. /** 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 */
  119608. static readonly ALWAYS: number;
  119609. /** Passed to stencilOperation to specify that stencil value must be kept */
  119610. static readonly KEEP: number;
  119611. /** Passed to stencilOperation to specify that stencil value must be replaced */
  119612. static readonly REPLACE: number;
  119613. private _isStencilTestDirty;
  119614. private _isStencilMaskDirty;
  119615. private _isStencilFuncDirty;
  119616. private _isStencilOpDirty;
  119617. private _stencilTest;
  119618. private _stencilMask;
  119619. private _stencilFunc;
  119620. private _stencilFuncRef;
  119621. private _stencilFuncMask;
  119622. private _stencilOpStencilFail;
  119623. private _stencilOpDepthFail;
  119624. private _stencilOpStencilDepthPass;
  119625. get isDirty(): boolean;
  119626. get stencilFunc(): number;
  119627. set stencilFunc(value: number);
  119628. get stencilFuncRef(): number;
  119629. set stencilFuncRef(value: number);
  119630. get stencilFuncMask(): number;
  119631. set stencilFuncMask(value: number);
  119632. get stencilOpStencilFail(): number;
  119633. set stencilOpStencilFail(value: number);
  119634. get stencilOpDepthFail(): number;
  119635. set stencilOpDepthFail(value: number);
  119636. get stencilOpStencilDepthPass(): number;
  119637. set stencilOpStencilDepthPass(value: number);
  119638. get stencilMask(): number;
  119639. set stencilMask(value: number);
  119640. get stencilTest(): boolean;
  119641. set stencilTest(value: boolean);
  119642. constructor();
  119643. reset(): void;
  119644. apply(gl: WebGLRenderingContext): void;
  119645. }
  119646. }
  119647. declare module BABYLON {
  119648. /**
  119649. * @hidden
  119650. **/
  119651. export class AlphaState {
  119652. private _isAlphaBlendDirty;
  119653. private _isBlendFunctionParametersDirty;
  119654. private _isBlendEquationParametersDirty;
  119655. private _isBlendConstantsDirty;
  119656. private _alphaBlend;
  119657. private _blendFunctionParameters;
  119658. private _blendEquationParameters;
  119659. private _blendConstants;
  119660. /**
  119661. * Initializes the state.
  119662. */
  119663. constructor();
  119664. get isDirty(): boolean;
  119665. get alphaBlend(): boolean;
  119666. set alphaBlend(value: boolean);
  119667. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  119668. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  119669. setAlphaEquationParameters(rgb: number, alpha: number): void;
  119670. reset(): void;
  119671. apply(gl: WebGLRenderingContext): void;
  119672. }
  119673. }
  119674. declare module BABYLON {
  119675. /** @hidden */
  119676. export class WebGLShaderProcessor implements IShaderProcessor {
  119677. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  119678. }
  119679. }
  119680. declare module BABYLON {
  119681. /** @hidden */
  119682. export class WebGL2ShaderProcessor implements IShaderProcessor {
  119683. attributeProcessor(attribute: string): string;
  119684. varyingProcessor(varying: string, isFragment: boolean): string;
  119685. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  119686. }
  119687. }
  119688. declare module BABYLON {
  119689. /**
  119690. * Interface for attribute information associated with buffer instanciation
  119691. */
  119692. export interface InstancingAttributeInfo {
  119693. /**
  119694. * Name of the GLSL attribute
  119695. * if attribute index is not specified, this is used to retrieve the index from the effect
  119696. */
  119697. attributeName: string;
  119698. /**
  119699. * Index/offset of the attribute in the vertex shader
  119700. * if not specified, this will be computes from the name.
  119701. */
  119702. index?: number;
  119703. /**
  119704. * size of the attribute, 1, 2, 3 or 4
  119705. */
  119706. attributeSize: number;
  119707. /**
  119708. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  119709. */
  119710. offset: number;
  119711. /**
  119712. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  119713. * default to 1
  119714. */
  119715. divisor?: number;
  119716. /**
  119717. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  119718. * default is FLOAT
  119719. */
  119720. attributeType?: number;
  119721. /**
  119722. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  119723. */
  119724. normalized?: boolean;
  119725. }
  119726. }
  119727. declare module BABYLON {
  119728. interface ThinEngine {
  119729. /**
  119730. * Update a video texture
  119731. * @param texture defines the texture to update
  119732. * @param video defines the video element to use
  119733. * @param invertY defines if data must be stored with Y axis inverted
  119734. */
  119735. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  119736. }
  119737. }
  119738. declare module BABYLON {
  119739. interface ThinEngine {
  119740. /**
  119741. * Creates a dynamic texture
  119742. * @param width defines the width of the texture
  119743. * @param height defines the height of the texture
  119744. * @param generateMipMaps defines if the engine should generate the mip levels
  119745. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  119746. * @returns the dynamic texture inside an InternalTexture
  119747. */
  119748. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  119749. /**
  119750. * Update the content of a dynamic texture
  119751. * @param texture defines the texture to update
  119752. * @param canvas defines the canvas containing the source
  119753. * @param invertY defines if data must be stored with Y axis inverted
  119754. * @param premulAlpha defines if alpha is stored as premultiplied
  119755. * @param format defines the format of the data
  119756. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119757. */
  119758. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  119759. }
  119760. }
  119761. declare module BABYLON {
  119762. /**
  119763. * Settings for finer control over video usage
  119764. */
  119765. export interface VideoTextureSettings {
  119766. /**
  119767. * Applies `autoplay` to video, if specified
  119768. */
  119769. autoPlay?: boolean;
  119770. /**
  119771. * Applies `muted` to video, if specified
  119772. */
  119773. muted?: boolean;
  119774. /**
  119775. * Applies `loop` to video, if specified
  119776. */
  119777. loop?: boolean;
  119778. /**
  119779. * Automatically updates internal texture from video at every frame in the render loop
  119780. */
  119781. autoUpdateTexture: boolean;
  119782. /**
  119783. * Image src displayed during the video loading or until the user interacts with the video.
  119784. */
  119785. poster?: string;
  119786. }
  119787. /**
  119788. * If you want to display a video in your scene, this is the special texture for that.
  119789. * This special texture works similar to other textures, with the exception of a few parameters.
  119790. * @see https://doc.babylonjs.com/how_to/video_texture
  119791. */
  119792. export class VideoTexture extends Texture {
  119793. /**
  119794. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  119795. */
  119796. readonly autoUpdateTexture: boolean;
  119797. /**
  119798. * The video instance used by the texture internally
  119799. */
  119800. readonly video: HTMLVideoElement;
  119801. private _onUserActionRequestedObservable;
  119802. /**
  119803. * Event triggerd when a dom action is required by the user to play the video.
  119804. * This happens due to recent changes in browser policies preventing video to auto start.
  119805. */
  119806. get onUserActionRequestedObservable(): Observable<Texture>;
  119807. private _generateMipMaps;
  119808. private _stillImageCaptured;
  119809. private _displayingPosterTexture;
  119810. private _settings;
  119811. private _createInternalTextureOnEvent;
  119812. private _frameId;
  119813. private _currentSrc;
  119814. /**
  119815. * Creates a video texture.
  119816. * If you want to display a video in your scene, this is the special texture for that.
  119817. * This special texture works similar to other textures, with the exception of a few parameters.
  119818. * @see https://doc.babylonjs.com/how_to/video_texture
  119819. * @param name optional name, will detect from video source, if not defined
  119820. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  119821. * @param scene is obviously the current scene.
  119822. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  119823. * @param invertY is false by default but can be used to invert video on Y axis
  119824. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  119825. * @param settings allows finer control over video usage
  119826. */
  119827. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  119828. private _getName;
  119829. private _getVideo;
  119830. private _createInternalTexture;
  119831. private reset;
  119832. /**
  119833. * @hidden Internal method to initiate `update`.
  119834. */
  119835. _rebuild(): void;
  119836. /**
  119837. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  119838. */
  119839. update(): void;
  119840. /**
  119841. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  119842. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  119843. */
  119844. updateTexture(isVisible: boolean): void;
  119845. protected _updateInternalTexture: () => void;
  119846. /**
  119847. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  119848. * @param url New url.
  119849. */
  119850. updateURL(url: string): void;
  119851. /**
  119852. * Clones the texture.
  119853. * @returns the cloned texture
  119854. */
  119855. clone(): VideoTexture;
  119856. /**
  119857. * Dispose the texture and release its associated resources.
  119858. */
  119859. dispose(): void;
  119860. /**
  119861. * Creates a video texture straight from a stream.
  119862. * @param scene Define the scene the texture should be created in
  119863. * @param stream Define the stream the texture should be created from
  119864. * @returns The created video texture as a promise
  119865. */
  119866. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  119867. /**
  119868. * Creates a video texture straight from your WebCam video feed.
  119869. * @param scene Define the scene the texture should be created in
  119870. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119871. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119872. * @returns The created video texture as a promise
  119873. */
  119874. static CreateFromWebCamAsync(scene: Scene, constraints: {
  119875. minWidth: number;
  119876. maxWidth: number;
  119877. minHeight: number;
  119878. maxHeight: number;
  119879. deviceId: string;
  119880. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  119881. /**
  119882. * Creates a video texture straight from your WebCam video feed.
  119883. * @param scene Define the scene the texture should be created in
  119884. * @param onReady Define a callback to triggered once the texture will be ready
  119885. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119886. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119887. */
  119888. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  119889. minWidth: number;
  119890. maxWidth: number;
  119891. minHeight: number;
  119892. maxHeight: number;
  119893. deviceId: string;
  119894. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  119895. }
  119896. }
  119897. declare module BABYLON {
  119898. /**
  119899. * Defines the interface used by objects working like Scene
  119900. * @hidden
  119901. */
  119902. export interface ISceneLike {
  119903. _addPendingData(data: any): void;
  119904. _removePendingData(data: any): void;
  119905. offlineProvider: IOfflineProvider;
  119906. }
  119907. /**
  119908. * Information about the current host
  119909. */
  119910. export interface HostInformation {
  119911. /**
  119912. * Defines if the current host is a mobile
  119913. */
  119914. isMobile: boolean;
  119915. }
  119916. /** Interface defining initialization parameters for Engine class */
  119917. export interface EngineOptions extends WebGLContextAttributes {
  119918. /**
  119919. * Defines if the engine should no exceed a specified device ratio
  119920. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  119921. */
  119922. limitDeviceRatio?: number;
  119923. /**
  119924. * Defines if webvr should be enabled automatically
  119925. * @see https://doc.babylonjs.com/how_to/webvr_camera
  119926. */
  119927. autoEnableWebVR?: boolean;
  119928. /**
  119929. * Defines if webgl2 should be turned off even if supported
  119930. * @see https://doc.babylonjs.com/features/webgl2
  119931. */
  119932. disableWebGL2Support?: boolean;
  119933. /**
  119934. * Defines if webaudio should be initialized as well
  119935. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119936. */
  119937. audioEngine?: boolean;
  119938. /**
  119939. * Defines if animations should run using a deterministic lock step
  119940. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119941. */
  119942. deterministicLockstep?: boolean;
  119943. /** Defines the maximum steps to use with deterministic lock step mode */
  119944. lockstepMaxSteps?: number;
  119945. /** Defines the seconds between each deterministic lock step */
  119946. timeStep?: number;
  119947. /**
  119948. * Defines that engine should ignore context lost events
  119949. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  119950. */
  119951. doNotHandleContextLost?: boolean;
  119952. /**
  119953. * Defines that engine should ignore modifying touch action attribute and style
  119954. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  119955. */
  119956. doNotHandleTouchAction?: boolean;
  119957. /**
  119958. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  119959. */
  119960. useHighPrecisionFloats?: boolean;
  119961. /**
  119962. * Make the canvas XR Compatible for XR sessions
  119963. */
  119964. xrCompatible?: boolean;
  119965. /**
  119966. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  119967. */
  119968. useHighPrecisionMatrix?: boolean;
  119969. /**
  119970. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  119971. */
  119972. failIfMajorPerformanceCaveat?: boolean;
  119973. }
  119974. /**
  119975. * The base engine class (root of all engines)
  119976. */
  119977. export class ThinEngine {
  119978. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  119979. static ExceptionList: ({
  119980. key: string;
  119981. capture: string;
  119982. captureConstraint: number;
  119983. targets: string[];
  119984. } | {
  119985. key: string;
  119986. capture: null;
  119987. captureConstraint: null;
  119988. targets: string[];
  119989. })[];
  119990. /** @hidden */
  119991. static _TextureLoaders: IInternalTextureLoader[];
  119992. /**
  119993. * Returns the current npm package of the sdk
  119994. */
  119995. static get NpmPackage(): string;
  119996. /**
  119997. * Returns the current version of the framework
  119998. */
  119999. static get Version(): string;
  120000. /**
  120001. * Returns a string describing the current engine
  120002. */
  120003. get description(): string;
  120004. /**
  120005. * Gets or sets the epsilon value used by collision engine
  120006. */
  120007. static CollisionsEpsilon: number;
  120008. /**
  120009. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  120010. */
  120011. static get ShadersRepository(): string;
  120012. static set ShadersRepository(value: string);
  120013. /** @hidden */
  120014. _shaderProcessor: IShaderProcessor;
  120015. /**
  120016. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  120017. */
  120018. forcePOTTextures: boolean;
  120019. /**
  120020. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  120021. */
  120022. isFullscreen: boolean;
  120023. /**
  120024. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  120025. */
  120026. cullBackFaces: boolean;
  120027. /**
  120028. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  120029. */
  120030. renderEvenInBackground: boolean;
  120031. /**
  120032. * Gets or sets a boolean indicating that cache can be kept between frames
  120033. */
  120034. preventCacheWipeBetweenFrames: boolean;
  120035. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  120036. validateShaderPrograms: boolean;
  120037. /**
  120038. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  120039. * This can provide greater z depth for distant objects.
  120040. */
  120041. useReverseDepthBuffer: boolean;
  120042. /**
  120043. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  120044. */
  120045. disableUniformBuffers: boolean;
  120046. /** @hidden */
  120047. _uniformBuffers: UniformBuffer[];
  120048. /**
  120049. * Gets a boolean indicating that the engine supports uniform buffers
  120050. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  120051. */
  120052. get supportsUniformBuffers(): boolean;
  120053. /** @hidden */
  120054. _gl: WebGLRenderingContext;
  120055. /** @hidden */
  120056. _webGLVersion: number;
  120057. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  120058. protected _windowIsBackground: boolean;
  120059. protected _creationOptions: EngineOptions;
  120060. protected _highPrecisionShadersAllowed: boolean;
  120061. /** @hidden */
  120062. get _shouldUseHighPrecisionShader(): boolean;
  120063. /**
  120064. * Gets a boolean indicating that only power of 2 textures are supported
  120065. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  120066. */
  120067. get needPOTTextures(): boolean;
  120068. /** @hidden */
  120069. _badOS: boolean;
  120070. /** @hidden */
  120071. _badDesktopOS: boolean;
  120072. private _hardwareScalingLevel;
  120073. /** @hidden */
  120074. _caps: EngineCapabilities;
  120075. private _isStencilEnable;
  120076. private _glVersion;
  120077. private _glRenderer;
  120078. private _glVendor;
  120079. /** @hidden */
  120080. _videoTextureSupported: boolean;
  120081. protected _renderingQueueLaunched: boolean;
  120082. protected _activeRenderLoops: (() => void)[];
  120083. /**
  120084. * Observable signaled when a context lost event is raised
  120085. */
  120086. onContextLostObservable: Observable<ThinEngine>;
  120087. /**
  120088. * Observable signaled when a context restored event is raised
  120089. */
  120090. onContextRestoredObservable: Observable<ThinEngine>;
  120091. private _onContextLost;
  120092. private _onContextRestored;
  120093. protected _contextWasLost: boolean;
  120094. /** @hidden */
  120095. _doNotHandleContextLost: boolean;
  120096. /**
  120097. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  120098. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  120099. */
  120100. get doNotHandleContextLost(): boolean;
  120101. set doNotHandleContextLost(value: boolean);
  120102. /**
  120103. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  120104. */
  120105. disableVertexArrayObjects: boolean;
  120106. /** @hidden */
  120107. protected _colorWrite: boolean;
  120108. /** @hidden */
  120109. protected _colorWriteChanged: boolean;
  120110. /** @hidden */
  120111. protected _depthCullingState: DepthCullingState;
  120112. /** @hidden */
  120113. protected _stencilState: StencilState;
  120114. /** @hidden */
  120115. _alphaState: AlphaState;
  120116. /** @hidden */
  120117. _alphaMode: number;
  120118. /** @hidden */
  120119. _alphaEquation: number;
  120120. /** @hidden */
  120121. _internalTexturesCache: InternalTexture[];
  120122. /** @hidden */
  120123. protected _activeChannel: number;
  120124. private _currentTextureChannel;
  120125. /** @hidden */
  120126. protected _boundTexturesCache: {
  120127. [key: string]: Nullable<InternalTexture>;
  120128. };
  120129. /** @hidden */
  120130. protected _currentEffect: Nullable<Effect>;
  120131. /** @hidden */
  120132. protected _currentProgram: Nullable<WebGLProgram>;
  120133. private _compiledEffects;
  120134. private _vertexAttribArraysEnabled;
  120135. /** @hidden */
  120136. protected _cachedViewport: Nullable<IViewportLike>;
  120137. private _cachedVertexArrayObject;
  120138. /** @hidden */
  120139. protected _cachedVertexBuffers: any;
  120140. /** @hidden */
  120141. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  120142. /** @hidden */
  120143. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  120144. /** @hidden */
  120145. _currentRenderTarget: Nullable<InternalTexture>;
  120146. private _uintIndicesCurrentlySet;
  120147. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  120148. /** @hidden */
  120149. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  120150. /** @hidden */
  120151. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  120152. private _currentBufferPointers;
  120153. private _currentInstanceLocations;
  120154. private _currentInstanceBuffers;
  120155. private _textureUnits;
  120156. /** @hidden */
  120157. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120158. /** @hidden */
  120159. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120160. /** @hidden */
  120161. _boundRenderFunction: any;
  120162. private _vaoRecordInProgress;
  120163. private _mustWipeVertexAttributes;
  120164. private _emptyTexture;
  120165. private _emptyCubeTexture;
  120166. private _emptyTexture3D;
  120167. private _emptyTexture2DArray;
  120168. /** @hidden */
  120169. _frameHandler: number;
  120170. private _nextFreeTextureSlots;
  120171. private _maxSimultaneousTextures;
  120172. private _activeRequests;
  120173. /** @hidden */
  120174. _transformTextureUrl: Nullable<(url: string) => string>;
  120175. /**
  120176. * Gets information about the current host
  120177. */
  120178. hostInformation: HostInformation;
  120179. protected get _supportsHardwareTextureRescaling(): boolean;
  120180. private _framebufferDimensionsObject;
  120181. /**
  120182. * sets the object from which width and height will be taken from when getting render width and height
  120183. * Will fallback to the gl object
  120184. * @param dimensions the framebuffer width and height that will be used.
  120185. */
  120186. set framebufferDimensionsObject(dimensions: Nullable<{
  120187. framebufferWidth: number;
  120188. framebufferHeight: number;
  120189. }>);
  120190. /**
  120191. * Gets the current viewport
  120192. */
  120193. get currentViewport(): Nullable<IViewportLike>;
  120194. /**
  120195. * Gets the default empty texture
  120196. */
  120197. get emptyTexture(): InternalTexture;
  120198. /**
  120199. * Gets the default empty 3D texture
  120200. */
  120201. get emptyTexture3D(): InternalTexture;
  120202. /**
  120203. * Gets the default empty 2D array texture
  120204. */
  120205. get emptyTexture2DArray(): InternalTexture;
  120206. /**
  120207. * Gets the default empty cube texture
  120208. */
  120209. get emptyCubeTexture(): InternalTexture;
  120210. /**
  120211. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  120212. */
  120213. readonly premultipliedAlpha: boolean;
  120214. /**
  120215. * Observable event triggered before each texture is initialized
  120216. */
  120217. onBeforeTextureInitObservable: Observable<Texture>;
  120218. /**
  120219. * Creates a new engine
  120220. * @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
  120221. * @param antialias defines enable antialiasing (default: false)
  120222. * @param options defines further options to be sent to the getContext() function
  120223. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  120224. */
  120225. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  120226. private _rebuildInternalTextures;
  120227. private _rebuildEffects;
  120228. /**
  120229. * Gets a boolean indicating if all created effects are ready
  120230. * @returns true if all effects are ready
  120231. */
  120232. areAllEffectsReady(): boolean;
  120233. protected _rebuildBuffers(): void;
  120234. protected _initGLContext(): void;
  120235. /**
  120236. * Gets version of the current webGL context
  120237. */
  120238. get webGLVersion(): number;
  120239. /**
  120240. * Gets a string identifying the name of the class
  120241. * @returns "Engine" string
  120242. */
  120243. getClassName(): string;
  120244. /**
  120245. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  120246. */
  120247. get isStencilEnable(): boolean;
  120248. /** @hidden */
  120249. _prepareWorkingCanvas(): void;
  120250. /**
  120251. * Reset the texture cache to empty state
  120252. */
  120253. resetTextureCache(): void;
  120254. /**
  120255. * Gets an object containing information about the current webGL context
  120256. * @returns an object containing the vender, the renderer and the version of the current webGL context
  120257. */
  120258. getGlInfo(): {
  120259. vendor: string;
  120260. renderer: string;
  120261. version: string;
  120262. };
  120263. /**
  120264. * Defines the hardware scaling level.
  120265. * By default the hardware scaling level is computed from the window device ratio.
  120266. * 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.
  120267. * @param level defines the level to use
  120268. */
  120269. setHardwareScalingLevel(level: number): void;
  120270. /**
  120271. * Gets the current hardware scaling level.
  120272. * By default the hardware scaling level is computed from the window device ratio.
  120273. * 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.
  120274. * @returns a number indicating the current hardware scaling level
  120275. */
  120276. getHardwareScalingLevel(): number;
  120277. /**
  120278. * Gets the list of loaded textures
  120279. * @returns an array containing all loaded textures
  120280. */
  120281. getLoadedTexturesCache(): InternalTexture[];
  120282. /**
  120283. * Gets the object containing all engine capabilities
  120284. * @returns the EngineCapabilities object
  120285. */
  120286. getCaps(): EngineCapabilities;
  120287. /**
  120288. * stop executing a render loop function and remove it from the execution array
  120289. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  120290. */
  120291. stopRenderLoop(renderFunction?: () => void): void;
  120292. /** @hidden */
  120293. _renderLoop(): void;
  120294. /**
  120295. * Gets the HTML canvas attached with the current webGL context
  120296. * @returns a HTML canvas
  120297. */
  120298. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  120299. /**
  120300. * Gets host window
  120301. * @returns the host window object
  120302. */
  120303. getHostWindow(): Nullable<Window>;
  120304. /**
  120305. * Gets the current render width
  120306. * @param useScreen defines if screen size must be used (or the current render target if any)
  120307. * @returns a number defining the current render width
  120308. */
  120309. getRenderWidth(useScreen?: boolean): number;
  120310. /**
  120311. * Gets the current render height
  120312. * @param useScreen defines if screen size must be used (or the current render target if any)
  120313. * @returns a number defining the current render height
  120314. */
  120315. getRenderHeight(useScreen?: boolean): number;
  120316. /**
  120317. * Can be used to override the current requestAnimationFrame requester.
  120318. * @hidden
  120319. */
  120320. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120321. /**
  120322. * Register and execute a render loop. The engine can have more than one render function
  120323. * @param renderFunction defines the function to continuously execute
  120324. */
  120325. runRenderLoop(renderFunction: () => void): void;
  120326. /**
  120327. * Clear the current render buffer or the current render target (if any is set up)
  120328. * @param color defines the color to use
  120329. * @param backBuffer defines if the back buffer must be cleared
  120330. * @param depth defines if the depth buffer must be cleared
  120331. * @param stencil defines if the stencil buffer must be cleared
  120332. */
  120333. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120334. private _viewportCached;
  120335. /** @hidden */
  120336. _viewport(x: number, y: number, width: number, height: number): void;
  120337. /**
  120338. * Set the WebGL's viewport
  120339. * @param viewport defines the viewport element to be used
  120340. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  120341. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  120342. */
  120343. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  120344. /**
  120345. * Begin a new frame
  120346. */
  120347. beginFrame(): void;
  120348. /**
  120349. * Enf the current frame
  120350. */
  120351. endFrame(): void;
  120352. /**
  120353. * Resize the view according to the canvas' size
  120354. */
  120355. resize(): void;
  120356. /**
  120357. * Force a specific size of the canvas
  120358. * @param width defines the new canvas' width
  120359. * @param height defines the new canvas' height
  120360. * @returns true if the size was changed
  120361. */
  120362. setSize(width: number, height: number): boolean;
  120363. /**
  120364. * Binds the frame buffer to the specified texture.
  120365. * @param texture The texture to render to or null for the default canvas
  120366. * @param faceIndex The face of the texture to render to in case of cube texture
  120367. * @param requiredWidth The width of the target to render to
  120368. * @param requiredHeight The height of the target to render to
  120369. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120370. * @param lodLevel defines the lod level to bind to the frame buffer
  120371. * @param layer defines the 2d array index to bind to frame buffer to
  120372. */
  120373. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  120374. /** @hidden */
  120375. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120376. /**
  120377. * Unbind the current render target texture from the webGL context
  120378. * @param texture defines the render target texture to unbind
  120379. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120380. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120381. */
  120382. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120383. /**
  120384. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  120385. */
  120386. flushFramebuffer(): void;
  120387. /**
  120388. * Unbind the current render target and bind the default framebuffer
  120389. */
  120390. restoreDefaultFramebuffer(): void;
  120391. /** @hidden */
  120392. protected _resetVertexBufferBinding(): void;
  120393. /**
  120394. * Creates a vertex buffer
  120395. * @param data the data for the vertex buffer
  120396. * @returns the new WebGL static buffer
  120397. */
  120398. createVertexBuffer(data: DataArray): DataBuffer;
  120399. private _createVertexBuffer;
  120400. /**
  120401. * Creates a dynamic vertex buffer
  120402. * @param data the data for the dynamic vertex buffer
  120403. * @returns the new WebGL dynamic buffer
  120404. */
  120405. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120406. protected _resetIndexBufferBinding(): void;
  120407. /**
  120408. * Creates a new index buffer
  120409. * @param indices defines the content of the index buffer
  120410. * @param updatable defines if the index buffer must be updatable
  120411. * @returns a new webGL buffer
  120412. */
  120413. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  120414. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  120415. /**
  120416. * Bind a webGL buffer to the webGL context
  120417. * @param buffer defines the buffer to bind
  120418. */
  120419. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  120420. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  120421. private bindBuffer;
  120422. /**
  120423. * update the bound buffer with the given data
  120424. * @param data defines the data to update
  120425. */
  120426. updateArrayBuffer(data: Float32Array): void;
  120427. private _vertexAttribPointer;
  120428. /** @hidden */
  120429. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  120430. private _bindVertexBuffersAttributes;
  120431. /**
  120432. * Records a vertex array object
  120433. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  120434. * @param vertexBuffers defines the list of vertex buffers to store
  120435. * @param indexBuffer defines the index buffer to store
  120436. * @param effect defines the effect to store
  120437. * @returns the new vertex array object
  120438. */
  120439. recordVertexArrayObject(vertexBuffers: {
  120440. [key: string]: VertexBuffer;
  120441. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120442. /**
  120443. * Bind a specific vertex array object
  120444. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  120445. * @param vertexArrayObject defines the vertex array object to bind
  120446. * @param indexBuffer defines the index buffer to bind
  120447. */
  120448. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  120449. /**
  120450. * Bind webGl buffers directly to the webGL context
  120451. * @param vertexBuffer defines the vertex buffer to bind
  120452. * @param indexBuffer defines the index buffer to bind
  120453. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120454. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120455. * @param effect defines the effect associated with the vertex buffer
  120456. */
  120457. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  120458. private _unbindVertexArrayObject;
  120459. /**
  120460. * Bind a list of vertex buffers to the webGL context
  120461. * @param vertexBuffers defines the list of vertex buffers to bind
  120462. * @param indexBuffer defines the index buffer to bind
  120463. * @param effect defines the effect associated with the vertex buffers
  120464. */
  120465. bindBuffers(vertexBuffers: {
  120466. [key: string]: Nullable<VertexBuffer>;
  120467. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  120468. /**
  120469. * Unbind all instance attributes
  120470. */
  120471. unbindInstanceAttributes(): void;
  120472. /**
  120473. * Release and free the memory of a vertex array object
  120474. * @param vao defines the vertex array object to delete
  120475. */
  120476. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  120477. /** @hidden */
  120478. _releaseBuffer(buffer: DataBuffer): boolean;
  120479. protected _deleteBuffer(buffer: DataBuffer): void;
  120480. /**
  120481. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  120482. * @param instancesBuffer defines the webGL buffer to update and bind
  120483. * @param data defines the data to store in the buffer
  120484. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  120485. */
  120486. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  120487. /**
  120488. * Bind the content of a webGL buffer used with instantiation
  120489. * @param instancesBuffer defines the webGL buffer to bind
  120490. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  120491. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  120492. */
  120493. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  120494. /**
  120495. * Disable the instance attribute corresponding to the name in parameter
  120496. * @param name defines the name of the attribute to disable
  120497. */
  120498. disableInstanceAttributeByName(name: string): void;
  120499. /**
  120500. * Disable the instance attribute corresponding to the location in parameter
  120501. * @param attributeLocation defines the attribute location of the attribute to disable
  120502. */
  120503. disableInstanceAttribute(attributeLocation: number): void;
  120504. /**
  120505. * Disable the attribute corresponding to the location in parameter
  120506. * @param attributeLocation defines the attribute location of the attribute to disable
  120507. */
  120508. disableAttributeByIndex(attributeLocation: number): void;
  120509. /**
  120510. * Send a draw order
  120511. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120512. * @param indexStart defines the starting index
  120513. * @param indexCount defines the number of index to draw
  120514. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120515. */
  120516. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120517. /**
  120518. * Draw a list of points
  120519. * @param verticesStart defines the index of first vertex to draw
  120520. * @param verticesCount defines the count of vertices to draw
  120521. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120522. */
  120523. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120524. /**
  120525. * Draw a list of unindexed primitives
  120526. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120527. * @param verticesStart defines the index of first vertex to draw
  120528. * @param verticesCount defines the count of vertices to draw
  120529. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120530. */
  120531. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120532. /**
  120533. * Draw a list of indexed primitives
  120534. * @param fillMode defines the primitive to use
  120535. * @param indexStart defines the starting index
  120536. * @param indexCount defines the number of index to draw
  120537. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120538. */
  120539. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120540. /**
  120541. * Draw a list of unindexed primitives
  120542. * @param fillMode defines the primitive to use
  120543. * @param verticesStart defines the index of first vertex to draw
  120544. * @param verticesCount defines the count of vertices to draw
  120545. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120546. */
  120547. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120548. private _drawMode;
  120549. /** @hidden */
  120550. protected _reportDrawCall(): void;
  120551. /** @hidden */
  120552. _releaseEffect(effect: Effect): void;
  120553. /** @hidden */
  120554. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120555. /**
  120556. * Create a new effect (used to store vertex/fragment shaders)
  120557. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  120558. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  120559. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  120560. * @param samplers defines an array of string used to represent textures
  120561. * @param defines defines the string containing the defines to use to compile the shaders
  120562. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  120563. * @param onCompiled defines a function to call when the effect creation is successful
  120564. * @param onError defines a function to call when the effect creation has failed
  120565. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  120566. * @returns the new Effect
  120567. */
  120568. 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;
  120569. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  120570. private _compileShader;
  120571. private _compileRawShader;
  120572. /** @hidden */
  120573. _getShaderSource(shader: WebGLShader): Nullable<string>;
  120574. /**
  120575. * Directly creates a webGL program
  120576. * @param pipelineContext defines the pipeline context to attach to
  120577. * @param vertexCode defines the vertex shader code to use
  120578. * @param fragmentCode defines the fragment shader code to use
  120579. * @param context defines the webGL context to use (if not set, the current one will be used)
  120580. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  120581. * @returns the new webGL program
  120582. */
  120583. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  120584. /**
  120585. * Creates a webGL program
  120586. * @param pipelineContext defines the pipeline context to attach to
  120587. * @param vertexCode defines the vertex shader code to use
  120588. * @param fragmentCode defines the fragment shader code to use
  120589. * @param defines defines the string containing the defines to use to compile the shaders
  120590. * @param context defines the webGL context to use (if not set, the current one will be used)
  120591. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  120592. * @returns the new webGL program
  120593. */
  120594. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  120595. /**
  120596. * Creates a new pipeline context
  120597. * @returns the new pipeline
  120598. */
  120599. createPipelineContext(): IPipelineContext;
  120600. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  120601. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  120602. /** @hidden */
  120603. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120604. /** @hidden */
  120605. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120606. /** @hidden */
  120607. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120608. /**
  120609. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  120610. * @param pipelineContext defines the pipeline context to use
  120611. * @param uniformsNames defines the list of uniform names
  120612. * @returns an array of webGL uniform locations
  120613. */
  120614. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  120615. /**
  120616. * Gets the lsit of active attributes for a given webGL program
  120617. * @param pipelineContext defines the pipeline context to use
  120618. * @param attributesNames defines the list of attribute names to get
  120619. * @returns an array of indices indicating the offset of each attribute
  120620. */
  120621. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120622. /**
  120623. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  120624. * @param effect defines the effect to activate
  120625. */
  120626. enableEffect(effect: Nullable<Effect>): void;
  120627. /**
  120628. * Set the value of an uniform to a number (int)
  120629. * @param uniform defines the webGL uniform location where to store the value
  120630. * @param value defines the int number to store
  120631. * @returns true if the value was set
  120632. */
  120633. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  120634. /**
  120635. * Set the value of an uniform to an array of int32
  120636. * @param uniform defines the webGL uniform location where to store the value
  120637. * @param array defines the array of int32 to store
  120638. * @returns true if the value was set
  120639. */
  120640. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120641. /**
  120642. * Set the value of an uniform to an array of int32 (stored as vec2)
  120643. * @param uniform defines the webGL uniform location where to store the value
  120644. * @param array defines the array of int32 to store
  120645. * @returns true if the value was set
  120646. */
  120647. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120648. /**
  120649. * Set the value of an uniform to an array of int32 (stored as vec3)
  120650. * @param uniform defines the webGL uniform location where to store the value
  120651. * @param array defines the array of int32 to store
  120652. * @returns true if the value was set
  120653. */
  120654. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120655. /**
  120656. * Set the value of an uniform to an array of int32 (stored as vec4)
  120657. * @param uniform defines the webGL uniform location where to store the value
  120658. * @param array defines the array of int32 to store
  120659. * @returns true if the value was set
  120660. */
  120661. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120662. /**
  120663. * Set the value of an uniform to an array of number
  120664. * @param uniform defines the webGL uniform location where to store the value
  120665. * @param array defines the array of number to store
  120666. * @returns true if the value was set
  120667. */
  120668. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120669. /**
  120670. * Set the value of an uniform to an array of number (stored as vec2)
  120671. * @param uniform defines the webGL uniform location where to store the value
  120672. * @param array defines the array of number to store
  120673. * @returns true if the value was set
  120674. */
  120675. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120676. /**
  120677. * Set the value of an uniform to an array of number (stored as vec3)
  120678. * @param uniform defines the webGL uniform location where to store the value
  120679. * @param array defines the array of number to store
  120680. * @returns true if the value was set
  120681. */
  120682. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120683. /**
  120684. * Set the value of an uniform to an array of number (stored as vec4)
  120685. * @param uniform defines the webGL uniform location where to store the value
  120686. * @param array defines the array of number to store
  120687. * @returns true if the value was set
  120688. */
  120689. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120690. /**
  120691. * Set the value of an uniform to an array of float32 (stored as matrices)
  120692. * @param uniform defines the webGL uniform location where to store the value
  120693. * @param matrices defines the array of float32 to store
  120694. * @returns true if the value was set
  120695. */
  120696. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  120697. /**
  120698. * Set the value of an uniform to a matrix (3x3)
  120699. * @param uniform defines the webGL uniform location where to store the value
  120700. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  120701. * @returns true if the value was set
  120702. */
  120703. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  120704. /**
  120705. * Set the value of an uniform to a matrix (2x2)
  120706. * @param uniform defines the webGL uniform location where to store the value
  120707. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120708. * @returns true if the value was set
  120709. */
  120710. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  120711. /**
  120712. * Set the value of an uniform to a number (float)
  120713. * @param uniform defines the webGL uniform location where to store the value
  120714. * @param value defines the float number to store
  120715. * @returns true if the value was transfered
  120716. */
  120717. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  120718. /**
  120719. * Set the value of an uniform to a vec2
  120720. * @param uniform defines the webGL uniform location where to store the value
  120721. * @param x defines the 1st component of the value
  120722. * @param y defines the 2nd component of the value
  120723. * @returns true if the value was set
  120724. */
  120725. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  120726. /**
  120727. * Set the value of an uniform to a vec3
  120728. * @param uniform defines the webGL uniform location where to store the value
  120729. * @param x defines the 1st component of the value
  120730. * @param y defines the 2nd component of the value
  120731. * @param z defines the 3rd component of the value
  120732. * @returns true if the value was set
  120733. */
  120734. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  120735. /**
  120736. * Set the value of an uniform to a vec4
  120737. * @param uniform defines the webGL uniform location where to store the value
  120738. * @param x defines the 1st component of the value
  120739. * @param y defines the 2nd component of the value
  120740. * @param z defines the 3rd component of the value
  120741. * @param w defines the 4th component of the value
  120742. * @returns true if the value was set
  120743. */
  120744. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  120745. /**
  120746. * Apply all cached states (depth, culling, stencil and alpha)
  120747. */
  120748. applyStates(): void;
  120749. /**
  120750. * Enable or disable color writing
  120751. * @param enable defines the state to set
  120752. */
  120753. setColorWrite(enable: boolean): void;
  120754. /**
  120755. * Gets a boolean indicating if color writing is enabled
  120756. * @returns the current color writing state
  120757. */
  120758. getColorWrite(): boolean;
  120759. /**
  120760. * Gets the depth culling state manager
  120761. */
  120762. get depthCullingState(): DepthCullingState;
  120763. /**
  120764. * Gets the alpha state manager
  120765. */
  120766. get alphaState(): AlphaState;
  120767. /**
  120768. * Gets the stencil state manager
  120769. */
  120770. get stencilState(): StencilState;
  120771. /**
  120772. * Clears the list of texture accessible through engine.
  120773. * This can help preventing texture load conflict due to name collision.
  120774. */
  120775. clearInternalTexturesCache(): void;
  120776. /**
  120777. * Force the entire cache to be cleared
  120778. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120779. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120780. */
  120781. wipeCaches(bruteForce?: boolean): void;
  120782. /** @hidden */
  120783. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  120784. min: number;
  120785. mag: number;
  120786. };
  120787. /** @hidden */
  120788. _createTexture(): WebGLTexture;
  120789. /**
  120790. * Usually called from Texture.ts.
  120791. * Passed information to create a WebGLTexture
  120792. * @param url defines a value which contains one of the following:
  120793. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120794. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120795. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120796. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120797. * @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)
  120798. * @param scene needed for loading to the correct scene
  120799. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120800. * @param onLoad optional callback to be called upon successful completion
  120801. * @param onError optional callback to be called upon failure
  120802. * @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
  120803. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120804. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120805. * @param forcedExtension defines the extension to use to pick the right loader
  120806. * @param mimeType defines an optional mime type
  120807. * @param loaderOptions options to be passed to the loader
  120808. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120809. */
  120810. 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;
  120811. /**
  120812. * Loads an image as an HTMLImageElement.
  120813. * @param input url string, ArrayBuffer, or Blob to load
  120814. * @param onLoad callback called when the image successfully loads
  120815. * @param onError callback called when the image fails to load
  120816. * @param offlineProvider offline provider for caching
  120817. * @param mimeType optional mime type
  120818. * @returns the HTMLImageElement of the loaded image
  120819. * @hidden
  120820. */
  120821. 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>;
  120822. /**
  120823. * @hidden
  120824. */
  120825. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  120826. private _unpackFlipYCached;
  120827. /**
  120828. * In case you are sharing the context with other applications, it might
  120829. * be interested to not cache the unpack flip y state to ensure a consistent
  120830. * value would be set.
  120831. */
  120832. enableUnpackFlipYCached: boolean;
  120833. /** @hidden */
  120834. _unpackFlipY(value: boolean): void;
  120835. /** @hidden */
  120836. _getUnpackAlignement(): number;
  120837. private _getTextureTarget;
  120838. /**
  120839. * Update the sampling mode of a given texture
  120840. * @param samplingMode defines the required sampling mode
  120841. * @param texture defines the texture to update
  120842. * @param generateMipMaps defines whether to generate mipmaps for the texture
  120843. */
  120844. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  120845. /**
  120846. * Update the sampling mode of a given texture
  120847. * @param texture defines the texture to update
  120848. * @param wrapU defines the texture wrap mode of the u coordinates
  120849. * @param wrapV defines the texture wrap mode of the v coordinates
  120850. * @param wrapR defines the texture wrap mode of the r coordinates
  120851. */
  120852. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  120853. /** @hidden */
  120854. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  120855. width: number;
  120856. height: number;
  120857. layers?: number;
  120858. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  120859. /** @hidden */
  120860. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120861. /** @hidden */
  120862. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  120863. /**
  120864. * Update a portion of an internal texture
  120865. * @param texture defines the texture to update
  120866. * @param imageData defines the data to store into the texture
  120867. * @param xOffset defines the x coordinates of the update rectangle
  120868. * @param yOffset defines the y coordinates of the update rectangle
  120869. * @param width defines the width of the update rectangle
  120870. * @param height defines the height of the update rectangle
  120871. * @param faceIndex defines the face index if texture is a cube (0 by default)
  120872. * @param lod defines the lod level to update (0 by default)
  120873. */
  120874. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  120875. /** @hidden */
  120876. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120877. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  120878. private _prepareWebGLTexture;
  120879. /** @hidden */
  120880. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  120881. private _getDepthStencilBuffer;
  120882. /** @hidden */
  120883. _releaseFramebufferObjects(texture: InternalTexture): void;
  120884. /** @hidden */
  120885. _releaseTexture(texture: InternalTexture): void;
  120886. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120887. protected _setProgram(program: WebGLProgram): void;
  120888. protected _boundUniforms: {
  120889. [key: number]: WebGLUniformLocation;
  120890. };
  120891. /**
  120892. * Binds an effect to the webGL context
  120893. * @param effect defines the effect to bind
  120894. */
  120895. bindSamplers(effect: Effect): void;
  120896. private _activateCurrentTexture;
  120897. /** @hidden */
  120898. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  120899. /** @hidden */
  120900. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  120901. /**
  120902. * Unbind all textures from the webGL context
  120903. */
  120904. unbindAllTextures(): void;
  120905. /**
  120906. * Sets a texture to the according uniform.
  120907. * @param channel The texture channel
  120908. * @param uniform The uniform to set
  120909. * @param texture The texture to apply
  120910. */
  120911. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  120912. private _bindSamplerUniformToChannel;
  120913. private _getTextureWrapMode;
  120914. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120915. /**
  120916. * Sets an array of texture to the webGL context
  120917. * @param channel defines the channel where the texture array must be set
  120918. * @param uniform defines the associated uniform location
  120919. * @param textures defines the array of textures to bind
  120920. */
  120921. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  120922. /** @hidden */
  120923. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  120924. private _setTextureParameterFloat;
  120925. private _setTextureParameterInteger;
  120926. /**
  120927. * Unbind all vertex attributes from the webGL context
  120928. */
  120929. unbindAllAttributes(): void;
  120930. /**
  120931. * 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
  120932. */
  120933. releaseEffects(): void;
  120934. /**
  120935. * Dispose and release all associated resources
  120936. */
  120937. dispose(): void;
  120938. /**
  120939. * Attach a new callback raised when context lost event is fired
  120940. * @param callback defines the callback to call
  120941. */
  120942. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120943. /**
  120944. * Attach a new callback raised when context restored event is fired
  120945. * @param callback defines the callback to call
  120946. */
  120947. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120948. /**
  120949. * Get the current error code of the webGL context
  120950. * @returns the error code
  120951. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120952. */
  120953. getError(): number;
  120954. private _canRenderToFloatFramebuffer;
  120955. private _canRenderToHalfFloatFramebuffer;
  120956. private _canRenderToFramebuffer;
  120957. /** @hidden */
  120958. _getWebGLTextureType(type: number): number;
  120959. /** @hidden */
  120960. _getInternalFormat(format: number): number;
  120961. /** @hidden */
  120962. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  120963. /** @hidden */
  120964. _getRGBAMultiSampleBufferFormat(type: number): number;
  120965. /** @hidden */
  120966. _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;
  120967. /**
  120968. * Loads a file from a url
  120969. * @param url url to load
  120970. * @param onSuccess callback called when the file successfully loads
  120971. * @param onProgress callback called while file is loading (if the server supports this mode)
  120972. * @param offlineProvider defines the offline provider for caching
  120973. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  120974. * @param onError callback called when the file fails to load
  120975. * @returns a file request object
  120976. * @hidden
  120977. */
  120978. 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;
  120979. /**
  120980. * Reads pixels from the current frame buffer. Please note that this function can be slow
  120981. * @param x defines the x coordinate of the rectangle where pixels must be read
  120982. * @param y defines the y coordinate of the rectangle where pixels must be read
  120983. * @param width defines the width of the rectangle where pixels must be read
  120984. * @param height defines the height of the rectangle where pixels must be read
  120985. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  120986. * @returns a Uint8Array containing RGBA colors
  120987. */
  120988. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  120989. private static _IsSupported;
  120990. private static _HasMajorPerformanceCaveat;
  120991. /**
  120992. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120993. */
  120994. static get IsSupported(): boolean;
  120995. /**
  120996. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120997. * @returns true if the engine can be created
  120998. * @ignorenaming
  120999. */
  121000. static isSupported(): boolean;
  121001. /**
  121002. * 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)
  121003. */
  121004. static get HasMajorPerformanceCaveat(): boolean;
  121005. /**
  121006. * Find the next highest power of two.
  121007. * @param x Number to start search from.
  121008. * @return Next highest power of two.
  121009. */
  121010. static CeilingPOT(x: number): number;
  121011. /**
  121012. * Find the next lowest power of two.
  121013. * @param x Number to start search from.
  121014. * @return Next lowest power of two.
  121015. */
  121016. static FloorPOT(x: number): number;
  121017. /**
  121018. * Find the nearest power of two.
  121019. * @param x Number to start search from.
  121020. * @return Next nearest power of two.
  121021. */
  121022. static NearestPOT(x: number): number;
  121023. /**
  121024. * Get the closest exponent of two
  121025. * @param value defines the value to approximate
  121026. * @param max defines the maximum value to return
  121027. * @param mode defines how to define the closest value
  121028. * @returns closest exponent of two of the given value
  121029. */
  121030. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  121031. /**
  121032. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  121033. * @param func - the function to be called
  121034. * @param requester - the object that will request the next frame. Falls back to window.
  121035. * @returns frame number
  121036. */
  121037. static QueueNewFrame(func: () => void, requester?: any): number;
  121038. /**
  121039. * Gets host document
  121040. * @returns the host document object
  121041. */
  121042. getHostDocument(): Nullable<Document>;
  121043. }
  121044. }
  121045. declare module BABYLON {
  121046. /**
  121047. * Defines the source of the internal texture
  121048. */
  121049. export enum InternalTextureSource {
  121050. /**
  121051. * The source of the texture data is unknown
  121052. */
  121053. Unknown = 0,
  121054. /**
  121055. * Texture data comes from an URL
  121056. */
  121057. Url = 1,
  121058. /**
  121059. * Texture data is only used for temporary storage
  121060. */
  121061. Temp = 2,
  121062. /**
  121063. * Texture data comes from raw data (ArrayBuffer)
  121064. */
  121065. Raw = 3,
  121066. /**
  121067. * Texture content is dynamic (video or dynamic texture)
  121068. */
  121069. Dynamic = 4,
  121070. /**
  121071. * Texture content is generated by rendering to it
  121072. */
  121073. RenderTarget = 5,
  121074. /**
  121075. * Texture content is part of a multi render target process
  121076. */
  121077. MultiRenderTarget = 6,
  121078. /**
  121079. * Texture data comes from a cube data file
  121080. */
  121081. Cube = 7,
  121082. /**
  121083. * Texture data comes from a raw cube data
  121084. */
  121085. CubeRaw = 8,
  121086. /**
  121087. * Texture data come from a prefiltered cube data file
  121088. */
  121089. CubePrefiltered = 9,
  121090. /**
  121091. * Texture content is raw 3D data
  121092. */
  121093. Raw3D = 10,
  121094. /**
  121095. * Texture content is raw 2D array data
  121096. */
  121097. Raw2DArray = 11,
  121098. /**
  121099. * Texture content is a depth texture
  121100. */
  121101. Depth = 12,
  121102. /**
  121103. * Texture data comes from a raw cube data encoded with RGBD
  121104. */
  121105. CubeRawRGBD = 13
  121106. }
  121107. /**
  121108. * Class used to store data associated with WebGL texture data for the engine
  121109. * This class should not be used directly
  121110. */
  121111. export class InternalTexture {
  121112. /** @hidden */
  121113. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  121114. /**
  121115. * Defines if the texture is ready
  121116. */
  121117. isReady: boolean;
  121118. /**
  121119. * Defines if the texture is a cube texture
  121120. */
  121121. isCube: boolean;
  121122. /**
  121123. * Defines if the texture contains 3D data
  121124. */
  121125. is3D: boolean;
  121126. /**
  121127. * Defines if the texture contains 2D array data
  121128. */
  121129. is2DArray: boolean;
  121130. /**
  121131. * Defines if the texture contains multiview data
  121132. */
  121133. isMultiview: boolean;
  121134. /**
  121135. * Gets the URL used to load this texture
  121136. */
  121137. url: string;
  121138. /**
  121139. * Gets the sampling mode of the texture
  121140. */
  121141. samplingMode: number;
  121142. /**
  121143. * Gets a boolean indicating if the texture needs mipmaps generation
  121144. */
  121145. generateMipMaps: boolean;
  121146. /**
  121147. * Gets the number of samples used by the texture (WebGL2+ only)
  121148. */
  121149. samples: number;
  121150. /**
  121151. * Gets the type of the texture (int, float...)
  121152. */
  121153. type: number;
  121154. /**
  121155. * Gets the format of the texture (RGB, RGBA...)
  121156. */
  121157. format: number;
  121158. /**
  121159. * Observable called when the texture is loaded
  121160. */
  121161. onLoadedObservable: Observable<InternalTexture>;
  121162. /**
  121163. * Gets the width of the texture
  121164. */
  121165. width: number;
  121166. /**
  121167. * Gets the height of the texture
  121168. */
  121169. height: number;
  121170. /**
  121171. * Gets the depth of the texture
  121172. */
  121173. depth: number;
  121174. /**
  121175. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  121176. */
  121177. baseWidth: number;
  121178. /**
  121179. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  121180. */
  121181. baseHeight: number;
  121182. /**
  121183. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  121184. */
  121185. baseDepth: number;
  121186. /**
  121187. * Gets a boolean indicating if the texture is inverted on Y axis
  121188. */
  121189. invertY: boolean;
  121190. /** @hidden */
  121191. _invertVScale: boolean;
  121192. /** @hidden */
  121193. _associatedChannel: number;
  121194. /** @hidden */
  121195. _source: InternalTextureSource;
  121196. /** @hidden */
  121197. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  121198. /** @hidden */
  121199. _bufferView: Nullable<ArrayBufferView>;
  121200. /** @hidden */
  121201. _bufferViewArray: Nullable<ArrayBufferView[]>;
  121202. /** @hidden */
  121203. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  121204. /** @hidden */
  121205. _size: number;
  121206. /** @hidden */
  121207. _extension: string;
  121208. /** @hidden */
  121209. _files: Nullable<string[]>;
  121210. /** @hidden */
  121211. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  121212. /** @hidden */
  121213. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  121214. /** @hidden */
  121215. _framebuffer: Nullable<WebGLFramebuffer>;
  121216. /** @hidden */
  121217. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  121218. /** @hidden */
  121219. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  121220. /** @hidden */
  121221. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  121222. /** @hidden */
  121223. _attachments: Nullable<number[]>;
  121224. /** @hidden */
  121225. _textureArray: Nullable<InternalTexture[]>;
  121226. /** @hidden */
  121227. _cachedCoordinatesMode: Nullable<number>;
  121228. /** @hidden */
  121229. _cachedWrapU: Nullable<number>;
  121230. /** @hidden */
  121231. _cachedWrapV: Nullable<number>;
  121232. /** @hidden */
  121233. _cachedWrapR: Nullable<number>;
  121234. /** @hidden */
  121235. _cachedAnisotropicFilteringLevel: Nullable<number>;
  121236. /** @hidden */
  121237. _isDisabled: boolean;
  121238. /** @hidden */
  121239. _compression: Nullable<string>;
  121240. /** @hidden */
  121241. _generateStencilBuffer: boolean;
  121242. /** @hidden */
  121243. _generateDepthBuffer: boolean;
  121244. /** @hidden */
  121245. _comparisonFunction: number;
  121246. /** @hidden */
  121247. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  121248. /** @hidden */
  121249. _lodGenerationScale: number;
  121250. /** @hidden */
  121251. _lodGenerationOffset: number;
  121252. /** @hidden */
  121253. _depthStencilTexture: Nullable<InternalTexture>;
  121254. /** @hidden */
  121255. _colorTextureArray: Nullable<WebGLTexture>;
  121256. /** @hidden */
  121257. _depthStencilTextureArray: Nullable<WebGLTexture>;
  121258. /** @hidden */
  121259. _lodTextureHigh: Nullable<BaseTexture>;
  121260. /** @hidden */
  121261. _lodTextureMid: Nullable<BaseTexture>;
  121262. /** @hidden */
  121263. _lodTextureLow: Nullable<BaseTexture>;
  121264. /** @hidden */
  121265. _isRGBD: boolean;
  121266. /** @hidden */
  121267. _linearSpecularLOD: boolean;
  121268. /** @hidden */
  121269. _irradianceTexture: Nullable<BaseTexture>;
  121270. /** @hidden */
  121271. _webGLTexture: Nullable<WebGLTexture>;
  121272. /** @hidden */
  121273. _references: number;
  121274. /** @hidden */
  121275. _gammaSpace: Nullable<boolean>;
  121276. private _engine;
  121277. /**
  121278. * Gets the Engine the texture belongs to.
  121279. * @returns The babylon engine
  121280. */
  121281. getEngine(): ThinEngine;
  121282. /**
  121283. * Gets the data source type of the texture
  121284. */
  121285. get source(): InternalTextureSource;
  121286. /**
  121287. * Creates a new InternalTexture
  121288. * @param engine defines the engine to use
  121289. * @param source defines the type of data that will be used
  121290. * @param delayAllocation if the texture allocation should be delayed (default: false)
  121291. */
  121292. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  121293. /**
  121294. * Increments the number of references (ie. the number of Texture that point to it)
  121295. */
  121296. incrementReferences(): void;
  121297. /**
  121298. * Change the size of the texture (not the size of the content)
  121299. * @param width defines the new width
  121300. * @param height defines the new height
  121301. * @param depth defines the new depth (1 by default)
  121302. */
  121303. updateSize(width: int, height: int, depth?: int): void;
  121304. /** @hidden */
  121305. _rebuild(): void;
  121306. /** @hidden */
  121307. _swapAndDie(target: InternalTexture): void;
  121308. /**
  121309. * Dispose the current allocated resources
  121310. */
  121311. dispose(): void;
  121312. }
  121313. }
  121314. declare module BABYLON {
  121315. /**
  121316. * Interface used to present a loading screen while loading a scene
  121317. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121318. */
  121319. export interface ILoadingScreen {
  121320. /**
  121321. * Function called to display the loading screen
  121322. */
  121323. displayLoadingUI: () => void;
  121324. /**
  121325. * Function called to hide the loading screen
  121326. */
  121327. hideLoadingUI: () => void;
  121328. /**
  121329. * Gets or sets the color to use for the background
  121330. */
  121331. loadingUIBackgroundColor: string;
  121332. /**
  121333. * Gets or sets the text to display while loading
  121334. */
  121335. loadingUIText: string;
  121336. }
  121337. /**
  121338. * Class used for the default loading screen
  121339. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121340. */
  121341. export class DefaultLoadingScreen implements ILoadingScreen {
  121342. private _renderingCanvas;
  121343. private _loadingText;
  121344. private _loadingDivBackgroundColor;
  121345. private _loadingDiv;
  121346. private _loadingTextDiv;
  121347. /** Gets or sets the logo url to use for the default loading screen */
  121348. static DefaultLogoUrl: string;
  121349. /** Gets or sets the spinner url to use for the default loading screen */
  121350. static DefaultSpinnerUrl: string;
  121351. /**
  121352. * Creates a new default loading screen
  121353. * @param _renderingCanvas defines the canvas used to render the scene
  121354. * @param _loadingText defines the default text to display
  121355. * @param _loadingDivBackgroundColor defines the default background color
  121356. */
  121357. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  121358. /**
  121359. * Function called to display the loading screen
  121360. */
  121361. displayLoadingUI(): void;
  121362. /**
  121363. * Function called to hide the loading screen
  121364. */
  121365. hideLoadingUI(): void;
  121366. /**
  121367. * Gets or sets the text to display while loading
  121368. */
  121369. set loadingUIText(text: string);
  121370. get loadingUIText(): string;
  121371. /**
  121372. * Gets or sets the color to use for the background
  121373. */
  121374. get loadingUIBackgroundColor(): string;
  121375. set loadingUIBackgroundColor(color: string);
  121376. private _resizeLoadingUI;
  121377. }
  121378. }
  121379. declare module BABYLON {
  121380. /**
  121381. * Interface for any object that can request an animation frame
  121382. */
  121383. export interface ICustomAnimationFrameRequester {
  121384. /**
  121385. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  121386. */
  121387. renderFunction?: Function;
  121388. /**
  121389. * Called to request the next frame to render to
  121390. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  121391. */
  121392. requestAnimationFrame: Function;
  121393. /**
  121394. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  121395. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  121396. */
  121397. requestID?: number;
  121398. }
  121399. }
  121400. declare module BABYLON {
  121401. /**
  121402. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  121403. */
  121404. export class PerformanceMonitor {
  121405. private _enabled;
  121406. private _rollingFrameTime;
  121407. private _lastFrameTimeMs;
  121408. /**
  121409. * constructor
  121410. * @param frameSampleSize The number of samples required to saturate the sliding window
  121411. */
  121412. constructor(frameSampleSize?: number);
  121413. /**
  121414. * Samples current frame
  121415. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  121416. */
  121417. sampleFrame(timeMs?: number): void;
  121418. /**
  121419. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121420. */
  121421. get averageFrameTime(): number;
  121422. /**
  121423. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121424. */
  121425. get averageFrameTimeVariance(): number;
  121426. /**
  121427. * Returns the frame time of the most recent frame
  121428. */
  121429. get instantaneousFrameTime(): number;
  121430. /**
  121431. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  121432. */
  121433. get averageFPS(): number;
  121434. /**
  121435. * Returns the average framerate in frames per second using the most recent frame time
  121436. */
  121437. get instantaneousFPS(): number;
  121438. /**
  121439. * Returns true if enough samples have been taken to completely fill the sliding window
  121440. */
  121441. get isSaturated(): boolean;
  121442. /**
  121443. * Enables contributions to the sliding window sample set
  121444. */
  121445. enable(): void;
  121446. /**
  121447. * Disables contributions to the sliding window sample set
  121448. * Samples will not be interpolated over the disabled period
  121449. */
  121450. disable(): void;
  121451. /**
  121452. * Returns true if sampling is enabled
  121453. */
  121454. get isEnabled(): boolean;
  121455. /**
  121456. * Resets performance monitor
  121457. */
  121458. reset(): void;
  121459. }
  121460. /**
  121461. * RollingAverage
  121462. *
  121463. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  121464. */
  121465. export class RollingAverage {
  121466. /**
  121467. * Current average
  121468. */
  121469. average: number;
  121470. /**
  121471. * Current variance
  121472. */
  121473. variance: number;
  121474. protected _samples: Array<number>;
  121475. protected _sampleCount: number;
  121476. protected _pos: number;
  121477. protected _m2: number;
  121478. /**
  121479. * constructor
  121480. * @param length The number of samples required to saturate the sliding window
  121481. */
  121482. constructor(length: number);
  121483. /**
  121484. * Adds a sample to the sample set
  121485. * @param v The sample value
  121486. */
  121487. add(v: number): void;
  121488. /**
  121489. * Returns previously added values or null if outside of history or outside the sliding window domain
  121490. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  121491. * @return Value previously recorded with add() or null if outside of range
  121492. */
  121493. history(i: number): number;
  121494. /**
  121495. * Returns true if enough samples have been taken to completely fill the sliding window
  121496. * @return true if sample-set saturated
  121497. */
  121498. isSaturated(): boolean;
  121499. /**
  121500. * Resets the rolling average (equivalent to 0 samples taken so far)
  121501. */
  121502. reset(): void;
  121503. /**
  121504. * Wraps a value around the sample range boundaries
  121505. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  121506. * @return Wrapped position in sample range
  121507. */
  121508. protected _wrapPosition(i: number): number;
  121509. }
  121510. }
  121511. declare module BABYLON {
  121512. /**
  121513. * This class is used to track a performance counter which is number based.
  121514. * The user has access to many properties which give statistics of different nature.
  121515. *
  121516. * The implementer can track two kinds of Performance Counter: time and count.
  121517. * 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.
  121518. * 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.
  121519. */
  121520. export class PerfCounter {
  121521. /**
  121522. * Gets or sets a global boolean to turn on and off all the counters
  121523. */
  121524. static Enabled: boolean;
  121525. /**
  121526. * Returns the smallest value ever
  121527. */
  121528. get min(): number;
  121529. /**
  121530. * Returns the biggest value ever
  121531. */
  121532. get max(): number;
  121533. /**
  121534. * Returns the average value since the performance counter is running
  121535. */
  121536. get average(): number;
  121537. /**
  121538. * Returns the average value of the last second the counter was monitored
  121539. */
  121540. get lastSecAverage(): number;
  121541. /**
  121542. * Returns the current value
  121543. */
  121544. get current(): number;
  121545. /**
  121546. * Gets the accumulated total
  121547. */
  121548. get total(): number;
  121549. /**
  121550. * Gets the total value count
  121551. */
  121552. get count(): number;
  121553. /**
  121554. * Creates a new counter
  121555. */
  121556. constructor();
  121557. /**
  121558. * Call this method to start monitoring a new frame.
  121559. * 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.
  121560. */
  121561. fetchNewFrame(): void;
  121562. /**
  121563. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  121564. * @param newCount the count value to add to the monitored count
  121565. * @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.
  121566. */
  121567. addCount(newCount: number, fetchResult: boolean): void;
  121568. /**
  121569. * Start monitoring this performance counter
  121570. */
  121571. beginMonitoring(): void;
  121572. /**
  121573. * Compute the time lapsed since the previous beginMonitoring() call.
  121574. * @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
  121575. */
  121576. endMonitoring(newFrame?: boolean): void;
  121577. private _fetchResult;
  121578. private _startMonitoringTime;
  121579. private _min;
  121580. private _max;
  121581. private _average;
  121582. private _current;
  121583. private _totalValueCount;
  121584. private _totalAccumulated;
  121585. private _lastSecAverage;
  121586. private _lastSecAccumulated;
  121587. private _lastSecTime;
  121588. private _lastSecValueCount;
  121589. }
  121590. }
  121591. declare module BABYLON {
  121592. interface ThinEngine {
  121593. /** @hidden */
  121594. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  121595. }
  121596. }
  121597. declare module BABYLON {
  121598. /**
  121599. * Class used to work with sound analyzer using fast fourier transform (FFT)
  121600. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121601. */
  121602. export class Analyser {
  121603. /**
  121604. * Gets or sets the smoothing
  121605. * @ignorenaming
  121606. */
  121607. SMOOTHING: number;
  121608. /**
  121609. * Gets or sets the FFT table size
  121610. * @ignorenaming
  121611. */
  121612. FFT_SIZE: number;
  121613. /**
  121614. * Gets or sets the bar graph amplitude
  121615. * @ignorenaming
  121616. */
  121617. BARGRAPHAMPLITUDE: number;
  121618. /**
  121619. * Gets or sets the position of the debug canvas
  121620. * @ignorenaming
  121621. */
  121622. DEBUGCANVASPOS: {
  121623. x: number;
  121624. y: number;
  121625. };
  121626. /**
  121627. * Gets or sets the debug canvas size
  121628. * @ignorenaming
  121629. */
  121630. DEBUGCANVASSIZE: {
  121631. width: number;
  121632. height: number;
  121633. };
  121634. private _byteFreqs;
  121635. private _byteTime;
  121636. private _floatFreqs;
  121637. private _webAudioAnalyser;
  121638. private _debugCanvas;
  121639. private _debugCanvasContext;
  121640. private _scene;
  121641. private _registerFunc;
  121642. private _audioEngine;
  121643. /**
  121644. * Creates a new analyser
  121645. * @param scene defines hosting scene
  121646. */
  121647. constructor(scene: Scene);
  121648. /**
  121649. * Get the number of data values you will have to play with for the visualization
  121650. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  121651. * @returns a number
  121652. */
  121653. getFrequencyBinCount(): number;
  121654. /**
  121655. * Gets the current frequency data as a byte array
  121656. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  121657. * @returns a Uint8Array
  121658. */
  121659. getByteFrequencyData(): Uint8Array;
  121660. /**
  121661. * Gets the current waveform as a byte array
  121662. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  121663. * @returns a Uint8Array
  121664. */
  121665. getByteTimeDomainData(): Uint8Array;
  121666. /**
  121667. * Gets the current frequency data as a float array
  121668. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  121669. * @returns a Float32Array
  121670. */
  121671. getFloatFrequencyData(): Float32Array;
  121672. /**
  121673. * Renders the debug canvas
  121674. */
  121675. drawDebugCanvas(): void;
  121676. /**
  121677. * Stops rendering the debug canvas and removes it
  121678. */
  121679. stopDebugCanvas(): void;
  121680. /**
  121681. * Connects two audio nodes
  121682. * @param inputAudioNode defines first node to connect
  121683. * @param outputAudioNode defines second node to connect
  121684. */
  121685. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  121686. /**
  121687. * Releases all associated resources
  121688. */
  121689. dispose(): void;
  121690. }
  121691. }
  121692. declare module BABYLON {
  121693. /**
  121694. * This represents an audio engine and it is responsible
  121695. * to play, synchronize and analyse sounds throughout the application.
  121696. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121697. */
  121698. export interface IAudioEngine extends IDisposable {
  121699. /**
  121700. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  121701. */
  121702. readonly canUseWebAudio: boolean;
  121703. /**
  121704. * Gets the current AudioContext if available.
  121705. */
  121706. readonly audioContext: Nullable<AudioContext>;
  121707. /**
  121708. * The master gain node defines the global audio volume of your audio engine.
  121709. */
  121710. readonly masterGain: GainNode;
  121711. /**
  121712. * Gets whether or not mp3 are supported by your browser.
  121713. */
  121714. readonly isMP3supported: boolean;
  121715. /**
  121716. * Gets whether or not ogg are supported by your browser.
  121717. */
  121718. readonly isOGGsupported: boolean;
  121719. /**
  121720. * Defines if Babylon should emit a warning if WebAudio is not supported.
  121721. * @ignoreNaming
  121722. */
  121723. WarnedWebAudioUnsupported: boolean;
  121724. /**
  121725. * Defines if the audio engine relies on a custom unlocked button.
  121726. * In this case, the embedded button will not be displayed.
  121727. */
  121728. useCustomUnlockedButton: boolean;
  121729. /**
  121730. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  121731. */
  121732. readonly unlocked: boolean;
  121733. /**
  121734. * Event raised when audio has been unlocked on the browser.
  121735. */
  121736. onAudioUnlockedObservable: Observable<IAudioEngine>;
  121737. /**
  121738. * Event raised when audio has been locked on the browser.
  121739. */
  121740. onAudioLockedObservable: Observable<IAudioEngine>;
  121741. /**
  121742. * Flags the audio engine in Locked state.
  121743. * This happens due to new browser policies preventing audio to autoplay.
  121744. */
  121745. lock(): void;
  121746. /**
  121747. * Unlocks the audio engine once a user action has been done on the dom.
  121748. * This is helpful to resume play once browser policies have been satisfied.
  121749. */
  121750. unlock(): void;
  121751. /**
  121752. * Gets the global volume sets on the master gain.
  121753. * @returns the global volume if set or -1 otherwise
  121754. */
  121755. getGlobalVolume(): number;
  121756. /**
  121757. * Sets the global volume of your experience (sets on the master gain).
  121758. * @param newVolume Defines the new global volume of the application
  121759. */
  121760. setGlobalVolume(newVolume: number): void;
  121761. /**
  121762. * Connect the audio engine to an audio analyser allowing some amazing
  121763. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  121764. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  121765. * @param analyser The analyser to connect to the engine
  121766. */
  121767. connectToAnalyser(analyser: Analyser): void;
  121768. }
  121769. }
  121770. declare module BABYLON {
  121771. /**
  121772. * Defines the interface used by display changed events
  121773. */
  121774. export interface IDisplayChangedEventArgs {
  121775. /** Gets the vrDisplay object (if any) */
  121776. vrDisplay: Nullable<any>;
  121777. /** Gets a boolean indicating if webVR is supported */
  121778. vrSupported: boolean;
  121779. }
  121780. /**
  121781. * Defines the interface used by objects containing a viewport (like a camera)
  121782. */
  121783. interface IViewportOwnerLike {
  121784. /**
  121785. * Gets or sets the viewport
  121786. */
  121787. viewport: IViewportLike;
  121788. }
  121789. /**
  121790. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  121791. */
  121792. export class Engine extends ThinEngine {
  121793. /** Defines that alpha blending is disabled */
  121794. static readonly ALPHA_DISABLE: number;
  121795. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  121796. static readonly ALPHA_ADD: number;
  121797. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  121798. static readonly ALPHA_COMBINE: number;
  121799. /** Defines that alpha blending to DEST - SRC * DEST */
  121800. static readonly ALPHA_SUBTRACT: number;
  121801. /** Defines that alpha blending to SRC * DEST */
  121802. static readonly ALPHA_MULTIPLY: number;
  121803. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  121804. static readonly ALPHA_MAXIMIZED: number;
  121805. /** Defines that alpha blending to SRC + DEST */
  121806. static readonly ALPHA_ONEONE: number;
  121807. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  121808. static readonly ALPHA_PREMULTIPLIED: number;
  121809. /**
  121810. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  121811. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  121812. */
  121813. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  121814. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  121815. static readonly ALPHA_INTERPOLATE: number;
  121816. /**
  121817. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  121818. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  121819. */
  121820. static readonly ALPHA_SCREENMODE: number;
  121821. /** Defines that the ressource is not delayed*/
  121822. static readonly DELAYLOADSTATE_NONE: number;
  121823. /** Defines that the ressource was successfully delay loaded */
  121824. static readonly DELAYLOADSTATE_LOADED: number;
  121825. /** Defines that the ressource is currently delay loading */
  121826. static readonly DELAYLOADSTATE_LOADING: number;
  121827. /** Defines that the ressource is delayed and has not started loading */
  121828. static readonly DELAYLOADSTATE_NOTLOADED: number;
  121829. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  121830. static readonly NEVER: number;
  121831. /** 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 */
  121832. static readonly ALWAYS: number;
  121833. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  121834. static readonly LESS: number;
  121835. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  121836. static readonly EQUAL: number;
  121837. /** 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 */
  121838. static readonly LEQUAL: number;
  121839. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  121840. static readonly GREATER: number;
  121841. /** 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 */
  121842. static readonly GEQUAL: number;
  121843. /** 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 */
  121844. static readonly NOTEQUAL: number;
  121845. /** Passed to stencilOperation to specify that stencil value must be kept */
  121846. static readonly KEEP: number;
  121847. /** Passed to stencilOperation to specify that stencil value must be replaced */
  121848. static readonly REPLACE: number;
  121849. /** Passed to stencilOperation to specify that stencil value must be incremented */
  121850. static readonly INCR: number;
  121851. /** Passed to stencilOperation to specify that stencil value must be decremented */
  121852. static readonly DECR: number;
  121853. /** Passed to stencilOperation to specify that stencil value must be inverted */
  121854. static readonly INVERT: number;
  121855. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  121856. static readonly INCR_WRAP: number;
  121857. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  121858. static readonly DECR_WRAP: number;
  121859. /** Texture is not repeating outside of 0..1 UVs */
  121860. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  121861. /** Texture is repeating outside of 0..1 UVs */
  121862. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  121863. /** Texture is repeating and mirrored */
  121864. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  121865. /** ALPHA */
  121866. static readonly TEXTUREFORMAT_ALPHA: number;
  121867. /** LUMINANCE */
  121868. static readonly TEXTUREFORMAT_LUMINANCE: number;
  121869. /** LUMINANCE_ALPHA */
  121870. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  121871. /** RGB */
  121872. static readonly TEXTUREFORMAT_RGB: number;
  121873. /** RGBA */
  121874. static readonly TEXTUREFORMAT_RGBA: number;
  121875. /** RED */
  121876. static readonly TEXTUREFORMAT_RED: number;
  121877. /** RED (2nd reference) */
  121878. static readonly TEXTUREFORMAT_R: number;
  121879. /** RG */
  121880. static readonly TEXTUREFORMAT_RG: number;
  121881. /** RED_INTEGER */
  121882. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  121883. /** RED_INTEGER (2nd reference) */
  121884. static readonly TEXTUREFORMAT_R_INTEGER: number;
  121885. /** RG_INTEGER */
  121886. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  121887. /** RGB_INTEGER */
  121888. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  121889. /** RGBA_INTEGER */
  121890. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  121891. /** UNSIGNED_BYTE */
  121892. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  121893. /** UNSIGNED_BYTE (2nd reference) */
  121894. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  121895. /** FLOAT */
  121896. static readonly TEXTURETYPE_FLOAT: number;
  121897. /** HALF_FLOAT */
  121898. static readonly TEXTURETYPE_HALF_FLOAT: number;
  121899. /** BYTE */
  121900. static readonly TEXTURETYPE_BYTE: number;
  121901. /** SHORT */
  121902. static readonly TEXTURETYPE_SHORT: number;
  121903. /** UNSIGNED_SHORT */
  121904. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  121905. /** INT */
  121906. static readonly TEXTURETYPE_INT: number;
  121907. /** UNSIGNED_INT */
  121908. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  121909. /** UNSIGNED_SHORT_4_4_4_4 */
  121910. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  121911. /** UNSIGNED_SHORT_5_5_5_1 */
  121912. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  121913. /** UNSIGNED_SHORT_5_6_5 */
  121914. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  121915. /** UNSIGNED_INT_2_10_10_10_REV */
  121916. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  121917. /** UNSIGNED_INT_24_8 */
  121918. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  121919. /** UNSIGNED_INT_10F_11F_11F_REV */
  121920. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  121921. /** UNSIGNED_INT_5_9_9_9_REV */
  121922. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  121923. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  121924. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121925. /** nearest is mag = nearest and min = nearest and mip = linear */
  121926. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  121927. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121928. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  121929. /** Trilinear is mag = linear and min = linear and mip = linear */
  121930. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  121931. /** nearest is mag = nearest and min = nearest and mip = linear */
  121932. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  121933. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121934. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  121935. /** Trilinear is mag = linear and min = linear and mip = linear */
  121936. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  121937. /** mag = nearest and min = nearest and mip = nearest */
  121938. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  121939. /** mag = nearest and min = linear and mip = nearest */
  121940. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  121941. /** mag = nearest and min = linear and mip = linear */
  121942. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  121943. /** mag = nearest and min = linear and mip = none */
  121944. static readonly TEXTURE_NEAREST_LINEAR: number;
  121945. /** mag = nearest and min = nearest and mip = none */
  121946. static readonly TEXTURE_NEAREST_NEAREST: number;
  121947. /** mag = linear and min = nearest and mip = nearest */
  121948. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  121949. /** mag = linear and min = nearest and mip = linear */
  121950. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  121951. /** mag = linear and min = linear and mip = none */
  121952. static readonly TEXTURE_LINEAR_LINEAR: number;
  121953. /** mag = linear and min = nearest and mip = none */
  121954. static readonly TEXTURE_LINEAR_NEAREST: number;
  121955. /** Explicit coordinates mode */
  121956. static readonly TEXTURE_EXPLICIT_MODE: number;
  121957. /** Spherical coordinates mode */
  121958. static readonly TEXTURE_SPHERICAL_MODE: number;
  121959. /** Planar coordinates mode */
  121960. static readonly TEXTURE_PLANAR_MODE: number;
  121961. /** Cubic coordinates mode */
  121962. static readonly TEXTURE_CUBIC_MODE: number;
  121963. /** Projection coordinates mode */
  121964. static readonly TEXTURE_PROJECTION_MODE: number;
  121965. /** Skybox coordinates mode */
  121966. static readonly TEXTURE_SKYBOX_MODE: number;
  121967. /** Inverse Cubic coordinates mode */
  121968. static readonly TEXTURE_INVCUBIC_MODE: number;
  121969. /** Equirectangular coordinates mode */
  121970. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  121971. /** Equirectangular Fixed coordinates mode */
  121972. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  121973. /** Equirectangular Fixed Mirrored coordinates mode */
  121974. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  121975. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  121976. static readonly SCALEMODE_FLOOR: number;
  121977. /** Defines that texture rescaling will look for the nearest power of 2 size */
  121978. static readonly SCALEMODE_NEAREST: number;
  121979. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  121980. static readonly SCALEMODE_CEILING: number;
  121981. /**
  121982. * Returns the current npm package of the sdk
  121983. */
  121984. static get NpmPackage(): string;
  121985. /**
  121986. * Returns the current version of the framework
  121987. */
  121988. static get Version(): string;
  121989. /** Gets the list of created engines */
  121990. static get Instances(): Engine[];
  121991. /**
  121992. * Gets the latest created engine
  121993. */
  121994. static get LastCreatedEngine(): Nullable<Engine>;
  121995. /**
  121996. * Gets the latest created scene
  121997. */
  121998. static get LastCreatedScene(): Nullable<Scene>;
  121999. /**
  122000. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  122001. * @param flag defines which part of the materials must be marked as dirty
  122002. * @param predicate defines a predicate used to filter which materials should be affected
  122003. */
  122004. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  122005. /**
  122006. * Method called to create the default loading screen.
  122007. * This can be overriden in your own app.
  122008. * @param canvas The rendering canvas element
  122009. * @returns The loading screen
  122010. */
  122011. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  122012. /**
  122013. * Method called to create the default rescale post process on each engine.
  122014. */
  122015. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  122016. /**
  122017. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  122018. **/
  122019. enableOfflineSupport: boolean;
  122020. /**
  122021. * 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)
  122022. **/
  122023. disableManifestCheck: boolean;
  122024. /**
  122025. * Gets the list of created scenes
  122026. */
  122027. scenes: Scene[];
  122028. /**
  122029. * Event raised when a new scene is created
  122030. */
  122031. onNewSceneAddedObservable: Observable<Scene>;
  122032. /**
  122033. * Gets the list of created postprocesses
  122034. */
  122035. postProcesses: PostProcess[];
  122036. /**
  122037. * Gets a boolean indicating if the pointer is currently locked
  122038. */
  122039. isPointerLock: boolean;
  122040. /**
  122041. * Observable event triggered each time the rendering canvas is resized
  122042. */
  122043. onResizeObservable: Observable<Engine>;
  122044. /**
  122045. * Observable event triggered each time the canvas loses focus
  122046. */
  122047. onCanvasBlurObservable: Observable<Engine>;
  122048. /**
  122049. * Observable event triggered each time the canvas gains focus
  122050. */
  122051. onCanvasFocusObservable: Observable<Engine>;
  122052. /**
  122053. * Observable event triggered each time the canvas receives pointerout event
  122054. */
  122055. onCanvasPointerOutObservable: Observable<PointerEvent>;
  122056. /**
  122057. * Observable raised when the engine begins a new frame
  122058. */
  122059. onBeginFrameObservable: Observable<Engine>;
  122060. /**
  122061. * If set, will be used to request the next animation frame for the render loop
  122062. */
  122063. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  122064. /**
  122065. * Observable raised when the engine ends the current frame
  122066. */
  122067. onEndFrameObservable: Observable<Engine>;
  122068. /**
  122069. * Observable raised when the engine is about to compile a shader
  122070. */
  122071. onBeforeShaderCompilationObservable: Observable<Engine>;
  122072. /**
  122073. * Observable raised when the engine has jsut compiled a shader
  122074. */
  122075. onAfterShaderCompilationObservable: Observable<Engine>;
  122076. /**
  122077. * Gets the audio engine
  122078. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122079. * @ignorenaming
  122080. */
  122081. static audioEngine: IAudioEngine;
  122082. /**
  122083. * Default AudioEngine factory responsible of creating the Audio Engine.
  122084. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  122085. */
  122086. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  122087. /**
  122088. * Default offline support factory responsible of creating a tool used to store data locally.
  122089. * By default, this will create a Database object if the workload has been embedded.
  122090. */
  122091. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  122092. private _loadingScreen;
  122093. private _pointerLockRequested;
  122094. private _rescalePostProcess;
  122095. private _deterministicLockstep;
  122096. private _lockstepMaxSteps;
  122097. private _timeStep;
  122098. protected get _supportsHardwareTextureRescaling(): boolean;
  122099. private _fps;
  122100. private _deltaTime;
  122101. /** @hidden */
  122102. _drawCalls: PerfCounter;
  122103. /** 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 */
  122104. canvasTabIndex: number;
  122105. /**
  122106. * Turn this value on if you want to pause FPS computation when in background
  122107. */
  122108. disablePerformanceMonitorInBackground: boolean;
  122109. private _performanceMonitor;
  122110. /**
  122111. * Gets the performance monitor attached to this engine
  122112. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122113. */
  122114. get performanceMonitor(): PerformanceMonitor;
  122115. private _onFocus;
  122116. private _onBlur;
  122117. private _onCanvasPointerOut;
  122118. private _onCanvasBlur;
  122119. private _onCanvasFocus;
  122120. private _onFullscreenChange;
  122121. private _onPointerLockChange;
  122122. /**
  122123. * Gets the HTML element used to attach event listeners
  122124. * @returns a HTML element
  122125. */
  122126. getInputElement(): Nullable<HTMLElement>;
  122127. /**
  122128. * Creates a new engine
  122129. * @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
  122130. * @param antialias defines enable antialiasing (default: false)
  122131. * @param options defines further options to be sent to the getContext() function
  122132. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  122133. */
  122134. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  122135. /**
  122136. * Gets current aspect ratio
  122137. * @param viewportOwner defines the camera to use to get the aspect ratio
  122138. * @param useScreen defines if screen size must be used (or the current render target if any)
  122139. * @returns a number defining the aspect ratio
  122140. */
  122141. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  122142. /**
  122143. * Gets current screen aspect ratio
  122144. * @returns a number defining the aspect ratio
  122145. */
  122146. getScreenAspectRatio(): number;
  122147. /**
  122148. * Gets the client rect of the HTML canvas attached with the current webGL context
  122149. * @returns a client rectanglee
  122150. */
  122151. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  122152. /**
  122153. * Gets the client rect of the HTML element used for events
  122154. * @returns a client rectanglee
  122155. */
  122156. getInputElementClientRect(): Nullable<ClientRect>;
  122157. /**
  122158. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  122159. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122160. * @returns true if engine is in deterministic lock step mode
  122161. */
  122162. isDeterministicLockStep(): boolean;
  122163. /**
  122164. * Gets the max steps when engine is running in deterministic lock step
  122165. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122166. * @returns the max steps
  122167. */
  122168. getLockstepMaxSteps(): number;
  122169. /**
  122170. * Returns the time in ms between steps when using deterministic lock step.
  122171. * @returns time step in (ms)
  122172. */
  122173. getTimeStep(): number;
  122174. /**
  122175. * Force the mipmap generation for the given render target texture
  122176. * @param texture defines the render target texture to use
  122177. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  122178. */
  122179. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  122180. /** States */
  122181. /**
  122182. * Set various states to the webGL context
  122183. * @param culling defines backface culling state
  122184. * @param zOffset defines the value to apply to zOffset (0 by default)
  122185. * @param force defines if states must be applied even if cache is up to date
  122186. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  122187. */
  122188. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122189. /**
  122190. * Set the z offset to apply to current rendering
  122191. * @param value defines the offset to apply
  122192. */
  122193. setZOffset(value: number): void;
  122194. /**
  122195. * Gets the current value of the zOffset
  122196. * @returns the current zOffset state
  122197. */
  122198. getZOffset(): number;
  122199. /**
  122200. * Enable or disable depth buffering
  122201. * @param enable defines the state to set
  122202. */
  122203. setDepthBuffer(enable: boolean): void;
  122204. /**
  122205. * Gets a boolean indicating if depth writing is enabled
  122206. * @returns the current depth writing state
  122207. */
  122208. getDepthWrite(): boolean;
  122209. /**
  122210. * Enable or disable depth writing
  122211. * @param enable defines the state to set
  122212. */
  122213. setDepthWrite(enable: boolean): void;
  122214. /**
  122215. * Gets a boolean indicating if stencil buffer is enabled
  122216. * @returns the current stencil buffer state
  122217. */
  122218. getStencilBuffer(): boolean;
  122219. /**
  122220. * Enable or disable the stencil buffer
  122221. * @param enable defines if the stencil buffer must be enabled or disabled
  122222. */
  122223. setStencilBuffer(enable: boolean): void;
  122224. /**
  122225. * Gets the current stencil mask
  122226. * @returns a number defining the new stencil mask to use
  122227. */
  122228. getStencilMask(): number;
  122229. /**
  122230. * Sets the current stencil mask
  122231. * @param mask defines the new stencil mask to use
  122232. */
  122233. setStencilMask(mask: number): void;
  122234. /**
  122235. * Gets the current stencil function
  122236. * @returns a number defining the stencil function to use
  122237. */
  122238. getStencilFunction(): number;
  122239. /**
  122240. * Gets the current stencil reference value
  122241. * @returns a number defining the stencil reference value to use
  122242. */
  122243. getStencilFunctionReference(): number;
  122244. /**
  122245. * Gets the current stencil mask
  122246. * @returns a number defining the stencil mask to use
  122247. */
  122248. getStencilFunctionMask(): number;
  122249. /**
  122250. * Sets the current stencil function
  122251. * @param stencilFunc defines the new stencil function to use
  122252. */
  122253. setStencilFunction(stencilFunc: number): void;
  122254. /**
  122255. * Sets the current stencil reference
  122256. * @param reference defines the new stencil reference to use
  122257. */
  122258. setStencilFunctionReference(reference: number): void;
  122259. /**
  122260. * Sets the current stencil mask
  122261. * @param mask defines the new stencil mask to use
  122262. */
  122263. setStencilFunctionMask(mask: number): void;
  122264. /**
  122265. * Gets the current stencil operation when stencil fails
  122266. * @returns a number defining stencil operation to use when stencil fails
  122267. */
  122268. getStencilOperationFail(): number;
  122269. /**
  122270. * Gets the current stencil operation when depth fails
  122271. * @returns a number defining stencil operation to use when depth fails
  122272. */
  122273. getStencilOperationDepthFail(): number;
  122274. /**
  122275. * Gets the current stencil operation when stencil passes
  122276. * @returns a number defining stencil operation to use when stencil passes
  122277. */
  122278. getStencilOperationPass(): number;
  122279. /**
  122280. * Sets the stencil operation to use when stencil fails
  122281. * @param operation defines the stencil operation to use when stencil fails
  122282. */
  122283. setStencilOperationFail(operation: number): void;
  122284. /**
  122285. * Sets the stencil operation to use when depth fails
  122286. * @param operation defines the stencil operation to use when depth fails
  122287. */
  122288. setStencilOperationDepthFail(operation: number): void;
  122289. /**
  122290. * Sets the stencil operation to use when stencil passes
  122291. * @param operation defines the stencil operation to use when stencil passes
  122292. */
  122293. setStencilOperationPass(operation: number): void;
  122294. /**
  122295. * Sets a boolean indicating if the dithering state is enabled or disabled
  122296. * @param value defines the dithering state
  122297. */
  122298. setDitheringState(value: boolean): void;
  122299. /**
  122300. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  122301. * @param value defines the rasterizer state
  122302. */
  122303. setRasterizerState(value: boolean): void;
  122304. /**
  122305. * Gets the current depth function
  122306. * @returns a number defining the depth function
  122307. */
  122308. getDepthFunction(): Nullable<number>;
  122309. /**
  122310. * Sets the current depth function
  122311. * @param depthFunc defines the function to use
  122312. */
  122313. setDepthFunction(depthFunc: number): void;
  122314. /**
  122315. * Sets the current depth function to GREATER
  122316. */
  122317. setDepthFunctionToGreater(): void;
  122318. /**
  122319. * Sets the current depth function to GEQUAL
  122320. */
  122321. setDepthFunctionToGreaterOrEqual(): void;
  122322. /**
  122323. * Sets the current depth function to LESS
  122324. */
  122325. setDepthFunctionToLess(): void;
  122326. /**
  122327. * Sets the current depth function to LEQUAL
  122328. */
  122329. setDepthFunctionToLessOrEqual(): void;
  122330. private _cachedStencilBuffer;
  122331. private _cachedStencilFunction;
  122332. private _cachedStencilMask;
  122333. private _cachedStencilOperationPass;
  122334. private _cachedStencilOperationFail;
  122335. private _cachedStencilOperationDepthFail;
  122336. private _cachedStencilReference;
  122337. /**
  122338. * Caches the the state of the stencil buffer
  122339. */
  122340. cacheStencilState(): void;
  122341. /**
  122342. * Restores the state of the stencil buffer
  122343. */
  122344. restoreStencilState(): void;
  122345. /**
  122346. * Directly set the WebGL Viewport
  122347. * @param x defines the x coordinate of the viewport (in screen space)
  122348. * @param y defines the y coordinate of the viewport (in screen space)
  122349. * @param width defines the width of the viewport (in screen space)
  122350. * @param height defines the height of the viewport (in screen space)
  122351. * @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
  122352. */
  122353. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  122354. /**
  122355. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  122356. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122357. * @param y defines the y-coordinate of the corner of the clear rectangle
  122358. * @param width defines the width of the clear rectangle
  122359. * @param height defines the height of the clear rectangle
  122360. * @param clearColor defines the clear color
  122361. */
  122362. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  122363. /**
  122364. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  122365. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122366. * @param y defines the y-coordinate of the corner of the clear rectangle
  122367. * @param width defines the width of the clear rectangle
  122368. * @param height defines the height of the clear rectangle
  122369. */
  122370. enableScissor(x: number, y: number, width: number, height: number): void;
  122371. /**
  122372. * Disable previously set scissor test rectangle
  122373. */
  122374. disableScissor(): void;
  122375. protected _reportDrawCall(): void;
  122376. /**
  122377. * Initializes a webVR display and starts listening to display change events
  122378. * The onVRDisplayChangedObservable will be notified upon these changes
  122379. * @returns The onVRDisplayChangedObservable
  122380. */
  122381. initWebVR(): Observable<IDisplayChangedEventArgs>;
  122382. /** @hidden */
  122383. _prepareVRComponent(): void;
  122384. /** @hidden */
  122385. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  122386. /** @hidden */
  122387. _submitVRFrame(): void;
  122388. /**
  122389. * Call this function to leave webVR mode
  122390. * Will do nothing if webVR is not supported or if there is no webVR device
  122391. * @see https://doc.babylonjs.com/how_to/webvr_camera
  122392. */
  122393. disableVR(): void;
  122394. /**
  122395. * Gets a boolean indicating that the system is in VR mode and is presenting
  122396. * @returns true if VR mode is engaged
  122397. */
  122398. isVRPresenting(): boolean;
  122399. /** @hidden */
  122400. _requestVRFrame(): void;
  122401. /** @hidden */
  122402. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  122403. /**
  122404. * Gets the source code of the vertex shader associated with a specific webGL program
  122405. * @param program defines the program to use
  122406. * @returns a string containing the source code of the vertex shader associated with the program
  122407. */
  122408. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  122409. /**
  122410. * Gets the source code of the fragment shader associated with a specific webGL program
  122411. * @param program defines the program to use
  122412. * @returns a string containing the source code of the fragment shader associated with the program
  122413. */
  122414. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  122415. /**
  122416. * Sets a depth stencil texture from a render target to the according uniform.
  122417. * @param channel The texture channel
  122418. * @param uniform The uniform to set
  122419. * @param texture The render target texture containing the depth stencil texture to apply
  122420. */
  122421. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  122422. /**
  122423. * Sets a texture to the webGL context from a postprocess
  122424. * @param channel defines the channel to use
  122425. * @param postProcess defines the source postprocess
  122426. */
  122427. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  122428. /**
  122429. * Binds the output of the passed in post process to the texture channel specified
  122430. * @param channel The channel the texture should be bound to
  122431. * @param postProcess The post process which's output should be bound
  122432. */
  122433. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  122434. protected _rebuildBuffers(): void;
  122435. /** @hidden */
  122436. _renderFrame(): void;
  122437. _renderLoop(): void;
  122438. /** @hidden */
  122439. _renderViews(): boolean;
  122440. /**
  122441. * Toggle full screen mode
  122442. * @param requestPointerLock defines if a pointer lock should be requested from the user
  122443. */
  122444. switchFullscreen(requestPointerLock: boolean): void;
  122445. /**
  122446. * Enters full screen mode
  122447. * @param requestPointerLock defines if a pointer lock should be requested from the user
  122448. */
  122449. enterFullscreen(requestPointerLock: boolean): void;
  122450. /**
  122451. * Exits full screen mode
  122452. */
  122453. exitFullscreen(): void;
  122454. /**
  122455. * Enters Pointerlock mode
  122456. */
  122457. enterPointerlock(): void;
  122458. /**
  122459. * Exits Pointerlock mode
  122460. */
  122461. exitPointerlock(): void;
  122462. /**
  122463. * Begin a new frame
  122464. */
  122465. beginFrame(): void;
  122466. /**
  122467. * Enf the current frame
  122468. */
  122469. endFrame(): void;
  122470. resize(): void;
  122471. /**
  122472. * Force a specific size of the canvas
  122473. * @param width defines the new canvas' width
  122474. * @param height defines the new canvas' height
  122475. * @returns true if the size was changed
  122476. */
  122477. setSize(width: number, height: number): boolean;
  122478. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122479. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  122480. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  122481. _releaseTexture(texture: InternalTexture): void;
  122482. /**
  122483. * @hidden
  122484. * Rescales a texture
  122485. * @param source input texutre
  122486. * @param destination destination texture
  122487. * @param scene scene to use to render the resize
  122488. * @param internalFormat format to use when resizing
  122489. * @param onComplete callback to be called when resize has completed
  122490. */
  122491. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  122492. /**
  122493. * Gets the current framerate
  122494. * @returns a number representing the framerate
  122495. */
  122496. getFps(): number;
  122497. /**
  122498. * Gets the time spent between current and previous frame
  122499. * @returns a number representing the delta time in ms
  122500. */
  122501. getDeltaTime(): number;
  122502. private _measureFps;
  122503. /** @hidden */
  122504. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  122505. /**
  122506. * Updates the sample count of a render target texture
  122507. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  122508. * @param texture defines the texture to update
  122509. * @param samples defines the sample count to set
  122510. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  122511. */
  122512. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  122513. /**
  122514. * Updates a depth texture Comparison Mode and Function.
  122515. * If the comparison Function is equal to 0, the mode will be set to none.
  122516. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  122517. * @param texture The texture to set the comparison function for
  122518. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  122519. */
  122520. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  122521. /**
  122522. * Creates a webGL buffer to use with instanciation
  122523. * @param capacity defines the size of the buffer
  122524. * @returns the webGL buffer
  122525. */
  122526. createInstancesBuffer(capacity: number): DataBuffer;
  122527. /**
  122528. * Delete a webGL buffer used with instanciation
  122529. * @param buffer defines the webGL buffer to delete
  122530. */
  122531. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  122532. private _clientWaitAsync;
  122533. /** @hidden */
  122534. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  122535. dispose(): void;
  122536. private _disableTouchAction;
  122537. /**
  122538. * Display the loading screen
  122539. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122540. */
  122541. displayLoadingUI(): void;
  122542. /**
  122543. * Hide the loading screen
  122544. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122545. */
  122546. hideLoadingUI(): void;
  122547. /**
  122548. * Gets the current loading screen object
  122549. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122550. */
  122551. get loadingScreen(): ILoadingScreen;
  122552. /**
  122553. * Sets the current loading screen object
  122554. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122555. */
  122556. set loadingScreen(loadingScreen: ILoadingScreen);
  122557. /**
  122558. * Sets the current loading screen text
  122559. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122560. */
  122561. set loadingUIText(text: string);
  122562. /**
  122563. * Sets the current loading screen background color
  122564. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122565. */
  122566. set loadingUIBackgroundColor(color: string);
  122567. /** Pointerlock and fullscreen */
  122568. /**
  122569. * Ask the browser to promote the current element to pointerlock mode
  122570. * @param element defines the DOM element to promote
  122571. */
  122572. static _RequestPointerlock(element: HTMLElement): void;
  122573. /**
  122574. * Asks the browser to exit pointerlock mode
  122575. */
  122576. static _ExitPointerlock(): void;
  122577. /**
  122578. * Ask the browser to promote the current element to fullscreen rendering mode
  122579. * @param element defines the DOM element to promote
  122580. */
  122581. static _RequestFullscreen(element: HTMLElement): void;
  122582. /**
  122583. * Asks the browser to exit fullscreen mode
  122584. */
  122585. static _ExitFullscreen(): void;
  122586. }
  122587. }
  122588. declare module BABYLON {
  122589. /**
  122590. * The engine store class is responsible to hold all the instances of Engine and Scene created
  122591. * during the life time of the application.
  122592. */
  122593. export class EngineStore {
  122594. /** Gets the list of created engines */
  122595. static Instances: Engine[];
  122596. /** @hidden */
  122597. static _LastCreatedScene: Nullable<Scene>;
  122598. /**
  122599. * Gets the latest created engine
  122600. */
  122601. static get LastCreatedEngine(): Nullable<Engine>;
  122602. /**
  122603. * Gets the latest created scene
  122604. */
  122605. static get LastCreatedScene(): Nullable<Scene>;
  122606. /**
  122607. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122608. * @ignorenaming
  122609. */
  122610. static UseFallbackTexture: boolean;
  122611. /**
  122612. * Texture content used if a texture cannot loaded
  122613. * @ignorenaming
  122614. */
  122615. static FallbackTexture: string;
  122616. }
  122617. }
  122618. declare module BABYLON {
  122619. /**
  122620. * Helper class that provides a small promise polyfill
  122621. */
  122622. export class PromisePolyfill {
  122623. /**
  122624. * Static function used to check if the polyfill is required
  122625. * If this is the case then the function will inject the polyfill to window.Promise
  122626. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  122627. */
  122628. static Apply(force?: boolean): void;
  122629. }
  122630. }
  122631. declare module BABYLON {
  122632. /**
  122633. * Interface for screenshot methods with describe argument called `size` as object with options
  122634. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  122635. */
  122636. export interface IScreenshotSize {
  122637. /**
  122638. * number in pixels for canvas height
  122639. */
  122640. height?: number;
  122641. /**
  122642. * multiplier allowing render at a higher or lower resolution
  122643. * If value is defined then height and width will be ignored and taken from camera
  122644. */
  122645. precision?: number;
  122646. /**
  122647. * number in pixels for canvas width
  122648. */
  122649. width?: number;
  122650. }
  122651. }
  122652. declare module BABYLON {
  122653. interface IColor4Like {
  122654. r: float;
  122655. g: float;
  122656. b: float;
  122657. a: float;
  122658. }
  122659. /**
  122660. * Class containing a set of static utilities functions
  122661. */
  122662. export class Tools {
  122663. /**
  122664. * Gets or sets the base URL to use to load assets
  122665. */
  122666. static get BaseUrl(): string;
  122667. static set BaseUrl(value: string);
  122668. /**
  122669. * Enable/Disable Custom HTTP Request Headers globally.
  122670. * default = false
  122671. * @see CustomRequestHeaders
  122672. */
  122673. static UseCustomRequestHeaders: boolean;
  122674. /**
  122675. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  122676. * i.e. when loading files, where the server/service expects an Authorization header
  122677. */
  122678. static CustomRequestHeaders: {
  122679. [key: string]: string;
  122680. };
  122681. /**
  122682. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  122683. */
  122684. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  122685. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  122686. /**
  122687. * Default behaviour for cors in the application.
  122688. * It can be a string if the expected behavior is identical in the entire app.
  122689. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  122690. */
  122691. static get CorsBehavior(): string | ((url: string | string[]) => string);
  122692. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  122693. /**
  122694. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122695. * @ignorenaming
  122696. */
  122697. static get UseFallbackTexture(): boolean;
  122698. static set UseFallbackTexture(value: boolean);
  122699. /**
  122700. * Use this object to register external classes like custom textures or material
  122701. * to allow the laoders to instantiate them
  122702. */
  122703. static get RegisteredExternalClasses(): {
  122704. [key: string]: Object;
  122705. };
  122706. static set RegisteredExternalClasses(classes: {
  122707. [key: string]: Object;
  122708. });
  122709. /**
  122710. * Texture content used if a texture cannot loaded
  122711. * @ignorenaming
  122712. */
  122713. static get fallbackTexture(): string;
  122714. static set fallbackTexture(value: string);
  122715. /**
  122716. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  122717. * @param u defines the coordinate on X axis
  122718. * @param v defines the coordinate on Y axis
  122719. * @param width defines the width of the source data
  122720. * @param height defines the height of the source data
  122721. * @param pixels defines the source byte array
  122722. * @param color defines the output color
  122723. */
  122724. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  122725. /**
  122726. * Interpolates between a and b via alpha
  122727. * @param a The lower value (returned when alpha = 0)
  122728. * @param b The upper value (returned when alpha = 1)
  122729. * @param alpha The interpolation-factor
  122730. * @return The mixed value
  122731. */
  122732. static Mix(a: number, b: number, alpha: number): number;
  122733. /**
  122734. * Tries to instantiate a new object from a given class name
  122735. * @param className defines the class name to instantiate
  122736. * @returns the new object or null if the system was not able to do the instantiation
  122737. */
  122738. static Instantiate(className: string): any;
  122739. /**
  122740. * Provides a slice function that will work even on IE
  122741. * @param data defines the array to slice
  122742. * @param start defines the start of the data (optional)
  122743. * @param end defines the end of the data (optional)
  122744. * @returns the new sliced array
  122745. */
  122746. static Slice<T>(data: T, start?: number, end?: number): T;
  122747. /**
  122748. * Provides a slice function that will work even on IE
  122749. * The difference between this and Slice is that this will force-convert to array
  122750. * @param data defines the array to slice
  122751. * @param start defines the start of the data (optional)
  122752. * @param end defines the end of the data (optional)
  122753. * @returns the new sliced array
  122754. */
  122755. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  122756. /**
  122757. * Polyfill for setImmediate
  122758. * @param action defines the action to execute after the current execution block
  122759. */
  122760. static SetImmediate(action: () => void): void;
  122761. /**
  122762. * Function indicating if a number is an exponent of 2
  122763. * @param value defines the value to test
  122764. * @returns true if the value is an exponent of 2
  122765. */
  122766. static IsExponentOfTwo(value: number): boolean;
  122767. private static _tmpFloatArray;
  122768. /**
  122769. * Returns the nearest 32-bit single precision float representation of a Number
  122770. * @param value A Number. If the parameter is of a different type, it will get converted
  122771. * to a number or to NaN if it cannot be converted
  122772. * @returns number
  122773. */
  122774. static FloatRound(value: number): number;
  122775. /**
  122776. * Extracts the filename from a path
  122777. * @param path defines the path to use
  122778. * @returns the filename
  122779. */
  122780. static GetFilename(path: string): string;
  122781. /**
  122782. * Extracts the "folder" part of a path (everything before the filename).
  122783. * @param uri The URI to extract the info from
  122784. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  122785. * @returns The "folder" part of the path
  122786. */
  122787. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  122788. /**
  122789. * Extracts text content from a DOM element hierarchy
  122790. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  122791. */
  122792. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  122793. /**
  122794. * Convert an angle in radians to degrees
  122795. * @param angle defines the angle to convert
  122796. * @returns the angle in degrees
  122797. */
  122798. static ToDegrees(angle: number): number;
  122799. /**
  122800. * Convert an angle in degrees to radians
  122801. * @param angle defines the angle to convert
  122802. * @returns the angle in radians
  122803. */
  122804. static ToRadians(angle: number): number;
  122805. /**
  122806. * Returns an array if obj is not an array
  122807. * @param obj defines the object to evaluate as an array
  122808. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  122809. * @returns either obj directly if obj is an array or a new array containing obj
  122810. */
  122811. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  122812. /**
  122813. * Gets the pointer prefix to use
  122814. * @param engine defines the engine we are finding the prefix for
  122815. * @returns "pointer" if touch is enabled. Else returns "mouse"
  122816. */
  122817. static GetPointerPrefix(engine: Engine): string;
  122818. /**
  122819. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  122820. * @param url define the url we are trying
  122821. * @param element define the dom element where to configure the cors policy
  122822. */
  122823. static SetCorsBehavior(url: string | string[], element: {
  122824. crossOrigin: string | null;
  122825. }): void;
  122826. /**
  122827. * Removes unwanted characters from an url
  122828. * @param url defines the url to clean
  122829. * @returns the cleaned url
  122830. */
  122831. static CleanUrl(url: string): string;
  122832. /**
  122833. * Gets or sets a function used to pre-process url before using them to load assets
  122834. */
  122835. static get PreprocessUrl(): (url: string) => string;
  122836. static set PreprocessUrl(processor: (url: string) => string);
  122837. /**
  122838. * Loads an image as an HTMLImageElement.
  122839. * @param input url string, ArrayBuffer, or Blob to load
  122840. * @param onLoad callback called when the image successfully loads
  122841. * @param onError callback called when the image fails to load
  122842. * @param offlineProvider offline provider for caching
  122843. * @param mimeType optional mime type
  122844. * @returns the HTMLImageElement of the loaded image
  122845. */
  122846. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  122847. /**
  122848. * Loads a file from a url
  122849. * @param url url string, ArrayBuffer, or Blob to load
  122850. * @param onSuccess callback called when the file successfully loads
  122851. * @param onProgress callback called while file is loading (if the server supports this mode)
  122852. * @param offlineProvider defines the offline provider for caching
  122853. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122854. * @param onError callback called when the file fails to load
  122855. * @returns a file request object
  122856. */
  122857. 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;
  122858. /**
  122859. * Loads a file from a url
  122860. * @param url the file url to load
  122861. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122862. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  122863. */
  122864. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  122865. /**
  122866. * Load a script (identified by an url). When the url returns, the
  122867. * content of this file is added into a new script element, attached to the DOM (body element)
  122868. * @param scriptUrl defines the url of the script to laod
  122869. * @param onSuccess defines the callback called when the script is loaded
  122870. * @param onError defines the callback to call if an error occurs
  122871. * @param scriptId defines the id of the script element
  122872. */
  122873. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  122874. /**
  122875. * Load an asynchronous script (identified by an url). When the url returns, the
  122876. * content of this file is added into a new script element, attached to the DOM (body element)
  122877. * @param scriptUrl defines the url of the script to laod
  122878. * @param scriptId defines the id of the script element
  122879. * @returns a promise request object
  122880. */
  122881. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  122882. /**
  122883. * Loads a file from a blob
  122884. * @param fileToLoad defines the blob to use
  122885. * @param callback defines the callback to call when data is loaded
  122886. * @param progressCallback defines the callback to call during loading process
  122887. * @returns a file request object
  122888. */
  122889. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  122890. /**
  122891. * Reads a file from a File object
  122892. * @param file defines the file to load
  122893. * @param onSuccess defines the callback to call when data is loaded
  122894. * @param onProgress defines the callback to call during loading process
  122895. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  122896. * @param onError defines the callback to call when an error occurs
  122897. * @returns a file request object
  122898. */
  122899. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  122900. /**
  122901. * Creates a data url from a given string content
  122902. * @param content defines the content to convert
  122903. * @returns the new data url link
  122904. */
  122905. static FileAsURL(content: string): string;
  122906. /**
  122907. * Format the given number to a specific decimal format
  122908. * @param value defines the number to format
  122909. * @param decimals defines the number of decimals to use
  122910. * @returns the formatted string
  122911. */
  122912. static Format(value: number, decimals?: number): string;
  122913. /**
  122914. * Tries to copy an object by duplicating every property
  122915. * @param source defines the source object
  122916. * @param destination defines the target object
  122917. * @param doNotCopyList defines a list of properties to avoid
  122918. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  122919. */
  122920. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  122921. /**
  122922. * Gets a boolean indicating if the given object has no own property
  122923. * @param obj defines the object to test
  122924. * @returns true if object has no own property
  122925. */
  122926. static IsEmpty(obj: any): boolean;
  122927. /**
  122928. * Function used to register events at window level
  122929. * @param windowElement defines the Window object to use
  122930. * @param events defines the events to register
  122931. */
  122932. static RegisterTopRootEvents(windowElement: Window, events: {
  122933. name: string;
  122934. handler: Nullable<(e: FocusEvent) => any>;
  122935. }[]): void;
  122936. /**
  122937. * Function used to unregister events from window level
  122938. * @param windowElement defines the Window object to use
  122939. * @param events defines the events to unregister
  122940. */
  122941. static UnregisterTopRootEvents(windowElement: Window, events: {
  122942. name: string;
  122943. handler: Nullable<(e: FocusEvent) => any>;
  122944. }[]): void;
  122945. /**
  122946. * @ignore
  122947. */
  122948. static _ScreenshotCanvas: HTMLCanvasElement;
  122949. /**
  122950. * Dumps the current bound framebuffer
  122951. * @param width defines the rendering width
  122952. * @param height defines the rendering height
  122953. * @param engine defines the hosting engine
  122954. * @param successCallback defines the callback triggered once the data are available
  122955. * @param mimeType defines the mime type of the result
  122956. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  122957. */
  122958. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122959. /**
  122960. * Converts the canvas data to blob.
  122961. * This acts as a polyfill for browsers not supporting the to blob function.
  122962. * @param canvas Defines the canvas to extract the data from
  122963. * @param successCallback Defines the callback triggered once the data are available
  122964. * @param mimeType Defines the mime type of the result
  122965. */
  122966. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  122967. /**
  122968. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  122969. * @param successCallback defines the callback triggered once the data are available
  122970. * @param mimeType defines the mime type of the result
  122971. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  122972. */
  122973. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122974. /**
  122975. * Downloads a blob in the browser
  122976. * @param blob defines the blob to download
  122977. * @param fileName defines the name of the downloaded file
  122978. */
  122979. static Download(blob: Blob, fileName: string): void;
  122980. /**
  122981. * Will return the right value of the noPreventDefault variable
  122982. * Needed to keep backwards compatibility to the old API.
  122983. *
  122984. * @param args arguments passed to the attachControl function
  122985. * @returns the correct value for noPreventDefault
  122986. */
  122987. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  122988. /**
  122989. * Captures a screenshot of the current rendering
  122990. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122991. * @param engine defines the rendering engine
  122992. * @param camera defines the source camera
  122993. * @param size This parameter can be set to a single number or to an object with the
  122994. * following (optional) properties: precision, width, height. If a single number is passed,
  122995. * it will be used for both width and height. If an object is passed, the screenshot size
  122996. * will be derived from the parameters. The precision property is a multiplier allowing
  122997. * rendering at a higher or lower resolution
  122998. * @param successCallback defines the callback receives a single parameter which contains the
  122999. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123000. * src parameter of an <img> to display it
  123001. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123002. * Check your browser for supported MIME types
  123003. */
  123004. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  123005. /**
  123006. * Captures a screenshot of the current rendering
  123007. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123008. * @param engine defines the rendering engine
  123009. * @param camera defines the source camera
  123010. * @param size This parameter can be set to a single number or to an object with the
  123011. * following (optional) properties: precision, width, height. If a single number is passed,
  123012. * it will be used for both width and height. If an object is passed, the screenshot size
  123013. * will be derived from the parameters. The precision property is a multiplier allowing
  123014. * rendering at a higher or lower resolution
  123015. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123016. * Check your browser for supported MIME types
  123017. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123018. * to the src parameter of an <img> to display it
  123019. */
  123020. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  123021. /**
  123022. * Generates an image screenshot from the specified camera.
  123023. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123024. * @param engine The engine to use for rendering
  123025. * @param camera The camera to use for rendering
  123026. * @param size This parameter can be set to a single number or to an object with the
  123027. * following (optional) properties: precision, width, height. If a single number is passed,
  123028. * it will be used for both width and height. If an object is passed, the screenshot size
  123029. * will be derived from the parameters. The precision property is a multiplier allowing
  123030. * rendering at a higher or lower resolution
  123031. * @param successCallback The callback receives a single parameter which contains the
  123032. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123033. * src parameter of an <img> to display it
  123034. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123035. * Check your browser for supported MIME types
  123036. * @param samples Texture samples (default: 1)
  123037. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123038. * @param fileName A name for for the downloaded file.
  123039. */
  123040. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  123041. /**
  123042. * Generates an image screenshot from the specified camera.
  123043. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123044. * @param engine The engine to use for rendering
  123045. * @param camera The camera to use for rendering
  123046. * @param size This parameter can be set to a single number or to an object with the
  123047. * following (optional) properties: precision, width, height. If a single number is passed,
  123048. * it will be used for both width and height. If an object is passed, the screenshot size
  123049. * will be derived from the parameters. The precision property is a multiplier allowing
  123050. * rendering at a higher or lower resolution
  123051. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123052. * Check your browser for supported MIME types
  123053. * @param samples Texture samples (default: 1)
  123054. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123055. * @param fileName A name for for the downloaded file.
  123056. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123057. * to the src parameter of an <img> to display it
  123058. */
  123059. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  123060. /**
  123061. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  123062. * Be aware Math.random() could cause collisions, but:
  123063. * "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"
  123064. * @returns a pseudo random id
  123065. */
  123066. static RandomId(): string;
  123067. /**
  123068. * Test if the given uri is a base64 string
  123069. * @param uri The uri to test
  123070. * @return True if the uri is a base64 string or false otherwise
  123071. */
  123072. static IsBase64(uri: string): boolean;
  123073. /**
  123074. * Decode the given base64 uri.
  123075. * @param uri The uri to decode
  123076. * @return The decoded base64 data.
  123077. */
  123078. static DecodeBase64(uri: string): ArrayBuffer;
  123079. /**
  123080. * Gets the absolute url.
  123081. * @param url the input url
  123082. * @return the absolute url
  123083. */
  123084. static GetAbsoluteUrl(url: string): string;
  123085. /**
  123086. * No log
  123087. */
  123088. static readonly NoneLogLevel: number;
  123089. /**
  123090. * Only message logs
  123091. */
  123092. static readonly MessageLogLevel: number;
  123093. /**
  123094. * Only warning logs
  123095. */
  123096. static readonly WarningLogLevel: number;
  123097. /**
  123098. * Only error logs
  123099. */
  123100. static readonly ErrorLogLevel: number;
  123101. /**
  123102. * All logs
  123103. */
  123104. static readonly AllLogLevel: number;
  123105. /**
  123106. * Gets a value indicating the number of loading errors
  123107. * @ignorenaming
  123108. */
  123109. static get errorsCount(): number;
  123110. /**
  123111. * Callback called when a new log is added
  123112. */
  123113. static OnNewCacheEntry: (entry: string) => void;
  123114. /**
  123115. * Log a message to the console
  123116. * @param message defines the message to log
  123117. */
  123118. static Log(message: string): void;
  123119. /**
  123120. * Write a warning message to the console
  123121. * @param message defines the message to log
  123122. */
  123123. static Warn(message: string): void;
  123124. /**
  123125. * Write an error message to the console
  123126. * @param message defines the message to log
  123127. */
  123128. static Error(message: string): void;
  123129. /**
  123130. * Gets current log cache (list of logs)
  123131. */
  123132. static get LogCache(): string;
  123133. /**
  123134. * Clears the log cache
  123135. */
  123136. static ClearLogCache(): void;
  123137. /**
  123138. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  123139. */
  123140. static set LogLevels(level: number);
  123141. /**
  123142. * Checks if the window object exists
  123143. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  123144. */
  123145. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  123146. /**
  123147. * No performance log
  123148. */
  123149. static readonly PerformanceNoneLogLevel: number;
  123150. /**
  123151. * Use user marks to log performance
  123152. */
  123153. static readonly PerformanceUserMarkLogLevel: number;
  123154. /**
  123155. * Log performance to the console
  123156. */
  123157. static readonly PerformanceConsoleLogLevel: number;
  123158. private static _performance;
  123159. /**
  123160. * Sets the current performance log level
  123161. */
  123162. static set PerformanceLogLevel(level: number);
  123163. private static _StartPerformanceCounterDisabled;
  123164. private static _EndPerformanceCounterDisabled;
  123165. private static _StartUserMark;
  123166. private static _EndUserMark;
  123167. private static _StartPerformanceConsole;
  123168. private static _EndPerformanceConsole;
  123169. /**
  123170. * Starts a performance counter
  123171. */
  123172. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123173. /**
  123174. * Ends a specific performance coutner
  123175. */
  123176. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123177. /**
  123178. * Gets either window.performance.now() if supported or Date.now() else
  123179. */
  123180. static get Now(): number;
  123181. /**
  123182. * This method will return the name of the class used to create the instance of the given object.
  123183. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  123184. * @param object the object to get the class name from
  123185. * @param isType defines if the object is actually a type
  123186. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  123187. */
  123188. static GetClassName(object: any, isType?: boolean): string;
  123189. /**
  123190. * Gets the first element of an array satisfying a given predicate
  123191. * @param array defines the array to browse
  123192. * @param predicate defines the predicate to use
  123193. * @returns null if not found or the element
  123194. */
  123195. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  123196. /**
  123197. * This method will return the name of the full name of the class, including its owning module (if any).
  123198. * 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).
  123199. * @param object the object to get the class name from
  123200. * @param isType defines if the object is actually a type
  123201. * @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.
  123202. * @ignorenaming
  123203. */
  123204. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  123205. /**
  123206. * Returns a promise that resolves after the given amount of time.
  123207. * @param delay Number of milliseconds to delay
  123208. * @returns Promise that resolves after the given amount of time
  123209. */
  123210. static DelayAsync(delay: number): Promise<void>;
  123211. /**
  123212. * Utility function to detect if the current user agent is Safari
  123213. * @returns whether or not the current user agent is safari
  123214. */
  123215. static IsSafari(): boolean;
  123216. }
  123217. /**
  123218. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  123219. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  123220. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  123221. * @param name The name of the class, case should be preserved
  123222. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  123223. */
  123224. export function className(name: string, module?: string): (target: Object) => void;
  123225. /**
  123226. * An implementation of a loop for asynchronous functions.
  123227. */
  123228. export class AsyncLoop {
  123229. /**
  123230. * Defines the number of iterations for the loop
  123231. */
  123232. iterations: number;
  123233. /**
  123234. * Defines the current index of the loop.
  123235. */
  123236. index: number;
  123237. private _done;
  123238. private _fn;
  123239. private _successCallback;
  123240. /**
  123241. * Constructor.
  123242. * @param iterations the number of iterations.
  123243. * @param func the function to run each iteration
  123244. * @param successCallback the callback that will be called upon succesful execution
  123245. * @param offset starting offset.
  123246. */
  123247. constructor(
  123248. /**
  123249. * Defines the number of iterations for the loop
  123250. */
  123251. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  123252. /**
  123253. * Execute the next iteration. Must be called after the last iteration was finished.
  123254. */
  123255. executeNext(): void;
  123256. /**
  123257. * Break the loop and run the success callback.
  123258. */
  123259. breakLoop(): void;
  123260. /**
  123261. * Create and run an async loop.
  123262. * @param iterations the number of iterations.
  123263. * @param fn the function to run each iteration
  123264. * @param successCallback the callback that will be called upon succesful execution
  123265. * @param offset starting offset.
  123266. * @returns the created async loop object
  123267. */
  123268. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  123269. /**
  123270. * A for-loop that will run a given number of iterations synchronous and the rest async.
  123271. * @param iterations total number of iterations
  123272. * @param syncedIterations number of synchronous iterations in each async iteration.
  123273. * @param fn the function to call each iteration.
  123274. * @param callback a success call back that will be called when iterating stops.
  123275. * @param breakFunction a break condition (optional)
  123276. * @param timeout timeout settings for the setTimeout function. default - 0.
  123277. * @returns the created async loop object
  123278. */
  123279. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  123280. }
  123281. }
  123282. declare module BABYLON {
  123283. /**
  123284. * This class implement a typical dictionary using a string as key and the generic type T as value.
  123285. * The underlying implementation relies on an associative array to ensure the best performances.
  123286. * The value can be anything including 'null' but except 'undefined'
  123287. */
  123288. export class StringDictionary<T> {
  123289. /**
  123290. * This will clear this dictionary and copy the content from the 'source' one.
  123291. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  123292. * @param source the dictionary to take the content from and copy to this dictionary
  123293. */
  123294. copyFrom(source: StringDictionary<T>): void;
  123295. /**
  123296. * Get a value based from its key
  123297. * @param key the given key to get the matching value from
  123298. * @return the value if found, otherwise undefined is returned
  123299. */
  123300. get(key: string): T | undefined;
  123301. /**
  123302. * Get a value from its key or add it if it doesn't exist.
  123303. * This method will ensure you that a given key/data will be present in the dictionary.
  123304. * @param key the given key to get the matching value from
  123305. * @param factory the factory that will create the value if the key is not present in the dictionary.
  123306. * The factory will only be invoked if there's no data for the given key.
  123307. * @return the value corresponding to the key.
  123308. */
  123309. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  123310. /**
  123311. * Get a value from its key if present in the dictionary otherwise add it
  123312. * @param key the key to get the value from
  123313. * @param val if there's no such key/value pair in the dictionary add it with this value
  123314. * @return the value corresponding to the key
  123315. */
  123316. getOrAdd(key: string, val: T): T;
  123317. /**
  123318. * Check if there's a given key in the dictionary
  123319. * @param key the key to check for
  123320. * @return true if the key is present, false otherwise
  123321. */
  123322. contains(key: string): boolean;
  123323. /**
  123324. * Add a new key and its corresponding value
  123325. * @param key the key to add
  123326. * @param value the value corresponding to the key
  123327. * @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
  123328. */
  123329. add(key: string, value: T): boolean;
  123330. /**
  123331. * Update a specific value associated to a key
  123332. * @param key defines the key to use
  123333. * @param value defines the value to store
  123334. * @returns true if the value was updated (or false if the key was not found)
  123335. */
  123336. set(key: string, value: T): boolean;
  123337. /**
  123338. * Get the element of the given key and remove it from the dictionary
  123339. * @param key defines the key to search
  123340. * @returns the value associated with the key or null if not found
  123341. */
  123342. getAndRemove(key: string): Nullable<T>;
  123343. /**
  123344. * Remove a key/value from the dictionary.
  123345. * @param key the key to remove
  123346. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  123347. */
  123348. remove(key: string): boolean;
  123349. /**
  123350. * Clear the whole content of the dictionary
  123351. */
  123352. clear(): void;
  123353. /**
  123354. * Gets the current count
  123355. */
  123356. get count(): number;
  123357. /**
  123358. * Execute a callback on each key/val of the dictionary.
  123359. * Note that you can remove any element in this dictionary in the callback implementation
  123360. * @param callback the callback to execute on a given key/value pair
  123361. */
  123362. forEach(callback: (key: string, val: T) => void): void;
  123363. /**
  123364. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  123365. * If the callback returns null or undefined the method will iterate to the next key/value pair
  123366. * Note that you can remove any element in this dictionary in the callback implementation
  123367. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  123368. * @returns the first item
  123369. */
  123370. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  123371. private _count;
  123372. private _data;
  123373. }
  123374. }
  123375. declare module BABYLON {
  123376. /** @hidden */
  123377. export interface ICollisionCoordinator {
  123378. createCollider(): Collider;
  123379. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123380. init(scene: Scene): void;
  123381. }
  123382. /** @hidden */
  123383. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  123384. private _scene;
  123385. private _scaledPosition;
  123386. private _scaledVelocity;
  123387. private _finalPosition;
  123388. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123389. createCollider(): Collider;
  123390. init(scene: Scene): void;
  123391. private _collideWithWorld;
  123392. }
  123393. }
  123394. declare module BABYLON {
  123395. /**
  123396. * Class used to manage all inputs for the scene.
  123397. */
  123398. export class InputManager {
  123399. /** The distance in pixel that you have to move to prevent some events */
  123400. static DragMovementThreshold: number;
  123401. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  123402. static LongPressDelay: number;
  123403. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  123404. static DoubleClickDelay: number;
  123405. /** If you need to check double click without raising a single click at first click, enable this flag */
  123406. static ExclusiveDoubleClickMode: boolean;
  123407. /** 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. */
  123408. private _alreadyAttached;
  123409. private _alreadyAttachedTo;
  123410. private _wheelEventName;
  123411. private _onPointerMove;
  123412. private _onPointerDown;
  123413. private _onPointerUp;
  123414. private _initClickEvent;
  123415. private _initActionManager;
  123416. private _delayedSimpleClick;
  123417. private _delayedSimpleClickTimeout;
  123418. private _previousDelayedSimpleClickTimeout;
  123419. private _meshPickProceed;
  123420. private _previousButtonPressed;
  123421. private _currentPickResult;
  123422. private _previousPickResult;
  123423. private _totalPointersPressed;
  123424. private _doubleClickOccured;
  123425. private _pointerOverMesh;
  123426. private _pickedDownMesh;
  123427. private _pickedUpMesh;
  123428. private _pointerX;
  123429. private _pointerY;
  123430. private _unTranslatedPointerX;
  123431. private _unTranslatedPointerY;
  123432. private _startingPointerPosition;
  123433. private _previousStartingPointerPosition;
  123434. private _startingPointerTime;
  123435. private _previousStartingPointerTime;
  123436. private _pointerCaptures;
  123437. private _meshUnderPointerId;
  123438. private _onKeyDown;
  123439. private _onKeyUp;
  123440. private _keyboardIsAttached;
  123441. private _onCanvasFocusObserver;
  123442. private _onCanvasBlurObserver;
  123443. private _scene;
  123444. /**
  123445. * Creates a new InputManager
  123446. * @param scene defines the hosting scene
  123447. */
  123448. constructor(scene: Scene);
  123449. /**
  123450. * Gets the mesh that is currently under the pointer
  123451. */
  123452. get meshUnderPointer(): Nullable<AbstractMesh>;
  123453. /**
  123454. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  123455. * @param pointerId the pointer id to use
  123456. * @returns The mesh under this pointer id or null if not found
  123457. */
  123458. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  123459. /**
  123460. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  123461. */
  123462. get unTranslatedPointer(): Vector2;
  123463. /**
  123464. * Gets or sets the current on-screen X position of the pointer
  123465. */
  123466. get pointerX(): number;
  123467. set pointerX(value: number);
  123468. /**
  123469. * Gets or sets the current on-screen Y position of the pointer
  123470. */
  123471. get pointerY(): number;
  123472. set pointerY(value: number);
  123473. private _updatePointerPosition;
  123474. private _processPointerMove;
  123475. private _setRayOnPointerInfo;
  123476. private _checkPrePointerObservable;
  123477. /**
  123478. * Use this method to simulate a pointer move on a mesh
  123479. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123480. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123481. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123482. */
  123483. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  123484. /**
  123485. * Use this method to simulate a pointer down on a mesh
  123486. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123487. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123488. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123489. */
  123490. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  123491. private _processPointerDown;
  123492. /** @hidden */
  123493. _isPointerSwiping(): boolean;
  123494. /**
  123495. * Use this method to simulate a pointer up on a mesh
  123496. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123497. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123498. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123499. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  123500. */
  123501. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  123502. private _processPointerUp;
  123503. /**
  123504. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  123505. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  123506. * @returns true if the pointer was captured
  123507. */
  123508. isPointerCaptured(pointerId?: number): boolean;
  123509. /**
  123510. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  123511. * @param attachUp defines if you want to attach events to pointerup
  123512. * @param attachDown defines if you want to attach events to pointerdown
  123513. * @param attachMove defines if you want to attach events to pointermove
  123514. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  123515. */
  123516. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  123517. /**
  123518. * Detaches all event handlers
  123519. */
  123520. detachControl(): void;
  123521. /**
  123522. * Force the value of meshUnderPointer
  123523. * @param mesh defines the mesh to use
  123524. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  123525. */
  123526. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  123527. /**
  123528. * Gets the mesh under the pointer
  123529. * @returns a Mesh or null if no mesh is under the pointer
  123530. */
  123531. getPointerOverMesh(): Nullable<AbstractMesh>;
  123532. }
  123533. }
  123534. declare module BABYLON {
  123535. /**
  123536. * This class defines the direct association between an animation and a target
  123537. */
  123538. export class TargetedAnimation {
  123539. /**
  123540. * Animation to perform
  123541. */
  123542. animation: Animation;
  123543. /**
  123544. * Target to animate
  123545. */
  123546. target: any;
  123547. /**
  123548. * Returns the string "TargetedAnimation"
  123549. * @returns "TargetedAnimation"
  123550. */
  123551. getClassName(): string;
  123552. /**
  123553. * Serialize the object
  123554. * @returns the JSON object representing the current entity
  123555. */
  123556. serialize(): any;
  123557. }
  123558. /**
  123559. * Use this class to create coordinated animations on multiple targets
  123560. */
  123561. export class AnimationGroup implements IDisposable {
  123562. /** The name of the animation group */
  123563. name: string;
  123564. private _scene;
  123565. private _targetedAnimations;
  123566. private _animatables;
  123567. private _from;
  123568. private _to;
  123569. private _isStarted;
  123570. private _isPaused;
  123571. private _speedRatio;
  123572. private _loopAnimation;
  123573. private _isAdditive;
  123574. /**
  123575. * Gets or sets the unique id of the node
  123576. */
  123577. uniqueId: number;
  123578. /**
  123579. * This observable will notify when one animation have ended
  123580. */
  123581. onAnimationEndObservable: Observable<TargetedAnimation>;
  123582. /**
  123583. * Observer raised when one animation loops
  123584. */
  123585. onAnimationLoopObservable: Observable<TargetedAnimation>;
  123586. /**
  123587. * Observer raised when all animations have looped
  123588. */
  123589. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  123590. /**
  123591. * This observable will notify when all animations have ended.
  123592. */
  123593. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  123594. /**
  123595. * This observable will notify when all animations have paused.
  123596. */
  123597. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  123598. /**
  123599. * This observable will notify when all animations are playing.
  123600. */
  123601. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  123602. /**
  123603. * Gets the first frame
  123604. */
  123605. get from(): number;
  123606. /**
  123607. * Gets the last frame
  123608. */
  123609. get to(): number;
  123610. /**
  123611. * Define if the animations are started
  123612. */
  123613. get isStarted(): boolean;
  123614. /**
  123615. * Gets a value indicating that the current group is playing
  123616. */
  123617. get isPlaying(): boolean;
  123618. /**
  123619. * Gets or sets the speed ratio to use for all animations
  123620. */
  123621. get speedRatio(): number;
  123622. /**
  123623. * Gets or sets the speed ratio to use for all animations
  123624. */
  123625. set speedRatio(value: number);
  123626. /**
  123627. * Gets or sets if all animations should loop or not
  123628. */
  123629. get loopAnimation(): boolean;
  123630. set loopAnimation(value: boolean);
  123631. /**
  123632. * Gets or sets if all animations should be evaluated additively
  123633. */
  123634. get isAdditive(): boolean;
  123635. set isAdditive(value: boolean);
  123636. /**
  123637. * Gets the targeted animations for this animation group
  123638. */
  123639. get targetedAnimations(): Array<TargetedAnimation>;
  123640. /**
  123641. * returning the list of animatables controlled by this animation group.
  123642. */
  123643. get animatables(): Array<Animatable>;
  123644. /**
  123645. * Gets the list of target animations
  123646. */
  123647. get children(): TargetedAnimation[];
  123648. /**
  123649. * Instantiates a new Animation Group.
  123650. * This helps managing several animations at once.
  123651. * @see https://doc.babylonjs.com/how_to/group
  123652. * @param name Defines the name of the group
  123653. * @param scene Defines the scene the group belongs to
  123654. */
  123655. constructor(
  123656. /** The name of the animation group */
  123657. name: string, scene?: Nullable<Scene>);
  123658. /**
  123659. * Add an animation (with its target) in the group
  123660. * @param animation defines the animation we want to add
  123661. * @param target defines the target of the animation
  123662. * @returns the TargetedAnimation object
  123663. */
  123664. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  123665. /**
  123666. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  123667. * It can add constant keys at begin or end
  123668. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  123669. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  123670. * @returns the animation group
  123671. */
  123672. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  123673. private _animationLoopCount;
  123674. private _animationLoopFlags;
  123675. private _processLoop;
  123676. /**
  123677. * Start all animations on given targets
  123678. * @param loop defines if animations must loop
  123679. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  123680. * @param from defines the from key (optional)
  123681. * @param to defines the to key (optional)
  123682. * @param isAdditive defines the additive state for the resulting animatables (optional)
  123683. * @returns the current animation group
  123684. */
  123685. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  123686. /**
  123687. * Pause all animations
  123688. * @returns the animation group
  123689. */
  123690. pause(): AnimationGroup;
  123691. /**
  123692. * Play all animations to initial state
  123693. * This function will start() the animations if they were not started or will restart() them if they were paused
  123694. * @param loop defines if animations must loop
  123695. * @returns the animation group
  123696. */
  123697. play(loop?: boolean): AnimationGroup;
  123698. /**
  123699. * Reset all animations to initial state
  123700. * @returns the animation group
  123701. */
  123702. reset(): AnimationGroup;
  123703. /**
  123704. * Restart animations from key 0
  123705. * @returns the animation group
  123706. */
  123707. restart(): AnimationGroup;
  123708. /**
  123709. * Stop all animations
  123710. * @returns the animation group
  123711. */
  123712. stop(): AnimationGroup;
  123713. /**
  123714. * Set animation weight for all animatables
  123715. * @param weight defines the weight to use
  123716. * @return the animationGroup
  123717. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123718. */
  123719. setWeightForAllAnimatables(weight: number): AnimationGroup;
  123720. /**
  123721. * Synchronize and normalize all animatables with a source animatable
  123722. * @param root defines the root animatable to synchronize with
  123723. * @return the animationGroup
  123724. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123725. */
  123726. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  123727. /**
  123728. * Goes to a specific frame in this animation group
  123729. * @param frame the frame number to go to
  123730. * @return the animationGroup
  123731. */
  123732. goToFrame(frame: number): AnimationGroup;
  123733. /**
  123734. * Dispose all associated resources
  123735. */
  123736. dispose(): void;
  123737. private _checkAnimationGroupEnded;
  123738. /**
  123739. * Clone the current animation group and returns a copy
  123740. * @param newName defines the name of the new group
  123741. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  123742. * @returns the new aniamtion group
  123743. */
  123744. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  123745. /**
  123746. * Serializes the animationGroup to an object
  123747. * @returns Serialized object
  123748. */
  123749. serialize(): any;
  123750. /**
  123751. * Returns a new AnimationGroup object parsed from the source provided.
  123752. * @param parsedAnimationGroup defines the source
  123753. * @param scene defines the scene that will receive the animationGroup
  123754. * @returns a new AnimationGroup
  123755. */
  123756. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  123757. /**
  123758. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  123759. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  123760. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  123761. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  123762. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  123763. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  123764. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  123765. */
  123766. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  123767. /**
  123768. * Returns the string "AnimationGroup"
  123769. * @returns "AnimationGroup"
  123770. */
  123771. getClassName(): string;
  123772. /**
  123773. * Creates a detailled string about the object
  123774. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  123775. * @returns a string representing the object
  123776. */
  123777. toString(fullDetails?: boolean): string;
  123778. }
  123779. }
  123780. declare module BABYLON {
  123781. /**
  123782. * Define an interface for all classes that will hold resources
  123783. */
  123784. export interface IDisposable {
  123785. /**
  123786. * Releases all held resources
  123787. */
  123788. dispose(): void;
  123789. }
  123790. /** Interface defining initialization parameters for Scene class */
  123791. export interface SceneOptions {
  123792. /**
  123793. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  123794. * It will improve performance when the number of geometries becomes important.
  123795. */
  123796. useGeometryUniqueIdsMap?: boolean;
  123797. /**
  123798. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  123799. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123800. */
  123801. useMaterialMeshMap?: boolean;
  123802. /**
  123803. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  123804. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123805. */
  123806. useClonedMeshMap?: boolean;
  123807. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  123808. virtual?: boolean;
  123809. }
  123810. /**
  123811. * Represents a scene to be rendered by the engine.
  123812. * @see https://doc.babylonjs.com/features/scene
  123813. */
  123814. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  123815. /** The fog is deactivated */
  123816. static readonly FOGMODE_NONE: number;
  123817. /** The fog density is following an exponential function */
  123818. static readonly FOGMODE_EXP: number;
  123819. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  123820. static readonly FOGMODE_EXP2: number;
  123821. /** The fog density is following a linear function. */
  123822. static readonly FOGMODE_LINEAR: number;
  123823. /**
  123824. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  123825. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123826. */
  123827. static MinDeltaTime: number;
  123828. /**
  123829. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  123830. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123831. */
  123832. static MaxDeltaTime: number;
  123833. /**
  123834. * Factory used to create the default material.
  123835. * @param name The name of the material to create
  123836. * @param scene The scene to create the material for
  123837. * @returns The default material
  123838. */
  123839. static DefaultMaterialFactory(scene: Scene): Material;
  123840. /**
  123841. * Factory used to create the a collision coordinator.
  123842. * @returns The collision coordinator
  123843. */
  123844. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  123845. /** @hidden */
  123846. _inputManager: InputManager;
  123847. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  123848. cameraToUseForPointers: Nullable<Camera>;
  123849. /** @hidden */
  123850. readonly _isScene: boolean;
  123851. /** @hidden */
  123852. _blockEntityCollection: boolean;
  123853. /**
  123854. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  123855. */
  123856. autoClear: boolean;
  123857. /**
  123858. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  123859. */
  123860. autoClearDepthAndStencil: boolean;
  123861. /**
  123862. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  123863. */
  123864. clearColor: Color4;
  123865. /**
  123866. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  123867. */
  123868. ambientColor: Color3;
  123869. /**
  123870. * This is use to store the default BRDF lookup for PBR materials in your scene.
  123871. * It should only be one of the following (if not the default embedded one):
  123872. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  123873. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  123874. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  123875. * The material properties need to be setup according to the type of texture in use.
  123876. */
  123877. environmentBRDFTexture: BaseTexture;
  123878. /**
  123879. * Texture used in all pbr material as the reflection texture.
  123880. * As in the majority of the scene they are the same (exception for multi room and so on),
  123881. * this is easier to reference from here than from all the materials.
  123882. */
  123883. get environmentTexture(): Nullable<BaseTexture>;
  123884. /**
  123885. * Texture used in all pbr material as the reflection texture.
  123886. * As in the majority of the scene they are the same (exception for multi room and so on),
  123887. * this is easier to set here than in all the materials.
  123888. */
  123889. set environmentTexture(value: Nullable<BaseTexture>);
  123890. /** @hidden */
  123891. protected _environmentIntensity: number;
  123892. /**
  123893. * Intensity of the environment in all pbr material.
  123894. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123895. * As in the majority of the scene they are the same (exception for multi room and so on),
  123896. * this is easier to reference from here than from all the materials.
  123897. */
  123898. get environmentIntensity(): number;
  123899. /**
  123900. * Intensity of the environment in all pbr material.
  123901. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123902. * As in the majority of the scene they are the same (exception for multi room and so on),
  123903. * this is easier to set here than in all the materials.
  123904. */
  123905. set environmentIntensity(value: number);
  123906. /** @hidden */
  123907. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123908. /**
  123909. * Default image processing configuration used either in the rendering
  123910. * Forward main pass or through the imageProcessingPostProcess if present.
  123911. * As in the majority of the scene they are the same (exception for multi camera),
  123912. * this is easier to reference from here than from all the materials and post process.
  123913. *
  123914. * No setter as we it is a shared configuration, you can set the values instead.
  123915. */
  123916. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123917. private _forceWireframe;
  123918. /**
  123919. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  123920. */
  123921. set forceWireframe(value: boolean);
  123922. get forceWireframe(): boolean;
  123923. private _skipFrustumClipping;
  123924. /**
  123925. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  123926. */
  123927. set skipFrustumClipping(value: boolean);
  123928. get skipFrustumClipping(): boolean;
  123929. private _forcePointsCloud;
  123930. /**
  123931. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  123932. */
  123933. set forcePointsCloud(value: boolean);
  123934. get forcePointsCloud(): boolean;
  123935. /**
  123936. * Gets or sets the active clipplane 1
  123937. */
  123938. clipPlane: Nullable<Plane>;
  123939. /**
  123940. * Gets or sets the active clipplane 2
  123941. */
  123942. clipPlane2: Nullable<Plane>;
  123943. /**
  123944. * Gets or sets the active clipplane 3
  123945. */
  123946. clipPlane3: Nullable<Plane>;
  123947. /**
  123948. * Gets or sets the active clipplane 4
  123949. */
  123950. clipPlane4: Nullable<Plane>;
  123951. /**
  123952. * Gets or sets the active clipplane 5
  123953. */
  123954. clipPlane5: Nullable<Plane>;
  123955. /**
  123956. * Gets or sets the active clipplane 6
  123957. */
  123958. clipPlane6: Nullable<Plane>;
  123959. /**
  123960. * Gets or sets a boolean indicating if animations are enabled
  123961. */
  123962. animationsEnabled: boolean;
  123963. private _animationPropertiesOverride;
  123964. /**
  123965. * Gets or sets the animation properties override
  123966. */
  123967. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  123968. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  123969. /**
  123970. * Gets or sets a boolean indicating if a constant deltatime has to be used
  123971. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  123972. */
  123973. useConstantAnimationDeltaTime: boolean;
  123974. /**
  123975. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  123976. * Please note that it requires to run a ray cast through the scene on every frame
  123977. */
  123978. constantlyUpdateMeshUnderPointer: boolean;
  123979. /**
  123980. * Defines the HTML cursor to use when hovering over interactive elements
  123981. */
  123982. hoverCursor: string;
  123983. /**
  123984. * Defines the HTML default cursor to use (empty by default)
  123985. */
  123986. defaultCursor: string;
  123987. /**
  123988. * Defines whether cursors are handled by the scene.
  123989. */
  123990. doNotHandleCursors: boolean;
  123991. /**
  123992. * This is used to call preventDefault() on pointer down
  123993. * in order to block unwanted artifacts like system double clicks
  123994. */
  123995. preventDefaultOnPointerDown: boolean;
  123996. /**
  123997. * This is used to call preventDefault() on pointer up
  123998. * in order to block unwanted artifacts like system double clicks
  123999. */
  124000. preventDefaultOnPointerUp: boolean;
  124001. /**
  124002. * Gets or sets user defined metadata
  124003. */
  124004. metadata: any;
  124005. /**
  124006. * For internal use only. Please do not use.
  124007. */
  124008. reservedDataStore: any;
  124009. /**
  124010. * Gets the name of the plugin used to load this scene (null by default)
  124011. */
  124012. loadingPluginName: string;
  124013. /**
  124014. * Use this array to add regular expressions used to disable offline support for specific urls
  124015. */
  124016. disableOfflineSupportExceptionRules: RegExp[];
  124017. /**
  124018. * An event triggered when the scene is disposed.
  124019. */
  124020. onDisposeObservable: Observable<Scene>;
  124021. private _onDisposeObserver;
  124022. /** Sets a function to be executed when this scene is disposed. */
  124023. set onDispose(callback: () => void);
  124024. /**
  124025. * An event triggered before rendering the scene (right after animations and physics)
  124026. */
  124027. onBeforeRenderObservable: Observable<Scene>;
  124028. private _onBeforeRenderObserver;
  124029. /** Sets a function to be executed before rendering this scene */
  124030. set beforeRender(callback: Nullable<() => void>);
  124031. /**
  124032. * An event triggered after rendering the scene
  124033. */
  124034. onAfterRenderObservable: Observable<Scene>;
  124035. /**
  124036. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  124037. */
  124038. onAfterRenderCameraObservable: Observable<Camera>;
  124039. private _onAfterRenderObserver;
  124040. /** Sets a function to be executed after rendering this scene */
  124041. set afterRender(callback: Nullable<() => void>);
  124042. /**
  124043. * An event triggered before animating the scene
  124044. */
  124045. onBeforeAnimationsObservable: Observable<Scene>;
  124046. /**
  124047. * An event triggered after animations processing
  124048. */
  124049. onAfterAnimationsObservable: Observable<Scene>;
  124050. /**
  124051. * An event triggered before draw calls are ready to be sent
  124052. */
  124053. onBeforeDrawPhaseObservable: Observable<Scene>;
  124054. /**
  124055. * An event triggered after draw calls have been sent
  124056. */
  124057. onAfterDrawPhaseObservable: Observable<Scene>;
  124058. /**
  124059. * An event triggered when the scene is ready
  124060. */
  124061. onReadyObservable: Observable<Scene>;
  124062. /**
  124063. * An event triggered before rendering a camera
  124064. */
  124065. onBeforeCameraRenderObservable: Observable<Camera>;
  124066. private _onBeforeCameraRenderObserver;
  124067. /** Sets a function to be executed before rendering a camera*/
  124068. set beforeCameraRender(callback: () => void);
  124069. /**
  124070. * An event triggered after rendering a camera
  124071. */
  124072. onAfterCameraRenderObservable: Observable<Camera>;
  124073. private _onAfterCameraRenderObserver;
  124074. /** Sets a function to be executed after rendering a camera*/
  124075. set afterCameraRender(callback: () => void);
  124076. /**
  124077. * An event triggered when active meshes evaluation is about to start
  124078. */
  124079. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  124080. /**
  124081. * An event triggered when active meshes evaluation is done
  124082. */
  124083. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  124084. /**
  124085. * An event triggered when particles rendering is about to start
  124086. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124087. */
  124088. onBeforeParticlesRenderingObservable: Observable<Scene>;
  124089. /**
  124090. * An event triggered when particles rendering is done
  124091. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124092. */
  124093. onAfterParticlesRenderingObservable: Observable<Scene>;
  124094. /**
  124095. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  124096. */
  124097. onDataLoadedObservable: Observable<Scene>;
  124098. /**
  124099. * An event triggered when a camera is created
  124100. */
  124101. onNewCameraAddedObservable: Observable<Camera>;
  124102. /**
  124103. * An event triggered when a camera is removed
  124104. */
  124105. onCameraRemovedObservable: Observable<Camera>;
  124106. /**
  124107. * An event triggered when a light is created
  124108. */
  124109. onNewLightAddedObservable: Observable<Light>;
  124110. /**
  124111. * An event triggered when a light is removed
  124112. */
  124113. onLightRemovedObservable: Observable<Light>;
  124114. /**
  124115. * An event triggered when a geometry is created
  124116. */
  124117. onNewGeometryAddedObservable: Observable<Geometry>;
  124118. /**
  124119. * An event triggered when a geometry is removed
  124120. */
  124121. onGeometryRemovedObservable: Observable<Geometry>;
  124122. /**
  124123. * An event triggered when a transform node is created
  124124. */
  124125. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  124126. /**
  124127. * An event triggered when a transform node is removed
  124128. */
  124129. onTransformNodeRemovedObservable: Observable<TransformNode>;
  124130. /**
  124131. * An event triggered when a mesh is created
  124132. */
  124133. onNewMeshAddedObservable: Observable<AbstractMesh>;
  124134. /**
  124135. * An event triggered when a mesh is removed
  124136. */
  124137. onMeshRemovedObservable: Observable<AbstractMesh>;
  124138. /**
  124139. * An event triggered when a skeleton is created
  124140. */
  124141. onNewSkeletonAddedObservable: Observable<Skeleton>;
  124142. /**
  124143. * An event triggered when a skeleton is removed
  124144. */
  124145. onSkeletonRemovedObservable: Observable<Skeleton>;
  124146. /**
  124147. * An event triggered when a material is created
  124148. */
  124149. onNewMaterialAddedObservable: Observable<Material>;
  124150. /**
  124151. * An event triggered when a material is removed
  124152. */
  124153. onMaterialRemovedObservable: Observable<Material>;
  124154. /**
  124155. * An event triggered when a texture is created
  124156. */
  124157. onNewTextureAddedObservable: Observable<BaseTexture>;
  124158. /**
  124159. * An event triggered when a texture is removed
  124160. */
  124161. onTextureRemovedObservable: Observable<BaseTexture>;
  124162. /**
  124163. * An event triggered when render targets are about to be rendered
  124164. * Can happen multiple times per frame.
  124165. */
  124166. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  124167. /**
  124168. * An event triggered when render targets were rendered.
  124169. * Can happen multiple times per frame.
  124170. */
  124171. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  124172. /**
  124173. * An event triggered before calculating deterministic simulation step
  124174. */
  124175. onBeforeStepObservable: Observable<Scene>;
  124176. /**
  124177. * An event triggered after calculating deterministic simulation step
  124178. */
  124179. onAfterStepObservable: Observable<Scene>;
  124180. /**
  124181. * An event triggered when the activeCamera property is updated
  124182. */
  124183. onActiveCameraChanged: Observable<Scene>;
  124184. /**
  124185. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  124186. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124187. * 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)
  124188. */
  124189. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124190. /**
  124191. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  124192. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124193. * 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)
  124194. */
  124195. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124196. /**
  124197. * This Observable will when a mesh has been imported into the scene.
  124198. */
  124199. onMeshImportedObservable: Observable<AbstractMesh>;
  124200. /**
  124201. * This Observable will when an animation file has been imported into the scene.
  124202. */
  124203. onAnimationFileImportedObservable: Observable<Scene>;
  124204. /**
  124205. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  124206. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  124207. */
  124208. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  124209. /** @hidden */
  124210. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  124211. /**
  124212. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  124213. */
  124214. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  124215. /**
  124216. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  124217. */
  124218. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  124219. /**
  124220. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  124221. */
  124222. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  124223. /** Callback called when a pointer move is detected */
  124224. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124225. /** Callback called when a pointer down is detected */
  124226. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124227. /** Callback called when a pointer up is detected */
  124228. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  124229. /** Callback called when a pointer pick is detected */
  124230. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  124231. /**
  124232. * 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).
  124233. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  124234. */
  124235. onPrePointerObservable: Observable<PointerInfoPre>;
  124236. /**
  124237. * Observable event triggered each time an input event is received from the rendering canvas
  124238. */
  124239. onPointerObservable: Observable<PointerInfo>;
  124240. /**
  124241. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  124242. */
  124243. get unTranslatedPointer(): Vector2;
  124244. /**
  124245. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  124246. */
  124247. static get DragMovementThreshold(): number;
  124248. static set DragMovementThreshold(value: number);
  124249. /**
  124250. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  124251. */
  124252. static get LongPressDelay(): number;
  124253. static set LongPressDelay(value: number);
  124254. /**
  124255. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  124256. */
  124257. static get DoubleClickDelay(): number;
  124258. static set DoubleClickDelay(value: number);
  124259. /** If you need to check double click without raising a single click at first click, enable this flag */
  124260. static get ExclusiveDoubleClickMode(): boolean;
  124261. static set ExclusiveDoubleClickMode(value: boolean);
  124262. /** @hidden */
  124263. _mirroredCameraPosition: Nullable<Vector3>;
  124264. /**
  124265. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  124266. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  124267. */
  124268. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  124269. /**
  124270. * Observable event triggered each time an keyboard event is received from the hosting window
  124271. */
  124272. onKeyboardObservable: Observable<KeyboardInfo>;
  124273. private _useRightHandedSystem;
  124274. /**
  124275. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  124276. */
  124277. set useRightHandedSystem(value: boolean);
  124278. get useRightHandedSystem(): boolean;
  124279. private _timeAccumulator;
  124280. private _currentStepId;
  124281. private _currentInternalStep;
  124282. /**
  124283. * Sets the step Id used by deterministic lock step
  124284. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124285. * @param newStepId defines the step Id
  124286. */
  124287. setStepId(newStepId: number): void;
  124288. /**
  124289. * Gets the step Id used by deterministic lock step
  124290. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124291. * @returns the step Id
  124292. */
  124293. getStepId(): number;
  124294. /**
  124295. * Gets the internal step used by deterministic lock step
  124296. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124297. * @returns the internal step
  124298. */
  124299. getInternalStep(): number;
  124300. private _fogEnabled;
  124301. /**
  124302. * Gets or sets a boolean indicating if fog is enabled on this scene
  124303. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124304. * (Default is true)
  124305. */
  124306. set fogEnabled(value: boolean);
  124307. get fogEnabled(): boolean;
  124308. private _fogMode;
  124309. /**
  124310. * Gets or sets the fog mode to use
  124311. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124312. * | mode | value |
  124313. * | --- | --- |
  124314. * | FOGMODE_NONE | 0 |
  124315. * | FOGMODE_EXP | 1 |
  124316. * | FOGMODE_EXP2 | 2 |
  124317. * | FOGMODE_LINEAR | 3 |
  124318. */
  124319. set fogMode(value: number);
  124320. get fogMode(): number;
  124321. /**
  124322. * Gets or sets the fog color to use
  124323. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124324. * (Default is Color3(0.2, 0.2, 0.3))
  124325. */
  124326. fogColor: Color3;
  124327. /**
  124328. * Gets or sets the fog density to use
  124329. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124330. * (Default is 0.1)
  124331. */
  124332. fogDensity: number;
  124333. /**
  124334. * Gets or sets the fog start distance to use
  124335. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124336. * (Default is 0)
  124337. */
  124338. fogStart: number;
  124339. /**
  124340. * Gets or sets the fog end distance to use
  124341. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124342. * (Default is 1000)
  124343. */
  124344. fogEnd: number;
  124345. /**
  124346. * Flag indicating that the frame buffer binding is handled by another component
  124347. */
  124348. prePass: boolean;
  124349. private _shadowsEnabled;
  124350. /**
  124351. * Gets or sets a boolean indicating if shadows are enabled on this scene
  124352. */
  124353. set shadowsEnabled(value: boolean);
  124354. get shadowsEnabled(): boolean;
  124355. private _lightsEnabled;
  124356. /**
  124357. * Gets or sets a boolean indicating if lights are enabled on this scene
  124358. */
  124359. set lightsEnabled(value: boolean);
  124360. get lightsEnabled(): boolean;
  124361. /** All of the active cameras added to this scene. */
  124362. activeCameras: Camera[];
  124363. /** @hidden */
  124364. _activeCamera: Nullable<Camera>;
  124365. /** Gets or sets the current active camera */
  124366. get activeCamera(): Nullable<Camera>;
  124367. set activeCamera(value: Nullable<Camera>);
  124368. private _defaultMaterial;
  124369. /** The default material used on meshes when no material is affected */
  124370. get defaultMaterial(): Material;
  124371. /** The default material used on meshes when no material is affected */
  124372. set defaultMaterial(value: Material);
  124373. private _texturesEnabled;
  124374. /**
  124375. * Gets or sets a boolean indicating if textures are enabled on this scene
  124376. */
  124377. set texturesEnabled(value: boolean);
  124378. get texturesEnabled(): boolean;
  124379. /**
  124380. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  124381. */
  124382. physicsEnabled: boolean;
  124383. /**
  124384. * Gets or sets a boolean indicating if particles are enabled on this scene
  124385. */
  124386. particlesEnabled: boolean;
  124387. /**
  124388. * Gets or sets a boolean indicating if sprites are enabled on this scene
  124389. */
  124390. spritesEnabled: boolean;
  124391. private _skeletonsEnabled;
  124392. /**
  124393. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  124394. */
  124395. set skeletonsEnabled(value: boolean);
  124396. get skeletonsEnabled(): boolean;
  124397. /**
  124398. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  124399. */
  124400. lensFlaresEnabled: boolean;
  124401. /**
  124402. * Gets or sets a boolean indicating if collisions are enabled on this scene
  124403. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124404. */
  124405. collisionsEnabled: boolean;
  124406. private _collisionCoordinator;
  124407. /** @hidden */
  124408. get collisionCoordinator(): ICollisionCoordinator;
  124409. /**
  124410. * Defines the gravity applied to this scene (used only for collisions)
  124411. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124412. */
  124413. gravity: Vector3;
  124414. /**
  124415. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  124416. */
  124417. postProcessesEnabled: boolean;
  124418. /**
  124419. * Gets the current postprocess manager
  124420. */
  124421. postProcessManager: PostProcessManager;
  124422. /**
  124423. * Gets or sets a boolean indicating if render targets are enabled on this scene
  124424. */
  124425. renderTargetsEnabled: boolean;
  124426. /**
  124427. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  124428. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  124429. */
  124430. dumpNextRenderTargets: boolean;
  124431. /**
  124432. * The list of user defined render targets added to the scene
  124433. */
  124434. customRenderTargets: RenderTargetTexture[];
  124435. /**
  124436. * Defines if texture loading must be delayed
  124437. * If true, textures will only be loaded when they need to be rendered
  124438. */
  124439. useDelayedTextureLoading: boolean;
  124440. /**
  124441. * Gets the list of meshes imported to the scene through SceneLoader
  124442. */
  124443. importedMeshesFiles: String[];
  124444. /**
  124445. * Gets or sets a boolean indicating if probes are enabled on this scene
  124446. */
  124447. probesEnabled: boolean;
  124448. /**
  124449. * Gets or sets the current offline provider to use to store scene data
  124450. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124451. */
  124452. offlineProvider: IOfflineProvider;
  124453. /**
  124454. * Gets or sets the action manager associated with the scene
  124455. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  124456. */
  124457. actionManager: AbstractActionManager;
  124458. private _meshesForIntersections;
  124459. /**
  124460. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  124461. */
  124462. proceduralTexturesEnabled: boolean;
  124463. private _engine;
  124464. private _totalVertices;
  124465. /** @hidden */
  124466. _activeIndices: PerfCounter;
  124467. /** @hidden */
  124468. _activeParticles: PerfCounter;
  124469. /** @hidden */
  124470. _activeBones: PerfCounter;
  124471. private _animationRatio;
  124472. /** @hidden */
  124473. _animationTimeLast: number;
  124474. /** @hidden */
  124475. _animationTime: number;
  124476. /**
  124477. * Gets or sets a general scale for animation speed
  124478. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  124479. */
  124480. animationTimeScale: number;
  124481. /** @hidden */
  124482. _cachedMaterial: Nullable<Material>;
  124483. /** @hidden */
  124484. _cachedEffect: Nullable<Effect>;
  124485. /** @hidden */
  124486. _cachedVisibility: Nullable<number>;
  124487. private _renderId;
  124488. private _frameId;
  124489. private _executeWhenReadyTimeoutId;
  124490. private _intermediateRendering;
  124491. private _viewUpdateFlag;
  124492. private _projectionUpdateFlag;
  124493. /** @hidden */
  124494. _toBeDisposed: Nullable<IDisposable>[];
  124495. private _activeRequests;
  124496. /** @hidden */
  124497. _pendingData: any[];
  124498. private _isDisposed;
  124499. /**
  124500. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  124501. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  124502. */
  124503. dispatchAllSubMeshesOfActiveMeshes: boolean;
  124504. private _activeMeshes;
  124505. private _processedMaterials;
  124506. private _renderTargets;
  124507. /** @hidden */
  124508. _activeParticleSystems: SmartArray<IParticleSystem>;
  124509. private _activeSkeletons;
  124510. private _softwareSkinnedMeshes;
  124511. private _renderingManager;
  124512. /** @hidden */
  124513. _activeAnimatables: Animatable[];
  124514. private _transformMatrix;
  124515. private _sceneUbo;
  124516. /** @hidden */
  124517. _viewMatrix: Matrix;
  124518. private _projectionMatrix;
  124519. /** @hidden */
  124520. _forcedViewPosition: Nullable<Vector3>;
  124521. /** @hidden */
  124522. _frustumPlanes: Plane[];
  124523. /**
  124524. * Gets the list of frustum planes (built from the active camera)
  124525. */
  124526. get frustumPlanes(): Plane[];
  124527. /**
  124528. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  124529. * This is useful if there are more lights that the maximum simulteanous authorized
  124530. */
  124531. requireLightSorting: boolean;
  124532. /** @hidden */
  124533. readonly useMaterialMeshMap: boolean;
  124534. /** @hidden */
  124535. readonly useClonedMeshMap: boolean;
  124536. private _externalData;
  124537. private _uid;
  124538. /**
  124539. * @hidden
  124540. * Backing store of defined scene components.
  124541. */
  124542. _components: ISceneComponent[];
  124543. /**
  124544. * @hidden
  124545. * Backing store of defined scene components.
  124546. */
  124547. _serializableComponents: ISceneSerializableComponent[];
  124548. /**
  124549. * List of components to register on the next registration step.
  124550. */
  124551. private _transientComponents;
  124552. /**
  124553. * Registers the transient components if needed.
  124554. */
  124555. private _registerTransientComponents;
  124556. /**
  124557. * @hidden
  124558. * Add a component to the scene.
  124559. * Note that the ccomponent could be registered on th next frame if this is called after
  124560. * the register component stage.
  124561. * @param component Defines the component to add to the scene
  124562. */
  124563. _addComponent(component: ISceneComponent): void;
  124564. /**
  124565. * @hidden
  124566. * Gets a component from the scene.
  124567. * @param name defines the name of the component to retrieve
  124568. * @returns the component or null if not present
  124569. */
  124570. _getComponent(name: string): Nullable<ISceneComponent>;
  124571. /**
  124572. * @hidden
  124573. * Defines the actions happening before camera updates.
  124574. */
  124575. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  124576. /**
  124577. * @hidden
  124578. * Defines the actions happening before clear the canvas.
  124579. */
  124580. _beforeClearStage: Stage<SimpleStageAction>;
  124581. /**
  124582. * @hidden
  124583. * Defines the actions when collecting render targets for the frame.
  124584. */
  124585. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  124586. /**
  124587. * @hidden
  124588. * Defines the actions happening for one camera in the frame.
  124589. */
  124590. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  124591. /**
  124592. * @hidden
  124593. * Defines the actions happening during the per mesh ready checks.
  124594. */
  124595. _isReadyForMeshStage: Stage<MeshStageAction>;
  124596. /**
  124597. * @hidden
  124598. * Defines the actions happening before evaluate active mesh checks.
  124599. */
  124600. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  124601. /**
  124602. * @hidden
  124603. * Defines the actions happening during the evaluate sub mesh checks.
  124604. */
  124605. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  124606. /**
  124607. * @hidden
  124608. * Defines the actions happening during the active mesh stage.
  124609. */
  124610. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  124611. /**
  124612. * @hidden
  124613. * Defines the actions happening during the per camera render target step.
  124614. */
  124615. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  124616. /**
  124617. * @hidden
  124618. * Defines the actions happening just before the active camera is drawing.
  124619. */
  124620. _beforeCameraDrawStage: Stage<CameraStageAction>;
  124621. /**
  124622. * @hidden
  124623. * Defines the actions happening just before a render target is drawing.
  124624. */
  124625. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  124626. /**
  124627. * @hidden
  124628. * Defines the actions happening just before a rendering group is drawing.
  124629. */
  124630. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  124631. /**
  124632. * @hidden
  124633. * Defines the actions happening just before a mesh is drawing.
  124634. */
  124635. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124636. /**
  124637. * @hidden
  124638. * Defines the actions happening just after a mesh has been drawn.
  124639. */
  124640. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124641. /**
  124642. * @hidden
  124643. * Defines the actions happening just after a rendering group has been drawn.
  124644. */
  124645. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  124646. /**
  124647. * @hidden
  124648. * Defines the actions happening just after the active camera has been drawn.
  124649. */
  124650. _afterCameraDrawStage: Stage<CameraStageAction>;
  124651. /**
  124652. * @hidden
  124653. * Defines the actions happening just after a render target has been drawn.
  124654. */
  124655. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  124656. /**
  124657. * @hidden
  124658. * Defines the actions happening just after rendering all cameras and computing intersections.
  124659. */
  124660. _afterRenderStage: Stage<SimpleStageAction>;
  124661. /**
  124662. * @hidden
  124663. * Defines the actions happening when a pointer move event happens.
  124664. */
  124665. _pointerMoveStage: Stage<PointerMoveStageAction>;
  124666. /**
  124667. * @hidden
  124668. * Defines the actions happening when a pointer down event happens.
  124669. */
  124670. _pointerDownStage: Stage<PointerUpDownStageAction>;
  124671. /**
  124672. * @hidden
  124673. * Defines the actions happening when a pointer up event happens.
  124674. */
  124675. _pointerUpStage: Stage<PointerUpDownStageAction>;
  124676. /**
  124677. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  124678. */
  124679. private geometriesByUniqueId;
  124680. /**
  124681. * Creates a new Scene
  124682. * @param engine defines the engine to use to render this scene
  124683. * @param options defines the scene options
  124684. */
  124685. constructor(engine: Engine, options?: SceneOptions);
  124686. /**
  124687. * Gets a string identifying the name of the class
  124688. * @returns "Scene" string
  124689. */
  124690. getClassName(): string;
  124691. private _defaultMeshCandidates;
  124692. /**
  124693. * @hidden
  124694. */
  124695. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  124696. private _defaultSubMeshCandidates;
  124697. /**
  124698. * @hidden
  124699. */
  124700. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  124701. /**
  124702. * Sets the default candidate providers for the scene.
  124703. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  124704. * and getCollidingSubMeshCandidates to their default function
  124705. */
  124706. setDefaultCandidateProviders(): void;
  124707. /**
  124708. * Gets the mesh that is currently under the pointer
  124709. */
  124710. get meshUnderPointer(): Nullable<AbstractMesh>;
  124711. /**
  124712. * Gets or sets the current on-screen X position of the pointer
  124713. */
  124714. get pointerX(): number;
  124715. set pointerX(value: number);
  124716. /**
  124717. * Gets or sets the current on-screen Y position of the pointer
  124718. */
  124719. get pointerY(): number;
  124720. set pointerY(value: number);
  124721. /**
  124722. * Gets the cached material (ie. the latest rendered one)
  124723. * @returns the cached material
  124724. */
  124725. getCachedMaterial(): Nullable<Material>;
  124726. /**
  124727. * Gets the cached effect (ie. the latest rendered one)
  124728. * @returns the cached effect
  124729. */
  124730. getCachedEffect(): Nullable<Effect>;
  124731. /**
  124732. * Gets the cached visibility state (ie. the latest rendered one)
  124733. * @returns the cached visibility state
  124734. */
  124735. getCachedVisibility(): Nullable<number>;
  124736. /**
  124737. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  124738. * @param material defines the current material
  124739. * @param effect defines the current effect
  124740. * @param visibility defines the current visibility state
  124741. * @returns true if one parameter is not cached
  124742. */
  124743. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  124744. /**
  124745. * Gets the engine associated with the scene
  124746. * @returns an Engine
  124747. */
  124748. getEngine(): Engine;
  124749. /**
  124750. * Gets the total number of vertices rendered per frame
  124751. * @returns the total number of vertices rendered per frame
  124752. */
  124753. getTotalVertices(): number;
  124754. /**
  124755. * Gets the performance counter for total vertices
  124756. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124757. */
  124758. get totalVerticesPerfCounter(): PerfCounter;
  124759. /**
  124760. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  124761. * @returns the total number of active indices rendered per frame
  124762. */
  124763. getActiveIndices(): number;
  124764. /**
  124765. * Gets the performance counter for active indices
  124766. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124767. */
  124768. get totalActiveIndicesPerfCounter(): PerfCounter;
  124769. /**
  124770. * Gets the total number of active particles rendered per frame
  124771. * @returns the total number of active particles rendered per frame
  124772. */
  124773. getActiveParticles(): number;
  124774. /**
  124775. * Gets the performance counter for active particles
  124776. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124777. */
  124778. get activeParticlesPerfCounter(): PerfCounter;
  124779. /**
  124780. * Gets the total number of active bones rendered per frame
  124781. * @returns the total number of active bones rendered per frame
  124782. */
  124783. getActiveBones(): number;
  124784. /**
  124785. * Gets the performance counter for active bones
  124786. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124787. */
  124788. get activeBonesPerfCounter(): PerfCounter;
  124789. /**
  124790. * Gets the array of active meshes
  124791. * @returns an array of AbstractMesh
  124792. */
  124793. getActiveMeshes(): SmartArray<AbstractMesh>;
  124794. /**
  124795. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  124796. * @returns a number
  124797. */
  124798. getAnimationRatio(): number;
  124799. /**
  124800. * Gets an unique Id for the current render phase
  124801. * @returns a number
  124802. */
  124803. getRenderId(): number;
  124804. /**
  124805. * Gets an unique Id for the current frame
  124806. * @returns a number
  124807. */
  124808. getFrameId(): number;
  124809. /** Call this function if you want to manually increment the render Id*/
  124810. incrementRenderId(): void;
  124811. private _createUbo;
  124812. /**
  124813. * Use this method to simulate a pointer move on a mesh
  124814. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124815. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124816. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124817. * @returns the current scene
  124818. */
  124819. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124820. /**
  124821. * Use this method to simulate a pointer down on a mesh
  124822. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124823. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124824. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124825. * @returns the current scene
  124826. */
  124827. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124828. /**
  124829. * Use this method to simulate a pointer up on a mesh
  124830. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124831. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124832. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124833. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124834. * @returns the current scene
  124835. */
  124836. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  124837. /**
  124838. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124839. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124840. * @returns true if the pointer was captured
  124841. */
  124842. isPointerCaptured(pointerId?: number): boolean;
  124843. /**
  124844. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124845. * @param attachUp defines if you want to attach events to pointerup
  124846. * @param attachDown defines if you want to attach events to pointerdown
  124847. * @param attachMove defines if you want to attach events to pointermove
  124848. */
  124849. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  124850. /** Detaches all event handlers*/
  124851. detachControl(): void;
  124852. /**
  124853. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  124854. * Delay loaded resources are not taking in account
  124855. * @return true if all required resources are ready
  124856. */
  124857. isReady(): boolean;
  124858. /** Resets all cached information relative to material (including effect and visibility) */
  124859. resetCachedMaterial(): void;
  124860. /**
  124861. * Registers a function to be called before every frame render
  124862. * @param func defines the function to register
  124863. */
  124864. registerBeforeRender(func: () => void): void;
  124865. /**
  124866. * Unregisters a function called before every frame render
  124867. * @param func defines the function to unregister
  124868. */
  124869. unregisterBeforeRender(func: () => void): void;
  124870. /**
  124871. * Registers a function to be called after every frame render
  124872. * @param func defines the function to register
  124873. */
  124874. registerAfterRender(func: () => void): void;
  124875. /**
  124876. * Unregisters a function called after every frame render
  124877. * @param func defines the function to unregister
  124878. */
  124879. unregisterAfterRender(func: () => void): void;
  124880. private _executeOnceBeforeRender;
  124881. /**
  124882. * The provided function will run before render once and will be disposed afterwards.
  124883. * A timeout delay can be provided so that the function will be executed in N ms.
  124884. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  124885. * @param func The function to be executed.
  124886. * @param timeout optional delay in ms
  124887. */
  124888. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  124889. /** @hidden */
  124890. _addPendingData(data: any): void;
  124891. /** @hidden */
  124892. _removePendingData(data: any): void;
  124893. /**
  124894. * Returns the number of items waiting to be loaded
  124895. * @returns the number of items waiting to be loaded
  124896. */
  124897. getWaitingItemsCount(): number;
  124898. /**
  124899. * Returns a boolean indicating if the scene is still loading data
  124900. */
  124901. get isLoading(): boolean;
  124902. /**
  124903. * Registers a function to be executed when the scene is ready
  124904. * @param {Function} func - the function to be executed
  124905. */
  124906. executeWhenReady(func: () => void): void;
  124907. /**
  124908. * Returns a promise that resolves when the scene is ready
  124909. * @returns A promise that resolves when the scene is ready
  124910. */
  124911. whenReadyAsync(): Promise<void>;
  124912. /** @hidden */
  124913. _checkIsReady(): void;
  124914. /**
  124915. * Gets all animatable attached to the scene
  124916. */
  124917. get animatables(): Animatable[];
  124918. /**
  124919. * Resets the last animation time frame.
  124920. * Useful to override when animations start running when loading a scene for the first time.
  124921. */
  124922. resetLastAnimationTimeFrame(): void;
  124923. /**
  124924. * Gets the current view matrix
  124925. * @returns a Matrix
  124926. */
  124927. getViewMatrix(): Matrix;
  124928. /**
  124929. * Gets the current projection matrix
  124930. * @returns a Matrix
  124931. */
  124932. getProjectionMatrix(): Matrix;
  124933. /**
  124934. * Gets the current transform matrix
  124935. * @returns a Matrix made of View * Projection
  124936. */
  124937. getTransformMatrix(): Matrix;
  124938. /**
  124939. * Sets the current transform matrix
  124940. * @param viewL defines the View matrix to use
  124941. * @param projectionL defines the Projection matrix to use
  124942. * @param viewR defines the right View matrix to use (if provided)
  124943. * @param projectionR defines the right Projection matrix to use (if provided)
  124944. */
  124945. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  124946. /**
  124947. * Gets the uniform buffer used to store scene data
  124948. * @returns a UniformBuffer
  124949. */
  124950. getSceneUniformBuffer(): UniformBuffer;
  124951. /**
  124952. * Gets an unique (relatively to the current scene) Id
  124953. * @returns an unique number for the scene
  124954. */
  124955. getUniqueId(): number;
  124956. /**
  124957. * Add a mesh to the list of scene's meshes
  124958. * @param newMesh defines the mesh to add
  124959. * @param recursive if all child meshes should also be added to the scene
  124960. */
  124961. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  124962. /**
  124963. * Remove a mesh for the list of scene's meshes
  124964. * @param toRemove defines the mesh to remove
  124965. * @param recursive if all child meshes should also be removed from the scene
  124966. * @returns the index where the mesh was in the mesh list
  124967. */
  124968. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  124969. /**
  124970. * Add a transform node to the list of scene's transform nodes
  124971. * @param newTransformNode defines the transform node to add
  124972. */
  124973. addTransformNode(newTransformNode: TransformNode): void;
  124974. /**
  124975. * Remove a transform node for the list of scene's transform nodes
  124976. * @param toRemove defines the transform node to remove
  124977. * @returns the index where the transform node was in the transform node list
  124978. */
  124979. removeTransformNode(toRemove: TransformNode): number;
  124980. /**
  124981. * Remove a skeleton for the list of scene's skeletons
  124982. * @param toRemove defines the skeleton to remove
  124983. * @returns the index where the skeleton was in the skeleton list
  124984. */
  124985. removeSkeleton(toRemove: Skeleton): number;
  124986. /**
  124987. * Remove a morph target for the list of scene's morph targets
  124988. * @param toRemove defines the morph target to remove
  124989. * @returns the index where the morph target was in the morph target list
  124990. */
  124991. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  124992. /**
  124993. * Remove a light for the list of scene's lights
  124994. * @param toRemove defines the light to remove
  124995. * @returns the index where the light was in the light list
  124996. */
  124997. removeLight(toRemove: Light): number;
  124998. /**
  124999. * Remove a camera for the list of scene's cameras
  125000. * @param toRemove defines the camera to remove
  125001. * @returns the index where the camera was in the camera list
  125002. */
  125003. removeCamera(toRemove: Camera): number;
  125004. /**
  125005. * Remove a particle system for the list of scene's particle systems
  125006. * @param toRemove defines the particle system to remove
  125007. * @returns the index where the particle system was in the particle system list
  125008. */
  125009. removeParticleSystem(toRemove: IParticleSystem): number;
  125010. /**
  125011. * Remove a animation for the list of scene's animations
  125012. * @param toRemove defines the animation to remove
  125013. * @returns the index where the animation was in the animation list
  125014. */
  125015. removeAnimation(toRemove: Animation): number;
  125016. /**
  125017. * Will stop the animation of the given target
  125018. * @param target - the target
  125019. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  125020. * @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)
  125021. */
  125022. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  125023. /**
  125024. * Removes the given animation group from this scene.
  125025. * @param toRemove The animation group to remove
  125026. * @returns The index of the removed animation group
  125027. */
  125028. removeAnimationGroup(toRemove: AnimationGroup): number;
  125029. /**
  125030. * Removes the given multi-material from this scene.
  125031. * @param toRemove The multi-material to remove
  125032. * @returns The index of the removed multi-material
  125033. */
  125034. removeMultiMaterial(toRemove: MultiMaterial): number;
  125035. /**
  125036. * Removes the given material from this scene.
  125037. * @param toRemove The material to remove
  125038. * @returns The index of the removed material
  125039. */
  125040. removeMaterial(toRemove: Material): number;
  125041. /**
  125042. * Removes the given action manager from this scene.
  125043. * @param toRemove The action manager to remove
  125044. * @returns The index of the removed action manager
  125045. */
  125046. removeActionManager(toRemove: AbstractActionManager): number;
  125047. /**
  125048. * Removes the given texture from this scene.
  125049. * @param toRemove The texture to remove
  125050. * @returns The index of the removed texture
  125051. */
  125052. removeTexture(toRemove: BaseTexture): number;
  125053. /**
  125054. * Adds the given light to this scene
  125055. * @param newLight The light to add
  125056. */
  125057. addLight(newLight: Light): void;
  125058. /**
  125059. * Sorts the list list based on light priorities
  125060. */
  125061. sortLightsByPriority(): void;
  125062. /**
  125063. * Adds the given camera to this scene
  125064. * @param newCamera The camera to add
  125065. */
  125066. addCamera(newCamera: Camera): void;
  125067. /**
  125068. * Adds the given skeleton to this scene
  125069. * @param newSkeleton The skeleton to add
  125070. */
  125071. addSkeleton(newSkeleton: Skeleton): void;
  125072. /**
  125073. * Adds the given particle system to this scene
  125074. * @param newParticleSystem The particle system to add
  125075. */
  125076. addParticleSystem(newParticleSystem: IParticleSystem): void;
  125077. /**
  125078. * Adds the given animation to this scene
  125079. * @param newAnimation The animation to add
  125080. */
  125081. addAnimation(newAnimation: Animation): void;
  125082. /**
  125083. * Adds the given animation group to this scene.
  125084. * @param newAnimationGroup The animation group to add
  125085. */
  125086. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  125087. /**
  125088. * Adds the given multi-material to this scene
  125089. * @param newMultiMaterial The multi-material to add
  125090. */
  125091. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  125092. /**
  125093. * Adds the given material to this scene
  125094. * @param newMaterial The material to add
  125095. */
  125096. addMaterial(newMaterial: Material): void;
  125097. /**
  125098. * Adds the given morph target to this scene
  125099. * @param newMorphTargetManager The morph target to add
  125100. */
  125101. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  125102. /**
  125103. * Adds the given geometry to this scene
  125104. * @param newGeometry The geometry to add
  125105. */
  125106. addGeometry(newGeometry: Geometry): void;
  125107. /**
  125108. * Adds the given action manager to this scene
  125109. * @param newActionManager The action manager to add
  125110. */
  125111. addActionManager(newActionManager: AbstractActionManager): void;
  125112. /**
  125113. * Adds the given texture to this scene.
  125114. * @param newTexture The texture to add
  125115. */
  125116. addTexture(newTexture: BaseTexture): void;
  125117. /**
  125118. * Switch active camera
  125119. * @param newCamera defines the new active camera
  125120. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  125121. */
  125122. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  125123. /**
  125124. * sets the active camera of the scene using its ID
  125125. * @param id defines the camera's ID
  125126. * @return the new active camera or null if none found.
  125127. */
  125128. setActiveCameraByID(id: string): Nullable<Camera>;
  125129. /**
  125130. * sets the active camera of the scene using its name
  125131. * @param name defines the camera's name
  125132. * @returns the new active camera or null if none found.
  125133. */
  125134. setActiveCameraByName(name: string): Nullable<Camera>;
  125135. /**
  125136. * get an animation group using its name
  125137. * @param name defines the material's name
  125138. * @return the animation group or null if none found.
  125139. */
  125140. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  125141. /**
  125142. * Get a material using its unique id
  125143. * @param uniqueId defines the material's unique id
  125144. * @return the material or null if none found.
  125145. */
  125146. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  125147. /**
  125148. * get a material using its id
  125149. * @param id defines the material's ID
  125150. * @return the material or null if none found.
  125151. */
  125152. getMaterialByID(id: string): Nullable<Material>;
  125153. /**
  125154. * Gets a the last added material using a given id
  125155. * @param id defines the material's ID
  125156. * @return the last material with the given id or null if none found.
  125157. */
  125158. getLastMaterialByID(id: string): Nullable<Material>;
  125159. /**
  125160. * Gets a material using its name
  125161. * @param name defines the material's name
  125162. * @return the material or null if none found.
  125163. */
  125164. getMaterialByName(name: string): Nullable<Material>;
  125165. /**
  125166. * Get a texture using its unique id
  125167. * @param uniqueId defines the texture's unique id
  125168. * @return the texture or null if none found.
  125169. */
  125170. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  125171. /**
  125172. * Gets a camera using its id
  125173. * @param id defines the id to look for
  125174. * @returns the camera or null if not found
  125175. */
  125176. getCameraByID(id: string): Nullable<Camera>;
  125177. /**
  125178. * Gets a camera using its unique id
  125179. * @param uniqueId defines the unique id to look for
  125180. * @returns the camera or null if not found
  125181. */
  125182. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  125183. /**
  125184. * Gets a camera using its name
  125185. * @param name defines the camera's name
  125186. * @return the camera or null if none found.
  125187. */
  125188. getCameraByName(name: string): Nullable<Camera>;
  125189. /**
  125190. * Gets a bone using its id
  125191. * @param id defines the bone's id
  125192. * @return the bone or null if not found
  125193. */
  125194. getBoneByID(id: string): Nullable<Bone>;
  125195. /**
  125196. * Gets a bone using its id
  125197. * @param name defines the bone's name
  125198. * @return the bone or null if not found
  125199. */
  125200. getBoneByName(name: string): Nullable<Bone>;
  125201. /**
  125202. * Gets a light node using its name
  125203. * @param name defines the the light's name
  125204. * @return the light or null if none found.
  125205. */
  125206. getLightByName(name: string): Nullable<Light>;
  125207. /**
  125208. * Gets a light node using its id
  125209. * @param id defines the light's id
  125210. * @return the light or null if none found.
  125211. */
  125212. getLightByID(id: string): Nullable<Light>;
  125213. /**
  125214. * Gets a light node using its scene-generated unique ID
  125215. * @param uniqueId defines the light's unique id
  125216. * @return the light or null if none found.
  125217. */
  125218. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  125219. /**
  125220. * Gets a particle system by id
  125221. * @param id defines the particle system id
  125222. * @return the corresponding system or null if none found
  125223. */
  125224. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  125225. /**
  125226. * Gets a geometry using its ID
  125227. * @param id defines the geometry's id
  125228. * @return the geometry or null if none found.
  125229. */
  125230. getGeometryByID(id: string): Nullable<Geometry>;
  125231. private _getGeometryByUniqueID;
  125232. /**
  125233. * Add a new geometry to this scene
  125234. * @param geometry defines the geometry to be added to the scene.
  125235. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  125236. * @return a boolean defining if the geometry was added or not
  125237. */
  125238. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  125239. /**
  125240. * Removes an existing geometry
  125241. * @param geometry defines the geometry to be removed from the scene
  125242. * @return a boolean defining if the geometry was removed or not
  125243. */
  125244. removeGeometry(geometry: Geometry): boolean;
  125245. /**
  125246. * Gets the list of geometries attached to the scene
  125247. * @returns an array of Geometry
  125248. */
  125249. getGeometries(): Geometry[];
  125250. /**
  125251. * Gets the first added mesh found of a given ID
  125252. * @param id defines the id to search for
  125253. * @return the mesh found or null if not found at all
  125254. */
  125255. getMeshByID(id: string): Nullable<AbstractMesh>;
  125256. /**
  125257. * Gets a list of meshes using their id
  125258. * @param id defines the id to search for
  125259. * @returns a list of meshes
  125260. */
  125261. getMeshesByID(id: string): Array<AbstractMesh>;
  125262. /**
  125263. * Gets the first added transform node found of a given ID
  125264. * @param id defines the id to search for
  125265. * @return the found transform node or null if not found at all.
  125266. */
  125267. getTransformNodeByID(id: string): Nullable<TransformNode>;
  125268. /**
  125269. * Gets a transform node with its auto-generated unique id
  125270. * @param uniqueId efines the unique id to search for
  125271. * @return the found transform node or null if not found at all.
  125272. */
  125273. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  125274. /**
  125275. * Gets a list of transform nodes using their id
  125276. * @param id defines the id to search for
  125277. * @returns a list of transform nodes
  125278. */
  125279. getTransformNodesByID(id: string): Array<TransformNode>;
  125280. /**
  125281. * Gets a mesh with its auto-generated unique id
  125282. * @param uniqueId defines the unique id to search for
  125283. * @return the found mesh or null if not found at all.
  125284. */
  125285. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  125286. /**
  125287. * Gets a the last added mesh using a given id
  125288. * @param id defines the id to search for
  125289. * @return the found mesh or null if not found at all.
  125290. */
  125291. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  125292. /**
  125293. * Gets a the last added node (Mesh, Camera, Light) using a given id
  125294. * @param id defines the id to search for
  125295. * @return the found node or null if not found at all
  125296. */
  125297. getLastEntryByID(id: string): Nullable<Node>;
  125298. /**
  125299. * Gets a node (Mesh, Camera, Light) using a given id
  125300. * @param id defines the id to search for
  125301. * @return the found node or null if not found at all
  125302. */
  125303. getNodeByID(id: string): Nullable<Node>;
  125304. /**
  125305. * Gets a node (Mesh, Camera, Light) using a given name
  125306. * @param name defines the name to search for
  125307. * @return the found node or null if not found at all.
  125308. */
  125309. getNodeByName(name: string): Nullable<Node>;
  125310. /**
  125311. * Gets a mesh using a given name
  125312. * @param name defines the name to search for
  125313. * @return the found mesh or null if not found at all.
  125314. */
  125315. getMeshByName(name: string): Nullable<AbstractMesh>;
  125316. /**
  125317. * Gets a transform node using a given name
  125318. * @param name defines the name to search for
  125319. * @return the found transform node or null if not found at all.
  125320. */
  125321. getTransformNodeByName(name: string): Nullable<TransformNode>;
  125322. /**
  125323. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  125324. * @param id defines the id to search for
  125325. * @return the found skeleton or null if not found at all.
  125326. */
  125327. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  125328. /**
  125329. * Gets a skeleton using a given auto generated unique id
  125330. * @param uniqueId defines the unique id to search for
  125331. * @return the found skeleton or null if not found at all.
  125332. */
  125333. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  125334. /**
  125335. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  125336. * @param id defines the id to search for
  125337. * @return the found skeleton or null if not found at all.
  125338. */
  125339. getSkeletonById(id: string): Nullable<Skeleton>;
  125340. /**
  125341. * Gets a skeleton using a given name
  125342. * @param name defines the name to search for
  125343. * @return the found skeleton or null if not found at all.
  125344. */
  125345. getSkeletonByName(name: string): Nullable<Skeleton>;
  125346. /**
  125347. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  125348. * @param id defines the id to search for
  125349. * @return the found morph target manager or null if not found at all.
  125350. */
  125351. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  125352. /**
  125353. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  125354. * @param id defines the id to search for
  125355. * @return the found morph target or null if not found at all.
  125356. */
  125357. getMorphTargetById(id: string): Nullable<MorphTarget>;
  125358. /**
  125359. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  125360. * @param name defines the name to search for
  125361. * @return the found morph target or null if not found at all.
  125362. */
  125363. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  125364. /**
  125365. * Gets a post process using a given name (if many are found, this function will pick the first one)
  125366. * @param name defines the name to search for
  125367. * @return the found post process or null if not found at all.
  125368. */
  125369. getPostProcessByName(name: string): Nullable<PostProcess>;
  125370. /**
  125371. * Gets a boolean indicating if the given mesh is active
  125372. * @param mesh defines the mesh to look for
  125373. * @returns true if the mesh is in the active list
  125374. */
  125375. isActiveMesh(mesh: AbstractMesh): boolean;
  125376. /**
  125377. * Return a unique id as a string which can serve as an identifier for the scene
  125378. */
  125379. get uid(): string;
  125380. /**
  125381. * Add an externaly attached data from its key.
  125382. * This method call will fail and return false, if such key already exists.
  125383. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  125384. * @param key the unique key that identifies the data
  125385. * @param data the data object to associate to the key for this Engine instance
  125386. * @return true if no such key were already present and the data was added successfully, false otherwise
  125387. */
  125388. addExternalData<T>(key: string, data: T): boolean;
  125389. /**
  125390. * Get an externaly attached data from its key
  125391. * @param key the unique key that identifies the data
  125392. * @return the associated data, if present (can be null), or undefined if not present
  125393. */
  125394. getExternalData<T>(key: string): Nullable<T>;
  125395. /**
  125396. * Get an externaly attached data from its key, create it using a factory if it's not already present
  125397. * @param key the unique key that identifies the data
  125398. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  125399. * @return the associated data, can be null if the factory returned null.
  125400. */
  125401. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  125402. /**
  125403. * Remove an externaly attached data from the Engine instance
  125404. * @param key the unique key that identifies the data
  125405. * @return true if the data was successfully removed, false if it doesn't exist
  125406. */
  125407. removeExternalData(key: string): boolean;
  125408. private _evaluateSubMesh;
  125409. /**
  125410. * Clear the processed materials smart array preventing retention point in material dispose.
  125411. */
  125412. freeProcessedMaterials(): void;
  125413. private _preventFreeActiveMeshesAndRenderingGroups;
  125414. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  125415. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  125416. * when disposing several meshes in a row or a hierarchy of meshes.
  125417. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  125418. */
  125419. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  125420. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  125421. /**
  125422. * Clear the active meshes smart array preventing retention point in mesh dispose.
  125423. */
  125424. freeActiveMeshes(): void;
  125425. /**
  125426. * Clear the info related to rendering groups preventing retention points during dispose.
  125427. */
  125428. freeRenderingGroups(): void;
  125429. /** @hidden */
  125430. _isInIntermediateRendering(): boolean;
  125431. /**
  125432. * Lambda returning the list of potentially active meshes.
  125433. */
  125434. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  125435. /**
  125436. * Lambda returning the list of potentially active sub meshes.
  125437. */
  125438. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  125439. /**
  125440. * Lambda returning the list of potentially intersecting sub meshes.
  125441. */
  125442. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  125443. /**
  125444. * Lambda returning the list of potentially colliding sub meshes.
  125445. */
  125446. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  125447. private _activeMeshesFrozen;
  125448. private _skipEvaluateActiveMeshesCompletely;
  125449. /**
  125450. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  125451. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  125452. * @param onSuccess optional success callback
  125453. * @param onError optional error callback
  125454. * @returns the current scene
  125455. */
  125456. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  125457. /**
  125458. * Use this function to restart evaluating active meshes on every frame
  125459. * @returns the current scene
  125460. */
  125461. unfreezeActiveMeshes(): Scene;
  125462. private _evaluateActiveMeshes;
  125463. private _activeMesh;
  125464. /**
  125465. * Update the transform matrix to update from the current active camera
  125466. * @param force defines a boolean used to force the update even if cache is up to date
  125467. */
  125468. updateTransformMatrix(force?: boolean): void;
  125469. private _bindFrameBuffer;
  125470. /** @hidden */
  125471. _allowPostProcessClearColor: boolean;
  125472. /** @hidden */
  125473. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  125474. private _processSubCameras;
  125475. private _checkIntersections;
  125476. /** @hidden */
  125477. _advancePhysicsEngineStep(step: number): void;
  125478. /**
  125479. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  125480. */
  125481. getDeterministicFrameTime: () => number;
  125482. /** @hidden */
  125483. _animate(): void;
  125484. /** Execute all animations (for a frame) */
  125485. animate(): void;
  125486. /**
  125487. * Render the scene
  125488. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  125489. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  125490. */
  125491. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  125492. /**
  125493. * Freeze all materials
  125494. * A frozen material will not be updatable but should be faster to render
  125495. */
  125496. freezeMaterials(): void;
  125497. /**
  125498. * Unfreeze all materials
  125499. * A frozen material will not be updatable but should be faster to render
  125500. */
  125501. unfreezeMaterials(): void;
  125502. /**
  125503. * Releases all held ressources
  125504. */
  125505. dispose(): void;
  125506. /**
  125507. * Gets if the scene is already disposed
  125508. */
  125509. get isDisposed(): boolean;
  125510. /**
  125511. * Call this function to reduce memory footprint of the scene.
  125512. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  125513. */
  125514. clearCachedVertexData(): void;
  125515. /**
  125516. * This function will remove the local cached buffer data from texture.
  125517. * It will save memory but will prevent the texture from being rebuilt
  125518. */
  125519. cleanCachedTextureBuffer(): void;
  125520. /**
  125521. * Get the world extend vectors with an optional filter
  125522. *
  125523. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  125524. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  125525. */
  125526. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  125527. min: Vector3;
  125528. max: Vector3;
  125529. };
  125530. /**
  125531. * Creates a ray that can be used to pick in the scene
  125532. * @param x defines the x coordinate of the origin (on-screen)
  125533. * @param y defines the y coordinate of the origin (on-screen)
  125534. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  125535. * @param camera defines the camera to use for the picking
  125536. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  125537. * @returns a Ray
  125538. */
  125539. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  125540. /**
  125541. * Creates a ray that can be used to pick in the scene
  125542. * @param x defines the x coordinate of the origin (on-screen)
  125543. * @param y defines the y coordinate of the origin (on-screen)
  125544. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  125545. * @param result defines the ray where to store the picking ray
  125546. * @param camera defines the camera to use for the picking
  125547. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  125548. * @returns the current scene
  125549. */
  125550. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  125551. /**
  125552. * Creates a ray that can be used to pick in the scene
  125553. * @param x defines the x coordinate of the origin (on-screen)
  125554. * @param y defines the y coordinate of the origin (on-screen)
  125555. * @param camera defines the camera to use for the picking
  125556. * @returns a Ray
  125557. */
  125558. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  125559. /**
  125560. * Creates a ray that can be used to pick in the scene
  125561. * @param x defines the x coordinate of the origin (on-screen)
  125562. * @param y defines the y coordinate of the origin (on-screen)
  125563. * @param result defines the ray where to store the picking ray
  125564. * @param camera defines the camera to use for the picking
  125565. * @returns the current scene
  125566. */
  125567. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  125568. /** Launch a ray to try to pick a mesh in the scene
  125569. * @param x position on screen
  125570. * @param y position on screen
  125571. * @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
  125572. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125573. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125574. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125575. * @returns a PickingInfo
  125576. */
  125577. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  125578. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  125579. * @param x position on screen
  125580. * @param y position on screen
  125581. * @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
  125582. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125583. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125584. * @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)
  125585. */
  125586. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  125587. /** Use the given ray to pick a mesh in the scene
  125588. * @param ray The ray to use to pick meshes
  125589. * @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
  125590. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125591. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125592. * @returns a PickingInfo
  125593. */
  125594. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  125595. /**
  125596. * Launch a ray to try to pick a mesh in the scene
  125597. * @param x X position on screen
  125598. * @param y Y position on screen
  125599. * @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
  125600. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125601. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125602. * @returns an array of PickingInfo
  125603. */
  125604. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  125605. /**
  125606. * Launch a ray to try to pick a mesh in the scene
  125607. * @param ray Ray to use
  125608. * @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
  125609. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125610. * @returns an array of PickingInfo
  125611. */
  125612. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  125613. /**
  125614. * Force the value of meshUnderPointer
  125615. * @param mesh defines the mesh to use
  125616. * @param pointerId optional pointer id when using more than one pointer
  125617. */
  125618. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  125619. /**
  125620. * Gets the mesh under the pointer
  125621. * @returns a Mesh or null if no mesh is under the pointer
  125622. */
  125623. getPointerOverMesh(): Nullable<AbstractMesh>;
  125624. /** @hidden */
  125625. _rebuildGeometries(): void;
  125626. /** @hidden */
  125627. _rebuildTextures(): void;
  125628. private _getByTags;
  125629. /**
  125630. * Get a list of meshes by tags
  125631. * @param tagsQuery defines the tags query to use
  125632. * @param forEach defines a predicate used to filter results
  125633. * @returns an array of Mesh
  125634. */
  125635. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  125636. /**
  125637. * Get a list of cameras by tags
  125638. * @param tagsQuery defines the tags query to use
  125639. * @param forEach defines a predicate used to filter results
  125640. * @returns an array of Camera
  125641. */
  125642. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  125643. /**
  125644. * Get a list of lights by tags
  125645. * @param tagsQuery defines the tags query to use
  125646. * @param forEach defines a predicate used to filter results
  125647. * @returns an array of Light
  125648. */
  125649. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  125650. /**
  125651. * Get a list of materials by tags
  125652. * @param tagsQuery defines the tags query to use
  125653. * @param forEach defines a predicate used to filter results
  125654. * @returns an array of Material
  125655. */
  125656. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  125657. /**
  125658. * Get a list of transform nodes by tags
  125659. * @param tagsQuery defines the tags query to use
  125660. * @param forEach defines a predicate used to filter results
  125661. * @returns an array of TransformNode
  125662. */
  125663. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  125664. /**
  125665. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  125666. * This allowed control for front to back rendering or reversly depending of the special needs.
  125667. *
  125668. * @param renderingGroupId The rendering group id corresponding to its index
  125669. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  125670. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  125671. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  125672. */
  125673. 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;
  125674. /**
  125675. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  125676. *
  125677. * @param renderingGroupId The rendering group id corresponding to its index
  125678. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  125679. * @param depth Automatically clears depth between groups if true and autoClear is true.
  125680. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  125681. */
  125682. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  125683. /**
  125684. * Gets the current auto clear configuration for one rendering group of the rendering
  125685. * manager.
  125686. * @param index the rendering group index to get the information for
  125687. * @returns The auto clear setup for the requested rendering group
  125688. */
  125689. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  125690. private _blockMaterialDirtyMechanism;
  125691. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  125692. get blockMaterialDirtyMechanism(): boolean;
  125693. set blockMaterialDirtyMechanism(value: boolean);
  125694. /**
  125695. * Will flag all materials as dirty to trigger new shader compilation
  125696. * @param flag defines the flag used to specify which material part must be marked as dirty
  125697. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  125698. */
  125699. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  125700. /** @hidden */
  125701. _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;
  125702. /** @hidden */
  125703. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125704. /** @hidden */
  125705. _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;
  125706. /** @hidden */
  125707. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  125708. /** @hidden */
  125709. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  125710. /** @hidden */
  125711. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125712. }
  125713. }
  125714. declare module BABYLON {
  125715. /**
  125716. * Set of assets to keep when moving a scene into an asset container.
  125717. */
  125718. export class KeepAssets extends AbstractScene {
  125719. }
  125720. /**
  125721. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  125722. */
  125723. export class InstantiatedEntries {
  125724. /**
  125725. * List of new root nodes (eg. nodes with no parent)
  125726. */
  125727. rootNodes: TransformNode[];
  125728. /**
  125729. * List of new skeletons
  125730. */
  125731. skeletons: Skeleton[];
  125732. /**
  125733. * List of new animation groups
  125734. */
  125735. animationGroups: AnimationGroup[];
  125736. }
  125737. /**
  125738. * Container with a set of assets that can be added or removed from a scene.
  125739. */
  125740. export class AssetContainer extends AbstractScene {
  125741. private _wasAddedToScene;
  125742. /**
  125743. * The scene the AssetContainer belongs to.
  125744. */
  125745. scene: Scene;
  125746. /**
  125747. * Instantiates an AssetContainer.
  125748. * @param scene The scene the AssetContainer belongs to.
  125749. */
  125750. constructor(scene: Scene);
  125751. /**
  125752. * Instantiate or clone all meshes and add the new ones to the scene.
  125753. * Skeletons and animation groups will all be cloned
  125754. * @param nameFunction defines an optional function used to get new names for clones
  125755. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  125756. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  125757. */
  125758. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  125759. /**
  125760. * Adds all the assets from the container to the scene.
  125761. */
  125762. addAllToScene(): void;
  125763. /**
  125764. * Removes all the assets in the container from the scene
  125765. */
  125766. removeAllFromScene(): void;
  125767. /**
  125768. * Disposes all the assets in the container
  125769. */
  125770. dispose(): void;
  125771. private _moveAssets;
  125772. /**
  125773. * Removes all the assets contained in the scene and adds them to the container.
  125774. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  125775. */
  125776. moveAllFromScene(keepAssets?: KeepAssets): void;
  125777. /**
  125778. * 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.
  125779. * @returns the root mesh
  125780. */
  125781. createRootMesh(): Mesh;
  125782. /**
  125783. * Merge animations (direct and animation groups) from this asset container into a scene
  125784. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125785. * @param animatables set of animatables to retarget to a node from the scene
  125786. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  125787. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  125788. */
  125789. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  125790. }
  125791. }
  125792. declare module BABYLON {
  125793. /**
  125794. * Defines how the parser contract is defined.
  125795. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  125796. */
  125797. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  125798. /**
  125799. * Defines how the individual parser contract is defined.
  125800. * These parser can parse an individual asset
  125801. */
  125802. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  125803. /**
  125804. * Base class of the scene acting as a container for the different elements composing a scene.
  125805. * This class is dynamically extended by the different components of the scene increasing
  125806. * flexibility and reducing coupling
  125807. */
  125808. export abstract class AbstractScene {
  125809. /**
  125810. * Stores the list of available parsers in the application.
  125811. */
  125812. private static _BabylonFileParsers;
  125813. /**
  125814. * Stores the list of available individual parsers in the application.
  125815. */
  125816. private static _IndividualBabylonFileParsers;
  125817. /**
  125818. * Adds a parser in the list of available ones
  125819. * @param name Defines the name of the parser
  125820. * @param parser Defines the parser to add
  125821. */
  125822. static AddParser(name: string, parser: BabylonFileParser): void;
  125823. /**
  125824. * Gets a general parser from the list of avaialble ones
  125825. * @param name Defines the name of the parser
  125826. * @returns the requested parser or null
  125827. */
  125828. static GetParser(name: string): Nullable<BabylonFileParser>;
  125829. /**
  125830. * Adds n individual parser in the list of available ones
  125831. * @param name Defines the name of the parser
  125832. * @param parser Defines the parser to add
  125833. */
  125834. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  125835. /**
  125836. * Gets an individual parser from the list of avaialble ones
  125837. * @param name Defines the name of the parser
  125838. * @returns the requested parser or null
  125839. */
  125840. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  125841. /**
  125842. * Parser json data and populate both a scene and its associated container object
  125843. * @param jsonData Defines the data to parse
  125844. * @param scene Defines the scene to parse the data for
  125845. * @param container Defines the container attached to the parsing sequence
  125846. * @param rootUrl Defines the root url of the data
  125847. */
  125848. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  125849. /**
  125850. * Gets the list of root nodes (ie. nodes with no parent)
  125851. */
  125852. rootNodes: Node[];
  125853. /** All of the cameras added to this scene
  125854. * @see https://doc.babylonjs.com/babylon101/cameras
  125855. */
  125856. cameras: Camera[];
  125857. /**
  125858. * All of the lights added to this scene
  125859. * @see https://doc.babylonjs.com/babylon101/lights
  125860. */
  125861. lights: Light[];
  125862. /**
  125863. * All of the (abstract) meshes added to this scene
  125864. */
  125865. meshes: AbstractMesh[];
  125866. /**
  125867. * The list of skeletons added to the scene
  125868. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125869. */
  125870. skeletons: Skeleton[];
  125871. /**
  125872. * All of the particle systems added to this scene
  125873. * @see https://doc.babylonjs.com/babylon101/particles
  125874. */
  125875. particleSystems: IParticleSystem[];
  125876. /**
  125877. * Gets a list of Animations associated with the scene
  125878. */
  125879. animations: Animation[];
  125880. /**
  125881. * All of the animation groups added to this scene
  125882. * @see https://doc.babylonjs.com/how_to/group
  125883. */
  125884. animationGroups: AnimationGroup[];
  125885. /**
  125886. * All of the multi-materials added to this scene
  125887. * @see https://doc.babylonjs.com/how_to/multi_materials
  125888. */
  125889. multiMaterials: MultiMaterial[];
  125890. /**
  125891. * All of the materials added to this scene
  125892. * In the context of a Scene, it is not supposed to be modified manually.
  125893. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  125894. * Note also that the order of the Material within the array is not significant and might change.
  125895. * @see https://doc.babylonjs.com/babylon101/materials
  125896. */
  125897. materials: Material[];
  125898. /**
  125899. * The list of morph target managers added to the scene
  125900. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125901. */
  125902. morphTargetManagers: MorphTargetManager[];
  125903. /**
  125904. * The list of geometries used in the scene.
  125905. */
  125906. geometries: Geometry[];
  125907. /**
  125908. * All of the tranform nodes added to this scene
  125909. * In the context of a Scene, it is not supposed to be modified manually.
  125910. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125911. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125912. * @see https://doc.babylonjs.com/how_to/transformnode
  125913. */
  125914. transformNodes: TransformNode[];
  125915. /**
  125916. * ActionManagers available on the scene.
  125917. */
  125918. actionManagers: AbstractActionManager[];
  125919. /**
  125920. * Textures to keep.
  125921. */
  125922. textures: BaseTexture[];
  125923. /** @hidden */
  125924. protected _environmentTexture: Nullable<BaseTexture>;
  125925. /**
  125926. * Texture used in all pbr material as the reflection texture.
  125927. * As in the majority of the scene they are the same (exception for multi room and so on),
  125928. * this is easier to reference from here than from all the materials.
  125929. */
  125930. get environmentTexture(): Nullable<BaseTexture>;
  125931. set environmentTexture(value: Nullable<BaseTexture>);
  125932. /**
  125933. * The list of postprocesses added to the scene
  125934. */
  125935. postProcesses: PostProcess[];
  125936. /**
  125937. * @returns all meshes, lights, cameras, transformNodes and bones
  125938. */
  125939. getNodes(): Array<Node>;
  125940. }
  125941. }
  125942. declare module BABYLON {
  125943. /**
  125944. * Interface used to define options for Sound class
  125945. */
  125946. export interface ISoundOptions {
  125947. /**
  125948. * Does the sound autoplay once loaded.
  125949. */
  125950. autoplay?: boolean;
  125951. /**
  125952. * Does the sound loop after it finishes playing once.
  125953. */
  125954. loop?: boolean;
  125955. /**
  125956. * Sound's volume
  125957. */
  125958. volume?: number;
  125959. /**
  125960. * Is it a spatial sound?
  125961. */
  125962. spatialSound?: boolean;
  125963. /**
  125964. * Maximum distance to hear that sound
  125965. */
  125966. maxDistance?: number;
  125967. /**
  125968. * Uses user defined attenuation function
  125969. */
  125970. useCustomAttenuation?: boolean;
  125971. /**
  125972. * Define the roll off factor of spatial sounds.
  125973. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125974. */
  125975. rolloffFactor?: number;
  125976. /**
  125977. * Define the reference distance the sound should be heard perfectly.
  125978. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125979. */
  125980. refDistance?: number;
  125981. /**
  125982. * Define the distance attenuation model the sound will follow.
  125983. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125984. */
  125985. distanceModel?: string;
  125986. /**
  125987. * Defines the playback speed (1 by default)
  125988. */
  125989. playbackRate?: number;
  125990. /**
  125991. * Defines if the sound is from a streaming source
  125992. */
  125993. streaming?: boolean;
  125994. /**
  125995. * Defines an optional length (in seconds) inside the sound file
  125996. */
  125997. length?: number;
  125998. /**
  125999. * Defines an optional offset (in seconds) inside the sound file
  126000. */
  126001. offset?: number;
  126002. /**
  126003. * If true, URLs will not be required to state the audio file codec to use.
  126004. */
  126005. skipCodecCheck?: boolean;
  126006. }
  126007. }
  126008. declare module BABYLON {
  126009. /**
  126010. * Defines a sound that can be played in the application.
  126011. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  126012. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126013. */
  126014. export class Sound {
  126015. /**
  126016. * The name of the sound in the scene.
  126017. */
  126018. name: string;
  126019. /**
  126020. * Does the sound autoplay once loaded.
  126021. */
  126022. autoplay: boolean;
  126023. /**
  126024. * Does the sound loop after it finishes playing once.
  126025. */
  126026. loop: boolean;
  126027. /**
  126028. * Does the sound use a custom attenuation curve to simulate the falloff
  126029. * happening when the source gets further away from the camera.
  126030. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126031. */
  126032. useCustomAttenuation: boolean;
  126033. /**
  126034. * The sound track id this sound belongs to.
  126035. */
  126036. soundTrackId: number;
  126037. /**
  126038. * Is this sound currently played.
  126039. */
  126040. isPlaying: boolean;
  126041. /**
  126042. * Is this sound currently paused.
  126043. */
  126044. isPaused: boolean;
  126045. /**
  126046. * Does this sound enables spatial sound.
  126047. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126048. */
  126049. spatialSound: boolean;
  126050. /**
  126051. * Define the reference distance the sound should be heard perfectly.
  126052. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126053. */
  126054. refDistance: number;
  126055. /**
  126056. * Define the roll off factor of spatial sounds.
  126057. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126058. */
  126059. rolloffFactor: number;
  126060. /**
  126061. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  126062. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126063. */
  126064. maxDistance: number;
  126065. /**
  126066. * Define the distance attenuation model the sound will follow.
  126067. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126068. */
  126069. distanceModel: string;
  126070. /**
  126071. * @hidden
  126072. * Back Compat
  126073. **/
  126074. onended: () => any;
  126075. /**
  126076. * Gets or sets an object used to store user defined information for the sound.
  126077. */
  126078. metadata: any;
  126079. /**
  126080. * Observable event when the current playing sound finishes.
  126081. */
  126082. onEndedObservable: Observable<Sound>;
  126083. /**
  126084. * Gets the current time for the sound.
  126085. */
  126086. get currentTime(): number;
  126087. private _panningModel;
  126088. private _playbackRate;
  126089. private _streaming;
  126090. private _startTime;
  126091. private _startOffset;
  126092. private _position;
  126093. /** @hidden */
  126094. _positionInEmitterSpace: boolean;
  126095. private _localDirection;
  126096. private _volume;
  126097. private _isReadyToPlay;
  126098. private _isDirectional;
  126099. private _readyToPlayCallback;
  126100. private _audioBuffer;
  126101. private _soundSource;
  126102. private _streamingSource;
  126103. private _soundPanner;
  126104. private _soundGain;
  126105. private _inputAudioNode;
  126106. private _outputAudioNode;
  126107. private _coneInnerAngle;
  126108. private _coneOuterAngle;
  126109. private _coneOuterGain;
  126110. private _scene;
  126111. private _connectedTransformNode;
  126112. private _customAttenuationFunction;
  126113. private _registerFunc;
  126114. private _isOutputConnected;
  126115. private _htmlAudioElement;
  126116. private _urlType;
  126117. private _length?;
  126118. private _offset?;
  126119. /** @hidden */
  126120. static _SceneComponentInitialization: (scene: Scene) => void;
  126121. /**
  126122. * Create a sound and attach it to a scene
  126123. * @param name Name of your sound
  126124. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  126125. * @param scene defines the scene the sound belongs to
  126126. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  126127. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  126128. */
  126129. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  126130. /**
  126131. * Release the sound and its associated resources
  126132. */
  126133. dispose(): void;
  126134. /**
  126135. * Gets if the sounds is ready to be played or not.
  126136. * @returns true if ready, otherwise false
  126137. */
  126138. isReady(): boolean;
  126139. private _soundLoaded;
  126140. /**
  126141. * Sets the data of the sound from an audiobuffer
  126142. * @param audioBuffer The audioBuffer containing the data
  126143. */
  126144. setAudioBuffer(audioBuffer: AudioBuffer): void;
  126145. /**
  126146. * Updates the current sounds options such as maxdistance, loop...
  126147. * @param options A JSON object containing values named as the object properties
  126148. */
  126149. updateOptions(options: ISoundOptions): void;
  126150. private _createSpatialParameters;
  126151. private _updateSpatialParameters;
  126152. /**
  126153. * Switch the panning model to HRTF:
  126154. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126155. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126156. */
  126157. switchPanningModelToHRTF(): void;
  126158. /**
  126159. * Switch the panning model to Equal Power:
  126160. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126161. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126162. */
  126163. switchPanningModelToEqualPower(): void;
  126164. private _switchPanningModel;
  126165. /**
  126166. * Connect this sound to a sound track audio node like gain...
  126167. * @param soundTrackAudioNode the sound track audio node to connect to
  126168. */
  126169. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  126170. /**
  126171. * Transform this sound into a directional source
  126172. * @param coneInnerAngle Size of the inner cone in degree
  126173. * @param coneOuterAngle Size of the outer cone in degree
  126174. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  126175. */
  126176. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  126177. /**
  126178. * Gets or sets the inner angle for the directional cone.
  126179. */
  126180. get directionalConeInnerAngle(): number;
  126181. /**
  126182. * Gets or sets the inner angle for the directional cone.
  126183. */
  126184. set directionalConeInnerAngle(value: number);
  126185. /**
  126186. * Gets or sets the outer angle for the directional cone.
  126187. */
  126188. get directionalConeOuterAngle(): number;
  126189. /**
  126190. * Gets or sets the outer angle for the directional cone.
  126191. */
  126192. set directionalConeOuterAngle(value: number);
  126193. /**
  126194. * Sets the position of the emitter if spatial sound is enabled
  126195. * @param newPosition Defines the new posisiton
  126196. */
  126197. setPosition(newPosition: Vector3): void;
  126198. /**
  126199. * Sets the local direction of the emitter if spatial sound is enabled
  126200. * @param newLocalDirection Defines the new local direction
  126201. */
  126202. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  126203. private _updateDirection;
  126204. /** @hidden */
  126205. updateDistanceFromListener(): void;
  126206. /**
  126207. * Sets a new custom attenuation function for the sound.
  126208. * @param callback Defines the function used for the attenuation
  126209. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126210. */
  126211. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  126212. /**
  126213. * Play the sound
  126214. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  126215. * @param offset (optional) Start the sound at a specific time in seconds
  126216. * @param length (optional) Sound duration (in seconds)
  126217. */
  126218. play(time?: number, offset?: number, length?: number): void;
  126219. private _onended;
  126220. /**
  126221. * Stop the sound
  126222. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  126223. */
  126224. stop(time?: number): void;
  126225. /**
  126226. * Put the sound in pause
  126227. */
  126228. pause(): void;
  126229. /**
  126230. * Sets a dedicated volume for this sounds
  126231. * @param newVolume Define the new volume of the sound
  126232. * @param time Define time for gradual change to new volume
  126233. */
  126234. setVolume(newVolume: number, time?: number): void;
  126235. /**
  126236. * Set the sound play back rate
  126237. * @param newPlaybackRate Define the playback rate the sound should be played at
  126238. */
  126239. setPlaybackRate(newPlaybackRate: number): void;
  126240. /**
  126241. * Gets the volume of the sound.
  126242. * @returns the volume of the sound
  126243. */
  126244. getVolume(): number;
  126245. /**
  126246. * Attach the sound to a dedicated mesh
  126247. * @param transformNode The transform node to connect the sound with
  126248. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126249. */
  126250. attachToMesh(transformNode: TransformNode): void;
  126251. /**
  126252. * Detach the sound from the previously attached mesh
  126253. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126254. */
  126255. detachFromMesh(): void;
  126256. private _onRegisterAfterWorldMatrixUpdate;
  126257. /**
  126258. * Clone the current sound in the scene.
  126259. * @returns the new sound clone
  126260. */
  126261. clone(): Nullable<Sound>;
  126262. /**
  126263. * Gets the current underlying audio buffer containing the data
  126264. * @returns the audio buffer
  126265. */
  126266. getAudioBuffer(): Nullable<AudioBuffer>;
  126267. /**
  126268. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  126269. * @returns the source node
  126270. */
  126271. getSoundSource(): Nullable<AudioBufferSourceNode>;
  126272. /**
  126273. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  126274. * @returns the gain node
  126275. */
  126276. getSoundGain(): Nullable<GainNode>;
  126277. /**
  126278. * Serializes the Sound in a JSON representation
  126279. * @returns the JSON representation of the sound
  126280. */
  126281. serialize(): any;
  126282. /**
  126283. * Parse a JSON representation of a sound to innstantiate in a given scene
  126284. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  126285. * @param scene Define the scene the new parsed sound should be created in
  126286. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  126287. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  126288. * @returns the newly parsed sound
  126289. */
  126290. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  126291. }
  126292. }
  126293. declare module BABYLON {
  126294. /**
  126295. * This defines an action helpful to play a defined sound on a triggered action.
  126296. */
  126297. export class PlaySoundAction extends Action {
  126298. private _sound;
  126299. /**
  126300. * Instantiate the action
  126301. * @param triggerOptions defines the trigger options
  126302. * @param sound defines the sound to play
  126303. * @param condition defines the trigger related conditions
  126304. */
  126305. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126306. /** @hidden */
  126307. _prepare(): void;
  126308. /**
  126309. * Execute the action and play the sound.
  126310. */
  126311. execute(): void;
  126312. /**
  126313. * Serializes the actions and its related information.
  126314. * @param parent defines the object to serialize in
  126315. * @returns the serialized object
  126316. */
  126317. serialize(parent: any): any;
  126318. }
  126319. /**
  126320. * This defines an action helpful to stop a defined sound on a triggered action.
  126321. */
  126322. export class StopSoundAction extends Action {
  126323. private _sound;
  126324. /**
  126325. * Instantiate the action
  126326. * @param triggerOptions defines the trigger options
  126327. * @param sound defines the sound to stop
  126328. * @param condition defines the trigger related conditions
  126329. */
  126330. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126331. /** @hidden */
  126332. _prepare(): void;
  126333. /**
  126334. * Execute the action and stop the sound.
  126335. */
  126336. execute(): void;
  126337. /**
  126338. * Serializes the actions and its related information.
  126339. * @param parent defines the object to serialize in
  126340. * @returns the serialized object
  126341. */
  126342. serialize(parent: any): any;
  126343. }
  126344. }
  126345. declare module BABYLON {
  126346. /**
  126347. * This defines an action responsible to change the value of a property
  126348. * by interpolating between its current value and the newly set one once triggered.
  126349. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  126350. */
  126351. export class InterpolateValueAction extends Action {
  126352. /**
  126353. * Defines the path of the property where the value should be interpolated
  126354. */
  126355. propertyPath: string;
  126356. /**
  126357. * Defines the target value at the end of the interpolation.
  126358. */
  126359. value: any;
  126360. /**
  126361. * Defines the time it will take for the property to interpolate to the value.
  126362. */
  126363. duration: number;
  126364. /**
  126365. * Defines if the other scene animations should be stopped when the action has been triggered
  126366. */
  126367. stopOtherAnimations?: boolean;
  126368. /**
  126369. * Defines a callback raised once the interpolation animation has been done.
  126370. */
  126371. onInterpolationDone?: () => void;
  126372. /**
  126373. * Observable triggered once the interpolation animation has been done.
  126374. */
  126375. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  126376. private _target;
  126377. private _effectiveTarget;
  126378. private _property;
  126379. /**
  126380. * Instantiate the action
  126381. * @param triggerOptions defines the trigger options
  126382. * @param target defines the object containing the value to interpolate
  126383. * @param propertyPath defines the path to the property in the target object
  126384. * @param value defines the target value at the end of the interpolation
  126385. * @param duration deines the time it will take for the property to interpolate to the value.
  126386. * @param condition defines the trigger related conditions
  126387. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  126388. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  126389. */
  126390. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  126391. /** @hidden */
  126392. _prepare(): void;
  126393. /**
  126394. * Execute the action starts the value interpolation.
  126395. */
  126396. execute(): void;
  126397. /**
  126398. * Serializes the actions and its related information.
  126399. * @param parent defines the object to serialize in
  126400. * @returns the serialized object
  126401. */
  126402. serialize(parent: any): any;
  126403. }
  126404. }
  126405. declare module BABYLON {
  126406. /**
  126407. * This represents the default audio engine used in babylon.
  126408. * It is responsible to play, synchronize and analyse sounds throughout the application.
  126409. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126410. */
  126411. export class AudioEngine implements IAudioEngine {
  126412. private _audioContext;
  126413. private _audioContextInitialized;
  126414. private _muteButton;
  126415. private _hostElement;
  126416. /**
  126417. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  126418. */
  126419. canUseWebAudio: boolean;
  126420. /**
  126421. * The master gain node defines the global audio volume of your audio engine.
  126422. */
  126423. masterGain: GainNode;
  126424. /**
  126425. * Defines if Babylon should emit a warning if WebAudio is not supported.
  126426. * @ignoreNaming
  126427. */
  126428. WarnedWebAudioUnsupported: boolean;
  126429. /**
  126430. * Gets whether or not mp3 are supported by your browser.
  126431. */
  126432. isMP3supported: boolean;
  126433. /**
  126434. * Gets whether or not ogg are supported by your browser.
  126435. */
  126436. isOGGsupported: boolean;
  126437. /**
  126438. * Gets whether audio has been unlocked on the device.
  126439. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  126440. * a user interaction has happened.
  126441. */
  126442. unlocked: boolean;
  126443. /**
  126444. * Defines if the audio engine relies on a custom unlocked button.
  126445. * In this case, the embedded button will not be displayed.
  126446. */
  126447. useCustomUnlockedButton: boolean;
  126448. /**
  126449. * Event raised when audio has been unlocked on the browser.
  126450. */
  126451. onAudioUnlockedObservable: Observable<IAudioEngine>;
  126452. /**
  126453. * Event raised when audio has been locked on the browser.
  126454. */
  126455. onAudioLockedObservable: Observable<IAudioEngine>;
  126456. /**
  126457. * Gets the current AudioContext if available.
  126458. */
  126459. get audioContext(): Nullable<AudioContext>;
  126460. private _connectedAnalyser;
  126461. /**
  126462. * Instantiates a new audio engine.
  126463. *
  126464. * There should be only one per page as some browsers restrict the number
  126465. * of audio contexts you can create.
  126466. * @param hostElement defines the host element where to display the mute icon if necessary
  126467. */
  126468. constructor(hostElement?: Nullable<HTMLElement>);
  126469. /**
  126470. * Flags the audio engine in Locked state.
  126471. * This happens due to new browser policies preventing audio to autoplay.
  126472. */
  126473. lock(): void;
  126474. /**
  126475. * Unlocks the audio engine once a user action has been done on the dom.
  126476. * This is helpful to resume play once browser policies have been satisfied.
  126477. */
  126478. unlock(): void;
  126479. private _resumeAudioContext;
  126480. private _initializeAudioContext;
  126481. private _tryToRun;
  126482. private _triggerRunningState;
  126483. private _triggerSuspendedState;
  126484. private _displayMuteButton;
  126485. private _moveButtonToTopLeft;
  126486. private _onResize;
  126487. private _hideMuteButton;
  126488. /**
  126489. * Destroy and release the resources associated with the audio ccontext.
  126490. */
  126491. dispose(): void;
  126492. /**
  126493. * Gets the global volume sets on the master gain.
  126494. * @returns the global volume if set or -1 otherwise
  126495. */
  126496. getGlobalVolume(): number;
  126497. /**
  126498. * Sets the global volume of your experience (sets on the master gain).
  126499. * @param newVolume Defines the new global volume of the application
  126500. */
  126501. setGlobalVolume(newVolume: number): void;
  126502. /**
  126503. * Connect the audio engine to an audio analyser allowing some amazing
  126504. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  126505. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  126506. * @param analyser The analyser to connect to the engine
  126507. */
  126508. connectToAnalyser(analyser: Analyser): void;
  126509. }
  126510. }
  126511. declare module BABYLON {
  126512. /**
  126513. * Options allowed during the creation of a sound track.
  126514. */
  126515. export interface ISoundTrackOptions {
  126516. /**
  126517. * The volume the sound track should take during creation
  126518. */
  126519. volume?: number;
  126520. /**
  126521. * Define if the sound track is the main sound track of the scene
  126522. */
  126523. mainTrack?: boolean;
  126524. }
  126525. /**
  126526. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  126527. * It will be also used in a future release to apply effects on a specific track.
  126528. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  126529. */
  126530. export class SoundTrack {
  126531. /**
  126532. * The unique identifier of the sound track in the scene.
  126533. */
  126534. id: number;
  126535. /**
  126536. * The list of sounds included in the sound track.
  126537. */
  126538. soundCollection: Array<Sound>;
  126539. private _outputAudioNode;
  126540. private _scene;
  126541. private _connectedAnalyser;
  126542. private _options;
  126543. private _isInitialized;
  126544. /**
  126545. * Creates a new sound track.
  126546. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  126547. * @param scene Define the scene the sound track belongs to
  126548. * @param options
  126549. */
  126550. constructor(scene: Scene, options?: ISoundTrackOptions);
  126551. private _initializeSoundTrackAudioGraph;
  126552. /**
  126553. * Release the sound track and its associated resources
  126554. */
  126555. dispose(): void;
  126556. /**
  126557. * Adds a sound to this sound track
  126558. * @param sound define the cound to add
  126559. * @ignoreNaming
  126560. */
  126561. addSound(sound: Sound): void;
  126562. /**
  126563. * Removes a sound to this sound track
  126564. * @param sound define the cound to remove
  126565. * @ignoreNaming
  126566. */
  126567. removeSound(sound: Sound): void;
  126568. /**
  126569. * Set a global volume for the full sound track.
  126570. * @param newVolume Define the new volume of the sound track
  126571. */
  126572. setVolume(newVolume: number): void;
  126573. /**
  126574. * Switch the panning model to HRTF:
  126575. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126576. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126577. */
  126578. switchPanningModelToHRTF(): void;
  126579. /**
  126580. * Switch the panning model to Equal Power:
  126581. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126582. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126583. */
  126584. switchPanningModelToEqualPower(): void;
  126585. /**
  126586. * Connect the sound track to an audio analyser allowing some amazing
  126587. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  126588. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  126589. * @param analyser The analyser to connect to the engine
  126590. */
  126591. connectToAnalyser(analyser: Analyser): void;
  126592. }
  126593. }
  126594. declare module BABYLON {
  126595. interface AbstractScene {
  126596. /**
  126597. * The list of sounds used in the scene.
  126598. */
  126599. sounds: Nullable<Array<Sound>>;
  126600. }
  126601. interface Scene {
  126602. /**
  126603. * @hidden
  126604. * Backing field
  126605. */
  126606. _mainSoundTrack: SoundTrack;
  126607. /**
  126608. * The main sound track played by the scene.
  126609. * It cotains your primary collection of sounds.
  126610. */
  126611. mainSoundTrack: SoundTrack;
  126612. /**
  126613. * The list of sound tracks added to the scene
  126614. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126615. */
  126616. soundTracks: Nullable<Array<SoundTrack>>;
  126617. /**
  126618. * Gets a sound using a given name
  126619. * @param name defines the name to search for
  126620. * @return the found sound or null if not found at all.
  126621. */
  126622. getSoundByName(name: string): Nullable<Sound>;
  126623. /**
  126624. * Gets or sets if audio support is enabled
  126625. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126626. */
  126627. audioEnabled: boolean;
  126628. /**
  126629. * Gets or sets if audio will be output to headphones
  126630. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126631. */
  126632. headphone: boolean;
  126633. /**
  126634. * Gets or sets custom audio listener position provider
  126635. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126636. */
  126637. audioListenerPositionProvider: Nullable<() => Vector3>;
  126638. /**
  126639. * Gets or sets a refresh rate when using 3D audio positioning
  126640. */
  126641. audioPositioningRefreshRate: number;
  126642. }
  126643. /**
  126644. * Defines the sound scene component responsible to manage any sounds
  126645. * in a given scene.
  126646. */
  126647. export class AudioSceneComponent implements ISceneSerializableComponent {
  126648. private static _CameraDirectionLH;
  126649. private static _CameraDirectionRH;
  126650. /**
  126651. * The component name helpfull to identify the component in the list of scene components.
  126652. */
  126653. readonly name: string;
  126654. /**
  126655. * The scene the component belongs to.
  126656. */
  126657. scene: Scene;
  126658. private _audioEnabled;
  126659. /**
  126660. * Gets whether audio is enabled or not.
  126661. * Please use related enable/disable method to switch state.
  126662. */
  126663. get audioEnabled(): boolean;
  126664. private _headphone;
  126665. /**
  126666. * Gets whether audio is outputing to headphone or not.
  126667. * Please use the according Switch methods to change output.
  126668. */
  126669. get headphone(): boolean;
  126670. /**
  126671. * Gets or sets a refresh rate when using 3D audio positioning
  126672. */
  126673. audioPositioningRefreshRate: number;
  126674. private _audioListenerPositionProvider;
  126675. /**
  126676. * Gets the current audio listener position provider
  126677. */
  126678. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  126679. /**
  126680. * Sets a custom listener position for all sounds in the scene
  126681. * By default, this is the position of the first active camera
  126682. */
  126683. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  126684. /**
  126685. * Creates a new instance of the component for the given scene
  126686. * @param scene Defines the scene to register the component in
  126687. */
  126688. constructor(scene: Scene);
  126689. /**
  126690. * Registers the component in a given scene
  126691. */
  126692. register(): void;
  126693. /**
  126694. * Rebuilds the elements related to this component in case of
  126695. * context lost for instance.
  126696. */
  126697. rebuild(): void;
  126698. /**
  126699. * Serializes the component data to the specified json object
  126700. * @param serializationObject The object to serialize to
  126701. */
  126702. serialize(serializationObject: any): void;
  126703. /**
  126704. * Adds all the elements from the container to the scene
  126705. * @param container the container holding the elements
  126706. */
  126707. addFromContainer(container: AbstractScene): void;
  126708. /**
  126709. * Removes all the elements in the container from the scene
  126710. * @param container contains the elements to remove
  126711. * @param dispose if the removed element should be disposed (default: false)
  126712. */
  126713. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126714. /**
  126715. * Disposes the component and the associated ressources.
  126716. */
  126717. dispose(): void;
  126718. /**
  126719. * Disables audio in the associated scene.
  126720. */
  126721. disableAudio(): void;
  126722. /**
  126723. * Enables audio in the associated scene.
  126724. */
  126725. enableAudio(): void;
  126726. /**
  126727. * Switch audio to headphone output.
  126728. */
  126729. switchAudioModeForHeadphones(): void;
  126730. /**
  126731. * Switch audio to normal speakers.
  126732. */
  126733. switchAudioModeForNormalSpeakers(): void;
  126734. private _cachedCameraDirection;
  126735. private _cachedCameraPosition;
  126736. private _lastCheck;
  126737. private _afterRender;
  126738. }
  126739. }
  126740. declare module BABYLON {
  126741. /**
  126742. * Wraps one or more Sound objects and selects one with random weight for playback.
  126743. */
  126744. export class WeightedSound {
  126745. /** When true a Sound will be selected and played when the current playing Sound completes. */
  126746. loop: boolean;
  126747. private _coneInnerAngle;
  126748. private _coneOuterAngle;
  126749. private _volume;
  126750. /** A Sound is currently playing. */
  126751. isPlaying: boolean;
  126752. /** A Sound is currently paused. */
  126753. isPaused: boolean;
  126754. private _sounds;
  126755. private _weights;
  126756. private _currentIndex?;
  126757. /**
  126758. * Creates a new WeightedSound from the list of sounds given.
  126759. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  126760. * @param sounds Array of Sounds that will be selected from.
  126761. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  126762. */
  126763. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  126764. /**
  126765. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  126766. */
  126767. get directionalConeInnerAngle(): number;
  126768. /**
  126769. * The size of cone in degress for a directional sound in which there will be no attenuation.
  126770. */
  126771. set directionalConeInnerAngle(value: number);
  126772. /**
  126773. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126774. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126775. */
  126776. get directionalConeOuterAngle(): number;
  126777. /**
  126778. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126779. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126780. */
  126781. set directionalConeOuterAngle(value: number);
  126782. /**
  126783. * Playback volume.
  126784. */
  126785. get volume(): number;
  126786. /**
  126787. * Playback volume.
  126788. */
  126789. set volume(value: number);
  126790. private _onended;
  126791. /**
  126792. * Suspend playback
  126793. */
  126794. pause(): void;
  126795. /**
  126796. * Stop playback
  126797. */
  126798. stop(): void;
  126799. /**
  126800. * Start playback.
  126801. * @param startOffset Position the clip head at a specific time in seconds.
  126802. */
  126803. play(startOffset?: number): void;
  126804. }
  126805. }
  126806. declare module BABYLON {
  126807. /**
  126808. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  126809. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126810. */
  126811. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  126812. /**
  126813. * Gets the name of the behavior.
  126814. */
  126815. get name(): string;
  126816. /**
  126817. * The easing function used by animations
  126818. */
  126819. static EasingFunction: BackEase;
  126820. /**
  126821. * The easing mode used by animations
  126822. */
  126823. static EasingMode: number;
  126824. /**
  126825. * The duration of the animation, in milliseconds
  126826. */
  126827. transitionDuration: number;
  126828. /**
  126829. * Length of the distance animated by the transition when lower radius is reached
  126830. */
  126831. lowerRadiusTransitionRange: number;
  126832. /**
  126833. * Length of the distance animated by the transition when upper radius is reached
  126834. */
  126835. upperRadiusTransitionRange: number;
  126836. private _autoTransitionRange;
  126837. /**
  126838. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126839. */
  126840. get autoTransitionRange(): boolean;
  126841. /**
  126842. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126843. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  126844. */
  126845. set autoTransitionRange(value: boolean);
  126846. private _attachedCamera;
  126847. private _onAfterCheckInputsObserver;
  126848. private _onMeshTargetChangedObserver;
  126849. /**
  126850. * Initializes the behavior.
  126851. */
  126852. init(): void;
  126853. /**
  126854. * Attaches the behavior to its arc rotate camera.
  126855. * @param camera Defines the camera to attach the behavior to
  126856. */
  126857. attach(camera: ArcRotateCamera): void;
  126858. /**
  126859. * Detaches the behavior from its current arc rotate camera.
  126860. */
  126861. detach(): void;
  126862. private _radiusIsAnimating;
  126863. private _radiusBounceTransition;
  126864. private _animatables;
  126865. private _cachedWheelPrecision;
  126866. /**
  126867. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  126868. * @param radiusLimit The limit to check against.
  126869. * @return Bool to indicate if at limit.
  126870. */
  126871. private _isRadiusAtLimit;
  126872. /**
  126873. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  126874. * @param radiusDelta The delta by which to animate to. Can be negative.
  126875. */
  126876. private _applyBoundRadiusAnimation;
  126877. /**
  126878. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  126879. */
  126880. protected _clearAnimationLocks(): void;
  126881. /**
  126882. * Stops and removes all animations that have been applied to the camera
  126883. */
  126884. stopAllAnimations(): void;
  126885. }
  126886. }
  126887. declare module BABYLON {
  126888. /**
  126889. * 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.
  126890. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126891. */
  126892. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  126893. /**
  126894. * Gets the name of the behavior.
  126895. */
  126896. get name(): string;
  126897. private _mode;
  126898. private _radiusScale;
  126899. private _positionScale;
  126900. private _defaultElevation;
  126901. private _elevationReturnTime;
  126902. private _elevationReturnWaitTime;
  126903. private _zoomStopsAnimation;
  126904. private _framingTime;
  126905. /**
  126906. * The easing function used by animations
  126907. */
  126908. static EasingFunction: ExponentialEase;
  126909. /**
  126910. * The easing mode used by animations
  126911. */
  126912. static EasingMode: number;
  126913. /**
  126914. * Sets the current mode used by the behavior
  126915. */
  126916. set mode(mode: number);
  126917. /**
  126918. * Gets current mode used by the behavior.
  126919. */
  126920. get mode(): number;
  126921. /**
  126922. * Sets the scale applied to the radius (1 by default)
  126923. */
  126924. set radiusScale(radius: number);
  126925. /**
  126926. * Gets the scale applied to the radius
  126927. */
  126928. get radiusScale(): number;
  126929. /**
  126930. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126931. */
  126932. set positionScale(scale: number);
  126933. /**
  126934. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126935. */
  126936. get positionScale(): number;
  126937. /**
  126938. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126939. * behaviour is triggered, in radians.
  126940. */
  126941. set defaultElevation(elevation: number);
  126942. /**
  126943. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126944. * behaviour is triggered, in radians.
  126945. */
  126946. get defaultElevation(): number;
  126947. /**
  126948. * Sets the time (in milliseconds) taken to return to the default beta position.
  126949. * Negative value indicates camera should not return to default.
  126950. */
  126951. set elevationReturnTime(speed: number);
  126952. /**
  126953. * Gets the time (in milliseconds) taken to return to the default beta position.
  126954. * Negative value indicates camera should not return to default.
  126955. */
  126956. get elevationReturnTime(): number;
  126957. /**
  126958. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126959. */
  126960. set elevationReturnWaitTime(time: number);
  126961. /**
  126962. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126963. */
  126964. get elevationReturnWaitTime(): number;
  126965. /**
  126966. * Sets the flag that indicates if user zooming should stop animation.
  126967. */
  126968. set zoomStopsAnimation(flag: boolean);
  126969. /**
  126970. * Gets the flag that indicates if user zooming should stop animation.
  126971. */
  126972. get zoomStopsAnimation(): boolean;
  126973. /**
  126974. * Sets the transition time when framing the mesh, in milliseconds
  126975. */
  126976. set framingTime(time: number);
  126977. /**
  126978. * Gets the transition time when framing the mesh, in milliseconds
  126979. */
  126980. get framingTime(): number;
  126981. /**
  126982. * Define if the behavior should automatically change the configured
  126983. * camera limits and sensibilities.
  126984. */
  126985. autoCorrectCameraLimitsAndSensibility: boolean;
  126986. private _onPrePointerObservableObserver;
  126987. private _onAfterCheckInputsObserver;
  126988. private _onMeshTargetChangedObserver;
  126989. private _attachedCamera;
  126990. private _isPointerDown;
  126991. private _lastInteractionTime;
  126992. /**
  126993. * Initializes the behavior.
  126994. */
  126995. init(): void;
  126996. /**
  126997. * Attaches the behavior to its arc rotate camera.
  126998. * @param camera Defines the camera to attach the behavior to
  126999. */
  127000. attach(camera: ArcRotateCamera): void;
  127001. /**
  127002. * Detaches the behavior from its current arc rotate camera.
  127003. */
  127004. detach(): void;
  127005. private _animatables;
  127006. private _betaIsAnimating;
  127007. private _betaTransition;
  127008. private _radiusTransition;
  127009. private _vectorTransition;
  127010. /**
  127011. * Targets the given mesh and updates zoom level accordingly.
  127012. * @param mesh The mesh to target.
  127013. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127014. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127015. */
  127016. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127017. /**
  127018. * Targets the given mesh with its children and updates zoom level accordingly.
  127019. * @param mesh The mesh to target.
  127020. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127021. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127022. */
  127023. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127024. /**
  127025. * Targets the given meshes with their children and updates zoom level accordingly.
  127026. * @param meshes The mesh to target.
  127027. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127028. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127029. */
  127030. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127031. /**
  127032. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  127033. * @param minimumWorld Determines the smaller position of the bounding box extend
  127034. * @param maximumWorld Determines the bigger position of the bounding box extend
  127035. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127036. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127037. */
  127038. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127039. /**
  127040. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  127041. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  127042. * frustum width.
  127043. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  127044. * to fully enclose the mesh in the viewing frustum.
  127045. */
  127046. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  127047. /**
  127048. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  127049. * is automatically returned to its default position (expected to be above ground plane).
  127050. */
  127051. private _maintainCameraAboveGround;
  127052. /**
  127053. * Returns the frustum slope based on the canvas ratio and camera FOV
  127054. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  127055. */
  127056. private _getFrustumSlope;
  127057. /**
  127058. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  127059. */
  127060. private _clearAnimationLocks;
  127061. /**
  127062. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127063. */
  127064. private _applyUserInteraction;
  127065. /**
  127066. * Stops and removes all animations that have been applied to the camera
  127067. */
  127068. stopAllAnimations(): void;
  127069. /**
  127070. * Gets a value indicating if the user is moving the camera
  127071. */
  127072. get isUserIsMoving(): boolean;
  127073. /**
  127074. * The camera can move all the way towards the mesh.
  127075. */
  127076. static IgnoreBoundsSizeMode: number;
  127077. /**
  127078. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  127079. */
  127080. static FitFrustumSidesMode: number;
  127081. }
  127082. }
  127083. declare module BABYLON {
  127084. /**
  127085. * Base class for Camera Pointer Inputs.
  127086. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  127087. * for example usage.
  127088. */
  127089. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  127090. /**
  127091. * Defines the camera the input is attached to.
  127092. */
  127093. abstract camera: Camera;
  127094. /**
  127095. * Whether keyboard modifier keys are pressed at time of last mouse event.
  127096. */
  127097. protected _altKey: boolean;
  127098. protected _ctrlKey: boolean;
  127099. protected _metaKey: boolean;
  127100. protected _shiftKey: boolean;
  127101. /**
  127102. * Which mouse buttons were pressed at time of last mouse event.
  127103. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  127104. */
  127105. protected _buttonsPressed: number;
  127106. /**
  127107. * Defines the buttons associated with the input to handle camera move.
  127108. */
  127109. buttons: number[];
  127110. /**
  127111. * Attach the input controls to a specific dom element to get the input from.
  127112. * @param element Defines the element the controls should be listened from
  127113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127114. */
  127115. attachControl(noPreventDefault?: boolean): void;
  127116. /**
  127117. * Detach the current controls from the specified dom element.
  127118. */
  127119. detachControl(): void;
  127120. /**
  127121. * Gets the class name of the current input.
  127122. * @returns the class name
  127123. */
  127124. getClassName(): string;
  127125. /**
  127126. * Get the friendly name associated with the input class.
  127127. * @returns the input friendly name
  127128. */
  127129. getSimpleName(): string;
  127130. /**
  127131. * Called on pointer POINTERDOUBLETAP event.
  127132. * Override this method to provide functionality on POINTERDOUBLETAP event.
  127133. */
  127134. protected onDoubleTap(type: string): void;
  127135. /**
  127136. * Called on pointer POINTERMOVE event if only a single touch is active.
  127137. * Override this method to provide functionality.
  127138. */
  127139. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127140. /**
  127141. * Called on pointer POINTERMOVE event if multiple touches are active.
  127142. * Override this method to provide functionality.
  127143. */
  127144. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127145. /**
  127146. * Called on JS contextmenu event.
  127147. * Override this method to provide functionality.
  127148. */
  127149. protected onContextMenu(evt: PointerEvent): void;
  127150. /**
  127151. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127152. * press.
  127153. * Override this method to provide functionality.
  127154. */
  127155. protected onButtonDown(evt: PointerEvent): void;
  127156. /**
  127157. * Called each time a new POINTERUP event occurs. Ie, for each button
  127158. * release.
  127159. * Override this method to provide functionality.
  127160. */
  127161. protected onButtonUp(evt: PointerEvent): void;
  127162. /**
  127163. * Called when window becomes inactive.
  127164. * Override this method to provide functionality.
  127165. */
  127166. protected onLostFocus(): void;
  127167. private _pointerInput;
  127168. private _observer;
  127169. private _onLostFocus;
  127170. private pointA;
  127171. private pointB;
  127172. }
  127173. }
  127174. declare module BABYLON {
  127175. /**
  127176. * Manage the pointers inputs to control an arc rotate camera.
  127177. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127178. */
  127179. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  127180. /**
  127181. * Defines the camera the input is attached to.
  127182. */
  127183. camera: ArcRotateCamera;
  127184. /**
  127185. * Gets the class name of the current input.
  127186. * @returns the class name
  127187. */
  127188. getClassName(): string;
  127189. /**
  127190. * Defines the buttons associated with the input to handle camera move.
  127191. */
  127192. buttons: number[];
  127193. /**
  127194. * Defines the pointer angular sensibility along the X axis or how fast is
  127195. * the camera rotating.
  127196. */
  127197. angularSensibilityX: number;
  127198. /**
  127199. * Defines the pointer angular sensibility along the Y axis or how fast is
  127200. * the camera rotating.
  127201. */
  127202. angularSensibilityY: number;
  127203. /**
  127204. * Defines the pointer pinch precision or how fast is the camera zooming.
  127205. */
  127206. pinchPrecision: number;
  127207. /**
  127208. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  127209. * from 0.
  127210. * It defines the percentage of current camera.radius to use as delta when
  127211. * pinch zoom is used.
  127212. */
  127213. pinchDeltaPercentage: number;
  127214. /**
  127215. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127216. * that any object in the plane at the camera's target point will scale
  127217. * perfectly with finger motion.
  127218. * Overrides pinchDeltaPercentage and pinchPrecision.
  127219. */
  127220. useNaturalPinchZoom: boolean;
  127221. /**
  127222. * Defines the pointer panning sensibility or how fast is the camera moving.
  127223. */
  127224. panningSensibility: number;
  127225. /**
  127226. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  127227. */
  127228. multiTouchPanning: boolean;
  127229. /**
  127230. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  127231. * zoom (pinch) through multitouch.
  127232. */
  127233. multiTouchPanAndZoom: boolean;
  127234. /**
  127235. * Revers pinch action direction.
  127236. */
  127237. pinchInwards: boolean;
  127238. private _isPanClick;
  127239. private _twoFingerActivityCount;
  127240. private _isPinching;
  127241. /**
  127242. * Called on pointer POINTERMOVE event if only a single touch is active.
  127243. */
  127244. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127245. /**
  127246. * Called on pointer POINTERDOUBLETAP event.
  127247. */
  127248. protected onDoubleTap(type: string): void;
  127249. /**
  127250. * Called on pointer POINTERMOVE event if multiple touches are active.
  127251. */
  127252. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127253. /**
  127254. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127255. * press.
  127256. */
  127257. protected onButtonDown(evt: PointerEvent): void;
  127258. /**
  127259. * Called each time a new POINTERUP event occurs. Ie, for each button
  127260. * release.
  127261. */
  127262. protected onButtonUp(evt: PointerEvent): void;
  127263. /**
  127264. * Called when window becomes inactive.
  127265. */
  127266. protected onLostFocus(): void;
  127267. }
  127268. }
  127269. declare module BABYLON {
  127270. /**
  127271. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  127272. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127273. */
  127274. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  127275. /**
  127276. * Defines the camera the input is attached to.
  127277. */
  127278. camera: ArcRotateCamera;
  127279. /**
  127280. * Defines the list of key codes associated with the up action (increase alpha)
  127281. */
  127282. keysUp: number[];
  127283. /**
  127284. * Defines the list of key codes associated with the down action (decrease alpha)
  127285. */
  127286. keysDown: number[];
  127287. /**
  127288. * Defines the list of key codes associated with the left action (increase beta)
  127289. */
  127290. keysLeft: number[];
  127291. /**
  127292. * Defines the list of key codes associated with the right action (decrease beta)
  127293. */
  127294. keysRight: number[];
  127295. /**
  127296. * Defines the list of key codes associated with the reset action.
  127297. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  127298. */
  127299. keysReset: number[];
  127300. /**
  127301. * Defines the panning sensibility of the inputs.
  127302. * (How fast is the camera panning)
  127303. */
  127304. panningSensibility: number;
  127305. /**
  127306. * Defines the zooming sensibility of the inputs.
  127307. * (How fast is the camera zooming)
  127308. */
  127309. zoomingSensibility: number;
  127310. /**
  127311. * Defines whether maintaining the alt key down switch the movement mode from
  127312. * orientation to zoom.
  127313. */
  127314. useAltToZoom: boolean;
  127315. /**
  127316. * Rotation speed of the camera
  127317. */
  127318. angularSpeed: number;
  127319. private _keys;
  127320. private _ctrlPressed;
  127321. private _altPressed;
  127322. private _onCanvasBlurObserver;
  127323. private _onKeyboardObserver;
  127324. private _engine;
  127325. private _scene;
  127326. /**
  127327. * Attach the input controls to a specific dom element to get the input from.
  127328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127329. */
  127330. attachControl(noPreventDefault?: boolean): void;
  127331. /**
  127332. * Detach the current controls from the specified dom element.
  127333. */
  127334. detachControl(): void;
  127335. /**
  127336. * Update the current camera state depending on the inputs that have been used this frame.
  127337. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127338. */
  127339. checkInputs(): void;
  127340. /**
  127341. * Gets the class name of the current intput.
  127342. * @returns the class name
  127343. */
  127344. getClassName(): string;
  127345. /**
  127346. * Get the friendly name associated with the input class.
  127347. * @returns the input friendly name
  127348. */
  127349. getSimpleName(): string;
  127350. }
  127351. }
  127352. declare module BABYLON {
  127353. /**
  127354. * Manage the mouse wheel inputs to control an arc rotate camera.
  127355. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127356. */
  127357. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  127358. /**
  127359. * Defines the camera the input is attached to.
  127360. */
  127361. camera: ArcRotateCamera;
  127362. /**
  127363. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  127364. */
  127365. wheelPrecision: number;
  127366. /**
  127367. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  127368. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  127369. */
  127370. wheelDeltaPercentage: number;
  127371. private _wheel;
  127372. private _observer;
  127373. private computeDeltaFromMouseWheelLegacyEvent;
  127374. /**
  127375. * Attach the input controls to a specific dom element to get the input from.
  127376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127377. */
  127378. attachControl(noPreventDefault?: boolean): void;
  127379. /**
  127380. * Detach the current controls from the specified dom element.
  127381. */
  127382. detachControl(): void;
  127383. /**
  127384. * Gets the class name of the current intput.
  127385. * @returns the class name
  127386. */
  127387. getClassName(): string;
  127388. /**
  127389. * Get the friendly name associated with the input class.
  127390. * @returns the input friendly name
  127391. */
  127392. getSimpleName(): string;
  127393. }
  127394. }
  127395. declare module BABYLON {
  127396. /**
  127397. * Default Inputs manager for the ArcRotateCamera.
  127398. * It groups all the default supported inputs for ease of use.
  127399. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127400. */
  127401. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  127402. /**
  127403. * Instantiates a new ArcRotateCameraInputsManager.
  127404. * @param camera Defines the camera the inputs belong to
  127405. */
  127406. constructor(camera: ArcRotateCamera);
  127407. /**
  127408. * Add mouse wheel input support to the input manager.
  127409. * @returns the current input manager
  127410. */
  127411. addMouseWheel(): ArcRotateCameraInputsManager;
  127412. /**
  127413. * Add pointers input support to the input manager.
  127414. * @returns the current input manager
  127415. */
  127416. addPointers(): ArcRotateCameraInputsManager;
  127417. /**
  127418. * Add keyboard input support to the input manager.
  127419. * @returns the current input manager
  127420. */
  127421. addKeyboard(): ArcRotateCameraInputsManager;
  127422. }
  127423. }
  127424. declare module BABYLON {
  127425. /**
  127426. * This represents an orbital type of camera.
  127427. *
  127428. * 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.
  127429. * 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.
  127430. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  127431. */
  127432. export class ArcRotateCamera extends TargetCamera {
  127433. /**
  127434. * Defines the rotation angle of the camera along the longitudinal axis.
  127435. */
  127436. alpha: number;
  127437. /**
  127438. * Defines the rotation angle of the camera along the latitudinal axis.
  127439. */
  127440. beta: number;
  127441. /**
  127442. * Defines the radius of the camera from it s target point.
  127443. */
  127444. radius: number;
  127445. protected _target: Vector3;
  127446. protected _targetHost: Nullable<AbstractMesh>;
  127447. /**
  127448. * Defines the target point of the camera.
  127449. * The camera looks towards it form the radius distance.
  127450. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  127451. */
  127452. get target(): Vector3;
  127453. set target(value: Vector3);
  127454. /**
  127455. * Define the current local position of the camera in the scene
  127456. */
  127457. get position(): Vector3;
  127458. set position(newPosition: Vector3);
  127459. protected _upToYMatrix: Matrix;
  127460. protected _YToUpMatrix: Matrix;
  127461. /**
  127462. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  127463. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  127464. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  127465. */
  127466. set upVector(vec: Vector3);
  127467. get upVector(): Vector3;
  127468. /**
  127469. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  127470. */
  127471. setMatUp(): void;
  127472. /**
  127473. * Current inertia value on the longitudinal axis.
  127474. * The bigger this number the longer it will take for the camera to stop.
  127475. */
  127476. inertialAlphaOffset: number;
  127477. /**
  127478. * Current inertia value on the latitudinal axis.
  127479. * The bigger this number the longer it will take for the camera to stop.
  127480. */
  127481. inertialBetaOffset: number;
  127482. /**
  127483. * Current inertia value on the radius axis.
  127484. * The bigger this number the longer it will take for the camera to stop.
  127485. */
  127486. inertialRadiusOffset: number;
  127487. /**
  127488. * Minimum allowed angle on the longitudinal axis.
  127489. * This can help limiting how the Camera is able to move in the scene.
  127490. */
  127491. lowerAlphaLimit: Nullable<number>;
  127492. /**
  127493. * Maximum allowed angle on the longitudinal axis.
  127494. * This can help limiting how the Camera is able to move in the scene.
  127495. */
  127496. upperAlphaLimit: Nullable<number>;
  127497. /**
  127498. * Minimum allowed angle on the latitudinal axis.
  127499. * This can help limiting how the Camera is able to move in the scene.
  127500. */
  127501. lowerBetaLimit: number;
  127502. /**
  127503. * Maximum allowed angle on the latitudinal axis.
  127504. * This can help limiting how the Camera is able to move in the scene.
  127505. */
  127506. upperBetaLimit: number;
  127507. /**
  127508. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  127509. * This can help limiting how the Camera is able to move in the scene.
  127510. */
  127511. lowerRadiusLimit: Nullable<number>;
  127512. /**
  127513. * Maximum allowed distance of the camera to the target (The camera can not get further).
  127514. * This can help limiting how the Camera is able to move in the scene.
  127515. */
  127516. upperRadiusLimit: Nullable<number>;
  127517. /**
  127518. * Defines the current inertia value used during panning of the camera along the X axis.
  127519. */
  127520. inertialPanningX: number;
  127521. /**
  127522. * Defines the current inertia value used during panning of the camera along the Y axis.
  127523. */
  127524. inertialPanningY: number;
  127525. /**
  127526. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  127527. * Basically if your fingers moves away from more than this distance you will be considered
  127528. * in pinch mode.
  127529. */
  127530. pinchToPanMaxDistance: number;
  127531. /**
  127532. * Defines the maximum distance the camera can pan.
  127533. * This could help keeping the cammera always in your scene.
  127534. */
  127535. panningDistanceLimit: Nullable<number>;
  127536. /**
  127537. * Defines the target of the camera before paning.
  127538. */
  127539. panningOriginTarget: Vector3;
  127540. /**
  127541. * Defines the value of the inertia used during panning.
  127542. * 0 would mean stop inertia and one would mean no decelleration at all.
  127543. */
  127544. panningInertia: number;
  127545. /**
  127546. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  127547. */
  127548. get angularSensibilityX(): number;
  127549. set angularSensibilityX(value: number);
  127550. /**
  127551. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  127552. */
  127553. get angularSensibilityY(): number;
  127554. set angularSensibilityY(value: number);
  127555. /**
  127556. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  127557. */
  127558. get pinchPrecision(): number;
  127559. set pinchPrecision(value: number);
  127560. /**
  127561. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  127562. * It will be used instead of pinchDeltaPrecision if different from 0.
  127563. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  127564. */
  127565. get pinchDeltaPercentage(): number;
  127566. set pinchDeltaPercentage(value: number);
  127567. /**
  127568. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  127569. * and pinch delta percentage.
  127570. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127571. * that any object in the plane at the camera's target point will scale
  127572. * perfectly with finger motion.
  127573. */
  127574. get useNaturalPinchZoom(): boolean;
  127575. set useNaturalPinchZoom(value: boolean);
  127576. /**
  127577. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  127578. */
  127579. get panningSensibility(): number;
  127580. set panningSensibility(value: number);
  127581. /**
  127582. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  127583. */
  127584. get keysUp(): number[];
  127585. set keysUp(value: number[]);
  127586. /**
  127587. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  127588. */
  127589. get keysDown(): number[];
  127590. set keysDown(value: number[]);
  127591. /**
  127592. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  127593. */
  127594. get keysLeft(): number[];
  127595. set keysLeft(value: number[]);
  127596. /**
  127597. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  127598. */
  127599. get keysRight(): number[];
  127600. set keysRight(value: number[]);
  127601. /**
  127602. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  127603. */
  127604. get wheelPrecision(): number;
  127605. set wheelPrecision(value: number);
  127606. /**
  127607. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  127608. * It will be used instead of pinchDeltaPrecision if different from 0.
  127609. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  127610. */
  127611. get wheelDeltaPercentage(): number;
  127612. set wheelDeltaPercentage(value: number);
  127613. /**
  127614. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  127615. */
  127616. zoomOnFactor: number;
  127617. /**
  127618. * Defines a screen offset for the camera position.
  127619. */
  127620. targetScreenOffset: Vector2;
  127621. /**
  127622. * Allows the camera to be completely reversed.
  127623. * If false the camera can not arrive upside down.
  127624. */
  127625. allowUpsideDown: boolean;
  127626. /**
  127627. * Define if double tap/click is used to restore the previously saved state of the camera.
  127628. */
  127629. useInputToRestoreState: boolean;
  127630. /** @hidden */
  127631. _viewMatrix: Matrix;
  127632. /** @hidden */
  127633. _useCtrlForPanning: boolean;
  127634. /** @hidden */
  127635. _panningMouseButton: number;
  127636. /**
  127637. * Defines the input associated to the camera.
  127638. */
  127639. inputs: ArcRotateCameraInputsManager;
  127640. /** @hidden */
  127641. _reset: () => void;
  127642. /**
  127643. * Defines the allowed panning axis.
  127644. */
  127645. panningAxis: Vector3;
  127646. protected _localDirection: Vector3;
  127647. protected _transformedDirection: Vector3;
  127648. private _bouncingBehavior;
  127649. /**
  127650. * Gets the bouncing behavior of the camera if it has been enabled.
  127651. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127652. */
  127653. get bouncingBehavior(): Nullable<BouncingBehavior>;
  127654. /**
  127655. * Defines if the bouncing behavior of the camera is enabled on the camera.
  127656. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127657. */
  127658. get useBouncingBehavior(): boolean;
  127659. set useBouncingBehavior(value: boolean);
  127660. private _framingBehavior;
  127661. /**
  127662. * Gets the framing behavior of the camera if it has been enabled.
  127663. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127664. */
  127665. get framingBehavior(): Nullable<FramingBehavior>;
  127666. /**
  127667. * Defines if the framing behavior of the camera is enabled on the camera.
  127668. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127669. */
  127670. get useFramingBehavior(): boolean;
  127671. set useFramingBehavior(value: boolean);
  127672. private _autoRotationBehavior;
  127673. /**
  127674. * Gets the auto rotation behavior of the camera if it has been enabled.
  127675. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127676. */
  127677. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  127678. /**
  127679. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  127680. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127681. */
  127682. get useAutoRotationBehavior(): boolean;
  127683. set useAutoRotationBehavior(value: boolean);
  127684. /**
  127685. * Observable triggered when the mesh target has been changed on the camera.
  127686. */
  127687. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  127688. /**
  127689. * Event raised when the camera is colliding with a mesh.
  127690. */
  127691. onCollide: (collidedMesh: AbstractMesh) => void;
  127692. /**
  127693. * Defines whether the camera should check collision with the objects oh the scene.
  127694. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  127695. */
  127696. checkCollisions: boolean;
  127697. /**
  127698. * Defines the collision radius of the camera.
  127699. * This simulates a sphere around the camera.
  127700. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  127701. */
  127702. collisionRadius: Vector3;
  127703. protected _collider: Collider;
  127704. protected _previousPosition: Vector3;
  127705. protected _collisionVelocity: Vector3;
  127706. protected _newPosition: Vector3;
  127707. protected _previousAlpha: number;
  127708. protected _previousBeta: number;
  127709. protected _previousRadius: number;
  127710. protected _collisionTriggered: boolean;
  127711. protected _targetBoundingCenter: Nullable<Vector3>;
  127712. private _computationVector;
  127713. /**
  127714. * Instantiates a new ArcRotateCamera in a given scene
  127715. * @param name Defines the name of the camera
  127716. * @param alpha Defines the camera rotation along the logitudinal axis
  127717. * @param beta Defines the camera rotation along the latitudinal axis
  127718. * @param radius Defines the camera distance from its target
  127719. * @param target Defines the camera target
  127720. * @param scene Defines the scene the camera belongs to
  127721. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  127722. */
  127723. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  127724. /** @hidden */
  127725. _initCache(): void;
  127726. /** @hidden */
  127727. _updateCache(ignoreParentClass?: boolean): void;
  127728. protected _getTargetPosition(): Vector3;
  127729. private _storedAlpha;
  127730. private _storedBeta;
  127731. private _storedRadius;
  127732. private _storedTarget;
  127733. private _storedTargetScreenOffset;
  127734. /**
  127735. * Stores the current state of the camera (alpha, beta, radius and target)
  127736. * @returns the camera itself
  127737. */
  127738. storeState(): Camera;
  127739. /**
  127740. * @hidden
  127741. * Restored camera state. You must call storeState() first
  127742. */
  127743. _restoreStateValues(): boolean;
  127744. /** @hidden */
  127745. _isSynchronizedViewMatrix(): boolean;
  127746. /**
  127747. * Attach the input controls to a specific dom element to get the input from.
  127748. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127749. */
  127750. attachControl(noPreventDefault?: boolean): void;
  127751. /**
  127752. * Attach the input controls to a specific dom element to get the input from.
  127753. * @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
  127754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127755. */
  127756. attachControl(ignored: any, noPreventDefault?: boolean): void;
  127757. /**
  127758. * Attached controls to the current camera.
  127759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127760. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  127761. */
  127762. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  127763. /**
  127764. * Attached controls to the current camera.
  127765. * @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
  127766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127767. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  127768. */
  127769. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  127770. /**
  127771. * Attached controls to the current camera.
  127772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127773. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  127774. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  127775. */
  127776. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  127777. /**
  127778. * Detach the current controls from the camera.
  127779. * The camera will stop reacting to inputs.
  127780. */
  127781. detachControl(): void;
  127782. /** @hidden */
  127783. _checkInputs(): void;
  127784. protected _checkLimits(): void;
  127785. /**
  127786. * Rebuilds angles (alpha, beta) and radius from the give position and target
  127787. */
  127788. rebuildAnglesAndRadius(): void;
  127789. /**
  127790. * Use a position to define the current camera related information like alpha, beta and radius
  127791. * @param position Defines the position to set the camera at
  127792. */
  127793. setPosition(position: Vector3): void;
  127794. /**
  127795. * Defines the target the camera should look at.
  127796. * This will automatically adapt alpha beta and radius to fit within the new target.
  127797. * @param target Defines the new target as a Vector or a mesh
  127798. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  127799. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  127800. */
  127801. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  127802. /** @hidden */
  127803. _getViewMatrix(): Matrix;
  127804. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  127805. /**
  127806. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  127807. * @param meshes Defines the mesh to zoom on
  127808. * @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)
  127809. */
  127810. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  127811. /**
  127812. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  127813. * The target will be changed but the radius
  127814. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  127815. * @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)
  127816. */
  127817. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  127818. min: Vector3;
  127819. max: Vector3;
  127820. distance: number;
  127821. }, doNotUpdateMaxZ?: boolean): void;
  127822. /**
  127823. * @override
  127824. * Override Camera.createRigCamera
  127825. */
  127826. createRigCamera(name: string, cameraIndex: number): Camera;
  127827. /**
  127828. * @hidden
  127829. * @override
  127830. * Override Camera._updateRigCameras
  127831. */
  127832. _updateRigCameras(): void;
  127833. /**
  127834. * Destroy the camera and release the current resources hold by it.
  127835. */
  127836. dispose(): void;
  127837. /**
  127838. * Gets the current object class name.
  127839. * @return the class name
  127840. */
  127841. getClassName(): string;
  127842. }
  127843. }
  127844. declare module BABYLON {
  127845. /**
  127846. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  127847. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127848. */
  127849. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  127850. /**
  127851. * Gets the name of the behavior.
  127852. */
  127853. get name(): string;
  127854. private _zoomStopsAnimation;
  127855. private _idleRotationSpeed;
  127856. private _idleRotationWaitTime;
  127857. private _idleRotationSpinupTime;
  127858. /**
  127859. * Sets the flag that indicates if user zooming should stop animation.
  127860. */
  127861. set zoomStopsAnimation(flag: boolean);
  127862. /**
  127863. * Gets the flag that indicates if user zooming should stop animation.
  127864. */
  127865. get zoomStopsAnimation(): boolean;
  127866. /**
  127867. * Sets the default speed at which the camera rotates around the model.
  127868. */
  127869. set idleRotationSpeed(speed: number);
  127870. /**
  127871. * Gets the default speed at which the camera rotates around the model.
  127872. */
  127873. get idleRotationSpeed(): number;
  127874. /**
  127875. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  127876. */
  127877. set idleRotationWaitTime(time: number);
  127878. /**
  127879. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  127880. */
  127881. get idleRotationWaitTime(): number;
  127882. /**
  127883. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127884. */
  127885. set idleRotationSpinupTime(time: number);
  127886. /**
  127887. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127888. */
  127889. get idleRotationSpinupTime(): number;
  127890. /**
  127891. * Gets a value indicating if the camera is currently rotating because of this behavior
  127892. */
  127893. get rotationInProgress(): boolean;
  127894. private _onPrePointerObservableObserver;
  127895. private _onAfterCheckInputsObserver;
  127896. private _attachedCamera;
  127897. private _isPointerDown;
  127898. private _lastFrameTime;
  127899. private _lastInteractionTime;
  127900. private _cameraRotationSpeed;
  127901. /**
  127902. * Initializes the behavior.
  127903. */
  127904. init(): void;
  127905. /**
  127906. * Attaches the behavior to its arc rotate camera.
  127907. * @param camera Defines the camera to attach the behavior to
  127908. */
  127909. attach(camera: ArcRotateCamera): void;
  127910. /**
  127911. * Detaches the behavior from its current arc rotate camera.
  127912. */
  127913. detach(): void;
  127914. /**
  127915. * Returns true if user is scrolling.
  127916. * @return true if user is scrolling.
  127917. */
  127918. private _userIsZooming;
  127919. private _lastFrameRadius;
  127920. private _shouldAnimationStopForInteraction;
  127921. /**
  127922. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127923. */
  127924. private _applyUserInteraction;
  127925. private _userIsMoving;
  127926. }
  127927. }
  127928. declare module BABYLON {
  127929. /**
  127930. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  127931. */
  127932. export class AttachToBoxBehavior implements Behavior<Mesh> {
  127933. private ui;
  127934. /**
  127935. * The name of the behavior
  127936. */
  127937. name: string;
  127938. /**
  127939. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  127940. */
  127941. distanceAwayFromFace: number;
  127942. /**
  127943. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  127944. */
  127945. distanceAwayFromBottomOfFace: number;
  127946. private _faceVectors;
  127947. private _target;
  127948. private _scene;
  127949. private _onRenderObserver;
  127950. private _tmpMatrix;
  127951. private _tmpVector;
  127952. /**
  127953. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  127954. * @param ui The transform node that should be attched to the mesh
  127955. */
  127956. constructor(ui: TransformNode);
  127957. /**
  127958. * Initializes the behavior
  127959. */
  127960. init(): void;
  127961. private _closestFace;
  127962. private _zeroVector;
  127963. private _lookAtTmpMatrix;
  127964. private _lookAtToRef;
  127965. /**
  127966. * Attaches the AttachToBoxBehavior to the passed in mesh
  127967. * @param target The mesh that the specified node will be attached to
  127968. */
  127969. attach(target: Mesh): void;
  127970. /**
  127971. * Detaches the behavior from the mesh
  127972. */
  127973. detach(): void;
  127974. }
  127975. }
  127976. declare module BABYLON {
  127977. /**
  127978. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  127979. */
  127980. export class FadeInOutBehavior implements Behavior<Mesh> {
  127981. /**
  127982. * Time in milliseconds to delay before fading in (Default: 0)
  127983. */
  127984. delay: number;
  127985. /**
  127986. * Time in milliseconds for the mesh to fade in (Default: 300)
  127987. */
  127988. fadeInTime: number;
  127989. private _millisecondsPerFrame;
  127990. private _hovered;
  127991. private _hoverValue;
  127992. private _ownerNode;
  127993. /**
  127994. * Instatiates the FadeInOutBehavior
  127995. */
  127996. constructor();
  127997. /**
  127998. * The name of the behavior
  127999. */
  128000. get name(): string;
  128001. /**
  128002. * Initializes the behavior
  128003. */
  128004. init(): void;
  128005. /**
  128006. * Attaches the fade behavior on the passed in mesh
  128007. * @param ownerNode The mesh that will be faded in/out once attached
  128008. */
  128009. attach(ownerNode: Mesh): void;
  128010. /**
  128011. * Detaches the behavior from the mesh
  128012. */
  128013. detach(): void;
  128014. /**
  128015. * Triggers the mesh to begin fading in or out
  128016. * @param value if the object should fade in or out (true to fade in)
  128017. */
  128018. fadeIn(value: boolean): void;
  128019. private _update;
  128020. private _setAllVisibility;
  128021. }
  128022. }
  128023. declare module BABYLON {
  128024. /**
  128025. * Class containing a set of static utilities functions for managing Pivots
  128026. * @hidden
  128027. */
  128028. export class PivotTools {
  128029. private static _PivotCached;
  128030. private static _OldPivotPoint;
  128031. private static _PivotTranslation;
  128032. private static _PivotTmpVector;
  128033. private static _PivotPostMultiplyPivotMatrix;
  128034. /** @hidden */
  128035. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  128036. /** @hidden */
  128037. static _RestorePivotPoint(mesh: AbstractMesh): void;
  128038. }
  128039. }
  128040. declare module BABYLON {
  128041. /**
  128042. * Class containing static functions to help procedurally build meshes
  128043. */
  128044. export class PlaneBuilder {
  128045. /**
  128046. * Creates a plane mesh
  128047. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  128048. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  128049. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  128050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128053. * @param name defines the name of the mesh
  128054. * @param options defines the options used to create the mesh
  128055. * @param scene defines the hosting scene
  128056. * @returns the plane mesh
  128057. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  128058. */
  128059. static CreatePlane(name: string, options: {
  128060. size?: number;
  128061. width?: number;
  128062. height?: number;
  128063. sideOrientation?: number;
  128064. frontUVs?: Vector4;
  128065. backUVs?: Vector4;
  128066. updatable?: boolean;
  128067. sourcePlane?: Plane;
  128068. }, scene?: Nullable<Scene>): Mesh;
  128069. }
  128070. }
  128071. declare module BABYLON {
  128072. /**
  128073. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  128074. */
  128075. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  128076. private static _AnyMouseID;
  128077. /**
  128078. * Abstract mesh the behavior is set on
  128079. */
  128080. attachedNode: AbstractMesh;
  128081. private _dragPlane;
  128082. private _scene;
  128083. private _pointerObserver;
  128084. private _beforeRenderObserver;
  128085. private static _planeScene;
  128086. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  128087. /**
  128088. * 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)
  128089. */
  128090. maxDragAngle: number;
  128091. /**
  128092. * @hidden
  128093. */
  128094. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  128095. /**
  128096. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128097. */
  128098. currentDraggingPointerID: number;
  128099. /**
  128100. * The last position where the pointer hit the drag plane in world space
  128101. */
  128102. lastDragPosition: Vector3;
  128103. /**
  128104. * If the behavior is currently in a dragging state
  128105. */
  128106. dragging: boolean;
  128107. /**
  128108. * 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)
  128109. */
  128110. dragDeltaRatio: number;
  128111. /**
  128112. * If the drag plane orientation should be updated during the dragging (Default: true)
  128113. */
  128114. updateDragPlane: boolean;
  128115. private _debugMode;
  128116. private _moving;
  128117. /**
  128118. * Fires each time the attached mesh is dragged with the pointer
  128119. * * delta between last drag position and current drag position in world space
  128120. * * dragDistance along the drag axis
  128121. * * dragPlaneNormal normal of the current drag plane used during the drag
  128122. * * dragPlanePoint in world space where the drag intersects the drag plane
  128123. */
  128124. onDragObservable: Observable<{
  128125. delta: Vector3;
  128126. dragPlanePoint: Vector3;
  128127. dragPlaneNormal: Vector3;
  128128. dragDistance: number;
  128129. pointerId: number;
  128130. }>;
  128131. /**
  128132. * Fires each time a drag begins (eg. mouse down on mesh)
  128133. */
  128134. onDragStartObservable: Observable<{
  128135. dragPlanePoint: Vector3;
  128136. pointerId: number;
  128137. }>;
  128138. /**
  128139. * Fires each time a drag ends (eg. mouse release after drag)
  128140. */
  128141. onDragEndObservable: Observable<{
  128142. dragPlanePoint: Vector3;
  128143. pointerId: number;
  128144. }>;
  128145. /**
  128146. * If the attached mesh should be moved when dragged
  128147. */
  128148. moveAttached: boolean;
  128149. /**
  128150. * If the drag behavior will react to drag events (Default: true)
  128151. */
  128152. enabled: boolean;
  128153. /**
  128154. * If pointer events should start and release the drag (Default: true)
  128155. */
  128156. startAndReleaseDragOnPointerEvents: boolean;
  128157. /**
  128158. * If camera controls should be detached during the drag
  128159. */
  128160. detachCameraControls: boolean;
  128161. /**
  128162. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  128163. */
  128164. useObjectOrientationForDragging: boolean;
  128165. private _options;
  128166. /**
  128167. * Gets the options used by the behavior
  128168. */
  128169. get options(): {
  128170. dragAxis?: Vector3;
  128171. dragPlaneNormal?: Vector3;
  128172. };
  128173. /**
  128174. * Sets the options used by the behavior
  128175. */
  128176. set options(options: {
  128177. dragAxis?: Vector3;
  128178. dragPlaneNormal?: Vector3;
  128179. });
  128180. /**
  128181. * Creates a pointer drag behavior that can be attached to a mesh
  128182. * @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)
  128183. */
  128184. constructor(options?: {
  128185. dragAxis?: Vector3;
  128186. dragPlaneNormal?: Vector3;
  128187. });
  128188. /**
  128189. * Predicate to determine if it is valid to move the object to a new position when it is moved
  128190. */
  128191. validateDrag: (targetPosition: Vector3) => boolean;
  128192. /**
  128193. * The name of the behavior
  128194. */
  128195. get name(): string;
  128196. /**
  128197. * Initializes the behavior
  128198. */
  128199. init(): void;
  128200. private _tmpVector;
  128201. private _alternatePickedPoint;
  128202. private _worldDragAxis;
  128203. private _targetPosition;
  128204. private _attachedToElement;
  128205. /**
  128206. * Attaches the drag behavior the passed in mesh
  128207. * @param ownerNode The mesh that will be dragged around once attached
  128208. * @param predicate Predicate to use for pick filtering
  128209. */
  128210. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  128211. /**
  128212. * Force relase the drag action by code.
  128213. */
  128214. releaseDrag(): void;
  128215. private _startDragRay;
  128216. private _lastPointerRay;
  128217. /**
  128218. * Simulates the start of a pointer drag event on the behavior
  128219. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  128220. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  128221. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  128222. */
  128223. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128224. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128225. private _dragDelta;
  128226. protected _moveDrag(ray: Ray): void;
  128227. private _pickWithRayOnDragPlane;
  128228. private _pointA;
  128229. private _pointC;
  128230. private _localAxis;
  128231. private _lookAt;
  128232. private _updateDragPlanePosition;
  128233. /**
  128234. * Detaches the behavior from the mesh
  128235. */
  128236. detach(): void;
  128237. }
  128238. }
  128239. declare module BABYLON {
  128240. /**
  128241. * A behavior that when attached to a mesh will allow the mesh to be scaled
  128242. */
  128243. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  128244. private _dragBehaviorA;
  128245. private _dragBehaviorB;
  128246. private _startDistance;
  128247. private _initialScale;
  128248. private _targetScale;
  128249. private _ownerNode;
  128250. private _sceneRenderObserver;
  128251. /**
  128252. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  128253. */
  128254. constructor();
  128255. /**
  128256. * The name of the behavior
  128257. */
  128258. get name(): string;
  128259. /**
  128260. * Initializes the behavior
  128261. */
  128262. init(): void;
  128263. private _getCurrentDistance;
  128264. /**
  128265. * Attaches the scale behavior the passed in mesh
  128266. * @param ownerNode The mesh that will be scaled around once attached
  128267. */
  128268. attach(ownerNode: Mesh): void;
  128269. /**
  128270. * Detaches the behavior from the mesh
  128271. */
  128272. detach(): void;
  128273. }
  128274. }
  128275. declare module BABYLON {
  128276. /**
  128277. * 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
  128278. */
  128279. export class SixDofDragBehavior implements Behavior<Mesh> {
  128280. private static _virtualScene;
  128281. private _ownerNode;
  128282. private _sceneRenderObserver;
  128283. private _scene;
  128284. private _targetPosition;
  128285. private _virtualOriginMesh;
  128286. private _virtualDragMesh;
  128287. private _pointerObserver;
  128288. private _moving;
  128289. private _startingOrientation;
  128290. private _attachedToElement;
  128291. /**
  128292. * 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)
  128293. */
  128294. private zDragFactor;
  128295. /**
  128296. * If the object should rotate to face the drag origin
  128297. */
  128298. rotateDraggedObject: boolean;
  128299. /**
  128300. * If the behavior is currently in a dragging state
  128301. */
  128302. dragging: boolean;
  128303. /**
  128304. * 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)
  128305. */
  128306. dragDeltaRatio: number;
  128307. /**
  128308. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128309. */
  128310. currentDraggingPointerID: number;
  128311. /**
  128312. * If camera controls should be detached during the drag
  128313. */
  128314. detachCameraControls: boolean;
  128315. /**
  128316. * Fires each time a drag starts
  128317. */
  128318. onDragStartObservable: Observable<{}>;
  128319. /**
  128320. * Fires each time a drag ends (eg. mouse release after drag)
  128321. */
  128322. onDragEndObservable: Observable<{}>;
  128323. /**
  128324. * 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
  128325. */
  128326. constructor();
  128327. /**
  128328. * The name of the behavior
  128329. */
  128330. get name(): string;
  128331. /**
  128332. * Initializes the behavior
  128333. */
  128334. init(): void;
  128335. /**
  128336. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  128337. */
  128338. private get _pointerCamera();
  128339. /**
  128340. * Attaches the scale behavior the passed in mesh
  128341. * @param ownerNode The mesh that will be scaled around once attached
  128342. */
  128343. attach(ownerNode: Mesh): void;
  128344. /**
  128345. * Detaches the behavior from the mesh
  128346. */
  128347. detach(): void;
  128348. }
  128349. }
  128350. declare module BABYLON {
  128351. /**
  128352. * Class used to apply inverse kinematics to bones
  128353. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  128354. */
  128355. export class BoneIKController {
  128356. private static _tmpVecs;
  128357. private static _tmpQuat;
  128358. private static _tmpMats;
  128359. /**
  128360. * Gets or sets the target mesh
  128361. */
  128362. targetMesh: AbstractMesh;
  128363. /** Gets or sets the mesh used as pole */
  128364. poleTargetMesh: AbstractMesh;
  128365. /**
  128366. * Gets or sets the bone used as pole
  128367. */
  128368. poleTargetBone: Nullable<Bone>;
  128369. /**
  128370. * Gets or sets the target position
  128371. */
  128372. targetPosition: Vector3;
  128373. /**
  128374. * Gets or sets the pole target position
  128375. */
  128376. poleTargetPosition: Vector3;
  128377. /**
  128378. * Gets or sets the pole target local offset
  128379. */
  128380. poleTargetLocalOffset: Vector3;
  128381. /**
  128382. * Gets or sets the pole angle
  128383. */
  128384. poleAngle: number;
  128385. /**
  128386. * Gets or sets the mesh associated with the controller
  128387. */
  128388. mesh: AbstractMesh;
  128389. /**
  128390. * 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)
  128391. */
  128392. slerpAmount: number;
  128393. private _bone1Quat;
  128394. private _bone1Mat;
  128395. private _bone2Ang;
  128396. private _bone1;
  128397. private _bone2;
  128398. private _bone1Length;
  128399. private _bone2Length;
  128400. private _maxAngle;
  128401. private _maxReach;
  128402. private _rightHandedSystem;
  128403. private _bendAxis;
  128404. private _slerping;
  128405. private _adjustRoll;
  128406. /**
  128407. * Gets or sets maximum allowed angle
  128408. */
  128409. get maxAngle(): number;
  128410. set maxAngle(value: number);
  128411. /**
  128412. * Creates a new BoneIKController
  128413. * @param mesh defines the mesh to control
  128414. * @param bone defines the bone to control
  128415. * @param options defines options to set up the controller
  128416. */
  128417. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  128418. targetMesh?: AbstractMesh;
  128419. poleTargetMesh?: AbstractMesh;
  128420. poleTargetBone?: Bone;
  128421. poleTargetLocalOffset?: Vector3;
  128422. poleAngle?: number;
  128423. bendAxis?: Vector3;
  128424. maxAngle?: number;
  128425. slerpAmount?: number;
  128426. });
  128427. private _setMaxAngle;
  128428. /**
  128429. * Force the controller to update the bones
  128430. */
  128431. update(): void;
  128432. }
  128433. }
  128434. declare module BABYLON {
  128435. /**
  128436. * Class used to make a bone look toward a point in space
  128437. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  128438. */
  128439. export class BoneLookController {
  128440. private static _tmpVecs;
  128441. private static _tmpQuat;
  128442. private static _tmpMats;
  128443. /**
  128444. * The target Vector3 that the bone will look at
  128445. */
  128446. target: Vector3;
  128447. /**
  128448. * The mesh that the bone is attached to
  128449. */
  128450. mesh: AbstractMesh;
  128451. /**
  128452. * The bone that will be looking to the target
  128453. */
  128454. bone: Bone;
  128455. /**
  128456. * The up axis of the coordinate system that is used when the bone is rotated
  128457. */
  128458. upAxis: Vector3;
  128459. /**
  128460. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  128461. */
  128462. upAxisSpace: Space;
  128463. /**
  128464. * Used to make an adjustment to the yaw of the bone
  128465. */
  128466. adjustYaw: number;
  128467. /**
  128468. * Used to make an adjustment to the pitch of the bone
  128469. */
  128470. adjustPitch: number;
  128471. /**
  128472. * Used to make an adjustment to the roll of the bone
  128473. */
  128474. adjustRoll: number;
  128475. /**
  128476. * 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)
  128477. */
  128478. slerpAmount: number;
  128479. private _minYaw;
  128480. private _maxYaw;
  128481. private _minPitch;
  128482. private _maxPitch;
  128483. private _minYawSin;
  128484. private _minYawCos;
  128485. private _maxYawSin;
  128486. private _maxYawCos;
  128487. private _midYawConstraint;
  128488. private _minPitchTan;
  128489. private _maxPitchTan;
  128490. private _boneQuat;
  128491. private _slerping;
  128492. private _transformYawPitch;
  128493. private _transformYawPitchInv;
  128494. private _firstFrameSkipped;
  128495. private _yawRange;
  128496. private _fowardAxis;
  128497. /**
  128498. * Gets or sets the minimum yaw angle that the bone can look to
  128499. */
  128500. get minYaw(): number;
  128501. set minYaw(value: number);
  128502. /**
  128503. * Gets or sets the maximum yaw angle that the bone can look to
  128504. */
  128505. get maxYaw(): number;
  128506. set maxYaw(value: number);
  128507. /**
  128508. * Gets or sets the minimum pitch angle that the bone can look to
  128509. */
  128510. get minPitch(): number;
  128511. set minPitch(value: number);
  128512. /**
  128513. * Gets or sets the maximum pitch angle that the bone can look to
  128514. */
  128515. get maxPitch(): number;
  128516. set maxPitch(value: number);
  128517. /**
  128518. * Create a BoneLookController
  128519. * @param mesh the mesh that the bone belongs to
  128520. * @param bone the bone that will be looking to the target
  128521. * @param target the target Vector3 to look at
  128522. * @param options optional settings:
  128523. * * maxYaw: the maximum angle the bone will yaw to
  128524. * * minYaw: the minimum angle the bone will yaw to
  128525. * * maxPitch: the maximum angle the bone will pitch to
  128526. * * minPitch: the minimum angle the bone will yaw to
  128527. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  128528. * * upAxis: the up axis of the coordinate system
  128529. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  128530. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  128531. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  128532. * * adjustYaw: used to make an adjustment to the yaw of the bone
  128533. * * adjustPitch: used to make an adjustment to the pitch of the bone
  128534. * * adjustRoll: used to make an adjustment to the roll of the bone
  128535. **/
  128536. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  128537. maxYaw?: number;
  128538. minYaw?: number;
  128539. maxPitch?: number;
  128540. minPitch?: number;
  128541. slerpAmount?: number;
  128542. upAxis?: Vector3;
  128543. upAxisSpace?: Space;
  128544. yawAxis?: Vector3;
  128545. pitchAxis?: Vector3;
  128546. adjustYaw?: number;
  128547. adjustPitch?: number;
  128548. adjustRoll?: number;
  128549. });
  128550. /**
  128551. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  128552. */
  128553. update(): void;
  128554. private _getAngleDiff;
  128555. private _getAngleBetween;
  128556. private _isAngleBetween;
  128557. }
  128558. }
  128559. declare module BABYLON {
  128560. /**
  128561. * Manage the gamepad inputs to control an arc rotate camera.
  128562. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128563. */
  128564. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  128565. /**
  128566. * Defines the camera the input is attached to.
  128567. */
  128568. camera: ArcRotateCamera;
  128569. /**
  128570. * Defines the gamepad the input is gathering event from.
  128571. */
  128572. gamepad: Nullable<Gamepad>;
  128573. /**
  128574. * Defines the gamepad rotation sensiblity.
  128575. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  128576. */
  128577. gamepadRotationSensibility: number;
  128578. /**
  128579. * Defines the gamepad move sensiblity.
  128580. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  128581. */
  128582. gamepadMoveSensibility: number;
  128583. private _yAxisScale;
  128584. /**
  128585. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  128586. */
  128587. get invertYAxis(): boolean;
  128588. set invertYAxis(value: boolean);
  128589. private _onGamepadConnectedObserver;
  128590. private _onGamepadDisconnectedObserver;
  128591. /**
  128592. * Attach the input controls to a specific dom element to get the input from.
  128593. */
  128594. attachControl(): void;
  128595. /**
  128596. * Detach the current controls from the specified dom element.
  128597. * @param element Defines the element to stop listening the inputs from
  128598. */
  128599. detachControl(): void;
  128600. /**
  128601. * Update the current camera state depending on the inputs that have been used this frame.
  128602. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128603. */
  128604. checkInputs(): void;
  128605. /**
  128606. * Gets the class name of the current intput.
  128607. * @returns the class name
  128608. */
  128609. getClassName(): string;
  128610. /**
  128611. * Get the friendly name associated with the input class.
  128612. * @returns the input friendly name
  128613. */
  128614. getSimpleName(): string;
  128615. }
  128616. }
  128617. declare module BABYLON {
  128618. interface ArcRotateCameraInputsManager {
  128619. /**
  128620. * Add orientation input support to the input manager.
  128621. * @returns the current input manager
  128622. */
  128623. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  128624. }
  128625. /**
  128626. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  128627. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128628. */
  128629. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  128630. /**
  128631. * Defines the camera the input is attached to.
  128632. */
  128633. camera: ArcRotateCamera;
  128634. /**
  128635. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  128636. */
  128637. alphaCorrection: number;
  128638. /**
  128639. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  128640. */
  128641. gammaCorrection: number;
  128642. private _alpha;
  128643. private _gamma;
  128644. private _dirty;
  128645. private _deviceOrientationHandler;
  128646. /**
  128647. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  128648. */
  128649. constructor();
  128650. /**
  128651. * Attach the input controls to a specific dom element to get the input from.
  128652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128653. */
  128654. attachControl(noPreventDefault?: boolean): void;
  128655. /** @hidden */
  128656. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  128657. /**
  128658. * Update the current camera state depending on the inputs that have been used this frame.
  128659. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128660. */
  128661. checkInputs(): void;
  128662. /**
  128663. * Detach the current controls from the specified dom element.
  128664. */
  128665. detachControl(): void;
  128666. /**
  128667. * Gets the class name of the current intput.
  128668. * @returns the class name
  128669. */
  128670. getClassName(): string;
  128671. /**
  128672. * Get the friendly name associated with the input class.
  128673. * @returns the input friendly name
  128674. */
  128675. getSimpleName(): string;
  128676. }
  128677. }
  128678. declare module BABYLON {
  128679. /**
  128680. * Listen to mouse events to control the camera.
  128681. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128682. */
  128683. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  128684. /**
  128685. * Defines the camera the input is attached to.
  128686. */
  128687. camera: FlyCamera;
  128688. /**
  128689. * Defines if touch is enabled. (Default is true.)
  128690. */
  128691. touchEnabled: boolean;
  128692. /**
  128693. * Defines the buttons associated with the input to handle camera rotation.
  128694. */
  128695. buttons: number[];
  128696. /**
  128697. * Assign buttons for Yaw control.
  128698. */
  128699. buttonsYaw: number[];
  128700. /**
  128701. * Assign buttons for Pitch control.
  128702. */
  128703. buttonsPitch: number[];
  128704. /**
  128705. * Assign buttons for Roll control.
  128706. */
  128707. buttonsRoll: number[];
  128708. /**
  128709. * Detect if any button is being pressed while mouse is moved.
  128710. * -1 = Mouse locked.
  128711. * 0 = Left button.
  128712. * 1 = Middle Button.
  128713. * 2 = Right Button.
  128714. */
  128715. activeButton: number;
  128716. /**
  128717. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  128718. * Higher values reduce its sensitivity.
  128719. */
  128720. angularSensibility: number;
  128721. private _observer;
  128722. private _rollObserver;
  128723. private previousPosition;
  128724. private noPreventDefault;
  128725. private element;
  128726. /**
  128727. * Listen to mouse events to control the camera.
  128728. * @param touchEnabled Define if touch is enabled. (Default is true.)
  128729. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128730. */
  128731. constructor(touchEnabled?: boolean);
  128732. /**
  128733. * Attach the mouse control to the HTML DOM element.
  128734. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  128735. */
  128736. attachControl(noPreventDefault?: boolean): void;
  128737. /**
  128738. * Detach the current controls from the specified dom element.
  128739. */
  128740. detachControl(): void;
  128741. /**
  128742. * Gets the class name of the current input.
  128743. * @returns the class name.
  128744. */
  128745. getClassName(): string;
  128746. /**
  128747. * Get the friendly name associated with the input class.
  128748. * @returns the input's friendly name.
  128749. */
  128750. getSimpleName(): string;
  128751. private _pointerInput;
  128752. private _onMouseMove;
  128753. /**
  128754. * Rotate camera by mouse offset.
  128755. */
  128756. private rotateCamera;
  128757. }
  128758. }
  128759. declare module BABYLON {
  128760. /**
  128761. * Default Inputs manager for the FlyCamera.
  128762. * It groups all the default supported inputs for ease of use.
  128763. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128764. */
  128765. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  128766. /**
  128767. * Instantiates a new FlyCameraInputsManager.
  128768. * @param camera Defines the camera the inputs belong to.
  128769. */
  128770. constructor(camera: FlyCamera);
  128771. /**
  128772. * Add keyboard input support to the input manager.
  128773. * @returns the new FlyCameraKeyboardMoveInput().
  128774. */
  128775. addKeyboard(): FlyCameraInputsManager;
  128776. /**
  128777. * Add mouse input support to the input manager.
  128778. * @param touchEnabled Enable touch screen support.
  128779. * @returns the new FlyCameraMouseInput().
  128780. */
  128781. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  128782. }
  128783. }
  128784. declare module BABYLON {
  128785. /**
  128786. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128787. * such as in a 3D Space Shooter or a Flight Simulator.
  128788. */
  128789. export class FlyCamera extends TargetCamera {
  128790. /**
  128791. * Define the collision ellipsoid of the camera.
  128792. * This is helpful for simulating a camera body, like a player's body.
  128793. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128794. */
  128795. ellipsoid: Vector3;
  128796. /**
  128797. * Define an offset for the position of the ellipsoid around the camera.
  128798. * This can be helpful if the camera is attached away from the player's body center,
  128799. * such as at its head.
  128800. */
  128801. ellipsoidOffset: Vector3;
  128802. /**
  128803. * Enable or disable collisions of the camera with the rest of the scene objects.
  128804. */
  128805. checkCollisions: boolean;
  128806. /**
  128807. * Enable or disable gravity on the camera.
  128808. */
  128809. applyGravity: boolean;
  128810. /**
  128811. * Define the current direction the camera is moving to.
  128812. */
  128813. cameraDirection: Vector3;
  128814. /**
  128815. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  128816. * This overrides and empties cameraRotation.
  128817. */
  128818. rotationQuaternion: Quaternion;
  128819. /**
  128820. * Track Roll to maintain the wanted Rolling when looking around.
  128821. */
  128822. _trackRoll: number;
  128823. /**
  128824. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  128825. */
  128826. rollCorrect: number;
  128827. /**
  128828. * Mimic a banked turn, Rolling the camera when Yawing.
  128829. * It's recommended to use rollCorrect = 10 for faster banking correction.
  128830. */
  128831. bankedTurn: boolean;
  128832. /**
  128833. * Limit in radians for how much Roll banking will add. (Default: 90°)
  128834. */
  128835. bankedTurnLimit: number;
  128836. /**
  128837. * Value of 0 disables the banked Roll.
  128838. * Value of 1 is equal to the Yaw angle in radians.
  128839. */
  128840. bankedTurnMultiplier: number;
  128841. /**
  128842. * The inputs manager loads all the input sources, such as keyboard and mouse.
  128843. */
  128844. inputs: FlyCameraInputsManager;
  128845. /**
  128846. * Gets the input sensibility for mouse input.
  128847. * Higher values reduce sensitivity.
  128848. */
  128849. get angularSensibility(): number;
  128850. /**
  128851. * Sets the input sensibility for a mouse input.
  128852. * Higher values reduce sensitivity.
  128853. */
  128854. set angularSensibility(value: number);
  128855. /**
  128856. * Get the keys for camera movement forward.
  128857. */
  128858. get keysForward(): number[];
  128859. /**
  128860. * Set the keys for camera movement forward.
  128861. */
  128862. set keysForward(value: number[]);
  128863. /**
  128864. * Get the keys for camera movement backward.
  128865. */
  128866. get keysBackward(): number[];
  128867. set keysBackward(value: number[]);
  128868. /**
  128869. * Get the keys for camera movement up.
  128870. */
  128871. get keysUp(): number[];
  128872. /**
  128873. * Set the keys for camera movement up.
  128874. */
  128875. set keysUp(value: number[]);
  128876. /**
  128877. * Get the keys for camera movement down.
  128878. */
  128879. get keysDown(): number[];
  128880. /**
  128881. * Set the keys for camera movement down.
  128882. */
  128883. set keysDown(value: number[]);
  128884. /**
  128885. * Get the keys for camera movement left.
  128886. */
  128887. get keysLeft(): number[];
  128888. /**
  128889. * Set the keys for camera movement left.
  128890. */
  128891. set keysLeft(value: number[]);
  128892. /**
  128893. * Set the keys for camera movement right.
  128894. */
  128895. get keysRight(): number[];
  128896. /**
  128897. * Set the keys for camera movement right.
  128898. */
  128899. set keysRight(value: number[]);
  128900. /**
  128901. * Event raised when the camera collides with a mesh in the scene.
  128902. */
  128903. onCollide: (collidedMesh: AbstractMesh) => void;
  128904. private _collider;
  128905. private _needMoveForGravity;
  128906. private _oldPosition;
  128907. private _diffPosition;
  128908. private _newPosition;
  128909. /** @hidden */
  128910. _localDirection: Vector3;
  128911. /** @hidden */
  128912. _transformedDirection: Vector3;
  128913. /**
  128914. * Instantiates a FlyCamera.
  128915. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128916. * such as in a 3D Space Shooter or a Flight Simulator.
  128917. * @param name Define the name of the camera in the scene.
  128918. * @param position Define the starting position of the camera in the scene.
  128919. * @param scene Define the scene the camera belongs to.
  128920. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  128921. */
  128922. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128923. /**
  128924. * Attach a control to the HTML DOM element.
  128925. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  128926. */
  128927. attachControl(noPreventDefault?: boolean): void;
  128928. /**
  128929. * Detach a control from the HTML DOM element.
  128930. * The camera will stop reacting to that input.
  128931. */
  128932. detachControl(): void;
  128933. private _collisionMask;
  128934. /**
  128935. * Get the mask that the camera ignores in collision events.
  128936. */
  128937. get collisionMask(): number;
  128938. /**
  128939. * Set the mask that the camera ignores in collision events.
  128940. */
  128941. set collisionMask(mask: number);
  128942. /** @hidden */
  128943. _collideWithWorld(displacement: Vector3): void;
  128944. /** @hidden */
  128945. private _onCollisionPositionChange;
  128946. /** @hidden */
  128947. _checkInputs(): void;
  128948. /** @hidden */
  128949. _decideIfNeedsToMove(): boolean;
  128950. /** @hidden */
  128951. _updatePosition(): void;
  128952. /**
  128953. * Restore the Roll to its target value at the rate specified.
  128954. * @param rate - Higher means slower restoring.
  128955. * @hidden
  128956. */
  128957. restoreRoll(rate: number): void;
  128958. /**
  128959. * Destroy the camera and release the current resources held by it.
  128960. */
  128961. dispose(): void;
  128962. /**
  128963. * Get the current object class name.
  128964. * @returns the class name.
  128965. */
  128966. getClassName(): string;
  128967. }
  128968. }
  128969. declare module BABYLON {
  128970. /**
  128971. * Listen to keyboard events to control the camera.
  128972. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128973. */
  128974. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  128975. /**
  128976. * Defines the camera the input is attached to.
  128977. */
  128978. camera: FlyCamera;
  128979. /**
  128980. * The list of keyboard keys used to control the forward move of the camera.
  128981. */
  128982. keysForward: number[];
  128983. /**
  128984. * The list of keyboard keys used to control the backward move of the camera.
  128985. */
  128986. keysBackward: number[];
  128987. /**
  128988. * The list of keyboard keys used to control the forward move of the camera.
  128989. */
  128990. keysUp: number[];
  128991. /**
  128992. * The list of keyboard keys used to control the backward move of the camera.
  128993. */
  128994. keysDown: number[];
  128995. /**
  128996. * The list of keyboard keys used to control the right strafe move of the camera.
  128997. */
  128998. keysRight: number[];
  128999. /**
  129000. * The list of keyboard keys used to control the left strafe move of the camera.
  129001. */
  129002. keysLeft: number[];
  129003. private _keys;
  129004. private _onCanvasBlurObserver;
  129005. private _onKeyboardObserver;
  129006. private _engine;
  129007. private _scene;
  129008. /**
  129009. * Attach the input controls to a specific dom element to get the input from.
  129010. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129011. */
  129012. attachControl(noPreventDefault?: boolean): void;
  129013. /**
  129014. * Detach the current controls from the specified dom element.
  129015. */
  129016. detachControl(): void;
  129017. /**
  129018. * Gets the class name of the current intput.
  129019. * @returns the class name
  129020. */
  129021. getClassName(): string;
  129022. /** @hidden */
  129023. _onLostFocus(e: FocusEvent): void;
  129024. /**
  129025. * Get the friendly name associated with the input class.
  129026. * @returns the input friendly name
  129027. */
  129028. getSimpleName(): string;
  129029. /**
  129030. * Update the current camera state depending on the inputs that have been used this frame.
  129031. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129032. */
  129033. checkInputs(): void;
  129034. }
  129035. }
  129036. declare module BABYLON {
  129037. /**
  129038. * Manage the mouse wheel inputs to control a follow camera.
  129039. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129040. */
  129041. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  129042. /**
  129043. * Defines the camera the input is attached to.
  129044. */
  129045. camera: FollowCamera;
  129046. /**
  129047. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  129048. */
  129049. axisControlRadius: boolean;
  129050. /**
  129051. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  129052. */
  129053. axisControlHeight: boolean;
  129054. /**
  129055. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  129056. */
  129057. axisControlRotation: boolean;
  129058. /**
  129059. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  129060. * relation to mouseWheel events.
  129061. */
  129062. wheelPrecision: number;
  129063. /**
  129064. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  129065. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  129066. */
  129067. wheelDeltaPercentage: number;
  129068. private _wheel;
  129069. private _observer;
  129070. /**
  129071. * Attach the input controls to a specific dom element to get the input from.
  129072. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129073. */
  129074. attachControl(noPreventDefault?: boolean): void;
  129075. /**
  129076. * Detach the current controls from the specified dom element.
  129077. */
  129078. detachControl(): void;
  129079. /**
  129080. * Gets the class name of the current intput.
  129081. * @returns the class name
  129082. */
  129083. getClassName(): string;
  129084. /**
  129085. * Get the friendly name associated with the input class.
  129086. * @returns the input friendly name
  129087. */
  129088. getSimpleName(): string;
  129089. }
  129090. }
  129091. declare module BABYLON {
  129092. /**
  129093. * Manage the pointers inputs to control an follow camera.
  129094. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129095. */
  129096. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  129097. /**
  129098. * Defines the camera the input is attached to.
  129099. */
  129100. camera: FollowCamera;
  129101. /**
  129102. * Gets the class name of the current input.
  129103. * @returns the class name
  129104. */
  129105. getClassName(): string;
  129106. /**
  129107. * Defines the pointer angular sensibility along the X axis or how fast is
  129108. * the camera rotating.
  129109. * A negative number will reverse the axis direction.
  129110. */
  129111. angularSensibilityX: number;
  129112. /**
  129113. * Defines the pointer angular sensibility along the Y axis or how fast is
  129114. * the camera rotating.
  129115. * A negative number will reverse the axis direction.
  129116. */
  129117. angularSensibilityY: number;
  129118. /**
  129119. * Defines the pointer pinch precision or how fast is the camera zooming.
  129120. * A negative number will reverse the axis direction.
  129121. */
  129122. pinchPrecision: number;
  129123. /**
  129124. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  129125. * from 0.
  129126. * It defines the percentage of current camera.radius to use as delta when
  129127. * pinch zoom is used.
  129128. */
  129129. pinchDeltaPercentage: number;
  129130. /**
  129131. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  129132. */
  129133. axisXControlRadius: boolean;
  129134. /**
  129135. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  129136. */
  129137. axisXControlHeight: boolean;
  129138. /**
  129139. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  129140. */
  129141. axisXControlRotation: boolean;
  129142. /**
  129143. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  129144. */
  129145. axisYControlRadius: boolean;
  129146. /**
  129147. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  129148. */
  129149. axisYControlHeight: boolean;
  129150. /**
  129151. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  129152. */
  129153. axisYControlRotation: boolean;
  129154. /**
  129155. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  129156. */
  129157. axisPinchControlRadius: boolean;
  129158. /**
  129159. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  129160. */
  129161. axisPinchControlHeight: boolean;
  129162. /**
  129163. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  129164. */
  129165. axisPinchControlRotation: boolean;
  129166. /**
  129167. * Log error messages if basic misconfiguration has occurred.
  129168. */
  129169. warningEnable: boolean;
  129170. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  129171. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  129172. private _warningCounter;
  129173. private _warning;
  129174. }
  129175. }
  129176. declare module BABYLON {
  129177. /**
  129178. * Default Inputs manager for the FollowCamera.
  129179. * It groups all the default supported inputs for ease of use.
  129180. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129181. */
  129182. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  129183. /**
  129184. * Instantiates a new FollowCameraInputsManager.
  129185. * @param camera Defines the camera the inputs belong to
  129186. */
  129187. constructor(camera: FollowCamera);
  129188. /**
  129189. * Add keyboard input support to the input manager.
  129190. * @returns the current input manager
  129191. */
  129192. addKeyboard(): FollowCameraInputsManager;
  129193. /**
  129194. * Add mouse wheel input support to the input manager.
  129195. * @returns the current input manager
  129196. */
  129197. addMouseWheel(): FollowCameraInputsManager;
  129198. /**
  129199. * Add pointers input support to the input manager.
  129200. * @returns the current input manager
  129201. */
  129202. addPointers(): FollowCameraInputsManager;
  129203. /**
  129204. * Add orientation input support to the input manager.
  129205. * @returns the current input manager
  129206. */
  129207. addVRDeviceOrientation(): FollowCameraInputsManager;
  129208. }
  129209. }
  129210. declare module BABYLON {
  129211. /**
  129212. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  129213. * an arc rotate version arcFollowCamera are available.
  129214. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129215. */
  129216. export class FollowCamera extends TargetCamera {
  129217. /**
  129218. * Distance the follow camera should follow an object at
  129219. */
  129220. radius: number;
  129221. /**
  129222. * Minimum allowed distance of the camera to the axis of rotation
  129223. * (The camera can not get closer).
  129224. * This can help limiting how the Camera is able to move in the scene.
  129225. */
  129226. lowerRadiusLimit: Nullable<number>;
  129227. /**
  129228. * Maximum allowed distance of the camera to the axis of rotation
  129229. * (The camera can not get further).
  129230. * This can help limiting how the Camera is able to move in the scene.
  129231. */
  129232. upperRadiusLimit: Nullable<number>;
  129233. /**
  129234. * Define a rotation offset between the camera and the object it follows
  129235. */
  129236. rotationOffset: number;
  129237. /**
  129238. * Minimum allowed angle to camera position relative to target object.
  129239. * This can help limiting how the Camera is able to move in the scene.
  129240. */
  129241. lowerRotationOffsetLimit: Nullable<number>;
  129242. /**
  129243. * Maximum allowed angle to camera position relative to target object.
  129244. * This can help limiting how the Camera is able to move in the scene.
  129245. */
  129246. upperRotationOffsetLimit: Nullable<number>;
  129247. /**
  129248. * Define a height offset between the camera and the object it follows.
  129249. * It can help following an object from the top (like a car chaing a plane)
  129250. */
  129251. heightOffset: number;
  129252. /**
  129253. * Minimum allowed height of camera position relative to target object.
  129254. * This can help limiting how the Camera is able to move in the scene.
  129255. */
  129256. lowerHeightOffsetLimit: Nullable<number>;
  129257. /**
  129258. * Maximum allowed height of camera position relative to target object.
  129259. * This can help limiting how the Camera is able to move in the scene.
  129260. */
  129261. upperHeightOffsetLimit: Nullable<number>;
  129262. /**
  129263. * Define how fast the camera can accelerate to follow it s target.
  129264. */
  129265. cameraAcceleration: number;
  129266. /**
  129267. * Define the speed limit of the camera following an object.
  129268. */
  129269. maxCameraSpeed: number;
  129270. /**
  129271. * Define the target of the camera.
  129272. */
  129273. lockedTarget: Nullable<AbstractMesh>;
  129274. /**
  129275. * Defines the input associated with the camera.
  129276. */
  129277. inputs: FollowCameraInputsManager;
  129278. /**
  129279. * Instantiates the follow camera.
  129280. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129281. * @param name Define the name of the camera in the scene
  129282. * @param position Define the position of the camera
  129283. * @param scene Define the scene the camera belong to
  129284. * @param lockedTarget Define the target of the camera
  129285. */
  129286. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  129287. private _follow;
  129288. /**
  129289. * Attached controls to the current camera.
  129290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129291. */
  129292. attachControl(noPreventDefault?: boolean): void;
  129293. /**
  129294. * Detach the current controls from the camera.
  129295. * The camera will stop reacting to inputs.
  129296. */
  129297. detachControl(): void;
  129298. /** @hidden */
  129299. _checkInputs(): void;
  129300. private _checkLimits;
  129301. /**
  129302. * Gets the camera class name.
  129303. * @returns the class name
  129304. */
  129305. getClassName(): string;
  129306. }
  129307. /**
  129308. * Arc Rotate version of the follow camera.
  129309. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  129310. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129311. */
  129312. export class ArcFollowCamera extends TargetCamera {
  129313. /** The longitudinal angle of the camera */
  129314. alpha: number;
  129315. /** The latitudinal angle of the camera */
  129316. beta: number;
  129317. /** The radius of the camera from its target */
  129318. radius: number;
  129319. private _cartesianCoordinates;
  129320. /** Define the camera target (the mesh it should follow) */
  129321. private _meshTarget;
  129322. /**
  129323. * Instantiates a new ArcFollowCamera
  129324. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129325. * @param name Define the name of the camera
  129326. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  129327. * @param beta Define the rotation angle of the camera around the elevation axis
  129328. * @param radius Define the radius of the camera from its target point
  129329. * @param target Define the target of the camera
  129330. * @param scene Define the scene the camera belongs to
  129331. */
  129332. constructor(name: string,
  129333. /** The longitudinal angle of the camera */
  129334. alpha: number,
  129335. /** The latitudinal angle of the camera */
  129336. beta: number,
  129337. /** The radius of the camera from its target */
  129338. radius: number,
  129339. /** Define the camera target (the mesh it should follow) */
  129340. target: Nullable<AbstractMesh>, scene: Scene);
  129341. private _follow;
  129342. /** @hidden */
  129343. _checkInputs(): void;
  129344. /**
  129345. * Returns the class name of the object.
  129346. * It is mostly used internally for serialization purposes.
  129347. */
  129348. getClassName(): string;
  129349. }
  129350. }
  129351. declare module BABYLON {
  129352. /**
  129353. * Manage the keyboard inputs to control the movement of a follow camera.
  129354. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129355. */
  129356. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  129357. /**
  129358. * Defines the camera the input is attached to.
  129359. */
  129360. camera: FollowCamera;
  129361. /**
  129362. * Defines the list of key codes associated with the up action (increase heightOffset)
  129363. */
  129364. keysHeightOffsetIncr: number[];
  129365. /**
  129366. * Defines the list of key codes associated with the down action (decrease heightOffset)
  129367. */
  129368. keysHeightOffsetDecr: number[];
  129369. /**
  129370. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  129371. */
  129372. keysHeightOffsetModifierAlt: boolean;
  129373. /**
  129374. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  129375. */
  129376. keysHeightOffsetModifierCtrl: boolean;
  129377. /**
  129378. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  129379. */
  129380. keysHeightOffsetModifierShift: boolean;
  129381. /**
  129382. * Defines the list of key codes associated with the left action (increase rotationOffset)
  129383. */
  129384. keysRotationOffsetIncr: number[];
  129385. /**
  129386. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  129387. */
  129388. keysRotationOffsetDecr: number[];
  129389. /**
  129390. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  129391. */
  129392. keysRotationOffsetModifierAlt: boolean;
  129393. /**
  129394. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  129395. */
  129396. keysRotationOffsetModifierCtrl: boolean;
  129397. /**
  129398. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  129399. */
  129400. keysRotationOffsetModifierShift: boolean;
  129401. /**
  129402. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  129403. */
  129404. keysRadiusIncr: number[];
  129405. /**
  129406. * Defines the list of key codes associated with the zoom-out action (increase radius)
  129407. */
  129408. keysRadiusDecr: number[];
  129409. /**
  129410. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  129411. */
  129412. keysRadiusModifierAlt: boolean;
  129413. /**
  129414. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  129415. */
  129416. keysRadiusModifierCtrl: boolean;
  129417. /**
  129418. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  129419. */
  129420. keysRadiusModifierShift: boolean;
  129421. /**
  129422. * Defines the rate of change of heightOffset.
  129423. */
  129424. heightSensibility: number;
  129425. /**
  129426. * Defines the rate of change of rotationOffset.
  129427. */
  129428. rotationSensibility: number;
  129429. /**
  129430. * Defines the rate of change of radius.
  129431. */
  129432. radiusSensibility: number;
  129433. private _keys;
  129434. private _ctrlPressed;
  129435. private _altPressed;
  129436. private _shiftPressed;
  129437. private _onCanvasBlurObserver;
  129438. private _onKeyboardObserver;
  129439. private _engine;
  129440. private _scene;
  129441. /**
  129442. * Attach the input controls to a specific dom element to get the input from.
  129443. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129444. */
  129445. attachControl(noPreventDefault?: boolean): void;
  129446. /**
  129447. * Detach the current controls from the specified dom element.
  129448. */
  129449. detachControl(): void;
  129450. /**
  129451. * Update the current camera state depending on the inputs that have been used this frame.
  129452. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129453. */
  129454. checkInputs(): void;
  129455. /**
  129456. * Gets the class name of the current input.
  129457. * @returns the class name
  129458. */
  129459. getClassName(): string;
  129460. /**
  129461. * Get the friendly name associated with the input class.
  129462. * @returns the input friendly name
  129463. */
  129464. getSimpleName(): string;
  129465. /**
  129466. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129467. * allow modification of the heightOffset value.
  129468. */
  129469. private _modifierHeightOffset;
  129470. /**
  129471. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129472. * allow modification of the rotationOffset value.
  129473. */
  129474. private _modifierRotationOffset;
  129475. /**
  129476. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129477. * allow modification of the radius value.
  129478. */
  129479. private _modifierRadius;
  129480. }
  129481. }
  129482. declare module BABYLON {
  129483. interface FreeCameraInputsManager {
  129484. /**
  129485. * @hidden
  129486. */
  129487. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  129488. /**
  129489. * Add orientation input support to the input manager.
  129490. * @returns the current input manager
  129491. */
  129492. addDeviceOrientation(): FreeCameraInputsManager;
  129493. }
  129494. /**
  129495. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  129496. * Screen rotation is taken into account.
  129497. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129498. */
  129499. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  129500. private _camera;
  129501. private _screenOrientationAngle;
  129502. private _constantTranform;
  129503. private _screenQuaternion;
  129504. private _alpha;
  129505. private _beta;
  129506. private _gamma;
  129507. /**
  129508. * Can be used to detect if a device orientation sensor is available on a device
  129509. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  129510. * @returns a promise that will resolve on orientation change
  129511. */
  129512. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  129513. /**
  129514. * @hidden
  129515. */
  129516. _onDeviceOrientationChangedObservable: Observable<void>;
  129517. /**
  129518. * Instantiates a new input
  129519. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129520. */
  129521. constructor();
  129522. /**
  129523. * Define the camera controlled by the input.
  129524. */
  129525. get camera(): FreeCamera;
  129526. set camera(camera: FreeCamera);
  129527. /**
  129528. * Attach the input controls to a specific dom element to get the input from.
  129529. */
  129530. attachControl(): void;
  129531. private _orientationChanged;
  129532. private _deviceOrientation;
  129533. /**
  129534. * Detach the current controls from the specified dom element.
  129535. */
  129536. detachControl(): void;
  129537. /**
  129538. * Update the current camera state depending on the inputs that have been used this frame.
  129539. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129540. */
  129541. checkInputs(): void;
  129542. /**
  129543. * Gets the class name of the current intput.
  129544. * @returns the class name
  129545. */
  129546. getClassName(): string;
  129547. /**
  129548. * Get the friendly name associated with the input class.
  129549. * @returns the input friendly name
  129550. */
  129551. getSimpleName(): string;
  129552. }
  129553. }
  129554. declare module BABYLON {
  129555. /**
  129556. * Manage the gamepad inputs to control a free camera.
  129557. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129558. */
  129559. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  129560. /**
  129561. * Define the camera the input is attached to.
  129562. */
  129563. camera: FreeCamera;
  129564. /**
  129565. * Define the Gamepad controlling the input
  129566. */
  129567. gamepad: Nullable<Gamepad>;
  129568. /**
  129569. * Defines the gamepad rotation sensiblity.
  129570. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129571. */
  129572. gamepadAngularSensibility: number;
  129573. /**
  129574. * Defines the gamepad move sensiblity.
  129575. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129576. */
  129577. gamepadMoveSensibility: number;
  129578. private _yAxisScale;
  129579. /**
  129580. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  129581. */
  129582. get invertYAxis(): boolean;
  129583. set invertYAxis(value: boolean);
  129584. private _onGamepadConnectedObserver;
  129585. private _onGamepadDisconnectedObserver;
  129586. private _cameraTransform;
  129587. private _deltaTransform;
  129588. private _vector3;
  129589. private _vector2;
  129590. /**
  129591. * Attach the input controls to a specific dom element to get the input from.
  129592. */
  129593. attachControl(): void;
  129594. /**
  129595. * Detach the current controls from the specified dom element.
  129596. */
  129597. detachControl(): void;
  129598. /**
  129599. * Update the current camera state depending on the inputs that have been used this frame.
  129600. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129601. */
  129602. checkInputs(): void;
  129603. /**
  129604. * Gets the class name of the current intput.
  129605. * @returns the class name
  129606. */
  129607. getClassName(): string;
  129608. /**
  129609. * Get the friendly name associated with the input class.
  129610. * @returns the input friendly name
  129611. */
  129612. getSimpleName(): string;
  129613. }
  129614. }
  129615. declare module BABYLON {
  129616. /**
  129617. * Defines the potential axis of a Joystick
  129618. */
  129619. export enum JoystickAxis {
  129620. /** X axis */
  129621. X = 0,
  129622. /** Y axis */
  129623. Y = 1,
  129624. /** Z axis */
  129625. Z = 2
  129626. }
  129627. /**
  129628. * Represents the different customization options available
  129629. * for VirtualJoystick
  129630. */
  129631. interface VirtualJoystickCustomizations {
  129632. /**
  129633. * Size of the joystick's puck
  129634. */
  129635. puckSize: number;
  129636. /**
  129637. * Size of the joystick's container
  129638. */
  129639. containerSize: number;
  129640. /**
  129641. * Color of the joystick && puck
  129642. */
  129643. color: string;
  129644. /**
  129645. * Image URL for the joystick's puck
  129646. */
  129647. puckImage?: string;
  129648. /**
  129649. * Image URL for the joystick's container
  129650. */
  129651. containerImage?: string;
  129652. /**
  129653. * Defines the unmoving position of the joystick container
  129654. */
  129655. position?: {
  129656. x: number;
  129657. y: number;
  129658. };
  129659. /**
  129660. * Defines whether or not the joystick container is always visible
  129661. */
  129662. alwaysVisible: boolean;
  129663. /**
  129664. * Defines whether or not to limit the movement of the puck to the joystick's container
  129665. */
  129666. limitToContainer: boolean;
  129667. }
  129668. /**
  129669. * Class used to define virtual joystick (used in touch mode)
  129670. */
  129671. export class VirtualJoystick {
  129672. /**
  129673. * Gets or sets a boolean indicating that left and right values must be inverted
  129674. */
  129675. reverseLeftRight: boolean;
  129676. /**
  129677. * Gets or sets a boolean indicating that up and down values must be inverted
  129678. */
  129679. reverseUpDown: boolean;
  129680. /**
  129681. * Gets the offset value for the position (ie. the change of the position value)
  129682. */
  129683. deltaPosition: Vector3;
  129684. /**
  129685. * Gets a boolean indicating if the virtual joystick was pressed
  129686. */
  129687. pressed: boolean;
  129688. /**
  129689. * Canvas the virtual joystick will render onto, default z-index of this is 5
  129690. */
  129691. static Canvas: Nullable<HTMLCanvasElement>;
  129692. /**
  129693. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  129694. */
  129695. limitToContainer: boolean;
  129696. private static _globalJoystickIndex;
  129697. private static _alwaysVisibleSticks;
  129698. private static vjCanvasContext;
  129699. private static vjCanvasWidth;
  129700. private static vjCanvasHeight;
  129701. private static halfWidth;
  129702. private static _GetDefaultOptions;
  129703. private _action;
  129704. private _axisTargetedByLeftAndRight;
  129705. private _axisTargetedByUpAndDown;
  129706. private _joystickSensibility;
  129707. private _inversedSensibility;
  129708. private _joystickPointerID;
  129709. private _joystickColor;
  129710. private _joystickPointerPos;
  129711. private _joystickPreviousPointerPos;
  129712. private _joystickPointerStartPos;
  129713. private _deltaJoystickVector;
  129714. private _leftJoystick;
  129715. private _touches;
  129716. private _joystickPosition;
  129717. private _alwaysVisible;
  129718. private _puckImage;
  129719. private _containerImage;
  129720. private _joystickPuckSize;
  129721. private _joystickContainerSize;
  129722. private _clearPuckSize;
  129723. private _clearContainerSize;
  129724. private _clearPuckSizeOffset;
  129725. private _clearContainerSizeOffset;
  129726. private _onPointerDownHandlerRef;
  129727. private _onPointerMoveHandlerRef;
  129728. private _onPointerUpHandlerRef;
  129729. private _onResize;
  129730. /**
  129731. * Creates a new virtual joystick
  129732. * @param leftJoystick defines that the joystick is for left hand (false by default)
  129733. * @param customizations Defines the options we want to customize the VirtualJoystick
  129734. */
  129735. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  129736. /**
  129737. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  129738. * @param newJoystickSensibility defines the new sensibility
  129739. */
  129740. setJoystickSensibility(newJoystickSensibility: number): void;
  129741. private _onPointerDown;
  129742. private _onPointerMove;
  129743. private _onPointerUp;
  129744. /**
  129745. * Change the color of the virtual joystick
  129746. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  129747. */
  129748. setJoystickColor(newColor: string): void;
  129749. /**
  129750. * Size of the joystick's container
  129751. */
  129752. set containerSize(newSize: number);
  129753. get containerSize(): number;
  129754. /**
  129755. * Size of the joystick's puck
  129756. */
  129757. set puckSize(newSize: number);
  129758. get puckSize(): number;
  129759. /**
  129760. * Clears the set position of the joystick
  129761. */
  129762. clearPosition(): void;
  129763. /**
  129764. * Defines whether or not the joystick container is always visible
  129765. */
  129766. set alwaysVisible(value: boolean);
  129767. get alwaysVisible(): boolean;
  129768. /**
  129769. * Sets the constant position of the Joystick container
  129770. * @param x X axis coordinate
  129771. * @param y Y axis coordinate
  129772. */
  129773. setPosition(x: number, y: number): void;
  129774. /**
  129775. * Defines a callback to call when the joystick is touched
  129776. * @param action defines the callback
  129777. */
  129778. setActionOnTouch(action: () => any): void;
  129779. /**
  129780. * Defines which axis you'd like to control for left & right
  129781. * @param axis defines the axis to use
  129782. */
  129783. setAxisForLeftRight(axis: JoystickAxis): void;
  129784. /**
  129785. * Defines which axis you'd like to control for up & down
  129786. * @param axis defines the axis to use
  129787. */
  129788. setAxisForUpDown(axis: JoystickAxis): void;
  129789. /**
  129790. * Clears the canvas from the previous puck / container draw
  129791. */
  129792. private _clearPreviousDraw;
  129793. /**
  129794. * Loads `urlPath` to be used for the container's image
  129795. * @param urlPath defines the urlPath of an image to use
  129796. */
  129797. setContainerImage(urlPath: string): void;
  129798. /**
  129799. * Loads `urlPath` to be used for the puck's image
  129800. * @param urlPath defines the urlPath of an image to use
  129801. */
  129802. setPuckImage(urlPath: string): void;
  129803. /**
  129804. * Draws the Virtual Joystick's container
  129805. */
  129806. private _drawContainer;
  129807. /**
  129808. * Draws the Virtual Joystick's puck
  129809. */
  129810. private _drawPuck;
  129811. private _drawVirtualJoystick;
  129812. /**
  129813. * Release internal HTML canvas
  129814. */
  129815. releaseCanvas(): void;
  129816. }
  129817. }
  129818. declare module BABYLON {
  129819. interface FreeCameraInputsManager {
  129820. /**
  129821. * Add virtual joystick input support to the input manager.
  129822. * @returns the current input manager
  129823. */
  129824. addVirtualJoystick(): FreeCameraInputsManager;
  129825. }
  129826. /**
  129827. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  129828. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129829. */
  129830. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  129831. /**
  129832. * Defines the camera the input is attached to.
  129833. */
  129834. camera: FreeCamera;
  129835. private _leftjoystick;
  129836. private _rightjoystick;
  129837. /**
  129838. * Gets the left stick of the virtual joystick.
  129839. * @returns The virtual Joystick
  129840. */
  129841. getLeftJoystick(): VirtualJoystick;
  129842. /**
  129843. * Gets the right stick of the virtual joystick.
  129844. * @returns The virtual Joystick
  129845. */
  129846. getRightJoystick(): VirtualJoystick;
  129847. /**
  129848. * Update the current camera state depending on the inputs that have been used this frame.
  129849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129850. */
  129851. checkInputs(): void;
  129852. /**
  129853. * Attach the input controls to a specific dom element to get the input from.
  129854. */
  129855. attachControl(): void;
  129856. /**
  129857. * Detach the current controls from the specified dom element.
  129858. */
  129859. detachControl(): void;
  129860. /**
  129861. * Gets the class name of the current intput.
  129862. * @returns the class name
  129863. */
  129864. getClassName(): string;
  129865. /**
  129866. * Get the friendly name associated with the input class.
  129867. * @returns the input friendly name
  129868. */
  129869. getSimpleName(): string;
  129870. }
  129871. }
  129872. declare module BABYLON {
  129873. /**
  129874. * This represents a FPS type of camera controlled by touch.
  129875. * This is like a universal camera minus the Gamepad controls.
  129876. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129877. */
  129878. export class TouchCamera extends FreeCamera {
  129879. /**
  129880. * Defines the touch sensibility for rotation.
  129881. * The higher the faster.
  129882. */
  129883. get touchAngularSensibility(): number;
  129884. set touchAngularSensibility(value: number);
  129885. /**
  129886. * Defines the touch sensibility for move.
  129887. * The higher the faster.
  129888. */
  129889. get touchMoveSensibility(): number;
  129890. set touchMoveSensibility(value: number);
  129891. /**
  129892. * Instantiates a new touch camera.
  129893. * This represents a FPS type of camera controlled by touch.
  129894. * This is like a universal camera minus the Gamepad controls.
  129895. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129896. * @param name Define the name of the camera in the scene
  129897. * @param position Define the start position of the camera in the scene
  129898. * @param scene Define the scene the camera belongs to
  129899. */
  129900. constructor(name: string, position: Vector3, scene: Scene);
  129901. /**
  129902. * Gets the current object class name.
  129903. * @return the class name
  129904. */
  129905. getClassName(): string;
  129906. /** @hidden */
  129907. _setupInputs(): void;
  129908. }
  129909. }
  129910. declare module BABYLON {
  129911. /**
  129912. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  129913. * being tilted forward or back and left or right.
  129914. */
  129915. export class DeviceOrientationCamera extends FreeCamera {
  129916. private _initialQuaternion;
  129917. private _quaternionCache;
  129918. private _tmpDragQuaternion;
  129919. private _disablePointerInputWhenUsingDeviceOrientation;
  129920. /**
  129921. * Creates a new device orientation camera
  129922. * @param name The name of the camera
  129923. * @param position The start position camera
  129924. * @param scene The scene the camera belongs to
  129925. */
  129926. constructor(name: string, position: Vector3, scene: Scene);
  129927. /**
  129928. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  129929. */
  129930. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  129931. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  129932. private _dragFactor;
  129933. /**
  129934. * Enabled turning on the y axis when the orientation sensor is active
  129935. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  129936. */
  129937. enableHorizontalDragging(dragFactor?: number): void;
  129938. /**
  129939. * Gets the current instance class name ("DeviceOrientationCamera").
  129940. * This helps avoiding instanceof at run time.
  129941. * @returns the class name
  129942. */
  129943. getClassName(): string;
  129944. /**
  129945. * @hidden
  129946. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  129947. */
  129948. _checkInputs(): void;
  129949. /**
  129950. * Reset the camera to its default orientation on the specified axis only.
  129951. * @param axis The axis to reset
  129952. */
  129953. resetToCurrentRotation(axis?: Axis): void;
  129954. }
  129955. }
  129956. declare module BABYLON {
  129957. /**
  129958. * Defines supported buttons for XBox360 compatible gamepads
  129959. */
  129960. export enum Xbox360Button {
  129961. /** A */
  129962. A = 0,
  129963. /** B */
  129964. B = 1,
  129965. /** X */
  129966. X = 2,
  129967. /** Y */
  129968. Y = 3,
  129969. /** Left button */
  129970. LB = 4,
  129971. /** Right button */
  129972. RB = 5,
  129973. /** Back */
  129974. Back = 8,
  129975. /** Start */
  129976. Start = 9,
  129977. /** Left stick */
  129978. LeftStick = 10,
  129979. /** Right stick */
  129980. RightStick = 11
  129981. }
  129982. /** Defines values for XBox360 DPad */
  129983. export enum Xbox360Dpad {
  129984. /** Up */
  129985. Up = 12,
  129986. /** Down */
  129987. Down = 13,
  129988. /** Left */
  129989. Left = 14,
  129990. /** Right */
  129991. Right = 15
  129992. }
  129993. /**
  129994. * Defines a XBox360 gamepad
  129995. */
  129996. export class Xbox360Pad extends Gamepad {
  129997. private _leftTrigger;
  129998. private _rightTrigger;
  129999. private _onlefttriggerchanged;
  130000. private _onrighttriggerchanged;
  130001. private _onbuttondown;
  130002. private _onbuttonup;
  130003. private _ondpaddown;
  130004. private _ondpadup;
  130005. /** Observable raised when a button is pressed */
  130006. onButtonDownObservable: Observable<Xbox360Button>;
  130007. /** Observable raised when a button is released */
  130008. onButtonUpObservable: Observable<Xbox360Button>;
  130009. /** Observable raised when a pad is pressed */
  130010. onPadDownObservable: Observable<Xbox360Dpad>;
  130011. /** Observable raised when a pad is released */
  130012. onPadUpObservable: Observable<Xbox360Dpad>;
  130013. private _buttonA;
  130014. private _buttonB;
  130015. private _buttonX;
  130016. private _buttonY;
  130017. private _buttonBack;
  130018. private _buttonStart;
  130019. private _buttonLB;
  130020. private _buttonRB;
  130021. private _buttonLeftStick;
  130022. private _buttonRightStick;
  130023. private _dPadUp;
  130024. private _dPadDown;
  130025. private _dPadLeft;
  130026. private _dPadRight;
  130027. private _isXboxOnePad;
  130028. /**
  130029. * Creates a new XBox360 gamepad object
  130030. * @param id defines the id of this gamepad
  130031. * @param index defines its index
  130032. * @param gamepad defines the internal HTML gamepad object
  130033. * @param xboxOne defines if it is a XBox One gamepad
  130034. */
  130035. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  130036. /**
  130037. * Defines the callback to call when left trigger is pressed
  130038. * @param callback defines the callback to use
  130039. */
  130040. onlefttriggerchanged(callback: (value: number) => void): void;
  130041. /**
  130042. * Defines the callback to call when right trigger is pressed
  130043. * @param callback defines the callback to use
  130044. */
  130045. onrighttriggerchanged(callback: (value: number) => void): void;
  130046. /**
  130047. * Gets the left trigger value
  130048. */
  130049. get leftTrigger(): number;
  130050. /**
  130051. * Sets the left trigger value
  130052. */
  130053. set leftTrigger(newValue: number);
  130054. /**
  130055. * Gets the right trigger value
  130056. */
  130057. get rightTrigger(): number;
  130058. /**
  130059. * Sets the right trigger value
  130060. */
  130061. set rightTrigger(newValue: number);
  130062. /**
  130063. * Defines the callback to call when a button is pressed
  130064. * @param callback defines the callback to use
  130065. */
  130066. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  130067. /**
  130068. * Defines the callback to call when a button is released
  130069. * @param callback defines the callback to use
  130070. */
  130071. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  130072. /**
  130073. * Defines the callback to call when a pad is pressed
  130074. * @param callback defines the callback to use
  130075. */
  130076. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  130077. /**
  130078. * Defines the callback to call when a pad is released
  130079. * @param callback defines the callback to use
  130080. */
  130081. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  130082. private _setButtonValue;
  130083. private _setDPadValue;
  130084. /**
  130085. * Gets the value of the `A` button
  130086. */
  130087. get buttonA(): number;
  130088. /**
  130089. * Sets the value of the `A` button
  130090. */
  130091. set buttonA(value: number);
  130092. /**
  130093. * Gets the value of the `B` button
  130094. */
  130095. get buttonB(): number;
  130096. /**
  130097. * Sets the value of the `B` button
  130098. */
  130099. set buttonB(value: number);
  130100. /**
  130101. * Gets the value of the `X` button
  130102. */
  130103. get buttonX(): number;
  130104. /**
  130105. * Sets the value of the `X` button
  130106. */
  130107. set buttonX(value: number);
  130108. /**
  130109. * Gets the value of the `Y` button
  130110. */
  130111. get buttonY(): number;
  130112. /**
  130113. * Sets the value of the `Y` button
  130114. */
  130115. set buttonY(value: number);
  130116. /**
  130117. * Gets the value of the `Start` button
  130118. */
  130119. get buttonStart(): number;
  130120. /**
  130121. * Sets the value of the `Start` button
  130122. */
  130123. set buttonStart(value: number);
  130124. /**
  130125. * Gets the value of the `Back` button
  130126. */
  130127. get buttonBack(): number;
  130128. /**
  130129. * Sets the value of the `Back` button
  130130. */
  130131. set buttonBack(value: number);
  130132. /**
  130133. * Gets the value of the `Left` button
  130134. */
  130135. get buttonLB(): number;
  130136. /**
  130137. * Sets the value of the `Left` button
  130138. */
  130139. set buttonLB(value: number);
  130140. /**
  130141. * Gets the value of the `Right` button
  130142. */
  130143. get buttonRB(): number;
  130144. /**
  130145. * Sets the value of the `Right` button
  130146. */
  130147. set buttonRB(value: number);
  130148. /**
  130149. * Gets the value of the Left joystick
  130150. */
  130151. get buttonLeftStick(): number;
  130152. /**
  130153. * Sets the value of the Left joystick
  130154. */
  130155. set buttonLeftStick(value: number);
  130156. /**
  130157. * Gets the value of the Right joystick
  130158. */
  130159. get buttonRightStick(): number;
  130160. /**
  130161. * Sets the value of the Right joystick
  130162. */
  130163. set buttonRightStick(value: number);
  130164. /**
  130165. * Gets the value of D-pad up
  130166. */
  130167. get dPadUp(): number;
  130168. /**
  130169. * Sets the value of D-pad up
  130170. */
  130171. set dPadUp(value: number);
  130172. /**
  130173. * Gets the value of D-pad down
  130174. */
  130175. get dPadDown(): number;
  130176. /**
  130177. * Sets the value of D-pad down
  130178. */
  130179. set dPadDown(value: number);
  130180. /**
  130181. * Gets the value of D-pad left
  130182. */
  130183. get dPadLeft(): number;
  130184. /**
  130185. * Sets the value of D-pad left
  130186. */
  130187. set dPadLeft(value: number);
  130188. /**
  130189. * Gets the value of D-pad right
  130190. */
  130191. get dPadRight(): number;
  130192. /**
  130193. * Sets the value of D-pad right
  130194. */
  130195. set dPadRight(value: number);
  130196. /**
  130197. * Force the gamepad to synchronize with device values
  130198. */
  130199. update(): void;
  130200. /**
  130201. * Disposes the gamepad
  130202. */
  130203. dispose(): void;
  130204. }
  130205. }
  130206. declare module BABYLON {
  130207. /**
  130208. * Defines supported buttons for DualShock compatible gamepads
  130209. */
  130210. export enum DualShockButton {
  130211. /** Cross */
  130212. Cross = 0,
  130213. /** Circle */
  130214. Circle = 1,
  130215. /** Square */
  130216. Square = 2,
  130217. /** Triangle */
  130218. Triangle = 3,
  130219. /** L1 */
  130220. L1 = 4,
  130221. /** R1 */
  130222. R1 = 5,
  130223. /** Share */
  130224. Share = 8,
  130225. /** Options */
  130226. Options = 9,
  130227. /** Left stick */
  130228. LeftStick = 10,
  130229. /** Right stick */
  130230. RightStick = 11
  130231. }
  130232. /** Defines values for DualShock DPad */
  130233. export enum DualShockDpad {
  130234. /** Up */
  130235. Up = 12,
  130236. /** Down */
  130237. Down = 13,
  130238. /** Left */
  130239. Left = 14,
  130240. /** Right */
  130241. Right = 15
  130242. }
  130243. /**
  130244. * Defines a DualShock gamepad
  130245. */
  130246. export class DualShockPad extends Gamepad {
  130247. private _leftTrigger;
  130248. private _rightTrigger;
  130249. private _onlefttriggerchanged;
  130250. private _onrighttriggerchanged;
  130251. private _onbuttondown;
  130252. private _onbuttonup;
  130253. private _ondpaddown;
  130254. private _ondpadup;
  130255. /** Observable raised when a button is pressed */
  130256. onButtonDownObservable: Observable<DualShockButton>;
  130257. /** Observable raised when a button is released */
  130258. onButtonUpObservable: Observable<DualShockButton>;
  130259. /** Observable raised when a pad is pressed */
  130260. onPadDownObservable: Observable<DualShockDpad>;
  130261. /** Observable raised when a pad is released */
  130262. onPadUpObservable: Observable<DualShockDpad>;
  130263. private _buttonCross;
  130264. private _buttonCircle;
  130265. private _buttonSquare;
  130266. private _buttonTriangle;
  130267. private _buttonShare;
  130268. private _buttonOptions;
  130269. private _buttonL1;
  130270. private _buttonR1;
  130271. private _buttonLeftStick;
  130272. private _buttonRightStick;
  130273. private _dPadUp;
  130274. private _dPadDown;
  130275. private _dPadLeft;
  130276. private _dPadRight;
  130277. /**
  130278. * Creates a new DualShock gamepad object
  130279. * @param id defines the id of this gamepad
  130280. * @param index defines its index
  130281. * @param gamepad defines the internal HTML gamepad object
  130282. */
  130283. constructor(id: string, index: number, gamepad: any);
  130284. /**
  130285. * Defines the callback to call when left trigger is pressed
  130286. * @param callback defines the callback to use
  130287. */
  130288. onlefttriggerchanged(callback: (value: number) => void): void;
  130289. /**
  130290. * Defines the callback to call when right trigger is pressed
  130291. * @param callback defines the callback to use
  130292. */
  130293. onrighttriggerchanged(callback: (value: number) => void): void;
  130294. /**
  130295. * Gets the left trigger value
  130296. */
  130297. get leftTrigger(): number;
  130298. /**
  130299. * Sets the left trigger value
  130300. */
  130301. set leftTrigger(newValue: number);
  130302. /**
  130303. * Gets the right trigger value
  130304. */
  130305. get rightTrigger(): number;
  130306. /**
  130307. * Sets the right trigger value
  130308. */
  130309. set rightTrigger(newValue: number);
  130310. /**
  130311. * Defines the callback to call when a button is pressed
  130312. * @param callback defines the callback to use
  130313. */
  130314. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  130315. /**
  130316. * Defines the callback to call when a button is released
  130317. * @param callback defines the callback to use
  130318. */
  130319. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  130320. /**
  130321. * Defines the callback to call when a pad is pressed
  130322. * @param callback defines the callback to use
  130323. */
  130324. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  130325. /**
  130326. * Defines the callback to call when a pad is released
  130327. * @param callback defines the callback to use
  130328. */
  130329. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  130330. private _setButtonValue;
  130331. private _setDPadValue;
  130332. /**
  130333. * Gets the value of the `Cross` button
  130334. */
  130335. get buttonCross(): number;
  130336. /**
  130337. * Sets the value of the `Cross` button
  130338. */
  130339. set buttonCross(value: number);
  130340. /**
  130341. * Gets the value of the `Circle` button
  130342. */
  130343. get buttonCircle(): number;
  130344. /**
  130345. * Sets the value of the `Circle` button
  130346. */
  130347. set buttonCircle(value: number);
  130348. /**
  130349. * Gets the value of the `Square` button
  130350. */
  130351. get buttonSquare(): number;
  130352. /**
  130353. * Sets the value of the `Square` button
  130354. */
  130355. set buttonSquare(value: number);
  130356. /**
  130357. * Gets the value of the `Triangle` button
  130358. */
  130359. get buttonTriangle(): number;
  130360. /**
  130361. * Sets the value of the `Triangle` button
  130362. */
  130363. set buttonTriangle(value: number);
  130364. /**
  130365. * Gets the value of the `Options` button
  130366. */
  130367. get buttonOptions(): number;
  130368. /**
  130369. * Sets the value of the `Options` button
  130370. */
  130371. set buttonOptions(value: number);
  130372. /**
  130373. * Gets the value of the `Share` button
  130374. */
  130375. get buttonShare(): number;
  130376. /**
  130377. * Sets the value of the `Share` button
  130378. */
  130379. set buttonShare(value: number);
  130380. /**
  130381. * Gets the value of the `L1` button
  130382. */
  130383. get buttonL1(): number;
  130384. /**
  130385. * Sets the value of the `L1` button
  130386. */
  130387. set buttonL1(value: number);
  130388. /**
  130389. * Gets the value of the `R1` button
  130390. */
  130391. get buttonR1(): number;
  130392. /**
  130393. * Sets the value of the `R1` button
  130394. */
  130395. set buttonR1(value: number);
  130396. /**
  130397. * Gets the value of the Left joystick
  130398. */
  130399. get buttonLeftStick(): number;
  130400. /**
  130401. * Sets the value of the Left joystick
  130402. */
  130403. set buttonLeftStick(value: number);
  130404. /**
  130405. * Gets the value of the Right joystick
  130406. */
  130407. get buttonRightStick(): number;
  130408. /**
  130409. * Sets the value of the Right joystick
  130410. */
  130411. set buttonRightStick(value: number);
  130412. /**
  130413. * Gets the value of D-pad up
  130414. */
  130415. get dPadUp(): number;
  130416. /**
  130417. * Sets the value of D-pad up
  130418. */
  130419. set dPadUp(value: number);
  130420. /**
  130421. * Gets the value of D-pad down
  130422. */
  130423. get dPadDown(): number;
  130424. /**
  130425. * Sets the value of D-pad down
  130426. */
  130427. set dPadDown(value: number);
  130428. /**
  130429. * Gets the value of D-pad left
  130430. */
  130431. get dPadLeft(): number;
  130432. /**
  130433. * Sets the value of D-pad left
  130434. */
  130435. set dPadLeft(value: number);
  130436. /**
  130437. * Gets the value of D-pad right
  130438. */
  130439. get dPadRight(): number;
  130440. /**
  130441. * Sets the value of D-pad right
  130442. */
  130443. set dPadRight(value: number);
  130444. /**
  130445. * Force the gamepad to synchronize with device values
  130446. */
  130447. update(): void;
  130448. /**
  130449. * Disposes the gamepad
  130450. */
  130451. dispose(): void;
  130452. }
  130453. }
  130454. declare module BABYLON {
  130455. /**
  130456. * Manager for handling gamepads
  130457. */
  130458. export class GamepadManager {
  130459. private _scene?;
  130460. private _babylonGamepads;
  130461. private _oneGamepadConnected;
  130462. /** @hidden */
  130463. _isMonitoring: boolean;
  130464. private _gamepadEventSupported;
  130465. private _gamepadSupport?;
  130466. /**
  130467. * observable to be triggered when the gamepad controller has been connected
  130468. */
  130469. onGamepadConnectedObservable: Observable<Gamepad>;
  130470. /**
  130471. * observable to be triggered when the gamepad controller has been disconnected
  130472. */
  130473. onGamepadDisconnectedObservable: Observable<Gamepad>;
  130474. private _onGamepadConnectedEvent;
  130475. private _onGamepadDisconnectedEvent;
  130476. /**
  130477. * Initializes the gamepad manager
  130478. * @param _scene BabylonJS scene
  130479. */
  130480. constructor(_scene?: Scene | undefined);
  130481. /**
  130482. * The gamepads in the game pad manager
  130483. */
  130484. get gamepads(): Gamepad[];
  130485. /**
  130486. * Get the gamepad controllers based on type
  130487. * @param type The type of gamepad controller
  130488. * @returns Nullable gamepad
  130489. */
  130490. getGamepadByType(type?: number): Nullable<Gamepad>;
  130491. /**
  130492. * Disposes the gamepad manager
  130493. */
  130494. dispose(): void;
  130495. private _addNewGamepad;
  130496. private _startMonitoringGamepads;
  130497. private _stopMonitoringGamepads;
  130498. /** @hidden */
  130499. _checkGamepadsStatus(): void;
  130500. private _updateGamepadObjects;
  130501. }
  130502. }
  130503. declare module BABYLON {
  130504. interface Scene {
  130505. /** @hidden */
  130506. _gamepadManager: Nullable<GamepadManager>;
  130507. /**
  130508. * Gets the gamepad manager associated with the scene
  130509. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  130510. */
  130511. gamepadManager: GamepadManager;
  130512. }
  130513. /**
  130514. * Interface representing a free camera inputs manager
  130515. */
  130516. interface FreeCameraInputsManager {
  130517. /**
  130518. * Adds gamepad input support to the FreeCameraInputsManager.
  130519. * @returns the FreeCameraInputsManager
  130520. */
  130521. addGamepad(): FreeCameraInputsManager;
  130522. }
  130523. /**
  130524. * Interface representing an arc rotate camera inputs manager
  130525. */
  130526. interface ArcRotateCameraInputsManager {
  130527. /**
  130528. * Adds gamepad input support to the ArcRotateCamera InputManager.
  130529. * @returns the camera inputs manager
  130530. */
  130531. addGamepad(): ArcRotateCameraInputsManager;
  130532. }
  130533. /**
  130534. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  130535. */
  130536. export class GamepadSystemSceneComponent implements ISceneComponent {
  130537. /**
  130538. * The component name helpfull to identify the component in the list of scene components.
  130539. */
  130540. readonly name: string;
  130541. /**
  130542. * The scene the component belongs to.
  130543. */
  130544. scene: Scene;
  130545. /**
  130546. * Creates a new instance of the component for the given scene
  130547. * @param scene Defines the scene to register the component in
  130548. */
  130549. constructor(scene: Scene);
  130550. /**
  130551. * Registers the component in a given scene
  130552. */
  130553. register(): void;
  130554. /**
  130555. * Rebuilds the elements related to this component in case of
  130556. * context lost for instance.
  130557. */
  130558. rebuild(): void;
  130559. /**
  130560. * Disposes the component and the associated ressources
  130561. */
  130562. dispose(): void;
  130563. private _beforeCameraUpdate;
  130564. }
  130565. }
  130566. declare module BABYLON {
  130567. /**
  130568. * 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,
  130569. * which still works and will still be found in many Playgrounds.
  130570. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130571. */
  130572. export class UniversalCamera extends TouchCamera {
  130573. /**
  130574. * Defines the gamepad rotation sensiblity.
  130575. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  130576. */
  130577. get gamepadAngularSensibility(): number;
  130578. set gamepadAngularSensibility(value: number);
  130579. /**
  130580. * Defines the gamepad move sensiblity.
  130581. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  130582. */
  130583. get gamepadMoveSensibility(): number;
  130584. set gamepadMoveSensibility(value: number);
  130585. /**
  130586. * 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,
  130587. * which still works and will still be found in many Playgrounds.
  130588. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130589. * @param name Define the name of the camera in the scene
  130590. * @param position Define the start position of the camera in the scene
  130591. * @param scene Define the scene the camera belongs to
  130592. */
  130593. constructor(name: string, position: Vector3, scene: Scene);
  130594. /**
  130595. * Gets the current object class name.
  130596. * @return the class name
  130597. */
  130598. getClassName(): string;
  130599. }
  130600. }
  130601. declare module BABYLON {
  130602. /**
  130603. * This represents a FPS type of camera. This is only here for back compat purpose.
  130604. * Please use the UniversalCamera instead as both are identical.
  130605. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130606. */
  130607. export class GamepadCamera extends UniversalCamera {
  130608. /**
  130609. * Instantiates a new Gamepad Camera
  130610. * This represents a FPS type of camera. This is only here for back compat purpose.
  130611. * Please use the UniversalCamera instead as both are identical.
  130612. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130613. * @param name Define the name of the camera in the scene
  130614. * @param position Define the start position of the camera in the scene
  130615. * @param scene Define the scene the camera belongs to
  130616. */
  130617. constructor(name: string, position: Vector3, scene: Scene);
  130618. /**
  130619. * Gets the current object class name.
  130620. * @return the class name
  130621. */
  130622. getClassName(): string;
  130623. }
  130624. }
  130625. declare module BABYLON {
  130626. /** @hidden */
  130627. export var passPixelShader: {
  130628. name: string;
  130629. shader: string;
  130630. };
  130631. }
  130632. declare module BABYLON {
  130633. /** @hidden */
  130634. export var passCubePixelShader: {
  130635. name: string;
  130636. shader: string;
  130637. };
  130638. }
  130639. declare module BABYLON {
  130640. /**
  130641. * PassPostProcess which produces an output the same as it's input
  130642. */
  130643. export class PassPostProcess extends PostProcess {
  130644. /**
  130645. * Gets a string identifying the name of the class
  130646. * @returns "PassPostProcess" string
  130647. */
  130648. getClassName(): string;
  130649. /**
  130650. * Creates the PassPostProcess
  130651. * @param name The name of the effect.
  130652. * @param options The required width/height ratio to downsize to before computing the render pass.
  130653. * @param camera The camera to apply the render pass to.
  130654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130655. * @param engine The engine which the post process will be applied. (default: current engine)
  130656. * @param reusable If the post process can be reused on the same frame. (default: false)
  130657. * @param textureType The type of texture to be used when performing the post processing.
  130658. * @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)
  130659. */
  130660. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130661. /** @hidden */
  130662. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  130663. }
  130664. /**
  130665. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  130666. */
  130667. export class PassCubePostProcess extends PostProcess {
  130668. private _face;
  130669. /**
  130670. * Gets or sets the cube face to display.
  130671. * * 0 is +X
  130672. * * 1 is -X
  130673. * * 2 is +Y
  130674. * * 3 is -Y
  130675. * * 4 is +Z
  130676. * * 5 is -Z
  130677. */
  130678. get face(): number;
  130679. set face(value: number);
  130680. /**
  130681. * Gets a string identifying the name of the class
  130682. * @returns "PassCubePostProcess" string
  130683. */
  130684. getClassName(): string;
  130685. /**
  130686. * Creates the PassCubePostProcess
  130687. * @param name The name of the effect.
  130688. * @param options The required width/height ratio to downsize to before computing the render pass.
  130689. * @param camera The camera to apply the render pass to.
  130690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130691. * @param engine The engine which the post process will be applied. (default: current engine)
  130692. * @param reusable If the post process can be reused on the same frame. (default: false)
  130693. * @param textureType The type of texture to be used when performing the post processing.
  130694. * @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)
  130695. */
  130696. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130697. /** @hidden */
  130698. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  130699. }
  130700. }
  130701. declare module BABYLON {
  130702. /** @hidden */
  130703. export var anaglyphPixelShader: {
  130704. name: string;
  130705. shader: string;
  130706. };
  130707. }
  130708. declare module BABYLON {
  130709. /**
  130710. * Postprocess used to generate anaglyphic rendering
  130711. */
  130712. export class AnaglyphPostProcess extends PostProcess {
  130713. private _passedProcess;
  130714. /**
  130715. * Gets a string identifying the name of the class
  130716. * @returns "AnaglyphPostProcess" string
  130717. */
  130718. getClassName(): string;
  130719. /**
  130720. * Creates a new AnaglyphPostProcess
  130721. * @param name defines postprocess name
  130722. * @param options defines creation options or target ratio scale
  130723. * @param rigCameras defines cameras using this postprocess
  130724. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  130725. * @param engine defines hosting engine
  130726. * @param reusable defines if the postprocess will be reused multiple times per frame
  130727. */
  130728. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  130729. }
  130730. }
  130731. declare module BABYLON {
  130732. /**
  130733. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  130734. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130735. */
  130736. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  130737. /**
  130738. * Creates a new AnaglyphArcRotateCamera
  130739. * @param name defines camera name
  130740. * @param alpha defines alpha angle (in radians)
  130741. * @param beta defines beta angle (in radians)
  130742. * @param radius defines radius
  130743. * @param target defines camera target
  130744. * @param interaxialDistance defines distance between each color axis
  130745. * @param scene defines the hosting scene
  130746. */
  130747. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  130748. /**
  130749. * Gets camera class name
  130750. * @returns AnaglyphArcRotateCamera
  130751. */
  130752. getClassName(): string;
  130753. }
  130754. }
  130755. declare module BABYLON {
  130756. /**
  130757. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  130758. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130759. */
  130760. export class AnaglyphFreeCamera extends FreeCamera {
  130761. /**
  130762. * Creates a new AnaglyphFreeCamera
  130763. * @param name defines camera name
  130764. * @param position defines initial position
  130765. * @param interaxialDistance defines distance between each color axis
  130766. * @param scene defines the hosting scene
  130767. */
  130768. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130769. /**
  130770. * Gets camera class name
  130771. * @returns AnaglyphFreeCamera
  130772. */
  130773. getClassName(): string;
  130774. }
  130775. }
  130776. declare module BABYLON {
  130777. /**
  130778. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  130779. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130780. */
  130781. export class AnaglyphGamepadCamera extends GamepadCamera {
  130782. /**
  130783. * Creates a new AnaglyphGamepadCamera
  130784. * @param name defines camera name
  130785. * @param position defines initial position
  130786. * @param interaxialDistance defines distance between each color axis
  130787. * @param scene defines the hosting scene
  130788. */
  130789. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130790. /**
  130791. * Gets camera class name
  130792. * @returns AnaglyphGamepadCamera
  130793. */
  130794. getClassName(): string;
  130795. }
  130796. }
  130797. declare module BABYLON {
  130798. /**
  130799. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  130800. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130801. */
  130802. export class AnaglyphUniversalCamera extends UniversalCamera {
  130803. /**
  130804. * Creates a new AnaglyphUniversalCamera
  130805. * @param name defines camera name
  130806. * @param position defines initial position
  130807. * @param interaxialDistance defines distance between each color axis
  130808. * @param scene defines the hosting scene
  130809. */
  130810. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130811. /**
  130812. * Gets camera class name
  130813. * @returns AnaglyphUniversalCamera
  130814. */
  130815. getClassName(): string;
  130816. }
  130817. }
  130818. declare module BABYLON {
  130819. /**
  130820. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  130821. * @see https://doc.babylonjs.com/features/cameras
  130822. */
  130823. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  130824. /**
  130825. * Creates a new StereoscopicArcRotateCamera
  130826. * @param name defines camera name
  130827. * @param alpha defines alpha angle (in radians)
  130828. * @param beta defines beta angle (in radians)
  130829. * @param radius defines radius
  130830. * @param target defines camera target
  130831. * @param interaxialDistance defines distance between each color axis
  130832. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130833. * @param scene defines the hosting scene
  130834. */
  130835. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130836. /**
  130837. * Gets camera class name
  130838. * @returns StereoscopicArcRotateCamera
  130839. */
  130840. getClassName(): string;
  130841. }
  130842. }
  130843. declare module BABYLON {
  130844. /**
  130845. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  130846. * @see https://doc.babylonjs.com/features/cameras
  130847. */
  130848. export class StereoscopicFreeCamera extends FreeCamera {
  130849. /**
  130850. * Creates a new StereoscopicFreeCamera
  130851. * @param name defines camera name
  130852. * @param position defines initial position
  130853. * @param interaxialDistance defines distance between each color axis
  130854. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130855. * @param scene defines the hosting scene
  130856. */
  130857. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130858. /**
  130859. * Gets camera class name
  130860. * @returns StereoscopicFreeCamera
  130861. */
  130862. getClassName(): string;
  130863. }
  130864. }
  130865. declare module BABYLON {
  130866. /**
  130867. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  130868. * @see https://doc.babylonjs.com/features/cameras
  130869. */
  130870. export class StereoscopicGamepadCamera extends GamepadCamera {
  130871. /**
  130872. * Creates a new StereoscopicGamepadCamera
  130873. * @param name defines camera name
  130874. * @param position defines initial position
  130875. * @param interaxialDistance defines distance between each color axis
  130876. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130877. * @param scene defines the hosting scene
  130878. */
  130879. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130880. /**
  130881. * Gets camera class name
  130882. * @returns StereoscopicGamepadCamera
  130883. */
  130884. getClassName(): string;
  130885. }
  130886. }
  130887. declare module BABYLON {
  130888. /**
  130889. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  130890. * @see https://doc.babylonjs.com/features/cameras
  130891. */
  130892. export class StereoscopicUniversalCamera extends UniversalCamera {
  130893. /**
  130894. * Creates a new StereoscopicUniversalCamera
  130895. * @param name defines camera name
  130896. * @param position defines initial position
  130897. * @param interaxialDistance defines distance between each color axis
  130898. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130899. * @param scene defines the hosting scene
  130900. */
  130901. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130902. /**
  130903. * Gets camera class name
  130904. * @returns StereoscopicUniversalCamera
  130905. */
  130906. getClassName(): string;
  130907. }
  130908. }
  130909. declare module BABYLON {
  130910. /**
  130911. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  130912. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130913. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130914. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130915. */
  130916. export class VirtualJoysticksCamera extends FreeCamera {
  130917. /**
  130918. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  130919. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130920. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130921. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130922. * @param name Define the name of the camera in the scene
  130923. * @param position Define the start position of the camera in the scene
  130924. * @param scene Define the scene the camera belongs to
  130925. */
  130926. constructor(name: string, position: Vector3, scene: Scene);
  130927. /**
  130928. * Gets the current object class name.
  130929. * @return the class name
  130930. */
  130931. getClassName(): string;
  130932. }
  130933. }
  130934. declare module BABYLON {
  130935. /**
  130936. * This represents all the required metrics to create a VR camera.
  130937. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  130938. */
  130939. export class VRCameraMetrics {
  130940. /**
  130941. * Define the horizontal resolution off the screen.
  130942. */
  130943. hResolution: number;
  130944. /**
  130945. * Define the vertical resolution off the screen.
  130946. */
  130947. vResolution: number;
  130948. /**
  130949. * Define the horizontal screen size.
  130950. */
  130951. hScreenSize: number;
  130952. /**
  130953. * Define the vertical screen size.
  130954. */
  130955. vScreenSize: number;
  130956. /**
  130957. * Define the vertical screen center position.
  130958. */
  130959. vScreenCenter: number;
  130960. /**
  130961. * Define the distance of the eyes to the screen.
  130962. */
  130963. eyeToScreenDistance: number;
  130964. /**
  130965. * Define the distance between both lenses
  130966. */
  130967. lensSeparationDistance: number;
  130968. /**
  130969. * Define the distance between both viewer's eyes.
  130970. */
  130971. interpupillaryDistance: number;
  130972. /**
  130973. * Define the distortion factor of the VR postprocess.
  130974. * Please, touch with care.
  130975. */
  130976. distortionK: number[];
  130977. /**
  130978. * Define the chromatic aberration correction factors for the VR post process.
  130979. */
  130980. chromaAbCorrection: number[];
  130981. /**
  130982. * Define the scale factor of the post process.
  130983. * The smaller the better but the slower.
  130984. */
  130985. postProcessScaleFactor: number;
  130986. /**
  130987. * Define an offset for the lens center.
  130988. */
  130989. lensCenterOffset: number;
  130990. /**
  130991. * Define if the current vr camera should compensate the distortion of the lense or not.
  130992. */
  130993. compensateDistortion: boolean;
  130994. /**
  130995. * Defines if multiview should be enabled when rendering (Default: false)
  130996. */
  130997. multiviewEnabled: boolean;
  130998. /**
  130999. * Gets the rendering aspect ratio based on the provided resolutions.
  131000. */
  131001. get aspectRatio(): number;
  131002. /**
  131003. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  131004. */
  131005. get aspectRatioFov(): number;
  131006. /**
  131007. * @hidden
  131008. */
  131009. get leftHMatrix(): Matrix;
  131010. /**
  131011. * @hidden
  131012. */
  131013. get rightHMatrix(): Matrix;
  131014. /**
  131015. * @hidden
  131016. */
  131017. get leftPreViewMatrix(): Matrix;
  131018. /**
  131019. * @hidden
  131020. */
  131021. get rightPreViewMatrix(): Matrix;
  131022. /**
  131023. * Get the default VRMetrics based on the most generic setup.
  131024. * @returns the default vr metrics
  131025. */
  131026. static GetDefault(): VRCameraMetrics;
  131027. }
  131028. }
  131029. declare module BABYLON {
  131030. /** @hidden */
  131031. export var vrDistortionCorrectionPixelShader: {
  131032. name: string;
  131033. shader: string;
  131034. };
  131035. }
  131036. declare module BABYLON {
  131037. /**
  131038. * VRDistortionCorrectionPostProcess used for mobile VR
  131039. */
  131040. export class VRDistortionCorrectionPostProcess extends PostProcess {
  131041. private _isRightEye;
  131042. private _distortionFactors;
  131043. private _postProcessScaleFactor;
  131044. private _lensCenterOffset;
  131045. private _scaleIn;
  131046. private _scaleFactor;
  131047. private _lensCenter;
  131048. /**
  131049. * Gets a string identifying the name of the class
  131050. * @returns "VRDistortionCorrectionPostProcess" string
  131051. */
  131052. getClassName(): string;
  131053. /**
  131054. * Initializes the VRDistortionCorrectionPostProcess
  131055. * @param name The name of the effect.
  131056. * @param camera The camera to apply the render pass to.
  131057. * @param isRightEye If this is for the right eye distortion
  131058. * @param vrMetrics All the required metrics for the VR camera
  131059. */
  131060. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  131061. }
  131062. }
  131063. declare module BABYLON {
  131064. /**
  131065. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  131066. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131067. */
  131068. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  131069. /**
  131070. * Creates a new VRDeviceOrientationArcRotateCamera
  131071. * @param name defines camera name
  131072. * @param alpha defines the camera rotation along the logitudinal axis
  131073. * @param beta defines the camera rotation along the latitudinal axis
  131074. * @param radius defines the camera distance from its target
  131075. * @param target defines the camera target
  131076. * @param scene defines the scene the camera belongs to
  131077. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131078. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131079. */
  131080. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131081. /**
  131082. * Gets camera class name
  131083. * @returns VRDeviceOrientationArcRotateCamera
  131084. */
  131085. getClassName(): string;
  131086. }
  131087. }
  131088. declare module BABYLON {
  131089. /**
  131090. * Camera used to simulate VR rendering (based on FreeCamera)
  131091. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131092. */
  131093. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  131094. /**
  131095. * Creates a new VRDeviceOrientationFreeCamera
  131096. * @param name defines camera name
  131097. * @param position defines the start position of the camera
  131098. * @param scene defines the scene the camera belongs to
  131099. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131100. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131101. */
  131102. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131103. /**
  131104. * Gets camera class name
  131105. * @returns VRDeviceOrientationFreeCamera
  131106. */
  131107. getClassName(): string;
  131108. }
  131109. }
  131110. declare module BABYLON {
  131111. /**
  131112. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  131113. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131114. */
  131115. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  131116. /**
  131117. * Creates a new VRDeviceOrientationGamepadCamera
  131118. * @param name defines camera name
  131119. * @param position defines the start position of the camera
  131120. * @param scene defines the scene the camera belongs to
  131121. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131122. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131123. */
  131124. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131125. /**
  131126. * Gets camera class name
  131127. * @returns VRDeviceOrientationGamepadCamera
  131128. */
  131129. getClassName(): string;
  131130. }
  131131. }
  131132. declare module BABYLON {
  131133. /**
  131134. * A class extending Texture allowing drawing on a texture
  131135. * @see https://doc.babylonjs.com/how_to/dynamictexture
  131136. */
  131137. export class DynamicTexture extends Texture {
  131138. private _generateMipMaps;
  131139. private _canvas;
  131140. private _context;
  131141. /**
  131142. * Creates a DynamicTexture
  131143. * @param name defines the name of the texture
  131144. * @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
  131145. * @param scene defines the scene where you want the texture
  131146. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  131147. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131148. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  131149. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  131150. */
  131151. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  131152. /**
  131153. * Get the current class name of the texture useful for serialization or dynamic coding.
  131154. * @returns "DynamicTexture"
  131155. */
  131156. getClassName(): string;
  131157. /**
  131158. * Gets the current state of canRescale
  131159. */
  131160. get canRescale(): boolean;
  131161. private _recreate;
  131162. /**
  131163. * Scales the texture
  131164. * @param ratio the scale factor to apply to both width and height
  131165. */
  131166. scale(ratio: number): void;
  131167. /**
  131168. * Resizes the texture
  131169. * @param width the new width
  131170. * @param height the new height
  131171. */
  131172. scaleTo(width: number, height: number): void;
  131173. /**
  131174. * Gets the context of the canvas used by the texture
  131175. * @returns the canvas context of the dynamic texture
  131176. */
  131177. getContext(): CanvasRenderingContext2D;
  131178. /**
  131179. * Clears the texture
  131180. */
  131181. clear(): void;
  131182. /**
  131183. * Updates the texture
  131184. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131185. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  131186. */
  131187. update(invertY?: boolean, premulAlpha?: boolean): void;
  131188. /**
  131189. * Draws text onto the texture
  131190. * @param text defines the text to be drawn
  131191. * @param x defines the placement of the text from the left
  131192. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  131193. * @param font defines the font to be used with font-style, font-size, font-name
  131194. * @param color defines the color used for the text
  131195. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  131196. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131197. * @param update defines whether texture is immediately update (default is true)
  131198. */
  131199. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  131200. /**
  131201. * Clones the texture
  131202. * @returns the clone of the texture.
  131203. */
  131204. clone(): DynamicTexture;
  131205. /**
  131206. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  131207. * @returns a serialized dynamic texture object
  131208. */
  131209. serialize(): any;
  131210. private _IsCanvasElement;
  131211. /** @hidden */
  131212. _rebuild(): void;
  131213. }
  131214. }
  131215. declare module BABYLON {
  131216. /**
  131217. * Class containing static functions to help procedurally build meshes
  131218. */
  131219. export class GroundBuilder {
  131220. /**
  131221. * Creates a ground mesh
  131222. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  131223. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  131224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131225. * @param name defines the name of the mesh
  131226. * @param options defines the options used to create the mesh
  131227. * @param scene defines the hosting scene
  131228. * @returns the ground mesh
  131229. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  131230. */
  131231. static CreateGround(name: string, options: {
  131232. width?: number;
  131233. height?: number;
  131234. subdivisions?: number;
  131235. subdivisionsX?: number;
  131236. subdivisionsY?: number;
  131237. updatable?: boolean;
  131238. }, scene: any): Mesh;
  131239. /**
  131240. * Creates a tiled ground mesh
  131241. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  131242. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  131243. * * 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
  131244. * * 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
  131245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131246. * @param name defines the name of the mesh
  131247. * @param options defines the options used to create the mesh
  131248. * @param scene defines the hosting scene
  131249. * @returns the tiled ground mesh
  131250. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  131251. */
  131252. static CreateTiledGround(name: string, options: {
  131253. xmin: number;
  131254. zmin: number;
  131255. xmax: number;
  131256. zmax: number;
  131257. subdivisions?: {
  131258. w: number;
  131259. h: number;
  131260. };
  131261. precision?: {
  131262. w: number;
  131263. h: number;
  131264. };
  131265. updatable?: boolean;
  131266. }, scene?: Nullable<Scene>): Mesh;
  131267. /**
  131268. * Creates a ground mesh from a height map
  131269. * * The parameter `url` sets the URL of the height map image resource.
  131270. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  131271. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  131272. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  131273. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  131274. * * 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.
  131275. * * 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).
  131276. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  131277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131278. * @param name defines the name of the mesh
  131279. * @param url defines the url to the height map
  131280. * @param options defines the options used to create the mesh
  131281. * @param scene defines the hosting scene
  131282. * @returns the ground mesh
  131283. * @see https://doc.babylonjs.com/babylon101/height_map
  131284. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  131285. */
  131286. static CreateGroundFromHeightMap(name: string, url: string, options: {
  131287. width?: number;
  131288. height?: number;
  131289. subdivisions?: number;
  131290. minHeight?: number;
  131291. maxHeight?: number;
  131292. colorFilter?: Color3;
  131293. alphaFilter?: number;
  131294. updatable?: boolean;
  131295. onReady?: (mesh: GroundMesh) => void;
  131296. }, scene?: Nullable<Scene>): GroundMesh;
  131297. }
  131298. }
  131299. declare module BABYLON {
  131300. /**
  131301. * Class containing static functions to help procedurally build meshes
  131302. */
  131303. export class TorusBuilder {
  131304. /**
  131305. * Creates a torus mesh
  131306. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  131307. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  131308. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  131309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131312. * @param name defines the name of the mesh
  131313. * @param options defines the options used to create the mesh
  131314. * @param scene defines the hosting scene
  131315. * @returns the torus mesh
  131316. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  131317. */
  131318. static CreateTorus(name: string, options: {
  131319. diameter?: number;
  131320. thickness?: number;
  131321. tessellation?: number;
  131322. updatable?: boolean;
  131323. sideOrientation?: number;
  131324. frontUVs?: Vector4;
  131325. backUVs?: Vector4;
  131326. }, scene: any): Mesh;
  131327. }
  131328. }
  131329. declare module BABYLON {
  131330. /**
  131331. * Class containing static functions to help procedurally build meshes
  131332. */
  131333. export class CylinderBuilder {
  131334. /**
  131335. * Creates a cylinder or a cone mesh
  131336. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  131337. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  131338. * * 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.
  131339. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  131340. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  131341. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  131342. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  131343. * * 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).
  131344. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  131345. * * 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).
  131346. * * 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
  131347. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  131348. * * 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
  131349. * * 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.
  131350. * * If `enclose` is false, a ring surface is one element.
  131351. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  131352. * * 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
  131353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131356. * @param name defines the name of the mesh
  131357. * @param options defines the options used to create the mesh
  131358. * @param scene defines the hosting scene
  131359. * @returns the cylinder mesh
  131360. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  131361. */
  131362. static CreateCylinder(name: string, options: {
  131363. height?: number;
  131364. diameterTop?: number;
  131365. diameterBottom?: number;
  131366. diameter?: number;
  131367. tessellation?: number;
  131368. subdivisions?: number;
  131369. arc?: number;
  131370. faceColors?: Color4[];
  131371. faceUV?: Vector4[];
  131372. updatable?: boolean;
  131373. hasRings?: boolean;
  131374. enclose?: boolean;
  131375. cap?: number;
  131376. sideOrientation?: number;
  131377. frontUVs?: Vector4;
  131378. backUVs?: Vector4;
  131379. }, scene: any): Mesh;
  131380. }
  131381. }
  131382. declare module BABYLON {
  131383. /**
  131384. * States of the webXR experience
  131385. */
  131386. export enum WebXRState {
  131387. /**
  131388. * Transitioning to being in XR mode
  131389. */
  131390. ENTERING_XR = 0,
  131391. /**
  131392. * Transitioning to non XR mode
  131393. */
  131394. EXITING_XR = 1,
  131395. /**
  131396. * In XR mode and presenting
  131397. */
  131398. IN_XR = 2,
  131399. /**
  131400. * Not entered XR mode
  131401. */
  131402. NOT_IN_XR = 3
  131403. }
  131404. /**
  131405. * The state of the XR camera's tracking
  131406. */
  131407. export enum WebXRTrackingState {
  131408. /**
  131409. * No transformation received, device is not being tracked
  131410. */
  131411. NOT_TRACKING = 0,
  131412. /**
  131413. * Tracking lost - using emulated position
  131414. */
  131415. TRACKING_LOST = 1,
  131416. /**
  131417. * Transformation tracking works normally
  131418. */
  131419. TRACKING = 2
  131420. }
  131421. /**
  131422. * Abstraction of the XR render target
  131423. */
  131424. export interface WebXRRenderTarget extends IDisposable {
  131425. /**
  131426. * xrpresent context of the canvas which can be used to display/mirror xr content
  131427. */
  131428. canvasContext: WebGLRenderingContext;
  131429. /**
  131430. * xr layer for the canvas
  131431. */
  131432. xrLayer: Nullable<XRWebGLLayer>;
  131433. /**
  131434. * Initializes the xr layer for the session
  131435. * @param xrSession xr session
  131436. * @returns a promise that will resolve once the XR Layer has been created
  131437. */
  131438. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  131439. }
  131440. }
  131441. declare module BABYLON {
  131442. /**
  131443. * COnfiguration object for WebXR output canvas
  131444. */
  131445. export class WebXRManagedOutputCanvasOptions {
  131446. /**
  131447. * An optional canvas in case you wish to create it yourself and provide it here.
  131448. * If not provided, a new canvas will be created
  131449. */
  131450. canvasElement?: HTMLCanvasElement;
  131451. /**
  131452. * Options for this XR Layer output
  131453. */
  131454. canvasOptions?: XRWebGLLayerInit;
  131455. /**
  131456. * CSS styling for a newly created canvas (if not provided)
  131457. */
  131458. newCanvasCssStyle?: string;
  131459. /**
  131460. * Get the default values of the configuration object
  131461. * @param engine defines the engine to use (can be null)
  131462. * @returns default values of this configuration object
  131463. */
  131464. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  131465. }
  131466. /**
  131467. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  131468. */
  131469. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  131470. private _options;
  131471. private _canvas;
  131472. private _engine;
  131473. private _originalCanvasSize;
  131474. /**
  131475. * Rendering context of the canvas which can be used to display/mirror xr content
  131476. */
  131477. canvasContext: WebGLRenderingContext;
  131478. /**
  131479. * xr layer for the canvas
  131480. */
  131481. xrLayer: Nullable<XRWebGLLayer>;
  131482. /**
  131483. * Obseervers registered here will be triggered when the xr layer was initialized
  131484. */
  131485. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  131486. /**
  131487. * Initializes the canvas to be added/removed upon entering/exiting xr
  131488. * @param _xrSessionManager The XR Session manager
  131489. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  131490. */
  131491. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  131492. /**
  131493. * Disposes of the object
  131494. */
  131495. dispose(): void;
  131496. /**
  131497. * Initializes the xr layer for the session
  131498. * @param xrSession xr session
  131499. * @returns a promise that will resolve once the XR Layer has been created
  131500. */
  131501. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  131502. private _addCanvas;
  131503. private _removeCanvas;
  131504. private _setCanvasSize;
  131505. private _setManagedOutputCanvas;
  131506. }
  131507. }
  131508. declare module BABYLON {
  131509. /**
  131510. * Manages an XRSession to work with Babylon's engine
  131511. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  131512. */
  131513. export class WebXRSessionManager implements IDisposable {
  131514. /** The scene which the session should be created for */
  131515. scene: Scene;
  131516. private _referenceSpace;
  131517. private _rttProvider;
  131518. private _sessionEnded;
  131519. private _xrNavigator;
  131520. private baseLayer;
  131521. /**
  131522. * The base reference space from which the session started. good if you want to reset your
  131523. * reference space
  131524. */
  131525. baseReferenceSpace: XRReferenceSpace;
  131526. /**
  131527. * Current XR frame
  131528. */
  131529. currentFrame: Nullable<XRFrame>;
  131530. /** WebXR timestamp updated every frame */
  131531. currentTimestamp: number;
  131532. /**
  131533. * Used just in case of a failure to initialize an immersive session.
  131534. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  131535. */
  131536. defaultHeightCompensation: number;
  131537. /**
  131538. * Fires every time a new xrFrame arrives which can be used to update the camera
  131539. */
  131540. onXRFrameObservable: Observable<XRFrame>;
  131541. /**
  131542. * Fires when the reference space changed
  131543. */
  131544. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  131545. /**
  131546. * Fires when the xr session is ended either by the device or manually done
  131547. */
  131548. onXRSessionEnded: Observable<any>;
  131549. /**
  131550. * Fires when the xr session is ended either by the device or manually done
  131551. */
  131552. onXRSessionInit: Observable<XRSession>;
  131553. /**
  131554. * Underlying xr session
  131555. */
  131556. session: XRSession;
  131557. /**
  131558. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  131559. * or get the offset the player is currently at.
  131560. */
  131561. viewerReferenceSpace: XRReferenceSpace;
  131562. /**
  131563. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  131564. * @param scene The scene which the session should be created for
  131565. */
  131566. constructor(
  131567. /** The scene which the session should be created for */
  131568. scene: Scene);
  131569. /**
  131570. * The current reference space used in this session. This reference space can constantly change!
  131571. * It is mainly used to offset the camera's position.
  131572. */
  131573. get referenceSpace(): XRReferenceSpace;
  131574. /**
  131575. * Set a new reference space and triggers the observable
  131576. */
  131577. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  131578. /**
  131579. * Disposes of the session manager
  131580. */
  131581. dispose(): void;
  131582. /**
  131583. * Stops the xrSession and restores the render loop
  131584. * @returns Promise which resolves after it exits XR
  131585. */
  131586. exitXRAsync(): Promise<void>;
  131587. /**
  131588. * Gets the correct render target texture to be rendered this frame for this eye
  131589. * @param eye the eye for which to get the render target
  131590. * @returns the render target for the specified eye
  131591. */
  131592. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  131593. /**
  131594. * Creates a WebXRRenderTarget object for the XR session
  131595. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  131596. * @param options optional options to provide when creating a new render target
  131597. * @returns a WebXR render target to which the session can render
  131598. */
  131599. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  131600. /**
  131601. * Initializes the manager
  131602. * After initialization enterXR can be called to start an XR session
  131603. * @returns Promise which resolves after it is initialized
  131604. */
  131605. initializeAsync(): Promise<void>;
  131606. /**
  131607. * Initializes an xr session
  131608. * @param xrSessionMode mode to initialize
  131609. * @param xrSessionInit defines optional and required values to pass to the session builder
  131610. * @returns a promise which will resolve once the session has been initialized
  131611. */
  131612. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  131613. /**
  131614. * Checks if a session would be supported for the creation options specified
  131615. * @param sessionMode session mode to check if supported eg. immersive-vr
  131616. * @returns A Promise that resolves to true if supported and false if not
  131617. */
  131618. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  131619. /**
  131620. * Resets the reference space to the one started the session
  131621. */
  131622. resetReferenceSpace(): void;
  131623. /**
  131624. * Starts rendering to the xr layer
  131625. */
  131626. runXRRenderLoop(): void;
  131627. /**
  131628. * Sets the reference space on the xr session
  131629. * @param referenceSpaceType space to set
  131630. * @returns a promise that will resolve once the reference space has been set
  131631. */
  131632. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  131633. /**
  131634. * Updates the render state of the session
  131635. * @param state state to set
  131636. * @returns a promise that resolves once the render state has been updated
  131637. */
  131638. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  131639. /**
  131640. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  131641. * @param sessionMode defines the session to test
  131642. * @returns a promise with boolean as final value
  131643. */
  131644. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  131645. private _createRenderTargetTexture;
  131646. }
  131647. }
  131648. declare module BABYLON {
  131649. /**
  131650. * WebXR Camera which holds the views for the xrSession
  131651. * @see https://doc.babylonjs.com/how_to/webxr_camera
  131652. */
  131653. export class WebXRCamera extends FreeCamera {
  131654. private _xrSessionManager;
  131655. private _firstFrame;
  131656. private _referenceQuaternion;
  131657. private _referencedPosition;
  131658. private _xrInvPositionCache;
  131659. private _xrInvQuaternionCache;
  131660. private _trackingState;
  131661. /**
  131662. * Observable raised before camera teleportation
  131663. */
  131664. onBeforeCameraTeleport: Observable<Vector3>;
  131665. /**
  131666. * Observable raised after camera teleportation
  131667. */
  131668. onAfterCameraTeleport: Observable<Vector3>;
  131669. /**
  131670. * Notifies when the camera's tracking state has changed.
  131671. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  131672. */
  131673. onTrackingStateChanged: Observable<WebXRTrackingState>;
  131674. /**
  131675. * Should position compensation execute on first frame.
  131676. * This is used when copying the position from a native (non XR) camera
  131677. */
  131678. compensateOnFirstFrame: boolean;
  131679. /**
  131680. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  131681. * @param name the name of the camera
  131682. * @param scene the scene to add the camera to
  131683. * @param _xrSessionManager a constructed xr session manager
  131684. */
  131685. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  131686. /**
  131687. * Get the current XR tracking state of the camera
  131688. */
  131689. get trackingState(): WebXRTrackingState;
  131690. private _setTrackingState;
  131691. /**
  131692. * Return the user's height, unrelated to the current ground.
  131693. * This will be the y position of this camera, when ground level is 0.
  131694. */
  131695. get realWorldHeight(): number;
  131696. /** @hidden */
  131697. _updateForDualEyeDebugging(): void;
  131698. /**
  131699. * Sets this camera's transformation based on a non-vr camera
  131700. * @param otherCamera the non-vr camera to copy the transformation from
  131701. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  131702. */
  131703. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  131704. /**
  131705. * Gets the current instance class name ("WebXRCamera").
  131706. * @returns the class name
  131707. */
  131708. getClassName(): string;
  131709. private _rotate180;
  131710. private _updateFromXRSession;
  131711. private _updateNumberOfRigCameras;
  131712. private _updateReferenceSpace;
  131713. private _updateReferenceSpaceOffset;
  131714. }
  131715. }
  131716. declare module BABYLON {
  131717. /**
  131718. * Defining the interface required for a (webxr) feature
  131719. */
  131720. export interface IWebXRFeature extends IDisposable {
  131721. /**
  131722. * Is this feature attached
  131723. */
  131724. attached: boolean;
  131725. /**
  131726. * Should auto-attach be disabled?
  131727. */
  131728. disableAutoAttach: boolean;
  131729. /**
  131730. * Attach the feature to the session
  131731. * Will usually be called by the features manager
  131732. *
  131733. * @param force should attachment be forced (even when already attached)
  131734. * @returns true if successful.
  131735. */
  131736. attach(force?: boolean): boolean;
  131737. /**
  131738. * Detach the feature from the session
  131739. * Will usually be called by the features manager
  131740. *
  131741. * @returns true if successful.
  131742. */
  131743. detach(): boolean;
  131744. /**
  131745. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  131746. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  131747. *
  131748. * @returns whether or not the feature is compatible in this environment
  131749. */
  131750. isCompatible(): boolean;
  131751. /**
  131752. * Was this feature disposed;
  131753. */
  131754. isDisposed: boolean;
  131755. /**
  131756. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  131757. */
  131758. xrNativeFeatureName?: string;
  131759. /**
  131760. * A list of (Babylon WebXR) features this feature depends on
  131761. */
  131762. dependsOn?: string[];
  131763. }
  131764. /**
  131765. * A list of the currently available features without referencing them
  131766. */
  131767. export class WebXRFeatureName {
  131768. /**
  131769. * The name of the anchor system feature
  131770. */
  131771. static readonly ANCHOR_SYSTEM: string;
  131772. /**
  131773. * The name of the background remover feature
  131774. */
  131775. static readonly BACKGROUND_REMOVER: string;
  131776. /**
  131777. * The name of the hit test feature
  131778. */
  131779. static readonly HIT_TEST: string;
  131780. /**
  131781. * physics impostors for xr controllers feature
  131782. */
  131783. static readonly PHYSICS_CONTROLLERS: string;
  131784. /**
  131785. * The name of the plane detection feature
  131786. */
  131787. static readonly PLANE_DETECTION: string;
  131788. /**
  131789. * The name of the pointer selection feature
  131790. */
  131791. static readonly POINTER_SELECTION: string;
  131792. /**
  131793. * The name of the teleportation feature
  131794. */
  131795. static readonly TELEPORTATION: string;
  131796. /**
  131797. * The name of the feature points feature.
  131798. */
  131799. static readonly FEATURE_POINTS: string;
  131800. /**
  131801. * The name of the hand tracking feature.
  131802. */
  131803. static readonly HAND_TRACKING: string;
  131804. }
  131805. /**
  131806. * Defining the constructor of a feature. Used to register the modules.
  131807. */
  131808. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  131809. /**
  131810. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  131811. * It is mainly used in AR sessions.
  131812. *
  131813. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  131814. */
  131815. export class WebXRFeaturesManager implements IDisposable {
  131816. private _xrSessionManager;
  131817. private static readonly _AvailableFeatures;
  131818. private _features;
  131819. /**
  131820. * constructs a new features manages.
  131821. *
  131822. * @param _xrSessionManager an instance of WebXRSessionManager
  131823. */
  131824. constructor(_xrSessionManager: WebXRSessionManager);
  131825. /**
  131826. * Used to register a module. After calling this function a developer can use this feature in the scene.
  131827. * Mainly used internally.
  131828. *
  131829. * @param featureName the name of the feature to register
  131830. * @param constructorFunction the function used to construct the module
  131831. * @param version the (babylon) version of the module
  131832. * @param stable is that a stable version of this module
  131833. */
  131834. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  131835. /**
  131836. * Returns a constructor of a specific feature.
  131837. *
  131838. * @param featureName the name of the feature to construct
  131839. * @param version the version of the feature to load
  131840. * @param xrSessionManager the xrSessionManager. Used to construct the module
  131841. * @param options optional options provided to the module.
  131842. * @returns a function that, when called, will return a new instance of this feature
  131843. */
  131844. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  131845. /**
  131846. * Can be used to return the list of features currently registered
  131847. *
  131848. * @returns an Array of available features
  131849. */
  131850. static GetAvailableFeatures(): string[];
  131851. /**
  131852. * Gets the versions available for a specific feature
  131853. * @param featureName the name of the feature
  131854. * @returns an array with the available versions
  131855. */
  131856. static GetAvailableVersions(featureName: string): string[];
  131857. /**
  131858. * Return the latest unstable version of this feature
  131859. * @param featureName the name of the feature to search
  131860. * @returns the version number. if not found will return -1
  131861. */
  131862. static GetLatestVersionOfFeature(featureName: string): number;
  131863. /**
  131864. * Return the latest stable version of this feature
  131865. * @param featureName the name of the feature to search
  131866. * @returns the version number. if not found will return -1
  131867. */
  131868. static GetStableVersionOfFeature(featureName: string): number;
  131869. /**
  131870. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  131871. * Can be used during a session to start a feature
  131872. * @param featureName the name of feature to attach
  131873. */
  131874. attachFeature(featureName: string): void;
  131875. /**
  131876. * Can be used inside a session or when the session ends to detach a specific feature
  131877. * @param featureName the name of the feature to detach
  131878. */
  131879. detachFeature(featureName: string): void;
  131880. /**
  131881. * Used to disable an already-enabled feature
  131882. * The feature will be disposed and will be recreated once enabled.
  131883. * @param featureName the feature to disable
  131884. * @returns true if disable was successful
  131885. */
  131886. disableFeature(featureName: string | {
  131887. Name: string;
  131888. }): boolean;
  131889. /**
  131890. * dispose this features manager
  131891. */
  131892. dispose(): void;
  131893. /**
  131894. * 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.
  131895. * 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.
  131896. *
  131897. * @param featureName the name of the feature to load or the class of the feature
  131898. * @param version optional version to load. if not provided the latest version will be enabled
  131899. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  131900. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  131901. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  131902. * @returns a new constructed feature or throws an error if feature not found.
  131903. */
  131904. enableFeature(featureName: string | {
  131905. Name: string;
  131906. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  131907. /**
  131908. * get the implementation of an enabled feature.
  131909. * @param featureName the name of the feature to load
  131910. * @returns the feature class, if found
  131911. */
  131912. getEnabledFeature(featureName: string): IWebXRFeature;
  131913. /**
  131914. * Get the list of enabled features
  131915. * @returns an array of enabled features
  131916. */
  131917. getEnabledFeatures(): string[];
  131918. /**
  131919. * This function will exten the session creation configuration object with enabled features.
  131920. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  131921. * according to the defined "required" variable, provided during enableFeature call
  131922. * @param xrSessionInit the xr Session init object to extend
  131923. *
  131924. * @returns an extended XRSessionInit object
  131925. */
  131926. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  131927. }
  131928. }
  131929. declare module BABYLON {
  131930. /**
  131931. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  131932. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  131933. */
  131934. export class WebXRExperienceHelper implements IDisposable {
  131935. private scene;
  131936. private _nonVRCamera;
  131937. private _originalSceneAutoClear;
  131938. private _supported;
  131939. /**
  131940. * Camera used to render xr content
  131941. */
  131942. camera: WebXRCamera;
  131943. /** A features manager for this xr session */
  131944. featuresManager: WebXRFeaturesManager;
  131945. /**
  131946. * Observers registered here will be triggered after the camera's initial transformation is set
  131947. * This can be used to set a different ground level or an extra rotation.
  131948. *
  131949. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  131950. * to the position set after this observable is done executing.
  131951. */
  131952. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  131953. /**
  131954. * Fires when the state of the experience helper has changed
  131955. */
  131956. onStateChangedObservable: Observable<WebXRState>;
  131957. /** Session manager used to keep track of xr session */
  131958. sessionManager: WebXRSessionManager;
  131959. /**
  131960. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  131961. */
  131962. state: WebXRState;
  131963. /**
  131964. * Creates a WebXRExperienceHelper
  131965. * @param scene The scene the helper should be created in
  131966. */
  131967. private constructor();
  131968. /**
  131969. * Creates the experience helper
  131970. * @param scene the scene to attach the experience helper to
  131971. * @returns a promise for the experience helper
  131972. */
  131973. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  131974. /**
  131975. * Disposes of the experience helper
  131976. */
  131977. dispose(): void;
  131978. /**
  131979. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  131980. * @param sessionMode options for the XR session
  131981. * @param referenceSpaceType frame of reference of the XR session
  131982. * @param renderTarget the output canvas that will be used to enter XR mode
  131983. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  131984. * @returns promise that resolves after xr mode has entered
  131985. */
  131986. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  131987. /**
  131988. * Exits XR mode and returns the scene to its original state
  131989. * @returns promise that resolves after xr mode has exited
  131990. */
  131991. exitXRAsync(): Promise<void>;
  131992. private _nonXRToXRCamera;
  131993. private _setState;
  131994. }
  131995. }
  131996. declare module BABYLON {
  131997. /**
  131998. * X-Y values for axes in WebXR
  131999. */
  132000. export interface IWebXRMotionControllerAxesValue {
  132001. /**
  132002. * The value of the x axis
  132003. */
  132004. x: number;
  132005. /**
  132006. * The value of the y-axis
  132007. */
  132008. y: number;
  132009. }
  132010. /**
  132011. * changed / previous values for the values of this component
  132012. */
  132013. export interface IWebXRMotionControllerComponentChangesValues<T> {
  132014. /**
  132015. * current (this frame) value
  132016. */
  132017. current: T;
  132018. /**
  132019. * previous (last change) value
  132020. */
  132021. previous: T;
  132022. }
  132023. /**
  132024. * Represents changes in the component between current frame and last values recorded
  132025. */
  132026. export interface IWebXRMotionControllerComponentChanges {
  132027. /**
  132028. * will be populated with previous and current values if axes changed
  132029. */
  132030. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  132031. /**
  132032. * will be populated with previous and current values if pressed changed
  132033. */
  132034. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132035. /**
  132036. * will be populated with previous and current values if touched changed
  132037. */
  132038. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132039. /**
  132040. * will be populated with previous and current values if value changed
  132041. */
  132042. value?: IWebXRMotionControllerComponentChangesValues<number>;
  132043. }
  132044. /**
  132045. * This class represents a single component (for example button or thumbstick) of a motion controller
  132046. */
  132047. export class WebXRControllerComponent implements IDisposable {
  132048. /**
  132049. * the id of this component
  132050. */
  132051. id: string;
  132052. /**
  132053. * the type of the component
  132054. */
  132055. type: MotionControllerComponentType;
  132056. private _buttonIndex;
  132057. private _axesIndices;
  132058. private _axes;
  132059. private _changes;
  132060. private _currentValue;
  132061. private _hasChanges;
  132062. private _pressed;
  132063. private _touched;
  132064. /**
  132065. * button component type
  132066. */
  132067. static BUTTON_TYPE: MotionControllerComponentType;
  132068. /**
  132069. * squeeze component type
  132070. */
  132071. static SQUEEZE_TYPE: MotionControllerComponentType;
  132072. /**
  132073. * Thumbstick component type
  132074. */
  132075. static THUMBSTICK_TYPE: MotionControllerComponentType;
  132076. /**
  132077. * Touchpad component type
  132078. */
  132079. static TOUCHPAD_TYPE: MotionControllerComponentType;
  132080. /**
  132081. * trigger component type
  132082. */
  132083. static TRIGGER_TYPE: MotionControllerComponentType;
  132084. /**
  132085. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  132086. * the axes data changes
  132087. */
  132088. onAxisValueChangedObservable: Observable<{
  132089. x: number;
  132090. y: number;
  132091. }>;
  132092. /**
  132093. * Observers registered here will be triggered when the state of a button changes
  132094. * State change is either pressed / touched / value
  132095. */
  132096. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  132097. /**
  132098. * Creates a new component for a motion controller.
  132099. * It is created by the motion controller itself
  132100. *
  132101. * @param id the id of this component
  132102. * @param type the type of the component
  132103. * @param _buttonIndex index in the buttons array of the gamepad
  132104. * @param _axesIndices indices of the values in the axes array of the gamepad
  132105. */
  132106. constructor(
  132107. /**
  132108. * the id of this component
  132109. */
  132110. id: string,
  132111. /**
  132112. * the type of the component
  132113. */
  132114. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  132115. /**
  132116. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  132117. */
  132118. get axes(): IWebXRMotionControllerAxesValue;
  132119. /**
  132120. * Get the changes. Elements will be populated only if they changed with their previous and current value
  132121. */
  132122. get changes(): IWebXRMotionControllerComponentChanges;
  132123. /**
  132124. * Return whether or not the component changed the last frame
  132125. */
  132126. get hasChanges(): boolean;
  132127. /**
  132128. * is the button currently pressed
  132129. */
  132130. get pressed(): boolean;
  132131. /**
  132132. * is the button currently touched
  132133. */
  132134. get touched(): boolean;
  132135. /**
  132136. * Get the current value of this component
  132137. */
  132138. get value(): number;
  132139. /**
  132140. * Dispose this component
  132141. */
  132142. dispose(): void;
  132143. /**
  132144. * Are there axes correlating to this component
  132145. * @return true is axes data is available
  132146. */
  132147. isAxes(): boolean;
  132148. /**
  132149. * Is this component a button (hence - pressable)
  132150. * @returns true if can be pressed
  132151. */
  132152. isButton(): boolean;
  132153. /**
  132154. * update this component using the gamepad object it is in. Called on every frame
  132155. * @param nativeController the native gamepad controller object
  132156. */
  132157. update(nativeController: IMinimalMotionControllerObject): void;
  132158. }
  132159. }
  132160. declare module BABYLON {
  132161. /**
  132162. * Interface used to represent data loading progression
  132163. */
  132164. export interface ISceneLoaderProgressEvent {
  132165. /**
  132166. * Defines if data length to load can be evaluated
  132167. */
  132168. readonly lengthComputable: boolean;
  132169. /**
  132170. * Defines the loaded data length
  132171. */
  132172. readonly loaded: number;
  132173. /**
  132174. * Defines the data length to load
  132175. */
  132176. readonly total: number;
  132177. }
  132178. /**
  132179. * Interface used by SceneLoader plugins to define supported file extensions
  132180. */
  132181. export interface ISceneLoaderPluginExtensions {
  132182. /**
  132183. * Defines the list of supported extensions
  132184. */
  132185. [extension: string]: {
  132186. isBinary: boolean;
  132187. };
  132188. }
  132189. /**
  132190. * Interface used by SceneLoader plugin factory
  132191. */
  132192. export interface ISceneLoaderPluginFactory {
  132193. /**
  132194. * Defines the name of the factory
  132195. */
  132196. name: string;
  132197. /**
  132198. * Function called to create a new plugin
  132199. * @return the new plugin
  132200. */
  132201. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  132202. /**
  132203. * The callback that returns true if the data can be directly loaded.
  132204. * @param data string containing the file data
  132205. * @returns if the data can be loaded directly
  132206. */
  132207. canDirectLoad?(data: string): boolean;
  132208. }
  132209. /**
  132210. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  132211. */
  132212. export interface ISceneLoaderPluginBase {
  132213. /**
  132214. * The friendly name of this plugin.
  132215. */
  132216. name: string;
  132217. /**
  132218. * The file extensions supported by this plugin.
  132219. */
  132220. extensions: string | ISceneLoaderPluginExtensions;
  132221. /**
  132222. * The callback called when loading from a url.
  132223. * @param scene scene loading this url
  132224. * @param url url to load
  132225. * @param onSuccess callback called when the file successfully loads
  132226. * @param onProgress callback called while file is loading (if the server supports this mode)
  132227. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  132228. * @param onError callback called when the file fails to load
  132229. * @returns a file request object
  132230. */
  132231. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132232. /**
  132233. * The callback called when loading from a file object.
  132234. * @param scene scene loading this file
  132235. * @param file defines the file to load
  132236. * @param onSuccess defines the callback to call when data is loaded
  132237. * @param onProgress defines the callback to call during loading process
  132238. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  132239. * @param onError defines the callback to call when an error occurs
  132240. * @returns a file request object
  132241. */
  132242. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132243. /**
  132244. * The callback that returns true if the data can be directly loaded.
  132245. * @param data string containing the file data
  132246. * @returns if the data can be loaded directly
  132247. */
  132248. canDirectLoad?(data: string): boolean;
  132249. /**
  132250. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  132251. * @param scene scene loading this data
  132252. * @param data string containing the data
  132253. * @returns data to pass to the plugin
  132254. */
  132255. directLoad?(scene: Scene, data: string): any;
  132256. /**
  132257. * The callback that allows custom handling of the root url based on the response url.
  132258. * @param rootUrl the original root url
  132259. * @param responseURL the response url if available
  132260. * @returns the new root url
  132261. */
  132262. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  132263. }
  132264. /**
  132265. * Interface used to define a SceneLoader plugin
  132266. */
  132267. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  132268. /**
  132269. * Import meshes into a scene.
  132270. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132271. * @param scene The scene to import into
  132272. * @param data The data to import
  132273. * @param rootUrl The root url for scene and resources
  132274. * @param meshes The meshes array to import into
  132275. * @param particleSystems The particle systems array to import into
  132276. * @param skeletons The skeletons array to import into
  132277. * @param onError The callback when import fails
  132278. * @returns True if successful or false otherwise
  132279. */
  132280. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  132281. /**
  132282. * Load into a scene.
  132283. * @param scene The scene to load into
  132284. * @param data The data to import
  132285. * @param rootUrl The root url for scene and resources
  132286. * @param onError The callback when import fails
  132287. * @returns True if successful or false otherwise
  132288. */
  132289. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  132290. /**
  132291. * Load into an asset container.
  132292. * @param scene The scene to load into
  132293. * @param data The data to import
  132294. * @param rootUrl The root url for scene and resources
  132295. * @param onError The callback when import fails
  132296. * @returns The loaded asset container
  132297. */
  132298. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  132299. }
  132300. /**
  132301. * Interface used to define an async SceneLoader plugin
  132302. */
  132303. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  132304. /**
  132305. * Import meshes into a scene.
  132306. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132307. * @param scene The scene to import into
  132308. * @param data The data to import
  132309. * @param rootUrl The root url for scene and resources
  132310. * @param onProgress The callback when the load progresses
  132311. * @param fileName Defines the name of the file to load
  132312. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  132313. */
  132314. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  132315. meshes: AbstractMesh[];
  132316. particleSystems: IParticleSystem[];
  132317. skeletons: Skeleton[];
  132318. animationGroups: AnimationGroup[];
  132319. }>;
  132320. /**
  132321. * Load into a scene.
  132322. * @param scene The scene to load into
  132323. * @param data The data to import
  132324. * @param rootUrl The root url for scene and resources
  132325. * @param onProgress The callback when the load progresses
  132326. * @param fileName Defines the name of the file to load
  132327. * @returns Nothing
  132328. */
  132329. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  132330. /**
  132331. * Load into an asset container.
  132332. * @param scene The scene to load into
  132333. * @param data The data to import
  132334. * @param rootUrl The root url for scene and resources
  132335. * @param onProgress The callback when the load progresses
  132336. * @param fileName Defines the name of the file to load
  132337. * @returns The loaded asset container
  132338. */
  132339. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  132340. }
  132341. /**
  132342. * Mode that determines how to handle old animation groups before loading new ones.
  132343. */
  132344. export enum SceneLoaderAnimationGroupLoadingMode {
  132345. /**
  132346. * Reset all old animations to initial state then dispose them.
  132347. */
  132348. Clean = 0,
  132349. /**
  132350. * Stop all old animations.
  132351. */
  132352. Stop = 1,
  132353. /**
  132354. * Restart old animations from first frame.
  132355. */
  132356. Sync = 2,
  132357. /**
  132358. * Old animations remains untouched.
  132359. */
  132360. NoSync = 3
  132361. }
  132362. /**
  132363. * Defines a plugin registered by the SceneLoader
  132364. */
  132365. interface IRegisteredPlugin {
  132366. /**
  132367. * Defines the plugin to use
  132368. */
  132369. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  132370. /**
  132371. * Defines if the plugin supports binary data
  132372. */
  132373. isBinary: boolean;
  132374. }
  132375. /**
  132376. * Class used to load scene from various file formats using registered plugins
  132377. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  132378. */
  132379. export class SceneLoader {
  132380. /**
  132381. * No logging while loading
  132382. */
  132383. static readonly NO_LOGGING: number;
  132384. /**
  132385. * Minimal logging while loading
  132386. */
  132387. static readonly MINIMAL_LOGGING: number;
  132388. /**
  132389. * Summary logging while loading
  132390. */
  132391. static readonly SUMMARY_LOGGING: number;
  132392. /**
  132393. * Detailled logging while loading
  132394. */
  132395. static readonly DETAILED_LOGGING: number;
  132396. /**
  132397. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  132398. */
  132399. static get ForceFullSceneLoadingForIncremental(): boolean;
  132400. static set ForceFullSceneLoadingForIncremental(value: boolean);
  132401. /**
  132402. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  132403. */
  132404. static get ShowLoadingScreen(): boolean;
  132405. static set ShowLoadingScreen(value: boolean);
  132406. /**
  132407. * Defines the current logging level (while loading the scene)
  132408. * @ignorenaming
  132409. */
  132410. static get loggingLevel(): number;
  132411. static set loggingLevel(value: number);
  132412. /**
  132413. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  132414. */
  132415. static get CleanBoneMatrixWeights(): boolean;
  132416. static set CleanBoneMatrixWeights(value: boolean);
  132417. /**
  132418. * Event raised when a plugin is used to load a scene
  132419. */
  132420. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  132421. private static _registeredPlugins;
  132422. private static _showingLoadingScreen;
  132423. /**
  132424. * Gets the default plugin (used to load Babylon files)
  132425. * @returns the .babylon plugin
  132426. */
  132427. static GetDefaultPlugin(): IRegisteredPlugin;
  132428. private static _GetPluginForExtension;
  132429. private static _GetPluginForDirectLoad;
  132430. private static _GetPluginForFilename;
  132431. private static _GetDirectLoad;
  132432. private static _LoadData;
  132433. private static _GetFileInfo;
  132434. /**
  132435. * Gets a plugin that can load the given extension
  132436. * @param extension defines the extension to load
  132437. * @returns a plugin or null if none works
  132438. */
  132439. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  132440. /**
  132441. * Gets a boolean indicating that the given extension can be loaded
  132442. * @param extension defines the extension to load
  132443. * @returns true if the extension is supported
  132444. */
  132445. static IsPluginForExtensionAvailable(extension: string): boolean;
  132446. /**
  132447. * Adds a new plugin to the list of registered plugins
  132448. * @param plugin defines the plugin to add
  132449. */
  132450. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  132451. /**
  132452. * Import meshes into a scene
  132453. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132454. * @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)
  132455. * @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)
  132456. * @param scene the instance of BABYLON.Scene to append to
  132457. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  132458. * @param onProgress a callback with a progress event for each file being loaded
  132459. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132460. * @param pluginExtension the extension used to determine the plugin
  132461. * @returns The loaded plugin
  132462. */
  132463. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  132464. /**
  132465. * Import meshes into a scene
  132466. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132467. * @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)
  132468. * @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)
  132469. * @param scene the instance of BABYLON.Scene to append to
  132470. * @param onProgress a callback with a progress event for each file being loaded
  132471. * @param pluginExtension the extension used to determine the plugin
  132472. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  132473. */
  132474. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  132475. meshes: AbstractMesh[];
  132476. particleSystems: IParticleSystem[];
  132477. skeletons: Skeleton[];
  132478. animationGroups: AnimationGroup[];
  132479. }>;
  132480. /**
  132481. * Load a scene
  132482. * @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)
  132483. * @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)
  132484. * @param engine is the instance of BABYLON.Engine to use to create the scene
  132485. * @param onSuccess a callback with the scene when import succeeds
  132486. * @param onProgress a callback with a progress event for each file being loaded
  132487. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132488. * @param pluginExtension the extension used to determine the plugin
  132489. * @returns The loaded plugin
  132490. */
  132491. 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>;
  132492. /**
  132493. * Load a scene
  132494. * @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)
  132495. * @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)
  132496. * @param engine is the instance of BABYLON.Engine to use to create the scene
  132497. * @param onProgress a callback with a progress event for each file being loaded
  132498. * @param pluginExtension the extension used to determine the plugin
  132499. * @returns The loaded scene
  132500. */
  132501. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  132502. /**
  132503. * Append a scene
  132504. * @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)
  132505. * @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)
  132506. * @param scene is the instance of BABYLON.Scene to append to
  132507. * @param onSuccess a callback with the scene when import succeeds
  132508. * @param onProgress a callback with a progress event for each file being loaded
  132509. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132510. * @param pluginExtension the extension used to determine the plugin
  132511. * @returns The loaded plugin
  132512. */
  132513. 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>;
  132514. /**
  132515. * Append a scene
  132516. * @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)
  132517. * @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)
  132518. * @param scene is the instance of BABYLON.Scene to append to
  132519. * @param onProgress a callback with a progress event for each file being loaded
  132520. * @param pluginExtension the extension used to determine the plugin
  132521. * @returns The given scene
  132522. */
  132523. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  132524. /**
  132525. * Load a scene into an asset container
  132526. * @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)
  132527. * @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)
  132528. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132529. * @param onSuccess a callback with the scene when import succeeds
  132530. * @param onProgress a callback with a progress event for each file being loaded
  132531. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132532. * @param pluginExtension the extension used to determine the plugin
  132533. * @returns The loaded plugin
  132534. */
  132535. 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>;
  132536. /**
  132537. * Load a scene into an asset container
  132538. * @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)
  132539. * @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)
  132540. * @param scene is the instance of Scene to append to
  132541. * @param onProgress a callback with a progress event for each file being loaded
  132542. * @param pluginExtension the extension used to determine the plugin
  132543. * @returns The loaded asset container
  132544. */
  132545. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  132546. /**
  132547. * Import animations from a file into a scene
  132548. * @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)
  132549. * @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)
  132550. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132551. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  132552. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  132553. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  132554. * @param onSuccess a callback with the scene when import succeeds
  132555. * @param onProgress a callback with a progress event for each file being loaded
  132556. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132557. * @param pluginExtension the extension used to determine the plugin
  132558. */
  132559. 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;
  132560. /**
  132561. * Import animations from a file into a scene
  132562. * @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)
  132563. * @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)
  132564. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132565. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  132566. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  132567. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  132568. * @param onSuccess a callback with the scene when import succeeds
  132569. * @param onProgress a callback with a progress event for each file being loaded
  132570. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132571. * @param pluginExtension the extension used to determine the plugin
  132572. * @returns the updated scene with imported animations
  132573. */
  132574. 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>;
  132575. }
  132576. }
  132577. declare module BABYLON {
  132578. /**
  132579. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  132580. */
  132581. export type MotionControllerHandedness = "none" | "left" | "right";
  132582. /**
  132583. * The type of components available in motion controllers.
  132584. * This is not the name of the component.
  132585. */
  132586. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  132587. /**
  132588. * The state of a controller component
  132589. */
  132590. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  132591. /**
  132592. * The schema of motion controller layout.
  132593. * No object will be initialized using this interface
  132594. * This is used just to define the profile.
  132595. */
  132596. export interface IMotionControllerLayout {
  132597. /**
  132598. * Path to load the assets. Usually relative to the base path
  132599. */
  132600. assetPath: string;
  132601. /**
  132602. * Available components (unsorted)
  132603. */
  132604. components: {
  132605. /**
  132606. * A map of component Ids
  132607. */
  132608. [componentId: string]: {
  132609. /**
  132610. * The type of input the component outputs
  132611. */
  132612. type: MotionControllerComponentType;
  132613. /**
  132614. * The indices of this component in the gamepad object
  132615. */
  132616. gamepadIndices: {
  132617. /**
  132618. * Index of button
  132619. */
  132620. button?: number;
  132621. /**
  132622. * If available, index of x-axis
  132623. */
  132624. xAxis?: number;
  132625. /**
  132626. * If available, index of y-axis
  132627. */
  132628. yAxis?: number;
  132629. };
  132630. /**
  132631. * The mesh's root node name
  132632. */
  132633. rootNodeName: string;
  132634. /**
  132635. * Animation definitions for this model
  132636. */
  132637. visualResponses: {
  132638. [stateKey: string]: {
  132639. /**
  132640. * What property will be animated
  132641. */
  132642. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  132643. /**
  132644. * What states influence this visual response
  132645. */
  132646. states: MotionControllerComponentStateType[];
  132647. /**
  132648. * Type of animation - movement or visibility
  132649. */
  132650. valueNodeProperty: "transform" | "visibility";
  132651. /**
  132652. * Base node name to move. Its position will be calculated according to the min and max nodes
  132653. */
  132654. valueNodeName?: string;
  132655. /**
  132656. * Minimum movement node
  132657. */
  132658. minNodeName?: string;
  132659. /**
  132660. * Max movement node
  132661. */
  132662. maxNodeName?: string;
  132663. };
  132664. };
  132665. /**
  132666. * If touch enabled, what is the name of node to display user feedback
  132667. */
  132668. touchPointNodeName?: string;
  132669. };
  132670. };
  132671. /**
  132672. * Is it xr standard mapping or not
  132673. */
  132674. gamepadMapping: "" | "xr-standard";
  132675. /**
  132676. * Base root node of this entire model
  132677. */
  132678. rootNodeName: string;
  132679. /**
  132680. * Defines the main button component id
  132681. */
  132682. selectComponentId: string;
  132683. }
  132684. /**
  132685. * A definition for the layout map in the input profile
  132686. */
  132687. export interface IMotionControllerLayoutMap {
  132688. /**
  132689. * Layouts with handedness type as a key
  132690. */
  132691. [handedness: string]: IMotionControllerLayout;
  132692. }
  132693. /**
  132694. * The XR Input profile schema
  132695. * Profiles can be found here:
  132696. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  132697. */
  132698. export interface IMotionControllerProfile {
  132699. /**
  132700. * fallback profiles for this profileId
  132701. */
  132702. fallbackProfileIds: string[];
  132703. /**
  132704. * The layout map, with handedness as key
  132705. */
  132706. layouts: IMotionControllerLayoutMap;
  132707. /**
  132708. * The id of this profile
  132709. * correlates to the profile(s) in the xrInput.profiles array
  132710. */
  132711. profileId: string;
  132712. }
  132713. /**
  132714. * A helper-interface for the 3 meshes needed for controller button animation
  132715. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  132716. */
  132717. export interface IMotionControllerButtonMeshMap {
  132718. /**
  132719. * the mesh that defines the pressed value mesh position.
  132720. * This is used to find the max-position of this button
  132721. */
  132722. pressedMesh: AbstractMesh;
  132723. /**
  132724. * the mesh that defines the unpressed value mesh position.
  132725. * This is used to find the min (or initial) position of this button
  132726. */
  132727. unpressedMesh: AbstractMesh;
  132728. /**
  132729. * The mesh that will be changed when value changes
  132730. */
  132731. valueMesh: AbstractMesh;
  132732. }
  132733. /**
  132734. * A helper-interface for the 3 meshes needed for controller axis animation.
  132735. * This will be expanded when touchpad animations are fully supported
  132736. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  132737. */
  132738. export interface IMotionControllerMeshMap {
  132739. /**
  132740. * the mesh that defines the maximum value mesh position.
  132741. */
  132742. maxMesh?: AbstractMesh;
  132743. /**
  132744. * the mesh that defines the minimum value mesh position.
  132745. */
  132746. minMesh?: AbstractMesh;
  132747. /**
  132748. * The mesh that will be changed when axis value changes
  132749. */
  132750. valueMesh?: AbstractMesh;
  132751. }
  132752. /**
  132753. * The elements needed for change-detection of the gamepad objects in motion controllers
  132754. */
  132755. export interface IMinimalMotionControllerObject {
  132756. /**
  132757. * Available axes of this controller
  132758. */
  132759. axes: number[];
  132760. /**
  132761. * An array of available buttons
  132762. */
  132763. buttons: Array<{
  132764. /**
  132765. * Value of the button/trigger
  132766. */
  132767. value: number;
  132768. /**
  132769. * If the button/trigger is currently touched
  132770. */
  132771. touched: boolean;
  132772. /**
  132773. * If the button/trigger is currently pressed
  132774. */
  132775. pressed: boolean;
  132776. }>;
  132777. /**
  132778. * EXPERIMENTAL haptic support.
  132779. */
  132780. hapticActuators?: Array<{
  132781. pulse: (value: number, duration: number) => Promise<boolean>;
  132782. }>;
  132783. }
  132784. /**
  132785. * An Abstract Motion controller
  132786. * This class receives an xrInput and a profile layout and uses those to initialize the components
  132787. * Each component has an observable to check for changes in value and state
  132788. */
  132789. export abstract class WebXRAbstractMotionController implements IDisposable {
  132790. protected scene: Scene;
  132791. protected layout: IMotionControllerLayout;
  132792. /**
  132793. * The gamepad object correlating to this controller
  132794. */
  132795. gamepadObject: IMinimalMotionControllerObject;
  132796. /**
  132797. * handedness (left/right/none) of this controller
  132798. */
  132799. handedness: MotionControllerHandedness;
  132800. private _initComponent;
  132801. private _modelReady;
  132802. /**
  132803. * A map of components (WebXRControllerComponent) in this motion controller
  132804. * Components have a ComponentType and can also have both button and axis definitions
  132805. */
  132806. readonly components: {
  132807. [id: string]: WebXRControllerComponent;
  132808. };
  132809. /**
  132810. * Disable the model's animation. Can be set at any time.
  132811. */
  132812. disableAnimation: boolean;
  132813. /**
  132814. * Observers registered here will be triggered when the model of this controller is done loading
  132815. */
  132816. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  132817. /**
  132818. * The profile id of this motion controller
  132819. */
  132820. abstract profileId: string;
  132821. /**
  132822. * The root mesh of the model. It is null if the model was not yet initialized
  132823. */
  132824. rootMesh: Nullable<AbstractMesh>;
  132825. /**
  132826. * constructs a new abstract motion controller
  132827. * @param scene the scene to which the model of the controller will be added
  132828. * @param layout The profile layout to load
  132829. * @param gamepadObject The gamepad object correlating to this controller
  132830. * @param handedness handedness (left/right/none) of this controller
  132831. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  132832. */
  132833. constructor(scene: Scene, layout: IMotionControllerLayout,
  132834. /**
  132835. * The gamepad object correlating to this controller
  132836. */
  132837. gamepadObject: IMinimalMotionControllerObject,
  132838. /**
  132839. * handedness (left/right/none) of this controller
  132840. */
  132841. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  132842. /**
  132843. * Dispose this controller, the model mesh and all its components
  132844. */
  132845. dispose(): void;
  132846. /**
  132847. * Returns all components of specific type
  132848. * @param type the type to search for
  132849. * @return an array of components with this type
  132850. */
  132851. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  132852. /**
  132853. * get a component based an its component id as defined in layout.components
  132854. * @param id the id of the component
  132855. * @returns the component correlates to the id or undefined if not found
  132856. */
  132857. getComponent(id: string): WebXRControllerComponent;
  132858. /**
  132859. * Get the list of components available in this motion controller
  132860. * @returns an array of strings correlating to available components
  132861. */
  132862. getComponentIds(): string[];
  132863. /**
  132864. * Get the first component of specific type
  132865. * @param type type of component to find
  132866. * @return a controller component or null if not found
  132867. */
  132868. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  132869. /**
  132870. * Get the main (Select) component of this controller as defined in the layout
  132871. * @returns the main component of this controller
  132872. */
  132873. getMainComponent(): WebXRControllerComponent;
  132874. /**
  132875. * Loads the model correlating to this controller
  132876. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  132877. * @returns A promise fulfilled with the result of the model loading
  132878. */
  132879. loadModel(): Promise<boolean>;
  132880. /**
  132881. * Update this model using the current XRFrame
  132882. * @param xrFrame the current xr frame to use and update the model
  132883. */
  132884. updateFromXRFrame(xrFrame: XRFrame): void;
  132885. /**
  132886. * Backwards compatibility due to a deeply-integrated typo
  132887. */
  132888. get handness(): XREye;
  132889. /**
  132890. * Pulse (vibrate) this controller
  132891. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  132892. * Consecutive calls to this function will cancel the last pulse call
  132893. *
  132894. * @param value the strength of the pulse in 0.0...1.0 range
  132895. * @param duration Duration of the pulse in milliseconds
  132896. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  132897. * @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
  132898. */
  132899. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  132900. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132901. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132902. /**
  132903. * Moves the axis on the controller mesh based on its current state
  132904. * @param axis the index of the axis
  132905. * @param axisValue the value of the axis which determines the meshes new position
  132906. * @hidden
  132907. */
  132908. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  132909. /**
  132910. * Update the model itself with the current frame data
  132911. * @param xrFrame the frame to use for updating the model mesh
  132912. */
  132913. protected updateModel(xrFrame: XRFrame): void;
  132914. /**
  132915. * Get the filename and path for this controller's model
  132916. * @returns a map of filename and path
  132917. */
  132918. protected abstract _getFilenameAndPath(): {
  132919. filename: string;
  132920. path: string;
  132921. };
  132922. /**
  132923. * This function is called before the mesh is loaded. It checks for loading constraints.
  132924. * For example, this function can check if the GLB loader is available
  132925. * If this function returns false, the generic controller will be loaded instead
  132926. * @returns Is the client ready to load the mesh
  132927. */
  132928. protected abstract _getModelLoadingConstraints(): boolean;
  132929. /**
  132930. * This function will be called after the model was successfully loaded and can be used
  132931. * for mesh transformations before it is available for the user
  132932. * @param meshes the loaded meshes
  132933. */
  132934. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  132935. /**
  132936. * Set the root mesh for this controller. Important for the WebXR controller class
  132937. * @param meshes the loaded meshes
  132938. */
  132939. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  132940. /**
  132941. * A function executed each frame that updates the mesh (if needed)
  132942. * @param xrFrame the current xrFrame
  132943. */
  132944. protected abstract _updateModel(xrFrame: XRFrame): void;
  132945. private _getGenericFilenameAndPath;
  132946. private _getGenericParentMesh;
  132947. }
  132948. }
  132949. declare module BABYLON {
  132950. /**
  132951. * A generic trigger-only motion controller for WebXR
  132952. */
  132953. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  132954. /**
  132955. * Static version of the profile id of this controller
  132956. */
  132957. static ProfileId: string;
  132958. profileId: string;
  132959. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  132960. protected _getFilenameAndPath(): {
  132961. filename: string;
  132962. path: string;
  132963. };
  132964. protected _getModelLoadingConstraints(): boolean;
  132965. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  132966. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132967. protected _updateModel(): void;
  132968. }
  132969. }
  132970. declare module BABYLON {
  132971. /**
  132972. * Class containing static functions to help procedurally build meshes
  132973. */
  132974. export class SphereBuilder {
  132975. /**
  132976. * Creates a sphere mesh
  132977. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  132978. * * 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`)
  132979. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  132980. * * 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
  132981. * * 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)
  132982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132985. * @param name defines the name of the mesh
  132986. * @param options defines the options used to create the mesh
  132987. * @param scene defines the hosting scene
  132988. * @returns the sphere mesh
  132989. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  132990. */
  132991. static CreateSphere(name: string, options: {
  132992. segments?: number;
  132993. diameter?: number;
  132994. diameterX?: number;
  132995. diameterY?: number;
  132996. diameterZ?: number;
  132997. arc?: number;
  132998. slice?: number;
  132999. sideOrientation?: number;
  133000. frontUVs?: Vector4;
  133001. backUVs?: Vector4;
  133002. updatable?: boolean;
  133003. }, scene?: Nullable<Scene>): Mesh;
  133004. }
  133005. }
  133006. declare module BABYLON {
  133007. /**
  133008. * A profiled motion controller has its profile loaded from an online repository.
  133009. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  133010. */
  133011. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  133012. private _repositoryUrl;
  133013. private _buttonMeshMapping;
  133014. private _touchDots;
  133015. /**
  133016. * The profile ID of this controller. Will be populated when the controller initializes.
  133017. */
  133018. profileId: string;
  133019. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  133020. dispose(): void;
  133021. protected _getFilenameAndPath(): {
  133022. filename: string;
  133023. path: string;
  133024. };
  133025. protected _getModelLoadingConstraints(): boolean;
  133026. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  133027. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133028. protected _updateModel(_xrFrame: XRFrame): void;
  133029. }
  133030. }
  133031. declare module BABYLON {
  133032. /**
  133033. * A construction function type to create a new controller based on an xrInput object
  133034. */
  133035. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  133036. /**
  133037. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  133038. *
  133039. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  133040. * it should be replaced with auto-loaded controllers.
  133041. *
  133042. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  133043. */
  133044. export class WebXRMotionControllerManager {
  133045. private static _AvailableControllers;
  133046. private static _Fallbacks;
  133047. private static _ProfileLoadingPromises;
  133048. private static _ProfilesList;
  133049. /**
  133050. * The base URL of the online controller repository. Can be changed at any time.
  133051. */
  133052. static BaseRepositoryUrl: string;
  133053. /**
  133054. * Which repository gets priority - local or online
  133055. */
  133056. static PrioritizeOnlineRepository: boolean;
  133057. /**
  133058. * Use the online repository, or use only locally-defined controllers
  133059. */
  133060. static UseOnlineRepository: boolean;
  133061. /**
  133062. * Clear the cache used for profile loading and reload when requested again
  133063. */
  133064. static ClearProfilesCache(): void;
  133065. /**
  133066. * Register the default fallbacks.
  133067. * This function is called automatically when this file is imported.
  133068. */
  133069. static DefaultFallbacks(): void;
  133070. /**
  133071. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  133072. * @param profileId the profile to which a fallback needs to be found
  133073. * @return an array with corresponding fallback profiles
  133074. */
  133075. static FindFallbackWithProfileId(profileId: string): string[];
  133076. /**
  133077. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  133078. * The order of search:
  133079. *
  133080. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  133081. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  133082. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  133083. * 4) return the generic trigger controller if none were found
  133084. *
  133085. * @param xrInput the xrInput to which a new controller is initialized
  133086. * @param scene the scene to which the model will be added
  133087. * @param forceProfile force a certain profile for this controller
  133088. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  133089. */
  133090. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  133091. /**
  133092. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  133093. *
  133094. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  133095. *
  133096. * @param type the profile type to register
  133097. * @param constructFunction the function to be called when loading this profile
  133098. */
  133099. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  133100. /**
  133101. * Register a fallback to a specific profile.
  133102. * @param profileId the profileId that will receive the fallbacks
  133103. * @param fallbacks A list of fallback profiles
  133104. */
  133105. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  133106. /**
  133107. * Will update the list of profiles available in the repository
  133108. * @return a promise that resolves to a map of profiles available online
  133109. */
  133110. static UpdateProfilesList(): Promise<{
  133111. [profile: string]: string;
  133112. }>;
  133113. private static _LoadProfileFromRepository;
  133114. private static _LoadProfilesFromAvailableControllers;
  133115. }
  133116. }
  133117. declare module BABYLON {
  133118. /**
  133119. * Configuration options for the WebXR controller creation
  133120. */
  133121. export interface IWebXRControllerOptions {
  133122. /**
  133123. * Should the controller mesh be animated when a user interacts with it
  133124. * The pressed buttons / thumbstick and touchpad animations will be disabled
  133125. */
  133126. disableMotionControllerAnimation?: boolean;
  133127. /**
  133128. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  133129. */
  133130. doNotLoadControllerMesh?: boolean;
  133131. /**
  133132. * Force a specific controller type for this controller.
  133133. * This can be used when creating your own profile or when testing different controllers
  133134. */
  133135. forceControllerProfile?: string;
  133136. /**
  133137. * Defines a rendering group ID for meshes that will be loaded.
  133138. * This is for the default controllers only.
  133139. */
  133140. renderingGroupId?: number;
  133141. }
  133142. /**
  133143. * Represents an XR controller
  133144. */
  133145. export class WebXRInputSource {
  133146. private _scene;
  133147. /** The underlying input source for the controller */
  133148. inputSource: XRInputSource;
  133149. private _options;
  133150. private _tmpVector;
  133151. private _uniqueId;
  133152. private _disposed;
  133153. /**
  133154. * 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
  133155. */
  133156. grip?: AbstractMesh;
  133157. /**
  133158. * If available, this is the gamepad object related to this controller.
  133159. * Using this object it is possible to get click events and trackpad changes of the
  133160. * webxr controller that is currently being used.
  133161. */
  133162. motionController?: WebXRAbstractMotionController;
  133163. /**
  133164. * Event that fires when the controller is removed/disposed.
  133165. * The object provided as event data is this controller, after associated assets were disposed.
  133166. * uniqueId is still available.
  133167. */
  133168. onDisposeObservable: Observable<WebXRInputSource>;
  133169. /**
  133170. * Will be triggered when the mesh associated with the motion controller is done loading.
  133171. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  133172. * A shortened version of controller -> motion controller -> on mesh loaded.
  133173. */
  133174. onMeshLoadedObservable: Observable<AbstractMesh>;
  133175. /**
  133176. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  133177. */
  133178. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  133179. /**
  133180. * Pointer which can be used to select objects or attach a visible laser to
  133181. */
  133182. pointer: AbstractMesh;
  133183. /**
  133184. * Creates the input source object
  133185. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  133186. * @param _scene the scene which the controller should be associated to
  133187. * @param inputSource the underlying input source for the controller
  133188. * @param _options options for this controller creation
  133189. */
  133190. constructor(_scene: Scene,
  133191. /** The underlying input source for the controller */
  133192. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  133193. /**
  133194. * Get this controllers unique id
  133195. */
  133196. get uniqueId(): string;
  133197. /**
  133198. * Disposes of the object
  133199. */
  133200. dispose(): void;
  133201. /**
  133202. * Gets a world space ray coming from the pointer or grip
  133203. * @param result the resulting ray
  133204. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  133205. */
  133206. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  133207. /**
  133208. * Updates the controller pose based on the given XRFrame
  133209. * @param xrFrame xr frame to update the pose with
  133210. * @param referenceSpace reference space to use
  133211. */
  133212. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  133213. }
  133214. }
  133215. declare module BABYLON {
  133216. /**
  133217. * The schema for initialization options of the XR Input class
  133218. */
  133219. export interface IWebXRInputOptions {
  133220. /**
  133221. * If set to true no model will be automatically loaded
  133222. */
  133223. doNotLoadControllerMeshes?: boolean;
  133224. /**
  133225. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  133226. * If not found, the xr input profile data will be used.
  133227. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  133228. */
  133229. forceInputProfile?: string;
  133230. /**
  133231. * Do not send a request to the controller repository to load the profile.
  133232. *
  133233. * Instead, use the controllers available in babylon itself.
  133234. */
  133235. disableOnlineControllerRepository?: boolean;
  133236. /**
  133237. * A custom URL for the controllers repository
  133238. */
  133239. customControllersRepositoryURL?: string;
  133240. /**
  133241. * Should the controller model's components not move according to the user input
  133242. */
  133243. disableControllerAnimation?: boolean;
  133244. /**
  133245. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  133246. */
  133247. controllerOptions?: IWebXRControllerOptions;
  133248. }
  133249. /**
  133250. * XR input used to track XR inputs such as controllers/rays
  133251. */
  133252. export class WebXRInput implements IDisposable {
  133253. /**
  133254. * the xr session manager for this session
  133255. */
  133256. xrSessionManager: WebXRSessionManager;
  133257. /**
  133258. * the WebXR camera for this session. Mainly used for teleportation
  133259. */
  133260. xrCamera: WebXRCamera;
  133261. private readonly options;
  133262. /**
  133263. * XR controllers being tracked
  133264. */
  133265. controllers: Array<WebXRInputSource>;
  133266. private _frameObserver;
  133267. private _sessionEndedObserver;
  133268. private _sessionInitObserver;
  133269. /**
  133270. * Event when a controller has been connected/added
  133271. */
  133272. onControllerAddedObservable: Observable<WebXRInputSource>;
  133273. /**
  133274. * Event when a controller has been removed/disconnected
  133275. */
  133276. onControllerRemovedObservable: Observable<WebXRInputSource>;
  133277. /**
  133278. * Initializes the WebXRInput
  133279. * @param xrSessionManager the xr session manager for this session
  133280. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  133281. * @param options = initialization options for this xr input
  133282. */
  133283. constructor(
  133284. /**
  133285. * the xr session manager for this session
  133286. */
  133287. xrSessionManager: WebXRSessionManager,
  133288. /**
  133289. * the WebXR camera for this session. Mainly used for teleportation
  133290. */
  133291. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  133292. private _onInputSourcesChange;
  133293. private _addAndRemoveControllers;
  133294. /**
  133295. * Disposes of the object
  133296. */
  133297. dispose(): void;
  133298. }
  133299. }
  133300. declare module BABYLON {
  133301. /**
  133302. * This is the base class for all WebXR features.
  133303. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  133304. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  133305. */
  133306. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  133307. protected _xrSessionManager: WebXRSessionManager;
  133308. private _attached;
  133309. private _removeOnDetach;
  133310. /**
  133311. * Is this feature disposed?
  133312. */
  133313. isDisposed: boolean;
  133314. /**
  133315. * Should auto-attach be disabled?
  133316. */
  133317. disableAutoAttach: boolean;
  133318. /**
  133319. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  133320. */
  133321. xrNativeFeatureName: string;
  133322. /**
  133323. * Construct a new (abstract) WebXR feature
  133324. * @param _xrSessionManager the xr session manager for this feature
  133325. */
  133326. constructor(_xrSessionManager: WebXRSessionManager);
  133327. /**
  133328. * Is this feature attached
  133329. */
  133330. get attached(): boolean;
  133331. /**
  133332. * attach this feature
  133333. *
  133334. * @param force should attachment be forced (even when already attached)
  133335. * @returns true if successful, false is failed or already attached
  133336. */
  133337. attach(force?: boolean): boolean;
  133338. /**
  133339. * detach this feature.
  133340. *
  133341. * @returns true if successful, false if failed or already detached
  133342. */
  133343. detach(): boolean;
  133344. /**
  133345. * Dispose this feature and all of the resources attached
  133346. */
  133347. dispose(): void;
  133348. /**
  133349. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  133350. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  133351. *
  133352. * @returns whether or not the feature is compatible in this environment
  133353. */
  133354. isCompatible(): boolean;
  133355. /**
  133356. * This is used to register callbacks that will automatically be removed when detach is called.
  133357. * @param observable the observable to which the observer will be attached
  133358. * @param callback the callback to register
  133359. */
  133360. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  133361. /**
  133362. * Code in this function will be executed on each xrFrame received from the browser.
  133363. * This function will not execute after the feature is detached.
  133364. * @param _xrFrame the current frame
  133365. */
  133366. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  133367. }
  133368. }
  133369. declare module BABYLON {
  133370. /**
  133371. * Renders a layer on top of an existing scene
  133372. */
  133373. export class UtilityLayerRenderer implements IDisposable {
  133374. /** the original scene that will be rendered on top of */
  133375. originalScene: Scene;
  133376. private _pointerCaptures;
  133377. private _lastPointerEvents;
  133378. private static _DefaultUtilityLayer;
  133379. private static _DefaultKeepDepthUtilityLayer;
  133380. private _sharedGizmoLight;
  133381. private _renderCamera;
  133382. /**
  133383. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  133384. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  133385. * @returns the camera that is used when rendering the utility layer
  133386. */
  133387. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  133388. /**
  133389. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  133390. * @param cam the camera that should be used when rendering the utility layer
  133391. */
  133392. setRenderCamera(cam: Nullable<Camera>): void;
  133393. /**
  133394. * @hidden
  133395. * Light which used by gizmos to get light shading
  133396. */
  133397. _getSharedGizmoLight(): HemisphericLight;
  133398. /**
  133399. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  133400. */
  133401. pickUtilitySceneFirst: boolean;
  133402. /**
  133403. * 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)
  133404. */
  133405. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  133406. /**
  133407. * 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)
  133408. */
  133409. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  133410. /**
  133411. * The scene that is rendered on top of the original scene
  133412. */
  133413. utilityLayerScene: Scene;
  133414. /**
  133415. * If the utility layer should automatically be rendered on top of existing scene
  133416. */
  133417. shouldRender: boolean;
  133418. /**
  133419. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  133420. */
  133421. onlyCheckPointerDownEvents: boolean;
  133422. /**
  133423. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  133424. */
  133425. processAllEvents: boolean;
  133426. /**
  133427. * Observable raised when the pointer move from the utility layer scene to the main scene
  133428. */
  133429. onPointerOutObservable: Observable<number>;
  133430. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  133431. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  133432. private _afterRenderObserver;
  133433. private _sceneDisposeObserver;
  133434. private _originalPointerObserver;
  133435. /**
  133436. * Instantiates a UtilityLayerRenderer
  133437. * @param originalScene the original scene that will be rendered on top of
  133438. * @param handleEvents boolean indicating if the utility layer should handle events
  133439. */
  133440. constructor(
  133441. /** the original scene that will be rendered on top of */
  133442. originalScene: Scene, handleEvents?: boolean);
  133443. private _notifyObservers;
  133444. /**
  133445. * Renders the utility layers scene on top of the original scene
  133446. */
  133447. render(): void;
  133448. /**
  133449. * Disposes of the renderer
  133450. */
  133451. dispose(): void;
  133452. private _updateCamera;
  133453. }
  133454. }
  133455. declare module BABYLON {
  133456. /**
  133457. * Options interface for the pointer selection module
  133458. */
  133459. export interface IWebXRControllerPointerSelectionOptions {
  133460. /**
  133461. * if provided, this scene will be used to render meshes.
  133462. */
  133463. customUtilityLayerScene?: Scene;
  133464. /**
  133465. * 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)
  133466. * If not disabled, the last picked point will be used to execute a pointer up event
  133467. * If disabled, pointer up event will be triggered right after the pointer down event.
  133468. * Used in screen and gaze target ray mode only
  133469. */
  133470. disablePointerUpOnTouchOut: boolean;
  133471. /**
  133472. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  133473. */
  133474. forceGazeMode: boolean;
  133475. /**
  133476. * 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
  133477. * to start a new countdown to the pointer down event.
  133478. * Defaults to 1.
  133479. */
  133480. gazeModePointerMovedFactor?: number;
  133481. /**
  133482. * Different button type to use instead of the main component
  133483. */
  133484. overrideButtonId?: string;
  133485. /**
  133486. * use this rendering group id for the meshes (optional)
  133487. */
  133488. renderingGroupId?: number;
  133489. /**
  133490. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  133491. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  133492. * 3000 means 3 seconds between pointing at something and selecting it
  133493. */
  133494. timeToSelect?: number;
  133495. /**
  133496. * Should meshes created here be added to a utility layer or the main scene
  133497. */
  133498. useUtilityLayer?: boolean;
  133499. /**
  133500. * Optional WebXR camera to be used for gaze selection
  133501. */
  133502. gazeCamera?: WebXRCamera;
  133503. /**
  133504. * the xr input to use with this pointer selection
  133505. */
  133506. xrInput: WebXRInput;
  133507. /**
  133508. * Should the scene pointerX and pointerY update be disabled
  133509. * This is required for fullscreen AR GUI, but might slow down other experiences.
  133510. * Disable in VR, if not needed.
  133511. * The first rig camera (left eye) will be used to calculate the projection
  133512. */
  133513. disableScenePointerVectorUpdate: boolean;
  133514. /**
  133515. * Enable pointer selection on all controllers instead of switching between them
  133516. */
  133517. enablePointerSelectionOnAllControllers?: boolean;
  133518. /**
  133519. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  133520. * If switch is enabled, it will still allow the user to switch between the different controllers
  133521. */
  133522. preferredHandedness?: XRHandedness;
  133523. /**
  133524. * Disable switching the pointer selection from one controller to the other.
  133525. * 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
  133526. */
  133527. disableSwitchOnClick?: boolean;
  133528. /**
  133529. * The maximum distance of the pointer selection feature. Defaults to 100.
  133530. */
  133531. maxPointerDistance?: number;
  133532. }
  133533. /**
  133534. * A module that will enable pointer selection for motion controllers of XR Input Sources
  133535. */
  133536. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  133537. private readonly _options;
  133538. private static _idCounter;
  133539. private _attachController;
  133540. private _controllers;
  133541. private _scene;
  133542. private _tmpVectorForPickCompare;
  133543. private _attachedController;
  133544. /**
  133545. * The module's name
  133546. */
  133547. static readonly Name: string;
  133548. /**
  133549. * The (Babylon) version of this module.
  133550. * This is an integer representing the implementation version.
  133551. * This number does not correspond to the WebXR specs version
  133552. */
  133553. static readonly Version: number;
  133554. /**
  133555. * Disable lighting on the laser pointer (so it will always be visible)
  133556. */
  133557. disablePointerLighting: boolean;
  133558. /**
  133559. * Disable lighting on the selection mesh (so it will always be visible)
  133560. */
  133561. disableSelectionMeshLighting: boolean;
  133562. /**
  133563. * Should the laser pointer be displayed
  133564. */
  133565. displayLaserPointer: boolean;
  133566. /**
  133567. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  133568. */
  133569. displaySelectionMesh: boolean;
  133570. /**
  133571. * This color will be set to the laser pointer when selection is triggered
  133572. */
  133573. laserPointerPickedColor: Color3;
  133574. /**
  133575. * Default color of the laser pointer
  133576. */
  133577. laserPointerDefaultColor: Color3;
  133578. /**
  133579. * default color of the selection ring
  133580. */
  133581. selectionMeshDefaultColor: Color3;
  133582. /**
  133583. * This color will be applied to the selection ring when selection is triggered
  133584. */
  133585. selectionMeshPickedColor: Color3;
  133586. /**
  133587. * Optional filter to be used for ray selection. This predicate shares behavior with
  133588. * scene.pointerMovePredicate which takes priority if it is also assigned.
  133589. */
  133590. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  133591. /**
  133592. * constructs a new background remover module
  133593. * @param _xrSessionManager the session manager for this module
  133594. * @param _options read-only options to be used in this module
  133595. */
  133596. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  133597. /**
  133598. * attach this feature
  133599. * Will usually be called by the features manager
  133600. *
  133601. * @returns true if successful.
  133602. */
  133603. attach(): boolean;
  133604. /**
  133605. * detach this feature.
  133606. * Will usually be called by the features manager
  133607. *
  133608. * @returns true if successful.
  133609. */
  133610. detach(): boolean;
  133611. /**
  133612. * Will get the mesh under a specific pointer.
  133613. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  133614. * @param controllerId the controllerId to check
  133615. * @returns The mesh under pointer or null if no mesh is under the pointer
  133616. */
  133617. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  133618. /**
  133619. * Get the xr controller that correlates to the pointer id in the pointer event
  133620. *
  133621. * @param id the pointer id to search for
  133622. * @returns the controller that correlates to this id or null if not found
  133623. */
  133624. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  133625. private _identityMatrix;
  133626. private _screenCoordinatesRef;
  133627. private _viewportRef;
  133628. protected _onXRFrame(_xrFrame: XRFrame): void;
  133629. private _attachGazeMode;
  133630. private _attachScreenRayMode;
  133631. private _attachTrackedPointerRayMode;
  133632. private _convertNormalToDirectionOfRay;
  133633. private _detachController;
  133634. private _generateNewMeshPair;
  133635. private _pickingMoved;
  133636. private _updatePointerDistance;
  133637. /** @hidden */
  133638. get lasterPointerDefaultColor(): Color3;
  133639. }
  133640. }
  133641. declare module BABYLON {
  133642. /**
  133643. * Button which can be used to enter a different mode of XR
  133644. */
  133645. export class WebXREnterExitUIButton {
  133646. /** button element */
  133647. element: HTMLElement;
  133648. /** XR initialization options for the button */
  133649. sessionMode: XRSessionMode;
  133650. /** Reference space type */
  133651. referenceSpaceType: XRReferenceSpaceType;
  133652. /**
  133653. * Creates a WebXREnterExitUIButton
  133654. * @param element button element
  133655. * @param sessionMode XR initialization session mode
  133656. * @param referenceSpaceType the type of reference space to be used
  133657. */
  133658. constructor(
  133659. /** button element */
  133660. element: HTMLElement,
  133661. /** XR initialization options for the button */
  133662. sessionMode: XRSessionMode,
  133663. /** Reference space type */
  133664. referenceSpaceType: XRReferenceSpaceType);
  133665. /**
  133666. * Extendable function which can be used to update the button's visuals when the state changes
  133667. * @param activeButton the current active button in the UI
  133668. */
  133669. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  133670. }
  133671. /**
  133672. * Options to create the webXR UI
  133673. */
  133674. export class WebXREnterExitUIOptions {
  133675. /**
  133676. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  133677. */
  133678. customButtons?: Array<WebXREnterExitUIButton>;
  133679. /**
  133680. * A reference space type to use when creating the default button.
  133681. * Default is local-floor
  133682. */
  133683. referenceSpaceType?: XRReferenceSpaceType;
  133684. /**
  133685. * Context to enter xr with
  133686. */
  133687. renderTarget?: Nullable<WebXRRenderTarget>;
  133688. /**
  133689. * A session mode to use when creating the default button.
  133690. * Default is immersive-vr
  133691. */
  133692. sessionMode?: XRSessionMode;
  133693. /**
  133694. * A list of optional features to init the session with
  133695. */
  133696. optionalFeatures?: string[];
  133697. /**
  133698. * A list of optional features to init the session with
  133699. */
  133700. requiredFeatures?: string[];
  133701. /**
  133702. * If defined, this function will be executed if the UI encounters an error when entering XR
  133703. */
  133704. onError?: (error: any) => void;
  133705. }
  133706. /**
  133707. * UI to allow the user to enter/exit XR mode
  133708. */
  133709. export class WebXREnterExitUI implements IDisposable {
  133710. private scene;
  133711. /** version of the options passed to this UI */
  133712. options: WebXREnterExitUIOptions;
  133713. private _activeButton;
  133714. private _buttons;
  133715. /**
  133716. * The HTML Div Element to which buttons are added.
  133717. */
  133718. readonly overlay: HTMLDivElement;
  133719. /**
  133720. * Fired every time the active button is changed.
  133721. *
  133722. * When xr is entered via a button that launches xr that button will be the callback parameter
  133723. *
  133724. * When exiting xr the callback parameter will be null)
  133725. */
  133726. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  133727. /**
  133728. *
  133729. * @param scene babylon scene object to use
  133730. * @param options (read-only) version of the options passed to this UI
  133731. */
  133732. private constructor();
  133733. /**
  133734. * Creates UI to allow the user to enter/exit XR mode
  133735. * @param scene the scene to add the ui to
  133736. * @param helper the xr experience helper to enter/exit xr with
  133737. * @param options options to configure the UI
  133738. * @returns the created ui
  133739. */
  133740. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  133741. /**
  133742. * Disposes of the XR UI component
  133743. */
  133744. dispose(): void;
  133745. private _updateButtons;
  133746. }
  133747. }
  133748. declare module BABYLON {
  133749. /**
  133750. * Class containing static functions to help procedurally build meshes
  133751. */
  133752. export class LinesBuilder {
  133753. /**
  133754. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  133755. * * 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
  133756. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  133757. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  133758. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  133759. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  133760. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133761. * * 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
  133762. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  133763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  133765. * @param name defines the name of the new line system
  133766. * @param options defines the options used to create the line system
  133767. * @param scene defines the hosting scene
  133768. * @returns a new line system mesh
  133769. */
  133770. static CreateLineSystem(name: string, options: {
  133771. lines: Vector3[][];
  133772. updatable?: boolean;
  133773. instance?: Nullable<LinesMesh>;
  133774. colors?: Nullable<Color4[][]>;
  133775. useVertexAlpha?: boolean;
  133776. }, scene: Nullable<Scene>): LinesMesh;
  133777. /**
  133778. * Creates a line mesh
  133779. * 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
  133780. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133781. * * The parameter `points` is an array successive Vector3
  133782. * * 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
  133783. * * The optional parameter `colors` is an array of successive Color4, one per line point
  133784. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  133785. * * When updating an instance, remember that only point positions can change, not the number of points
  133786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133787. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  133788. * @param name defines the name of the new line system
  133789. * @param options defines the options used to create the line system
  133790. * @param scene defines the hosting scene
  133791. * @returns a new line mesh
  133792. */
  133793. static CreateLines(name: string, options: {
  133794. points: Vector3[];
  133795. updatable?: boolean;
  133796. instance?: Nullable<LinesMesh>;
  133797. colors?: Color4[];
  133798. useVertexAlpha?: boolean;
  133799. }, scene?: Nullable<Scene>): LinesMesh;
  133800. /**
  133801. * Creates a dashed line mesh
  133802. * * 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
  133803. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133804. * * The parameter `points` is an array successive Vector3
  133805. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  133806. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  133807. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  133808. * * 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
  133809. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133810. * * When updating an instance, remember that only point positions can change, not the number of points
  133811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133812. * @param name defines the name of the mesh
  133813. * @param options defines the options used to create the mesh
  133814. * @param scene defines the hosting scene
  133815. * @returns the dashed line mesh
  133816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  133817. */
  133818. static CreateDashedLines(name: string, options: {
  133819. points: Vector3[];
  133820. dashSize?: number;
  133821. gapSize?: number;
  133822. dashNb?: number;
  133823. updatable?: boolean;
  133824. instance?: LinesMesh;
  133825. useVertexAlpha?: boolean;
  133826. }, scene?: Nullable<Scene>): LinesMesh;
  133827. }
  133828. }
  133829. declare module BABYLON {
  133830. /**
  133831. * Construction options for a timer
  133832. */
  133833. export interface ITimerOptions<T> {
  133834. /**
  133835. * Time-to-end
  133836. */
  133837. timeout: number;
  133838. /**
  133839. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  133840. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  133841. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  133842. */
  133843. contextObservable: Observable<T>;
  133844. /**
  133845. * Optional parameters when adding an observer to the observable
  133846. */
  133847. observableParameters?: {
  133848. mask?: number;
  133849. insertFirst?: boolean;
  133850. scope?: any;
  133851. };
  133852. /**
  133853. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  133854. */
  133855. breakCondition?: (data?: ITimerData<T>) => boolean;
  133856. /**
  133857. * Will be triggered when the time condition has met
  133858. */
  133859. onEnded?: (data: ITimerData<any>) => void;
  133860. /**
  133861. * Will be triggered when the break condition has met (prematurely ended)
  133862. */
  133863. onAborted?: (data: ITimerData<any>) => void;
  133864. /**
  133865. * Optional function to execute on each tick (or count)
  133866. */
  133867. onTick?: (data: ITimerData<any>) => void;
  133868. }
  133869. /**
  133870. * An interface defining the data sent by the timer
  133871. */
  133872. export interface ITimerData<T> {
  133873. /**
  133874. * When did it start
  133875. */
  133876. startTime: number;
  133877. /**
  133878. * Time now
  133879. */
  133880. currentTime: number;
  133881. /**
  133882. * Time passed since started
  133883. */
  133884. deltaTime: number;
  133885. /**
  133886. * How much is completed, in [0.0...1.0].
  133887. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  133888. */
  133889. completeRate: number;
  133890. /**
  133891. * What the registered observable sent in the last count
  133892. */
  133893. payload: T;
  133894. }
  133895. /**
  133896. * The current state of the timer
  133897. */
  133898. export enum TimerState {
  133899. /**
  133900. * Timer initialized, not yet started
  133901. */
  133902. INIT = 0,
  133903. /**
  133904. * Timer started and counting
  133905. */
  133906. STARTED = 1,
  133907. /**
  133908. * Timer ended (whether aborted or time reached)
  133909. */
  133910. ENDED = 2
  133911. }
  133912. /**
  133913. * A simple version of the timer. Will take options and start the timer immediately after calling it
  133914. *
  133915. * @param options options with which to initialize this timer
  133916. */
  133917. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  133918. /**
  133919. * An advanced implementation of a timer class
  133920. */
  133921. export class AdvancedTimer<T = any> implements IDisposable {
  133922. /**
  133923. * Will notify each time the timer calculates the remaining time
  133924. */
  133925. onEachCountObservable: Observable<ITimerData<T>>;
  133926. /**
  133927. * Will trigger when the timer was aborted due to the break condition
  133928. */
  133929. onTimerAbortedObservable: Observable<ITimerData<T>>;
  133930. /**
  133931. * Will trigger when the timer ended successfully
  133932. */
  133933. onTimerEndedObservable: Observable<ITimerData<T>>;
  133934. /**
  133935. * Will trigger when the timer state has changed
  133936. */
  133937. onStateChangedObservable: Observable<TimerState>;
  133938. private _observer;
  133939. private _contextObservable;
  133940. private _observableParameters;
  133941. private _startTime;
  133942. private _timer;
  133943. private _state;
  133944. private _breakCondition;
  133945. private _timeToEnd;
  133946. private _breakOnNextTick;
  133947. /**
  133948. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  133949. * @param options construction options for this advanced timer
  133950. */
  133951. constructor(options: ITimerOptions<T>);
  133952. /**
  133953. * set a breaking condition for this timer. Default is to never break during count
  133954. * @param predicate the new break condition. Returns true to break, false otherwise
  133955. */
  133956. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  133957. /**
  133958. * Reset ALL associated observables in this advanced timer
  133959. */
  133960. clearObservables(): void;
  133961. /**
  133962. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  133963. *
  133964. * @param timeToEnd how much time to measure until timer ended
  133965. */
  133966. start(timeToEnd?: number): void;
  133967. /**
  133968. * Will force a stop on the next tick.
  133969. */
  133970. stop(): void;
  133971. /**
  133972. * Dispose this timer, clearing all resources
  133973. */
  133974. dispose(): void;
  133975. private _setState;
  133976. private _tick;
  133977. private _stop;
  133978. }
  133979. }
  133980. declare module BABYLON {
  133981. /**
  133982. * The options container for the teleportation module
  133983. */
  133984. export interface IWebXRTeleportationOptions {
  133985. /**
  133986. * if provided, this scene will be used to render meshes.
  133987. */
  133988. customUtilityLayerScene?: Scene;
  133989. /**
  133990. * Values to configure the default target mesh
  133991. */
  133992. defaultTargetMeshOptions?: {
  133993. /**
  133994. * Fill color of the teleportation area
  133995. */
  133996. teleportationFillColor?: string;
  133997. /**
  133998. * Border color for the teleportation area
  133999. */
  134000. teleportationBorderColor?: string;
  134001. /**
  134002. * Disable the mesh's animation sequence
  134003. */
  134004. disableAnimation?: boolean;
  134005. /**
  134006. * Disable lighting on the material or the ring and arrow
  134007. */
  134008. disableLighting?: boolean;
  134009. /**
  134010. * Override the default material of the torus and arrow
  134011. */
  134012. torusArrowMaterial?: Material;
  134013. };
  134014. /**
  134015. * A list of meshes to use as floor meshes.
  134016. * Meshes can be added and removed after initializing the feature using the
  134017. * addFloorMesh and removeFloorMesh functions
  134018. * If empty, rotation will still work
  134019. */
  134020. floorMeshes?: AbstractMesh[];
  134021. /**
  134022. * use this rendering group id for the meshes (optional)
  134023. */
  134024. renderingGroupId?: number;
  134025. /**
  134026. * Should teleportation move only to snap points
  134027. */
  134028. snapPointsOnly?: boolean;
  134029. /**
  134030. * An array of points to which the teleportation will snap to.
  134031. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  134032. */
  134033. snapPositions?: Vector3[];
  134034. /**
  134035. * How close should the teleportation ray be in order to snap to position.
  134036. * Default to 0.8 units (meters)
  134037. */
  134038. snapToPositionRadius?: number;
  134039. /**
  134040. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  134041. * If you want to support rotation, make sure your mesh has a direction indicator.
  134042. *
  134043. * When left untouched, the default mesh will be initialized.
  134044. */
  134045. teleportationTargetMesh?: AbstractMesh;
  134046. /**
  134047. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  134048. */
  134049. timeToTeleport?: number;
  134050. /**
  134051. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  134052. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  134053. */
  134054. useMainComponentOnly?: boolean;
  134055. /**
  134056. * Should meshes created here be added to a utility layer or the main scene
  134057. */
  134058. useUtilityLayer?: boolean;
  134059. /**
  134060. * Babylon XR Input class for controller
  134061. */
  134062. xrInput: WebXRInput;
  134063. /**
  134064. * Meshes that the teleportation ray cannot go through
  134065. */
  134066. pickBlockerMeshes?: AbstractMesh[];
  134067. }
  134068. /**
  134069. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  134070. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  134071. * the input of the attached controllers.
  134072. */
  134073. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  134074. private _options;
  134075. private _controllers;
  134076. private _currentTeleportationControllerId;
  134077. private _floorMeshes;
  134078. private _quadraticBezierCurve;
  134079. private _selectionFeature;
  134080. private _snapToPositions;
  134081. private _snappedToPoint;
  134082. private _teleportationRingMaterial?;
  134083. private _tmpRay;
  134084. private _tmpVector;
  134085. private _tmpQuaternion;
  134086. /**
  134087. * The module's name
  134088. */
  134089. static readonly Name: string;
  134090. /**
  134091. * The (Babylon) version of this module.
  134092. * This is an integer representing the implementation version.
  134093. * This number does not correspond to the webxr specs version
  134094. */
  134095. static readonly Version: number;
  134096. /**
  134097. * Is movement backwards enabled
  134098. */
  134099. backwardsMovementEnabled: boolean;
  134100. /**
  134101. * Distance to travel when moving backwards
  134102. */
  134103. backwardsTeleportationDistance: number;
  134104. /**
  134105. * The distance from the user to the inspection point in the direction of the controller
  134106. * A higher number will allow the user to move further
  134107. * defaults to 5 (meters, in xr units)
  134108. */
  134109. parabolicCheckRadius: number;
  134110. /**
  134111. * Should the module support parabolic ray on top of direct ray
  134112. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  134113. * Very helpful when moving between floors / different heights
  134114. */
  134115. parabolicRayEnabled: boolean;
  134116. /**
  134117. * How much rotation should be applied when rotating right and left
  134118. */
  134119. rotationAngle: number;
  134120. /**
  134121. * Is rotation enabled when moving forward?
  134122. * Disabling this feature will prevent the user from deciding the direction when teleporting
  134123. */
  134124. rotationEnabled: boolean;
  134125. /**
  134126. * constructs a new anchor system
  134127. * @param _xrSessionManager an instance of WebXRSessionManager
  134128. * @param _options configuration object for this feature
  134129. */
  134130. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  134131. /**
  134132. * Get the snapPointsOnly flag
  134133. */
  134134. get snapPointsOnly(): boolean;
  134135. /**
  134136. * Sets the snapPointsOnly flag
  134137. * @param snapToPoints should teleportation be exclusively to snap points
  134138. */
  134139. set snapPointsOnly(snapToPoints: boolean);
  134140. /**
  134141. * Add a new mesh to the floor meshes array
  134142. * @param mesh the mesh to use as floor mesh
  134143. */
  134144. addFloorMesh(mesh: AbstractMesh): void;
  134145. /**
  134146. * Add a new snap-to point to fix teleportation to this position
  134147. * @param newSnapPoint The new Snap-To point
  134148. */
  134149. addSnapPoint(newSnapPoint: Vector3): void;
  134150. attach(): boolean;
  134151. detach(): boolean;
  134152. dispose(): void;
  134153. /**
  134154. * Remove a mesh from the floor meshes array
  134155. * @param mesh the mesh to remove
  134156. */
  134157. removeFloorMesh(mesh: AbstractMesh): void;
  134158. /**
  134159. * Remove a mesh from the floor meshes array using its name
  134160. * @param name the mesh name to remove
  134161. */
  134162. removeFloorMeshByName(name: string): void;
  134163. /**
  134164. * 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
  134165. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  134166. * @returns was the point found and removed or not
  134167. */
  134168. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  134169. /**
  134170. * This function sets a selection feature that will be disabled when
  134171. * the forward ray is shown and will be reattached when hidden.
  134172. * This is used to remove the selection rays when moving.
  134173. * @param selectionFeature the feature to disable when forward movement is enabled
  134174. */
  134175. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  134176. protected _onXRFrame(_xrFrame: XRFrame): void;
  134177. private _attachController;
  134178. private _createDefaultTargetMesh;
  134179. private _detachController;
  134180. private _findClosestSnapPointWithRadius;
  134181. private _setTargetMeshPosition;
  134182. private _setTargetMeshVisibility;
  134183. private _showParabolicPath;
  134184. private _teleportForward;
  134185. }
  134186. }
  134187. declare module BABYLON {
  134188. /**
  134189. * Options for the default xr helper
  134190. */
  134191. export class WebXRDefaultExperienceOptions {
  134192. /**
  134193. * Enable or disable default UI to enter XR
  134194. */
  134195. disableDefaultUI?: boolean;
  134196. /**
  134197. * Should teleportation not initialize. defaults to false.
  134198. */
  134199. disableTeleportation?: boolean;
  134200. /**
  134201. * Floor meshes that will be used for teleport
  134202. */
  134203. floorMeshes?: Array<AbstractMesh>;
  134204. /**
  134205. * If set to true, the first frame will not be used to reset position
  134206. * The first frame is mainly used when copying transformation from the old camera
  134207. * Mainly used in AR
  134208. */
  134209. ignoreNativeCameraTransformation?: boolean;
  134210. /**
  134211. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  134212. */
  134213. inputOptions?: IWebXRInputOptions;
  134214. /**
  134215. * optional configuration for the output canvas
  134216. */
  134217. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  134218. /**
  134219. * optional UI options. This can be used among other to change session mode and reference space type
  134220. */
  134221. uiOptions?: WebXREnterExitUIOptions;
  134222. /**
  134223. * When loading teleportation and pointer select, use stable versions instead of latest.
  134224. */
  134225. useStablePlugins?: boolean;
  134226. /**
  134227. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  134228. */
  134229. renderingGroupId?: number;
  134230. /**
  134231. * A list of optional features to init the session with
  134232. * If set to true, all features we support will be added
  134233. */
  134234. optionalFeatures?: boolean | string[];
  134235. }
  134236. /**
  134237. * Default experience which provides a similar setup to the previous webVRExperience
  134238. */
  134239. export class WebXRDefaultExperience {
  134240. /**
  134241. * Base experience
  134242. */
  134243. baseExperience: WebXRExperienceHelper;
  134244. /**
  134245. * Enables ui for entering/exiting xr
  134246. */
  134247. enterExitUI: WebXREnterExitUI;
  134248. /**
  134249. * Input experience extension
  134250. */
  134251. input: WebXRInput;
  134252. /**
  134253. * Enables laser pointer and selection
  134254. */
  134255. pointerSelection: WebXRControllerPointerSelection;
  134256. /**
  134257. * Default target xr should render to
  134258. */
  134259. renderTarget: WebXRRenderTarget;
  134260. /**
  134261. * Enables teleportation
  134262. */
  134263. teleportation: WebXRMotionControllerTeleportation;
  134264. private constructor();
  134265. /**
  134266. * Creates the default xr experience
  134267. * @param scene scene
  134268. * @param options options for basic configuration
  134269. * @returns resulting WebXRDefaultExperience
  134270. */
  134271. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134272. /**
  134273. * DIsposes of the experience helper
  134274. */
  134275. dispose(): void;
  134276. }
  134277. }
  134278. declare module BABYLON {
  134279. /**
  134280. * Options to modify the vr teleportation behavior.
  134281. */
  134282. export interface VRTeleportationOptions {
  134283. /**
  134284. * The name of the mesh which should be used as the teleportation floor. (default: null)
  134285. */
  134286. floorMeshName?: string;
  134287. /**
  134288. * A list of meshes to be used as the teleportation floor. (default: empty)
  134289. */
  134290. floorMeshes?: Mesh[];
  134291. /**
  134292. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  134293. */
  134294. teleportationMode?: number;
  134295. /**
  134296. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  134297. */
  134298. teleportationTime?: number;
  134299. /**
  134300. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  134301. */
  134302. teleportationSpeed?: number;
  134303. /**
  134304. * The easing function used in the animation or null for Linear. (default CircleEase)
  134305. */
  134306. easingFunction?: EasingFunction;
  134307. }
  134308. /**
  134309. * Options to modify the vr experience helper's behavior.
  134310. */
  134311. export interface VRExperienceHelperOptions extends WebVROptions {
  134312. /**
  134313. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  134314. */
  134315. createDeviceOrientationCamera?: boolean;
  134316. /**
  134317. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  134318. */
  134319. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  134320. /**
  134321. * Uses the main button on the controller to toggle the laser casted. (default: true)
  134322. */
  134323. laserToggle?: boolean;
  134324. /**
  134325. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  134326. */
  134327. floorMeshes?: Mesh[];
  134328. /**
  134329. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  134330. */
  134331. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  134332. /**
  134333. * Defines if WebXR should be used instead of WebVR (if available)
  134334. */
  134335. useXR?: boolean;
  134336. }
  134337. /**
  134338. * Event containing information after VR has been entered
  134339. */
  134340. export class OnAfterEnteringVRObservableEvent {
  134341. /**
  134342. * If entering vr was successful
  134343. */
  134344. success: boolean;
  134345. }
  134346. /**
  134347. * Helps to quickly add VR support to an existing scene.
  134348. * See https://doc.babylonjs.com/how_to/webvr_helper
  134349. */
  134350. export class VRExperienceHelper {
  134351. /** Options to modify the vr experience helper's behavior. */
  134352. webVROptions: VRExperienceHelperOptions;
  134353. private _scene;
  134354. private _position;
  134355. private _btnVR;
  134356. private _btnVRDisplayed;
  134357. private _webVRsupported;
  134358. private _webVRready;
  134359. private _webVRrequesting;
  134360. private _webVRpresenting;
  134361. private _hasEnteredVR;
  134362. private _fullscreenVRpresenting;
  134363. private _inputElement;
  134364. private _webVRCamera;
  134365. private _vrDeviceOrientationCamera;
  134366. private _deviceOrientationCamera;
  134367. private _existingCamera;
  134368. private _onKeyDown;
  134369. private _onVrDisplayPresentChange;
  134370. private _onVRDisplayChanged;
  134371. private _onVRRequestPresentStart;
  134372. private _onVRRequestPresentComplete;
  134373. /**
  134374. * 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)
  134375. */
  134376. enableGazeEvenWhenNoPointerLock: boolean;
  134377. /**
  134378. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  134379. */
  134380. exitVROnDoubleTap: boolean;
  134381. /**
  134382. * Observable raised right before entering VR.
  134383. */
  134384. onEnteringVRObservable: Observable<VRExperienceHelper>;
  134385. /**
  134386. * Observable raised when entering VR has completed.
  134387. */
  134388. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  134389. /**
  134390. * Observable raised when exiting VR.
  134391. */
  134392. onExitingVRObservable: Observable<VRExperienceHelper>;
  134393. /**
  134394. * Observable raised when controller mesh is loaded.
  134395. */
  134396. onControllerMeshLoadedObservable: Observable<WebVRController>;
  134397. /** Return this.onEnteringVRObservable
  134398. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  134399. */
  134400. get onEnteringVR(): Observable<VRExperienceHelper>;
  134401. /** Return this.onExitingVRObservable
  134402. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  134403. */
  134404. get onExitingVR(): Observable<VRExperienceHelper>;
  134405. /** Return this.onControllerMeshLoadedObservable
  134406. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  134407. */
  134408. get onControllerMeshLoaded(): Observable<WebVRController>;
  134409. private _rayLength;
  134410. private _useCustomVRButton;
  134411. private _teleportationRequested;
  134412. private _teleportActive;
  134413. private _floorMeshName;
  134414. private _floorMeshesCollection;
  134415. private _teleportationMode;
  134416. private _teleportationTime;
  134417. private _teleportationSpeed;
  134418. private _teleportationEasing;
  134419. private _rotationAllowed;
  134420. private _teleportBackwardsVector;
  134421. private _teleportationTarget;
  134422. private _isDefaultTeleportationTarget;
  134423. private _postProcessMove;
  134424. private _teleportationFillColor;
  134425. private _teleportationBorderColor;
  134426. private _rotationAngle;
  134427. private _haloCenter;
  134428. private _cameraGazer;
  134429. private _padSensibilityUp;
  134430. private _padSensibilityDown;
  134431. private _leftController;
  134432. private _rightController;
  134433. private _gazeColor;
  134434. private _laserColor;
  134435. private _pickedLaserColor;
  134436. private _pickedGazeColor;
  134437. /**
  134438. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  134439. */
  134440. onNewMeshSelected: Observable<AbstractMesh>;
  134441. /**
  134442. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  134443. * This observable will provide the mesh and the controller used to select the mesh
  134444. */
  134445. onMeshSelectedWithController: Observable<{
  134446. mesh: AbstractMesh;
  134447. controller: WebVRController;
  134448. }>;
  134449. /**
  134450. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  134451. */
  134452. onNewMeshPicked: Observable<PickingInfo>;
  134453. private _circleEase;
  134454. /**
  134455. * Observable raised before camera teleportation
  134456. */
  134457. onBeforeCameraTeleport: Observable<Vector3>;
  134458. /**
  134459. * Observable raised after camera teleportation
  134460. */
  134461. onAfterCameraTeleport: Observable<Vector3>;
  134462. /**
  134463. * Observable raised when current selected mesh gets unselected
  134464. */
  134465. onSelectedMeshUnselected: Observable<AbstractMesh>;
  134466. private _raySelectionPredicate;
  134467. /**
  134468. * To be optionaly changed by user to define custom ray selection
  134469. */
  134470. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  134471. /**
  134472. * To be optionaly changed by user to define custom selection logic (after ray selection)
  134473. */
  134474. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  134475. /**
  134476. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  134477. */
  134478. teleportationEnabled: boolean;
  134479. private _defaultHeight;
  134480. private _teleportationInitialized;
  134481. private _interactionsEnabled;
  134482. private _interactionsRequested;
  134483. private _displayGaze;
  134484. private _displayLaserPointer;
  134485. /**
  134486. * The mesh used to display where the user is going to teleport.
  134487. */
  134488. get teleportationTarget(): Mesh;
  134489. /**
  134490. * Sets the mesh to be used to display where the user is going to teleport.
  134491. */
  134492. set teleportationTarget(value: Mesh);
  134493. /**
  134494. * 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
  134495. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  134496. * See https://doc.babylonjs.com/resources/baking_transformations
  134497. */
  134498. get gazeTrackerMesh(): Mesh;
  134499. set gazeTrackerMesh(value: Mesh);
  134500. /**
  134501. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  134502. */
  134503. updateGazeTrackerScale: boolean;
  134504. /**
  134505. * If the gaze trackers color should be updated when selecting meshes
  134506. */
  134507. updateGazeTrackerColor: boolean;
  134508. /**
  134509. * If the controller laser color should be updated when selecting meshes
  134510. */
  134511. updateControllerLaserColor: boolean;
  134512. /**
  134513. * The gaze tracking mesh corresponding to the left controller
  134514. */
  134515. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  134516. /**
  134517. * The gaze tracking mesh corresponding to the right controller
  134518. */
  134519. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  134520. /**
  134521. * If the ray of the gaze should be displayed.
  134522. */
  134523. get displayGaze(): boolean;
  134524. /**
  134525. * Sets if the ray of the gaze should be displayed.
  134526. */
  134527. set displayGaze(value: boolean);
  134528. /**
  134529. * If the ray of the LaserPointer should be displayed.
  134530. */
  134531. get displayLaserPointer(): boolean;
  134532. /**
  134533. * Sets if the ray of the LaserPointer should be displayed.
  134534. */
  134535. set displayLaserPointer(value: boolean);
  134536. /**
  134537. * The deviceOrientationCamera used as the camera when not in VR.
  134538. */
  134539. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  134540. /**
  134541. * Based on the current WebVR support, returns the current VR camera used.
  134542. */
  134543. get currentVRCamera(): Nullable<Camera>;
  134544. /**
  134545. * The webVRCamera which is used when in VR.
  134546. */
  134547. get webVRCamera(): WebVRFreeCamera;
  134548. /**
  134549. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  134550. */
  134551. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  134552. /**
  134553. * The html button that is used to trigger entering into VR.
  134554. */
  134555. get vrButton(): Nullable<HTMLButtonElement>;
  134556. private get _teleportationRequestInitiated();
  134557. /**
  134558. * Defines whether or not Pointer lock should be requested when switching to
  134559. * full screen.
  134560. */
  134561. requestPointerLockOnFullScreen: boolean;
  134562. /**
  134563. * If asking to force XR, this will be populated with the default xr experience
  134564. */
  134565. xr: WebXRDefaultExperience;
  134566. /**
  134567. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  134568. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  134569. */
  134570. xrTestDone: boolean;
  134571. /**
  134572. * Instantiates a VRExperienceHelper.
  134573. * Helps to quickly add VR support to an existing scene.
  134574. * @param scene The scene the VRExperienceHelper belongs to.
  134575. * @param webVROptions Options to modify the vr experience helper's behavior.
  134576. */
  134577. constructor(scene: Scene,
  134578. /** Options to modify the vr experience helper's behavior. */
  134579. webVROptions?: VRExperienceHelperOptions);
  134580. private completeVRInit;
  134581. private _onDefaultMeshLoaded;
  134582. private _onResize;
  134583. private _onFullscreenChange;
  134584. /**
  134585. * Gets a value indicating if we are currently in VR mode.
  134586. */
  134587. get isInVRMode(): boolean;
  134588. private onVrDisplayPresentChange;
  134589. private onVRDisplayChanged;
  134590. private moveButtonToBottomRight;
  134591. private displayVRButton;
  134592. private updateButtonVisibility;
  134593. private _cachedAngularSensibility;
  134594. /**
  134595. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  134596. * Otherwise, will use the fullscreen API.
  134597. */
  134598. enterVR(): void;
  134599. /**
  134600. * Attempt to exit VR, or fullscreen.
  134601. */
  134602. exitVR(): void;
  134603. /**
  134604. * The position of the vr experience helper.
  134605. */
  134606. get position(): Vector3;
  134607. /**
  134608. * Sets the position of the vr experience helper.
  134609. */
  134610. set position(value: Vector3);
  134611. /**
  134612. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  134613. */
  134614. enableInteractions(): void;
  134615. private get _noControllerIsActive();
  134616. private beforeRender;
  134617. private _isTeleportationFloor;
  134618. /**
  134619. * Adds a floor mesh to be used for teleportation.
  134620. * @param floorMesh the mesh to be used for teleportation.
  134621. */
  134622. addFloorMesh(floorMesh: Mesh): void;
  134623. /**
  134624. * Removes a floor mesh from being used for teleportation.
  134625. * @param floorMesh the mesh to be removed.
  134626. */
  134627. removeFloorMesh(floorMesh: Mesh): void;
  134628. /**
  134629. * Enables interactions and teleportation using the VR controllers and gaze.
  134630. * @param vrTeleportationOptions options to modify teleportation behavior.
  134631. */
  134632. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  134633. private _onNewGamepadConnected;
  134634. private _tryEnableInteractionOnController;
  134635. private _onNewGamepadDisconnected;
  134636. private _enableInteractionOnController;
  134637. private _checkTeleportWithRay;
  134638. private _checkRotate;
  134639. private _checkTeleportBackwards;
  134640. private _enableTeleportationOnController;
  134641. private _createTeleportationCircles;
  134642. private _displayTeleportationTarget;
  134643. private _hideTeleportationTarget;
  134644. private _rotateCamera;
  134645. private _moveTeleportationSelectorTo;
  134646. private _workingVector;
  134647. private _workingQuaternion;
  134648. private _workingMatrix;
  134649. /**
  134650. * Time Constant Teleportation Mode
  134651. */
  134652. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  134653. /**
  134654. * Speed Constant Teleportation Mode
  134655. */
  134656. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  134657. /**
  134658. * Teleports the users feet to the desired location
  134659. * @param location The location where the user's feet should be placed
  134660. */
  134661. teleportCamera(location: Vector3): void;
  134662. private _convertNormalToDirectionOfRay;
  134663. private _castRayAndSelectObject;
  134664. private _notifySelectedMeshUnselected;
  134665. /**
  134666. * Permanently set new colors for the laser pointer
  134667. * @param color the new laser color
  134668. * @param pickedColor the new laser color when picked mesh detected
  134669. */
  134670. setLaserColor(color: Color3, pickedColor?: Color3): void;
  134671. /**
  134672. * Set lighting enabled / disabled on the laser pointer of both controllers
  134673. * @param enabled should the lighting be enabled on the laser pointer
  134674. */
  134675. setLaserLightingState(enabled?: boolean): void;
  134676. /**
  134677. * Permanently set new colors for the gaze pointer
  134678. * @param color the new gaze color
  134679. * @param pickedColor the new gaze color when picked mesh detected
  134680. */
  134681. setGazeColor(color: Color3, pickedColor?: Color3): void;
  134682. /**
  134683. * Sets the color of the laser ray from the vr controllers.
  134684. * @param color new color for the ray.
  134685. */
  134686. changeLaserColor(color: Color3): void;
  134687. /**
  134688. * Sets the color of the ray from the vr headsets gaze.
  134689. * @param color new color for the ray.
  134690. */
  134691. changeGazeColor(color: Color3): void;
  134692. /**
  134693. * Exits VR and disposes of the vr experience helper
  134694. */
  134695. dispose(): void;
  134696. /**
  134697. * Gets the name of the VRExperienceHelper class
  134698. * @returns "VRExperienceHelper"
  134699. */
  134700. getClassName(): string;
  134701. }
  134702. }
  134703. declare module BABYLON {
  134704. /**
  134705. * Contains an array of blocks representing the octree
  134706. */
  134707. export interface IOctreeContainer<T> {
  134708. /**
  134709. * Blocks within the octree
  134710. */
  134711. blocks: Array<OctreeBlock<T>>;
  134712. }
  134713. /**
  134714. * Class used to store a cell in an octree
  134715. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134716. */
  134717. export class OctreeBlock<T> {
  134718. /**
  134719. * Gets the content of the current block
  134720. */
  134721. entries: T[];
  134722. /**
  134723. * Gets the list of block children
  134724. */
  134725. blocks: Array<OctreeBlock<T>>;
  134726. private _depth;
  134727. private _maxDepth;
  134728. private _capacity;
  134729. private _minPoint;
  134730. private _maxPoint;
  134731. private _boundingVectors;
  134732. private _creationFunc;
  134733. /**
  134734. * Creates a new block
  134735. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  134736. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  134737. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  134738. * @param depth defines the current depth of this block in the octree
  134739. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  134740. * @param creationFunc defines a callback to call when an element is added to the block
  134741. */
  134742. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  134743. /**
  134744. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  134745. */
  134746. get capacity(): number;
  134747. /**
  134748. * Gets the minimum vector (in world space) of the block's bounding box
  134749. */
  134750. get minPoint(): Vector3;
  134751. /**
  134752. * Gets the maximum vector (in world space) of the block's bounding box
  134753. */
  134754. get maxPoint(): Vector3;
  134755. /**
  134756. * Add a new element to this block
  134757. * @param entry defines the element to add
  134758. */
  134759. addEntry(entry: T): void;
  134760. /**
  134761. * Remove an element from this block
  134762. * @param entry defines the element to remove
  134763. */
  134764. removeEntry(entry: T): void;
  134765. /**
  134766. * Add an array of elements to this block
  134767. * @param entries defines the array of elements to add
  134768. */
  134769. addEntries(entries: T[]): void;
  134770. /**
  134771. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  134772. * @param frustumPlanes defines the frustum planes to test
  134773. * @param selection defines the array to store current content if selection is positive
  134774. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134775. */
  134776. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134777. /**
  134778. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  134779. * @param sphereCenter defines the bounding sphere center
  134780. * @param sphereRadius defines the bounding sphere radius
  134781. * @param selection defines the array to store current content if selection is positive
  134782. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134783. */
  134784. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134785. /**
  134786. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  134787. * @param ray defines the ray to test with
  134788. * @param selection defines the array to store current content if selection is positive
  134789. */
  134790. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  134791. /**
  134792. * Subdivide the content into child blocks (this block will then be empty)
  134793. */
  134794. createInnerBlocks(): void;
  134795. /**
  134796. * @hidden
  134797. */
  134798. 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;
  134799. }
  134800. }
  134801. declare module BABYLON {
  134802. /**
  134803. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  134804. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134805. */
  134806. export class Octree<T> {
  134807. /** 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.) */
  134808. maxDepth: number;
  134809. /**
  134810. * Blocks within the octree containing objects
  134811. */
  134812. blocks: Array<OctreeBlock<T>>;
  134813. /**
  134814. * Content stored in the octree
  134815. */
  134816. dynamicContent: T[];
  134817. private _maxBlockCapacity;
  134818. private _selectionContent;
  134819. private _creationFunc;
  134820. /**
  134821. * Creates a octree
  134822. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134823. * @param creationFunc function to be used to instatiate the octree
  134824. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  134825. * @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.)
  134826. */
  134827. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  134828. /** 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.) */
  134829. maxDepth?: number);
  134830. /**
  134831. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  134832. * @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);
  134833. * @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);
  134834. * @param entries meshes to be added to the octree blocks
  134835. */
  134836. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  134837. /**
  134838. * Adds a mesh to the octree
  134839. * @param entry Mesh to add to the octree
  134840. */
  134841. addMesh(entry: T): void;
  134842. /**
  134843. * Remove an element from the octree
  134844. * @param entry defines the element to remove
  134845. */
  134846. removeMesh(entry: T): void;
  134847. /**
  134848. * Selects an array of meshes within the frustum
  134849. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  134850. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  134851. * @returns array of meshes within the frustum
  134852. */
  134853. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  134854. /**
  134855. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  134856. * @param sphereCenter defines the bounding sphere center
  134857. * @param sphereRadius defines the bounding sphere radius
  134858. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134859. * @returns an array of objects that intersect the sphere
  134860. */
  134861. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  134862. /**
  134863. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  134864. * @param ray defines the ray to test with
  134865. * @returns array of intersected objects
  134866. */
  134867. intersectsRay(ray: Ray): SmartArray<T>;
  134868. /**
  134869. * Adds a mesh into the octree block if it intersects the block
  134870. */
  134871. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  134872. /**
  134873. * Adds a submesh into the octree block if it intersects the block
  134874. */
  134875. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  134876. }
  134877. }
  134878. declare module BABYLON {
  134879. interface Scene {
  134880. /**
  134881. * @hidden
  134882. * Backing Filed
  134883. */
  134884. _selectionOctree: Octree<AbstractMesh>;
  134885. /**
  134886. * Gets the octree used to boost mesh selection (picking)
  134887. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134888. */
  134889. selectionOctree: Octree<AbstractMesh>;
  134890. /**
  134891. * Creates or updates the octree used to boost selection (picking)
  134892. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134893. * @param maxCapacity defines the maximum capacity per leaf
  134894. * @param maxDepth defines the maximum depth of the octree
  134895. * @returns an octree of AbstractMesh
  134896. */
  134897. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  134898. }
  134899. interface AbstractMesh {
  134900. /**
  134901. * @hidden
  134902. * Backing Field
  134903. */
  134904. _submeshesOctree: Octree<SubMesh>;
  134905. /**
  134906. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  134907. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  134908. * @param maxCapacity defines the maximum size of each block (64 by default)
  134909. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  134910. * @returns the new octree
  134911. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  134912. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134913. */
  134914. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  134915. }
  134916. /**
  134917. * Defines the octree scene component responsible to manage any octrees
  134918. * in a given scene.
  134919. */
  134920. export class OctreeSceneComponent {
  134921. /**
  134922. * The component name help to identify the component in the list of scene components.
  134923. */
  134924. readonly name: string;
  134925. /**
  134926. * The scene the component belongs to.
  134927. */
  134928. scene: Scene;
  134929. /**
  134930. * Indicates if the meshes have been checked to make sure they are isEnabled()
  134931. */
  134932. readonly checksIsEnabled: boolean;
  134933. /**
  134934. * Creates a new instance of the component for the given scene
  134935. * @param scene Defines the scene to register the component in
  134936. */
  134937. constructor(scene: Scene);
  134938. /**
  134939. * Registers the component in a given scene
  134940. */
  134941. register(): void;
  134942. /**
  134943. * Return the list of active meshes
  134944. * @returns the list of active meshes
  134945. */
  134946. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  134947. /**
  134948. * Return the list of active sub meshes
  134949. * @param mesh The mesh to get the candidates sub meshes from
  134950. * @returns the list of active sub meshes
  134951. */
  134952. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  134953. private _tempRay;
  134954. /**
  134955. * Return the list of sub meshes intersecting with a given local ray
  134956. * @param mesh defines the mesh to find the submesh for
  134957. * @param localRay defines the ray in local space
  134958. * @returns the list of intersecting sub meshes
  134959. */
  134960. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  134961. /**
  134962. * Return the list of sub meshes colliding with a collider
  134963. * @param mesh defines the mesh to find the submesh for
  134964. * @param collider defines the collider to evaluate the collision against
  134965. * @returns the list of colliding sub meshes
  134966. */
  134967. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  134968. /**
  134969. * Rebuilds the elements related to this component in case of
  134970. * context lost for instance.
  134971. */
  134972. rebuild(): void;
  134973. /**
  134974. * Disposes the component and the associated ressources.
  134975. */
  134976. dispose(): void;
  134977. }
  134978. }
  134979. declare module BABYLON {
  134980. /**
  134981. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  134982. */
  134983. export class Gizmo implements IDisposable {
  134984. /** The utility layer the gizmo will be added to */
  134985. gizmoLayer: UtilityLayerRenderer;
  134986. /**
  134987. * The root mesh of the gizmo
  134988. */
  134989. _rootMesh: Mesh;
  134990. private _attachedMesh;
  134991. private _attachedNode;
  134992. /**
  134993. * Ratio for the scale of the gizmo (Default: 1)
  134994. */
  134995. protected _scaleRatio: number;
  134996. /**
  134997. * boolean updated by pointermove when a gizmo mesh is hovered
  134998. */
  134999. protected _isHovered: boolean;
  135000. /**
  135001. * Ratio for the scale of the gizmo (Default: 1)
  135002. */
  135003. set scaleRatio(value: number);
  135004. get scaleRatio(): number;
  135005. /**
  135006. * True when the mouse pointer is hovered a gizmo mesh
  135007. */
  135008. get isHovered(): boolean;
  135009. /**
  135010. * If a custom mesh has been set (Default: false)
  135011. */
  135012. protected _customMeshSet: boolean;
  135013. /**
  135014. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  135015. * * When set, interactions will be enabled
  135016. */
  135017. get attachedMesh(): Nullable<AbstractMesh>;
  135018. set attachedMesh(value: Nullable<AbstractMesh>);
  135019. /**
  135020. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  135021. * * When set, interactions will be enabled
  135022. */
  135023. get attachedNode(): Nullable<Node>;
  135024. set attachedNode(value: Nullable<Node>);
  135025. /**
  135026. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  135027. * @param mesh The mesh to replace the default mesh of the gizmo
  135028. */
  135029. setCustomMesh(mesh: Mesh): void;
  135030. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  135031. /**
  135032. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  135033. */
  135034. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135035. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135036. /**
  135037. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  135038. */
  135039. updateGizmoPositionToMatchAttachedMesh: boolean;
  135040. /**
  135041. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  135042. */
  135043. updateScale: boolean;
  135044. protected _interactionsEnabled: boolean;
  135045. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135046. private _beforeRenderObserver;
  135047. private _tempQuaternion;
  135048. private _tempVector;
  135049. private _tempVector2;
  135050. private _tempMatrix1;
  135051. private _tempMatrix2;
  135052. private _rightHandtoLeftHandMatrix;
  135053. /**
  135054. * Creates a gizmo
  135055. * @param gizmoLayer The utility layer the gizmo will be added to
  135056. */
  135057. constructor(
  135058. /** The utility layer the gizmo will be added to */
  135059. gizmoLayer?: UtilityLayerRenderer);
  135060. /**
  135061. * Updates the gizmo to match the attached mesh's position/rotation
  135062. */
  135063. protected _update(): void;
  135064. /**
  135065. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  135066. * @param value Node, TransformNode or mesh
  135067. */
  135068. protected _matrixChanged(): void;
  135069. /**
  135070. * Disposes of the gizmo
  135071. */
  135072. dispose(): void;
  135073. }
  135074. }
  135075. declare module BABYLON {
  135076. /**
  135077. * Single plane drag gizmo
  135078. */
  135079. export class PlaneDragGizmo extends Gizmo {
  135080. /**
  135081. * Drag behavior responsible for the gizmos dragging interactions
  135082. */
  135083. dragBehavior: PointerDragBehavior;
  135084. private _pointerObserver;
  135085. /**
  135086. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135087. */
  135088. snapDistance: number;
  135089. /**
  135090. * Event that fires each time the gizmo snaps to a new location.
  135091. * * snapDistance is the the change in distance
  135092. */
  135093. onSnapObservable: Observable<{
  135094. snapDistance: number;
  135095. }>;
  135096. private _plane;
  135097. private _coloredMaterial;
  135098. private _hoverMaterial;
  135099. private _isEnabled;
  135100. private _parent;
  135101. /** @hidden */
  135102. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  135103. /** @hidden */
  135104. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  135105. /**
  135106. * Creates a PlaneDragGizmo
  135107. * @param gizmoLayer The utility layer the gizmo will be added to
  135108. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  135109. * @param color The color of the gizmo
  135110. */
  135111. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  135112. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135113. /**
  135114. * If the gizmo is enabled
  135115. */
  135116. set isEnabled(value: boolean);
  135117. get isEnabled(): boolean;
  135118. /**
  135119. * Disposes of the gizmo
  135120. */
  135121. dispose(): void;
  135122. }
  135123. }
  135124. declare module BABYLON {
  135125. /**
  135126. * Gizmo that enables dragging a mesh along 3 axis
  135127. */
  135128. export class PositionGizmo extends Gizmo {
  135129. /**
  135130. * Internal gizmo used for interactions on the x axis
  135131. */
  135132. xGizmo: AxisDragGizmo;
  135133. /**
  135134. * Internal gizmo used for interactions on the y axis
  135135. */
  135136. yGizmo: AxisDragGizmo;
  135137. /**
  135138. * Internal gizmo used for interactions on the z axis
  135139. */
  135140. zGizmo: AxisDragGizmo;
  135141. /**
  135142. * Internal gizmo used for interactions on the yz plane
  135143. */
  135144. xPlaneGizmo: PlaneDragGizmo;
  135145. /**
  135146. * Internal gizmo used for interactions on the xz plane
  135147. */
  135148. yPlaneGizmo: PlaneDragGizmo;
  135149. /**
  135150. * Internal gizmo used for interactions on the xy plane
  135151. */
  135152. zPlaneGizmo: PlaneDragGizmo;
  135153. /**
  135154. * private variables
  135155. */
  135156. private _meshAttached;
  135157. private _nodeAttached;
  135158. private _snapDistance;
  135159. /** Fires an event when any of it's sub gizmos are dragged */
  135160. onDragStartObservable: Observable<unknown>;
  135161. /** Fires an event when any of it's sub gizmos are released from dragging */
  135162. onDragEndObservable: Observable<unknown>;
  135163. /**
  135164. * If set to true, planar drag is enabled
  135165. */
  135166. private _planarGizmoEnabled;
  135167. get attachedMesh(): Nullable<AbstractMesh>;
  135168. set attachedMesh(mesh: Nullable<AbstractMesh>);
  135169. get attachedNode(): Nullable<Node>;
  135170. set attachedNode(node: Nullable<Node>);
  135171. /**
  135172. * True when the mouse pointer is hovering a gizmo mesh
  135173. */
  135174. get isHovered(): boolean;
  135175. /**
  135176. * Creates a PositionGizmo
  135177. * @param gizmoLayer The utility layer the gizmo will be added to
  135178. @param thickness display gizmo axis thickness
  135179. */
  135180. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  135181. /**
  135182. * If the planar drag gizmo is enabled
  135183. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  135184. */
  135185. set planarGizmoEnabled(value: boolean);
  135186. get planarGizmoEnabled(): boolean;
  135187. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135188. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135189. /**
  135190. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135191. */
  135192. set snapDistance(value: number);
  135193. get snapDistance(): number;
  135194. /**
  135195. * Ratio for the scale of the gizmo (Default: 1)
  135196. */
  135197. set scaleRatio(value: number);
  135198. get scaleRatio(): number;
  135199. /**
  135200. * Disposes of the gizmo
  135201. */
  135202. dispose(): void;
  135203. /**
  135204. * CustomMeshes are not supported by this gizmo
  135205. * @param mesh The mesh to replace the default mesh of the gizmo
  135206. */
  135207. setCustomMesh(mesh: Mesh): void;
  135208. }
  135209. }
  135210. declare module BABYLON {
  135211. /**
  135212. * Single axis drag gizmo
  135213. */
  135214. export class AxisDragGizmo extends Gizmo {
  135215. /**
  135216. * Drag behavior responsible for the gizmos dragging interactions
  135217. */
  135218. dragBehavior: PointerDragBehavior;
  135219. private _pointerObserver;
  135220. /**
  135221. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135222. */
  135223. snapDistance: number;
  135224. /**
  135225. * Event that fires each time the gizmo snaps to a new location.
  135226. * * snapDistance is the the change in distance
  135227. */
  135228. onSnapObservable: Observable<{
  135229. snapDistance: number;
  135230. }>;
  135231. private _isEnabled;
  135232. private _parent;
  135233. private _arrow;
  135234. private _coloredMaterial;
  135235. private _hoverMaterial;
  135236. /** @hidden */
  135237. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  135238. /** @hidden */
  135239. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  135240. /**
  135241. * Creates an AxisDragGizmo
  135242. * @param gizmoLayer The utility layer the gizmo will be added to
  135243. * @param dragAxis The axis which the gizmo will be able to drag on
  135244. * @param color The color of the gizmo
  135245. * @param thickness display gizmo axis thickness
  135246. */
  135247. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  135248. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135249. /**
  135250. * If the gizmo is enabled
  135251. */
  135252. set isEnabled(value: boolean);
  135253. get isEnabled(): boolean;
  135254. /**
  135255. * Disposes of the gizmo
  135256. */
  135257. dispose(): void;
  135258. }
  135259. }
  135260. declare module BABYLON.Debug {
  135261. /**
  135262. * The Axes viewer will show 3 axes in a specific point in space
  135263. */
  135264. export class AxesViewer {
  135265. private _xAxis;
  135266. private _yAxis;
  135267. private _zAxis;
  135268. private _scaleLinesFactor;
  135269. private _instanced;
  135270. /**
  135271. * Gets the hosting scene
  135272. */
  135273. scene: Nullable<Scene>;
  135274. /**
  135275. * Gets or sets a number used to scale line length
  135276. */
  135277. scaleLines: number;
  135278. /** Gets the node hierarchy used to render x-axis */
  135279. get xAxis(): TransformNode;
  135280. /** Gets the node hierarchy used to render y-axis */
  135281. get yAxis(): TransformNode;
  135282. /** Gets the node hierarchy used to render z-axis */
  135283. get zAxis(): TransformNode;
  135284. /**
  135285. * Creates a new AxesViewer
  135286. * @param scene defines the hosting scene
  135287. * @param scaleLines defines a number used to scale line length (1 by default)
  135288. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  135289. * @param xAxis defines the node hierarchy used to render the x-axis
  135290. * @param yAxis defines the node hierarchy used to render the y-axis
  135291. * @param zAxis defines the node hierarchy used to render the z-axis
  135292. */
  135293. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  135294. /**
  135295. * Force the viewer to update
  135296. * @param position defines the position of the viewer
  135297. * @param xaxis defines the x axis of the viewer
  135298. * @param yaxis defines the y axis of the viewer
  135299. * @param zaxis defines the z axis of the viewer
  135300. */
  135301. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  135302. /**
  135303. * Creates an instance of this axes viewer.
  135304. * @returns a new axes viewer with instanced meshes
  135305. */
  135306. createInstance(): AxesViewer;
  135307. /** Releases resources */
  135308. dispose(): void;
  135309. private static _SetRenderingGroupId;
  135310. }
  135311. }
  135312. declare module BABYLON.Debug {
  135313. /**
  135314. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  135315. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  135316. */
  135317. export class BoneAxesViewer extends AxesViewer {
  135318. /**
  135319. * Gets or sets the target mesh where to display the axes viewer
  135320. */
  135321. mesh: Nullable<Mesh>;
  135322. /**
  135323. * Gets or sets the target bone where to display the axes viewer
  135324. */
  135325. bone: Nullable<Bone>;
  135326. /** Gets current position */
  135327. pos: Vector3;
  135328. /** Gets direction of X axis */
  135329. xaxis: Vector3;
  135330. /** Gets direction of Y axis */
  135331. yaxis: Vector3;
  135332. /** Gets direction of Z axis */
  135333. zaxis: Vector3;
  135334. /**
  135335. * Creates a new BoneAxesViewer
  135336. * @param scene defines the hosting scene
  135337. * @param bone defines the target bone
  135338. * @param mesh defines the target mesh
  135339. * @param scaleLines defines a scaling factor for line length (1 by default)
  135340. */
  135341. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  135342. /**
  135343. * Force the viewer to update
  135344. */
  135345. update(): void;
  135346. /** Releases resources */
  135347. dispose(): void;
  135348. }
  135349. }
  135350. declare module BABYLON {
  135351. /**
  135352. * Interface used to define scene explorer extensibility option
  135353. */
  135354. export interface IExplorerExtensibilityOption {
  135355. /**
  135356. * Define the option label
  135357. */
  135358. label: string;
  135359. /**
  135360. * Defines the action to execute on click
  135361. */
  135362. action: (entity: any) => void;
  135363. }
  135364. /**
  135365. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  135366. */
  135367. export interface IExplorerExtensibilityGroup {
  135368. /**
  135369. * Defines a predicate to test if a given type mut be extended
  135370. */
  135371. predicate: (entity: any) => boolean;
  135372. /**
  135373. * Gets the list of options added to a type
  135374. */
  135375. entries: IExplorerExtensibilityOption[];
  135376. }
  135377. /**
  135378. * Interface used to define the options to use to create the Inspector
  135379. */
  135380. export interface IInspectorOptions {
  135381. /**
  135382. * Display in overlay mode (default: false)
  135383. */
  135384. overlay?: boolean;
  135385. /**
  135386. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  135387. */
  135388. globalRoot?: HTMLElement;
  135389. /**
  135390. * Display the Scene explorer
  135391. */
  135392. showExplorer?: boolean;
  135393. /**
  135394. * Display the property inspector
  135395. */
  135396. showInspector?: boolean;
  135397. /**
  135398. * Display in embed mode (both panes on the right)
  135399. */
  135400. embedMode?: boolean;
  135401. /**
  135402. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  135403. */
  135404. handleResize?: boolean;
  135405. /**
  135406. * Allow the panes to popup (default: true)
  135407. */
  135408. enablePopup?: boolean;
  135409. /**
  135410. * Allow the panes to be closed by users (default: true)
  135411. */
  135412. enableClose?: boolean;
  135413. /**
  135414. * Optional list of extensibility entries
  135415. */
  135416. explorerExtensibility?: IExplorerExtensibilityGroup[];
  135417. /**
  135418. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  135419. */
  135420. inspectorURL?: string;
  135421. /**
  135422. * Optional initial tab (default to DebugLayerTab.Properties)
  135423. */
  135424. initialTab?: DebugLayerTab;
  135425. }
  135426. interface Scene {
  135427. /**
  135428. * @hidden
  135429. * Backing field
  135430. */
  135431. _debugLayer: DebugLayer;
  135432. /**
  135433. * Gets the debug layer (aka Inspector) associated with the scene
  135434. * @see https://doc.babylonjs.com/features/playground_debuglayer
  135435. */
  135436. debugLayer: DebugLayer;
  135437. }
  135438. /**
  135439. * Enum of inspector action tab
  135440. */
  135441. export enum DebugLayerTab {
  135442. /**
  135443. * Properties tag (default)
  135444. */
  135445. Properties = 0,
  135446. /**
  135447. * Debug tab
  135448. */
  135449. Debug = 1,
  135450. /**
  135451. * Statistics tab
  135452. */
  135453. Statistics = 2,
  135454. /**
  135455. * Tools tab
  135456. */
  135457. Tools = 3,
  135458. /**
  135459. * Settings tab
  135460. */
  135461. Settings = 4
  135462. }
  135463. /**
  135464. * The debug layer (aka Inspector) is the go to tool in order to better understand
  135465. * what is happening in your scene
  135466. * @see https://doc.babylonjs.com/features/playground_debuglayer
  135467. */
  135468. export class DebugLayer {
  135469. /**
  135470. * Define the url to get the inspector script from.
  135471. * By default it uses the babylonjs CDN.
  135472. * @ignoreNaming
  135473. */
  135474. static InspectorURL: string;
  135475. private _scene;
  135476. private BJSINSPECTOR;
  135477. private _onPropertyChangedObservable?;
  135478. /**
  135479. * Observable triggered when a property is changed through the inspector.
  135480. */
  135481. get onPropertyChangedObservable(): any;
  135482. /**
  135483. * Instantiates a new debug layer.
  135484. * The debug layer (aka Inspector) is the go to tool in order to better understand
  135485. * what is happening in your scene
  135486. * @see https://doc.babylonjs.com/features/playground_debuglayer
  135487. * @param scene Defines the scene to inspect
  135488. */
  135489. constructor(scene: Scene);
  135490. /** Creates the inspector window. */
  135491. private _createInspector;
  135492. /**
  135493. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  135494. * @param entity defines the entity to select
  135495. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  135496. */
  135497. select(entity: any, lineContainerTitles?: string | string[]): void;
  135498. /** Get the inspector from bundle or global */
  135499. private _getGlobalInspector;
  135500. /**
  135501. * Get if the inspector is visible or not.
  135502. * @returns true if visible otherwise, false
  135503. */
  135504. isVisible(): boolean;
  135505. /**
  135506. * Hide the inspector and close its window.
  135507. */
  135508. hide(): void;
  135509. /**
  135510. * Update the scene in the inspector
  135511. */
  135512. setAsActiveScene(): void;
  135513. /**
  135514. * Launch the debugLayer.
  135515. * @param config Define the configuration of the inspector
  135516. * @return a promise fulfilled when the debug layer is visible
  135517. */
  135518. show(config?: IInspectorOptions): Promise<DebugLayer>;
  135519. }
  135520. }
  135521. declare module BABYLON {
  135522. /**
  135523. * Class containing static functions to help procedurally build meshes
  135524. */
  135525. export class BoxBuilder {
  135526. /**
  135527. * Creates a box mesh
  135528. * * The parameter `size` sets the size (float) of each box side (default 1)
  135529. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135530. * * 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)
  135531. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135535. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135536. * @param name defines the name of the mesh
  135537. * @param options defines the options used to create the mesh
  135538. * @param scene defines the hosting scene
  135539. * @returns the box mesh
  135540. */
  135541. static CreateBox(name: string, options: {
  135542. size?: number;
  135543. width?: number;
  135544. height?: number;
  135545. depth?: number;
  135546. faceUV?: Vector4[];
  135547. faceColors?: Color4[];
  135548. sideOrientation?: number;
  135549. frontUVs?: Vector4;
  135550. backUVs?: Vector4;
  135551. wrap?: boolean;
  135552. topBaseAt?: number;
  135553. bottomBaseAt?: number;
  135554. updatable?: boolean;
  135555. }, scene?: Nullable<Scene>): Mesh;
  135556. }
  135557. }
  135558. declare module BABYLON.Debug {
  135559. /**
  135560. * Used to show the physics impostor around the specific mesh
  135561. */
  135562. export class PhysicsViewer {
  135563. /** @hidden */
  135564. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  135565. /** @hidden */
  135566. protected _meshes: Array<Nullable<AbstractMesh>>;
  135567. /** @hidden */
  135568. protected _scene: Nullable<Scene>;
  135569. /** @hidden */
  135570. protected _numMeshes: number;
  135571. /** @hidden */
  135572. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  135573. private _renderFunction;
  135574. private _utilityLayer;
  135575. private _debugBoxMesh;
  135576. private _debugSphereMesh;
  135577. private _debugCylinderMesh;
  135578. private _debugMaterial;
  135579. private _debugMeshMeshes;
  135580. /**
  135581. * Creates a new PhysicsViewer
  135582. * @param scene defines the hosting scene
  135583. */
  135584. constructor(scene: Scene);
  135585. /** @hidden */
  135586. protected _updateDebugMeshes(): void;
  135587. /**
  135588. * Renders a specified physic impostor
  135589. * @param impostor defines the impostor to render
  135590. * @param targetMesh defines the mesh represented by the impostor
  135591. * @returns the new debug mesh used to render the impostor
  135592. */
  135593. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  135594. /**
  135595. * Hides a specified physic impostor
  135596. * @param impostor defines the impostor to hide
  135597. */
  135598. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  135599. private _getDebugMaterial;
  135600. private _getDebugBoxMesh;
  135601. private _getDebugSphereMesh;
  135602. private _getDebugCylinderMesh;
  135603. private _getDebugMeshMesh;
  135604. private _getDebugMesh;
  135605. /** Releases all resources */
  135606. dispose(): void;
  135607. }
  135608. }
  135609. declare module BABYLON {
  135610. /**
  135611. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  135612. * in order to better appreciate the issue one might have.
  135613. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  135614. */
  135615. export class RayHelper {
  135616. /**
  135617. * Defines the ray we are currently tryin to visualize.
  135618. */
  135619. ray: Nullable<Ray>;
  135620. private _renderPoints;
  135621. private _renderLine;
  135622. private _renderFunction;
  135623. private _scene;
  135624. private _onAfterRenderObserver;
  135625. private _onAfterStepObserver;
  135626. private _attachedToMesh;
  135627. private _meshSpaceDirection;
  135628. private _meshSpaceOrigin;
  135629. /**
  135630. * Helper function to create a colored helper in a scene in one line.
  135631. * @param ray Defines the ray we are currently tryin to visualize
  135632. * @param scene Defines the scene the ray is used in
  135633. * @param color Defines the color we want to see the ray in
  135634. * @returns The newly created ray helper.
  135635. */
  135636. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  135637. /**
  135638. * Instantiate a new ray helper.
  135639. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  135640. * in order to better appreciate the issue one might have.
  135641. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  135642. * @param ray Defines the ray we are currently tryin to visualize
  135643. */
  135644. constructor(ray: Ray);
  135645. /**
  135646. * Shows the ray we are willing to debug.
  135647. * @param scene Defines the scene the ray needs to be rendered in
  135648. * @param color Defines the color the ray needs to be rendered in
  135649. */
  135650. show(scene: Scene, color?: Color3): void;
  135651. /**
  135652. * Hides the ray we are debugging.
  135653. */
  135654. hide(): void;
  135655. private _render;
  135656. /**
  135657. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  135658. * @param mesh Defines the mesh we want the helper attached to
  135659. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  135660. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  135661. * @param length Defines the length of the ray
  135662. */
  135663. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  135664. /**
  135665. * Detach the ray helper from the mesh it has previously been attached to.
  135666. */
  135667. detachFromMesh(): void;
  135668. private _updateToMesh;
  135669. /**
  135670. * Dispose the helper and release its associated resources.
  135671. */
  135672. dispose(): void;
  135673. }
  135674. }
  135675. declare module BABYLON {
  135676. /**
  135677. * Defines the options associated with the creation of a SkeletonViewer.
  135678. */
  135679. export interface ISkeletonViewerOptions {
  135680. /** Should the system pause animations before building the Viewer? */
  135681. pauseAnimations: boolean;
  135682. /** Should the system return the skeleton to rest before building? */
  135683. returnToRest: boolean;
  135684. /** public Display Mode of the Viewer */
  135685. displayMode: number;
  135686. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  135687. displayOptions: ISkeletonViewerDisplayOptions;
  135688. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  135689. computeBonesUsingShaders: boolean;
  135690. /** Flag ignore non weighted bones */
  135691. useAllBones: boolean;
  135692. }
  135693. /**
  135694. * Defines how to display the various bone meshes for the viewer.
  135695. */
  135696. export interface ISkeletonViewerDisplayOptions {
  135697. /** How far down to start tapering the bone spurs */
  135698. midStep?: number;
  135699. /** How big is the midStep? */
  135700. midStepFactor?: number;
  135701. /** Base for the Sphere Size */
  135702. sphereBaseSize?: number;
  135703. /** The ratio of the sphere to the longest bone in units */
  135704. sphereScaleUnit?: number;
  135705. /** Ratio for the Sphere Size */
  135706. sphereFactor?: number;
  135707. /** Whether a spur should attach its far end to the child bone position */
  135708. spurFollowsChild?: boolean;
  135709. /** Whether to show local axes or not */
  135710. showLocalAxes?: boolean;
  135711. /** Length of each local axis */
  135712. localAxesSize?: number;
  135713. }
  135714. /**
  135715. * Defines the constructor options for the BoneWeight Shader.
  135716. */
  135717. export interface IBoneWeightShaderOptions {
  135718. /** Skeleton to Map */
  135719. skeleton: Skeleton;
  135720. /** Colors for Uninfluenced bones */
  135721. colorBase?: Color3;
  135722. /** Colors for 0.0-0.25 Weight bones */
  135723. colorZero?: Color3;
  135724. /** Color for 0.25-0.5 Weight Influence */
  135725. colorQuarter?: Color3;
  135726. /** Color for 0.5-0.75 Weight Influence */
  135727. colorHalf?: Color3;
  135728. /** Color for 0.75-1 Weight Influence */
  135729. colorFull?: Color3;
  135730. /** Color for Zero Weight Influence */
  135731. targetBoneIndex?: number;
  135732. }
  135733. /**
  135734. * Simple structure of the gradient steps for the Color Map.
  135735. */
  135736. export interface ISkeletonMapShaderColorMapKnot {
  135737. /** Color of the Knot */
  135738. color: Color3;
  135739. /** Location of the Knot */
  135740. location: number;
  135741. }
  135742. /**
  135743. * Defines the constructor options for the SkeletonMap Shader.
  135744. */
  135745. export interface ISkeletonMapShaderOptions {
  135746. /** Skeleton to Map */
  135747. skeleton: Skeleton;
  135748. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  135749. colorMap?: ISkeletonMapShaderColorMapKnot[];
  135750. }
  135751. }
  135752. declare module BABYLON {
  135753. /**
  135754. * Class containing static functions to help procedurally build meshes
  135755. */
  135756. export class RibbonBuilder {
  135757. /**
  135758. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135759. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135760. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135761. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135762. * * 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
  135763. * * 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
  135764. * * 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
  135765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135767. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135768. * * 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
  135769. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135770. * * 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
  135771. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135773. * @param name defines the name of the mesh
  135774. * @param options defines the options used to create the mesh
  135775. * @param scene defines the hosting scene
  135776. * @returns the ribbon mesh
  135777. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135778. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135779. */
  135780. static CreateRibbon(name: string, options: {
  135781. pathArray: Vector3[][];
  135782. closeArray?: boolean;
  135783. closePath?: boolean;
  135784. offset?: number;
  135785. updatable?: boolean;
  135786. sideOrientation?: number;
  135787. frontUVs?: Vector4;
  135788. backUVs?: Vector4;
  135789. instance?: Mesh;
  135790. invertUV?: boolean;
  135791. uvs?: Vector2[];
  135792. colors?: Color4[];
  135793. }, scene?: Nullable<Scene>): Mesh;
  135794. }
  135795. }
  135796. declare module BABYLON {
  135797. /**
  135798. * Class containing static functions to help procedurally build meshes
  135799. */
  135800. export class ShapeBuilder {
  135801. /**
  135802. * 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.
  135803. * * 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.
  135804. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135805. * * 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.
  135806. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  135807. * * 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
  135808. * * 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
  135809. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  135810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135812. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  135813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135814. * @param name defines the name of the mesh
  135815. * @param options defines the options used to create the mesh
  135816. * @param scene defines the hosting scene
  135817. * @returns the extruded shape mesh
  135818. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135820. */
  135821. static ExtrudeShape(name: string, options: {
  135822. shape: Vector3[];
  135823. path: Vector3[];
  135824. scale?: number;
  135825. rotation?: number;
  135826. cap?: number;
  135827. updatable?: boolean;
  135828. sideOrientation?: number;
  135829. frontUVs?: Vector4;
  135830. backUVs?: Vector4;
  135831. instance?: Mesh;
  135832. invertUV?: boolean;
  135833. }, scene?: Nullable<Scene>): Mesh;
  135834. /**
  135835. * Creates an custom extruded shape mesh.
  135836. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135837. * * 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.
  135838. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135839. * * 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
  135840. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135841. * * 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
  135842. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135843. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135844. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135845. * * 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
  135846. * * 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
  135847. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135849. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135850. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135852. * @param name defines the name of the mesh
  135853. * @param options defines the options used to create the mesh
  135854. * @param scene defines the hosting scene
  135855. * @returns the custom extruded shape mesh
  135856. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135857. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135858. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135859. */
  135860. static ExtrudeShapeCustom(name: string, options: {
  135861. shape: Vector3[];
  135862. path: Vector3[];
  135863. scaleFunction?: any;
  135864. rotationFunction?: any;
  135865. ribbonCloseArray?: boolean;
  135866. ribbonClosePath?: boolean;
  135867. cap?: number;
  135868. updatable?: boolean;
  135869. sideOrientation?: number;
  135870. frontUVs?: Vector4;
  135871. backUVs?: Vector4;
  135872. instance?: Mesh;
  135873. invertUV?: boolean;
  135874. }, scene?: Nullable<Scene>): Mesh;
  135875. private static _ExtrudeShapeGeneric;
  135876. }
  135877. }
  135878. declare module BABYLON.Debug {
  135879. /**
  135880. * Class used to render a debug view of a given skeleton
  135881. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  135882. */
  135883. export class SkeletonViewer {
  135884. /** defines the skeleton to render */
  135885. skeleton: Skeleton;
  135886. /** defines the mesh attached to the skeleton */
  135887. mesh: AbstractMesh;
  135888. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135889. autoUpdateBonesMatrices: boolean;
  135890. /** defines the rendering group id to use with the viewer */
  135891. renderingGroupId: number;
  135892. /** is the options for the viewer */
  135893. options: Partial<ISkeletonViewerOptions>;
  135894. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  135895. static readonly DISPLAY_LINES: number;
  135896. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  135897. static readonly DISPLAY_SPHERES: number;
  135898. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  135899. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  135900. /** public static method to create a BoneWeight Shader
  135901. * @param options The constructor options
  135902. * @param scene The scene that the shader is scoped to
  135903. * @returns The created ShaderMaterial
  135904. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  135905. */
  135906. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  135907. /** public static method to create a BoneWeight Shader
  135908. * @param options The constructor options
  135909. * @param scene The scene that the shader is scoped to
  135910. * @returns The created ShaderMaterial
  135911. */
  135912. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  135913. /** private static method to create a BoneWeight Shader
  135914. * @param size The size of the buffer to create (usually the bone count)
  135915. * @param colorMap The gradient data to generate
  135916. * @param scene The scene that the shader is scoped to
  135917. * @returns an Array of floats from the color gradient values
  135918. */
  135919. private static _CreateBoneMapColorBuffer;
  135920. /** If SkeletonViewer scene scope. */
  135921. private _scene;
  135922. /** Gets or sets the color used to render the skeleton */
  135923. color: Color3;
  135924. /** Array of the points of the skeleton fo the line view. */
  135925. private _debugLines;
  135926. /** The SkeletonViewers Mesh. */
  135927. private _debugMesh;
  135928. /** The local axes Meshes. */
  135929. private _localAxes;
  135930. /** If SkeletonViewer is enabled. */
  135931. private _isEnabled;
  135932. /** If SkeletonViewer is ready. */
  135933. private _ready;
  135934. /** SkeletonViewer render observable. */
  135935. private _obs;
  135936. /** The Utility Layer to render the gizmos in. */
  135937. private _utilityLayer;
  135938. private _boneIndices;
  135939. /** Gets the Scene. */
  135940. get scene(): Scene;
  135941. /** Gets the utilityLayer. */
  135942. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  135943. /** Checks Ready Status. */
  135944. get isReady(): Boolean;
  135945. /** Sets Ready Status. */
  135946. set ready(value: boolean);
  135947. /** Gets the debugMesh */
  135948. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  135949. /** Sets the debugMesh */
  135950. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  135951. /** Gets the displayMode */
  135952. get displayMode(): number;
  135953. /** Sets the displayMode */
  135954. set displayMode(value: number);
  135955. /**
  135956. * Creates a new SkeletonViewer
  135957. * @param skeleton defines the skeleton to render
  135958. * @param mesh defines the mesh attached to the skeleton
  135959. * @param scene defines the hosting scene
  135960. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  135961. * @param renderingGroupId defines the rendering group id to use with the viewer
  135962. * @param options All of the extra constructor options for the SkeletonViewer
  135963. */
  135964. constructor(
  135965. /** defines the skeleton to render */
  135966. skeleton: Skeleton,
  135967. /** defines the mesh attached to the skeleton */
  135968. mesh: AbstractMesh,
  135969. /** The Scene scope*/
  135970. scene: Scene,
  135971. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135972. autoUpdateBonesMatrices?: boolean,
  135973. /** defines the rendering group id to use with the viewer */
  135974. renderingGroupId?: number,
  135975. /** is the options for the viewer */
  135976. options?: Partial<ISkeletonViewerOptions>);
  135977. /** The Dynamic bindings for the update functions */
  135978. private _bindObs;
  135979. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  135980. update(): void;
  135981. /** Gets or sets a boolean indicating if the viewer is enabled */
  135982. set isEnabled(value: boolean);
  135983. get isEnabled(): boolean;
  135984. private _getBonePosition;
  135985. private _getLinesForBonesWithLength;
  135986. private _getLinesForBonesNoLength;
  135987. /** function to revert the mesh and scene back to the initial state. */
  135988. private _revert;
  135989. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  135990. private _getAbsoluteBindPoseToRef;
  135991. /** function to build and bind sphere joint points and spur bone representations. */
  135992. private _buildSpheresAndSpurs;
  135993. private _buildLocalAxes;
  135994. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  135995. private _displayLinesUpdate;
  135996. /** Changes the displayMode of the skeleton viewer
  135997. * @param mode The displayMode numerical value
  135998. */
  135999. changeDisplayMode(mode: number): void;
  136000. /** Sets a display option of the skeleton viewer
  136001. *
  136002. * | Option | Type | Default | Description |
  136003. * | ---------------- | ------- | ------- | ----------- |
  136004. * | 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`. |
  136005. * | 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`. |
  136006. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  136007. * | 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`. |
  136008. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  136009. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  136010. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  136011. *
  136012. * @param option String of the option name
  136013. * @param value The numerical option value
  136014. */
  136015. changeDisplayOptions(option: string, value: number): void;
  136016. /** Release associated resources */
  136017. dispose(): void;
  136018. }
  136019. }
  136020. declare module BABYLON {
  136021. /**
  136022. * Enum for Device Types
  136023. */
  136024. export enum DeviceType {
  136025. /** Generic */
  136026. Generic = 0,
  136027. /** Keyboard */
  136028. Keyboard = 1,
  136029. /** Mouse */
  136030. Mouse = 2,
  136031. /** Touch Pointers */
  136032. Touch = 3,
  136033. /** PS4 Dual Shock */
  136034. DualShock = 4,
  136035. /** Xbox */
  136036. Xbox = 5,
  136037. /** Switch Controller */
  136038. Switch = 6
  136039. }
  136040. /**
  136041. * Enum for All Pointers (Touch/Mouse)
  136042. */
  136043. export enum PointerInput {
  136044. /** Horizontal Axis */
  136045. Horizontal = 0,
  136046. /** Vertical Axis */
  136047. Vertical = 1,
  136048. /** Left Click or Touch */
  136049. LeftClick = 2,
  136050. /** Middle Click */
  136051. MiddleClick = 3,
  136052. /** Right Click */
  136053. RightClick = 4,
  136054. /** Browser Back */
  136055. BrowserBack = 5,
  136056. /** Browser Forward */
  136057. BrowserForward = 6
  136058. }
  136059. /**
  136060. * Enum for Dual Shock Gamepad
  136061. */
  136062. export enum DualShockInput {
  136063. /** Cross */
  136064. Cross = 0,
  136065. /** Circle */
  136066. Circle = 1,
  136067. /** Square */
  136068. Square = 2,
  136069. /** Triangle */
  136070. Triangle = 3,
  136071. /** L1 */
  136072. L1 = 4,
  136073. /** R1 */
  136074. R1 = 5,
  136075. /** L2 */
  136076. L2 = 6,
  136077. /** R2 */
  136078. R2 = 7,
  136079. /** Share */
  136080. Share = 8,
  136081. /** Options */
  136082. Options = 9,
  136083. /** L3 */
  136084. L3 = 10,
  136085. /** R3 */
  136086. R3 = 11,
  136087. /** DPadUp */
  136088. DPadUp = 12,
  136089. /** DPadDown */
  136090. DPadDown = 13,
  136091. /** DPadLeft */
  136092. DPadLeft = 14,
  136093. /** DRight */
  136094. DPadRight = 15,
  136095. /** Home */
  136096. Home = 16,
  136097. /** TouchPad */
  136098. TouchPad = 17,
  136099. /** LStickXAxis */
  136100. LStickXAxis = 18,
  136101. /** LStickYAxis */
  136102. LStickYAxis = 19,
  136103. /** RStickXAxis */
  136104. RStickXAxis = 20,
  136105. /** RStickYAxis */
  136106. RStickYAxis = 21
  136107. }
  136108. /**
  136109. * Enum for Xbox Gamepad
  136110. */
  136111. export enum XboxInput {
  136112. /** A */
  136113. A = 0,
  136114. /** B */
  136115. B = 1,
  136116. /** X */
  136117. X = 2,
  136118. /** Y */
  136119. Y = 3,
  136120. /** LB */
  136121. LB = 4,
  136122. /** RB */
  136123. RB = 5,
  136124. /** LT */
  136125. LT = 6,
  136126. /** RT */
  136127. RT = 7,
  136128. /** Back */
  136129. Back = 8,
  136130. /** Start */
  136131. Start = 9,
  136132. /** LS */
  136133. LS = 10,
  136134. /** RS */
  136135. RS = 11,
  136136. /** DPadUp */
  136137. DPadUp = 12,
  136138. /** DPadDown */
  136139. DPadDown = 13,
  136140. /** DPadLeft */
  136141. DPadLeft = 14,
  136142. /** DRight */
  136143. DPadRight = 15,
  136144. /** Home */
  136145. Home = 16,
  136146. /** LStickXAxis */
  136147. LStickXAxis = 17,
  136148. /** LStickYAxis */
  136149. LStickYAxis = 18,
  136150. /** RStickXAxis */
  136151. RStickXAxis = 19,
  136152. /** RStickYAxis */
  136153. RStickYAxis = 20
  136154. }
  136155. /**
  136156. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  136157. */
  136158. export enum SwitchInput {
  136159. /** B */
  136160. B = 0,
  136161. /** A */
  136162. A = 1,
  136163. /** Y */
  136164. Y = 2,
  136165. /** X */
  136166. X = 3,
  136167. /** L */
  136168. L = 4,
  136169. /** R */
  136170. R = 5,
  136171. /** ZL */
  136172. ZL = 6,
  136173. /** ZR */
  136174. ZR = 7,
  136175. /** Minus */
  136176. Minus = 8,
  136177. /** Plus */
  136178. Plus = 9,
  136179. /** LS */
  136180. LS = 10,
  136181. /** RS */
  136182. RS = 11,
  136183. /** DPadUp */
  136184. DPadUp = 12,
  136185. /** DPadDown */
  136186. DPadDown = 13,
  136187. /** DPadLeft */
  136188. DPadLeft = 14,
  136189. /** DRight */
  136190. DPadRight = 15,
  136191. /** Home */
  136192. Home = 16,
  136193. /** Capture */
  136194. Capture = 17,
  136195. /** LStickXAxis */
  136196. LStickXAxis = 18,
  136197. /** LStickYAxis */
  136198. LStickYAxis = 19,
  136199. /** RStickXAxis */
  136200. RStickXAxis = 20,
  136201. /** RStickYAxis */
  136202. RStickYAxis = 21
  136203. }
  136204. }
  136205. declare module BABYLON {
  136206. /**
  136207. * This class will take all inputs from Keyboard, Pointer, and
  136208. * any Gamepads and provide a polling system that all devices
  136209. * will use. This class assumes that there will only be one
  136210. * pointer device and one keyboard.
  136211. */
  136212. export class DeviceInputSystem implements IDisposable {
  136213. /**
  136214. * Returns onDeviceConnected callback property
  136215. * @returns Callback with function to execute when a device is connected
  136216. */
  136217. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  136218. /**
  136219. * Sets callback function when a device is connected and executes against all connected devices
  136220. * @param callback Function to execute when a device is connected
  136221. */
  136222. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  136223. /**
  136224. * Callback to be triggered when a device is disconnected
  136225. */
  136226. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  136227. /**
  136228. * Callback to be triggered when event driven input is updated
  136229. */
  136230. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  136231. private _inputs;
  136232. private _gamepads;
  136233. private _keyboardActive;
  136234. private _pointerActive;
  136235. private _elementToAttachTo;
  136236. private _keyboardDownEvent;
  136237. private _keyboardUpEvent;
  136238. private _pointerMoveEvent;
  136239. private _pointerDownEvent;
  136240. private _pointerUpEvent;
  136241. private _gamepadConnectedEvent;
  136242. private _gamepadDisconnectedEvent;
  136243. private _onDeviceConnected;
  136244. private static _MAX_KEYCODES;
  136245. private static _MAX_POINTER_INPUTS;
  136246. private constructor();
  136247. /**
  136248. * Creates a new DeviceInputSystem instance
  136249. * @param engine Engine to pull input element from
  136250. * @returns The new instance
  136251. */
  136252. static Create(engine: Engine): DeviceInputSystem;
  136253. /**
  136254. * Checks for current device input value, given an id and input index
  136255. * @param deviceName Id of connected device
  136256. * @param inputIndex Index of device input
  136257. * @returns Current value of input
  136258. */
  136259. /**
  136260. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  136261. * @param deviceType Enum specifiying device type
  136262. * @param deviceSlot "Slot" or index that device is referenced in
  136263. * @param inputIndex Id of input to be checked
  136264. * @returns Current value of input
  136265. */
  136266. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  136267. /**
  136268. * Dispose of all the eventlisteners
  136269. */
  136270. dispose(): void;
  136271. /**
  136272. * Checks for existing connections to devices and register them, if necessary
  136273. * Currently handles gamepads and mouse
  136274. */
  136275. private _checkForConnectedDevices;
  136276. /**
  136277. * Add a gamepad to the DeviceInputSystem
  136278. * @param gamepad A single DOM Gamepad object
  136279. */
  136280. private _addGamePad;
  136281. /**
  136282. * Add pointer device to DeviceInputSystem
  136283. * @param deviceType Type of Pointer to add
  136284. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  136285. * @param currentX Current X at point of adding
  136286. * @param currentY Current Y at point of adding
  136287. */
  136288. private _addPointerDevice;
  136289. /**
  136290. * Add device and inputs to device array
  136291. * @param deviceType Enum specifiying device type
  136292. * @param deviceSlot "Slot" or index that device is referenced in
  136293. * @param numberOfInputs Number of input entries to create for given device
  136294. */
  136295. private _registerDevice;
  136296. /**
  136297. * Given a specific device name, remove that device from the device map
  136298. * @param deviceType Enum specifiying device type
  136299. * @param deviceSlot "Slot" or index that device is referenced in
  136300. */
  136301. private _unregisterDevice;
  136302. /**
  136303. * Handle all actions that come from keyboard interaction
  136304. */
  136305. private _handleKeyActions;
  136306. /**
  136307. * Handle all actions that come from pointer interaction
  136308. */
  136309. private _handlePointerActions;
  136310. /**
  136311. * Handle all actions that come from gamepad interaction
  136312. */
  136313. private _handleGamepadActions;
  136314. /**
  136315. * Update all non-event based devices with each frame
  136316. * @param deviceType Enum specifiying device type
  136317. * @param deviceSlot "Slot" or index that device is referenced in
  136318. * @param inputIndex Id of input to be checked
  136319. */
  136320. private _updateDevice;
  136321. /**
  136322. * Gets DeviceType from the device name
  136323. * @param deviceName Name of Device from DeviceInputSystem
  136324. * @returns DeviceType enum value
  136325. */
  136326. private _getGamepadDeviceType;
  136327. }
  136328. }
  136329. declare module BABYLON {
  136330. /**
  136331. * Type to handle enforcement of inputs
  136332. */
  136333. 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;
  136334. }
  136335. declare module BABYLON {
  136336. /**
  136337. * Class that handles all input for a specific device
  136338. */
  136339. export class DeviceSource<T extends DeviceType> {
  136340. /** Type of device */
  136341. readonly deviceType: DeviceType;
  136342. /** "Slot" or index that device is referenced in */
  136343. readonly deviceSlot: number;
  136344. /**
  136345. * Observable to handle device input changes per device
  136346. */
  136347. readonly onInputChangedObservable: Observable<{
  136348. inputIndex: DeviceInput<T>;
  136349. previousState: Nullable<number>;
  136350. currentState: Nullable<number>;
  136351. }>;
  136352. private readonly _deviceInputSystem;
  136353. /**
  136354. * Default Constructor
  136355. * @param deviceInputSystem Reference to DeviceInputSystem
  136356. * @param deviceType Type of device
  136357. * @param deviceSlot "Slot" or index that device is referenced in
  136358. */
  136359. constructor(deviceInputSystem: DeviceInputSystem,
  136360. /** Type of device */
  136361. deviceType: DeviceType,
  136362. /** "Slot" or index that device is referenced in */
  136363. deviceSlot?: number);
  136364. /**
  136365. * Get input for specific input
  136366. * @param inputIndex index of specific input on device
  136367. * @returns Input value from DeviceInputSystem
  136368. */
  136369. getInput(inputIndex: DeviceInput<T>): number;
  136370. }
  136371. /**
  136372. * Class to keep track of devices
  136373. */
  136374. export class DeviceSourceManager implements IDisposable {
  136375. /**
  136376. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  136377. */
  136378. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  136379. /**
  136380. * Observable to be triggered when after a device is disconnected
  136381. */
  136382. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  136383. private readonly _devices;
  136384. private readonly _firstDevice;
  136385. private readonly _deviceInputSystem;
  136386. /**
  136387. * Default Constructor
  136388. * @param engine engine to pull input element from
  136389. */
  136390. constructor(engine: Engine);
  136391. /**
  136392. * Gets a DeviceSource, given a type and slot
  136393. * @param deviceType Enum specifying device type
  136394. * @param deviceSlot "Slot" or index that device is referenced in
  136395. * @returns DeviceSource object
  136396. */
  136397. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  136398. /**
  136399. * Gets an array of DeviceSource objects for a given device type
  136400. * @param deviceType Enum specifying device type
  136401. * @returns Array of DeviceSource objects
  136402. */
  136403. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  136404. /**
  136405. * Returns a read-only list of all available devices
  136406. * @returns Read-only array with active devices
  136407. */
  136408. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  136409. /**
  136410. * Dispose of DeviceInputSystem and other parts
  136411. */
  136412. dispose(): void;
  136413. /**
  136414. * Function to add device name to device list
  136415. * @param deviceType Enum specifying device type
  136416. * @param deviceSlot "Slot" or index that device is referenced in
  136417. */
  136418. private _addDevice;
  136419. /**
  136420. * Function to remove device name to device list
  136421. * @param deviceType Enum specifying device type
  136422. * @param deviceSlot "Slot" or index that device is referenced in
  136423. */
  136424. private _removeDevice;
  136425. /**
  136426. * Updates array storing first connected device of each type
  136427. * @param type Type of Device
  136428. */
  136429. private _updateFirstDevices;
  136430. }
  136431. }
  136432. declare module BABYLON {
  136433. /**
  136434. * Options to create the null engine
  136435. */
  136436. export class NullEngineOptions {
  136437. /**
  136438. * Render width (Default: 512)
  136439. */
  136440. renderWidth: number;
  136441. /**
  136442. * Render height (Default: 256)
  136443. */
  136444. renderHeight: number;
  136445. /**
  136446. * Texture size (Default: 512)
  136447. */
  136448. textureSize: number;
  136449. /**
  136450. * If delta time between frames should be constant
  136451. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136452. */
  136453. deterministicLockstep: boolean;
  136454. /**
  136455. * Maximum about of steps between frames (Default: 4)
  136456. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136457. */
  136458. lockstepMaxSteps: number;
  136459. /**
  136460. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  136461. */
  136462. useHighPrecisionMatrix?: boolean;
  136463. }
  136464. /**
  136465. * The null engine class provides support for headless version of babylon.js.
  136466. * This can be used in server side scenario or for testing purposes
  136467. */
  136468. export class NullEngine extends Engine {
  136469. private _options;
  136470. /**
  136471. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  136472. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136473. * @returns true if engine is in deterministic lock step mode
  136474. */
  136475. isDeterministicLockStep(): boolean;
  136476. /**
  136477. * Gets the max steps when engine is running in deterministic lock step
  136478. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136479. * @returns the max steps
  136480. */
  136481. getLockstepMaxSteps(): number;
  136482. /**
  136483. * Gets the current hardware scaling level.
  136484. * By default the hardware scaling level is computed from the window device ratio.
  136485. * 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.
  136486. * @returns a number indicating the current hardware scaling level
  136487. */
  136488. getHardwareScalingLevel(): number;
  136489. constructor(options?: NullEngineOptions);
  136490. /**
  136491. * Creates a vertex buffer
  136492. * @param vertices the data for the vertex buffer
  136493. * @returns the new WebGL static buffer
  136494. */
  136495. createVertexBuffer(vertices: FloatArray): DataBuffer;
  136496. /**
  136497. * Creates a new index buffer
  136498. * @param indices defines the content of the index buffer
  136499. * @param updatable defines if the index buffer must be updatable
  136500. * @returns a new webGL buffer
  136501. */
  136502. createIndexBuffer(indices: IndicesArray): DataBuffer;
  136503. /**
  136504. * Clear the current render buffer or the current render target (if any is set up)
  136505. * @param color defines the color to use
  136506. * @param backBuffer defines if the back buffer must be cleared
  136507. * @param depth defines if the depth buffer must be cleared
  136508. * @param stencil defines if the stencil buffer must be cleared
  136509. */
  136510. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  136511. /**
  136512. * Gets the current render width
  136513. * @param useScreen defines if screen size must be used (or the current render target if any)
  136514. * @returns a number defining the current render width
  136515. */
  136516. getRenderWidth(useScreen?: boolean): number;
  136517. /**
  136518. * Gets the current render height
  136519. * @param useScreen defines if screen size must be used (or the current render target if any)
  136520. * @returns a number defining the current render height
  136521. */
  136522. getRenderHeight(useScreen?: boolean): number;
  136523. /**
  136524. * Set the WebGL's viewport
  136525. * @param viewport defines the viewport element to be used
  136526. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  136527. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  136528. */
  136529. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  136530. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  136531. /**
  136532. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  136533. * @param pipelineContext defines the pipeline context to use
  136534. * @param uniformsNames defines the list of uniform names
  136535. * @returns an array of webGL uniform locations
  136536. */
  136537. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  136538. /**
  136539. * Gets the lsit of active attributes for a given webGL program
  136540. * @param pipelineContext defines the pipeline context to use
  136541. * @param attributesNames defines the list of attribute names to get
  136542. * @returns an array of indices indicating the offset of each attribute
  136543. */
  136544. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  136545. /**
  136546. * Binds an effect to the webGL context
  136547. * @param effect defines the effect to bind
  136548. */
  136549. bindSamplers(effect: Effect): void;
  136550. /**
  136551. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  136552. * @param effect defines the effect to activate
  136553. */
  136554. enableEffect(effect: Effect): void;
  136555. /**
  136556. * Set various states to the webGL context
  136557. * @param culling defines backface culling state
  136558. * @param zOffset defines the value to apply to zOffset (0 by default)
  136559. * @param force defines if states must be applied even if cache is up to date
  136560. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  136561. */
  136562. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  136563. /**
  136564. * Set the value of an uniform to an array of int32
  136565. * @param uniform defines the webGL uniform location where to store the value
  136566. * @param array defines the array of int32 to store
  136567. * @returns true if value was set
  136568. */
  136569. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136570. /**
  136571. * Set the value of an uniform to an array of int32 (stored as vec2)
  136572. * @param uniform defines the webGL uniform location where to store the value
  136573. * @param array defines the array of int32 to store
  136574. * @returns true if value was set
  136575. */
  136576. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136577. /**
  136578. * Set the value of an uniform to an array of int32 (stored as vec3)
  136579. * @param uniform defines the webGL uniform location where to store the value
  136580. * @param array defines the array of int32 to store
  136581. * @returns true if value was set
  136582. */
  136583. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136584. /**
  136585. * Set the value of an uniform to an array of int32 (stored as vec4)
  136586. * @param uniform defines the webGL uniform location where to store the value
  136587. * @param array defines the array of int32 to store
  136588. * @returns true if value was set
  136589. */
  136590. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136591. /**
  136592. * Set the value of an uniform to an array of float32
  136593. * @param uniform defines the webGL uniform location where to store the value
  136594. * @param array defines the array of float32 to store
  136595. * @returns true if value was set
  136596. */
  136597. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136598. /**
  136599. * Set the value of an uniform to an array of float32 (stored as vec2)
  136600. * @param uniform defines the webGL uniform location where to store the value
  136601. * @param array defines the array of float32 to store
  136602. * @returns true if value was set
  136603. */
  136604. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136605. /**
  136606. * Set the value of an uniform to an array of float32 (stored as vec3)
  136607. * @param uniform defines the webGL uniform location where to store the value
  136608. * @param array defines the array of float32 to store
  136609. * @returns true if value was set
  136610. */
  136611. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136612. /**
  136613. * Set the value of an uniform to an array of float32 (stored as vec4)
  136614. * @param uniform defines the webGL uniform location where to store the value
  136615. * @param array defines the array of float32 to store
  136616. * @returns true if value was set
  136617. */
  136618. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136619. /**
  136620. * Set the value of an uniform to an array of number
  136621. * @param uniform defines the webGL uniform location where to store the value
  136622. * @param array defines the array of number to store
  136623. * @returns true if value was set
  136624. */
  136625. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  136626. /**
  136627. * Set the value of an uniform to an array of number (stored as vec2)
  136628. * @param uniform defines the webGL uniform location where to store the value
  136629. * @param array defines the array of number to store
  136630. * @returns true if value was set
  136631. */
  136632. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  136633. /**
  136634. * Set the value of an uniform to an array of number (stored as vec3)
  136635. * @param uniform defines the webGL uniform location where to store the value
  136636. * @param array defines the array of number to store
  136637. * @returns true if value was set
  136638. */
  136639. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  136640. /**
  136641. * Set the value of an uniform to an array of number (stored as vec4)
  136642. * @param uniform defines the webGL uniform location where to store the value
  136643. * @param array defines the array of number to store
  136644. * @returns true if value was set
  136645. */
  136646. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  136647. /**
  136648. * Set the value of an uniform to an array of float32 (stored as matrices)
  136649. * @param uniform defines the webGL uniform location where to store the value
  136650. * @param matrices defines the array of float32 to store
  136651. * @returns true if value was set
  136652. */
  136653. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  136654. /**
  136655. * Set the value of an uniform to a matrix (3x3)
  136656. * @param uniform defines the webGL uniform location where to store the value
  136657. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  136658. * @returns true if value was set
  136659. */
  136660. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136661. /**
  136662. * Set the value of an uniform to a matrix (2x2)
  136663. * @param uniform defines the webGL uniform location where to store the value
  136664. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  136665. * @returns true if value was set
  136666. */
  136667. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136668. /**
  136669. * Set the value of an uniform to a number (float)
  136670. * @param uniform defines the webGL uniform location where to store the value
  136671. * @param value defines the float number to store
  136672. * @returns true if value was set
  136673. */
  136674. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  136675. /**
  136676. * Set the value of an uniform to a vec2
  136677. * @param uniform defines the webGL uniform location where to store the value
  136678. * @param x defines the 1st component of the value
  136679. * @param y defines the 2nd component of the value
  136680. * @returns true if value was set
  136681. */
  136682. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136683. /**
  136684. * Set the value of an uniform to a vec3
  136685. * @param uniform defines the webGL uniform location where to store the value
  136686. * @param x defines the 1st component of the value
  136687. * @param y defines the 2nd component of the value
  136688. * @param z defines the 3rd component of the value
  136689. * @returns true if value was set
  136690. */
  136691. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136692. /**
  136693. * Set the value of an uniform to a boolean
  136694. * @param uniform defines the webGL uniform location where to store the value
  136695. * @param bool defines the boolean to store
  136696. * @returns true if value was set
  136697. */
  136698. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  136699. /**
  136700. * Set the value of an uniform to a vec4
  136701. * @param uniform defines the webGL uniform location where to store the value
  136702. * @param x defines the 1st component of the value
  136703. * @param y defines the 2nd component of the value
  136704. * @param z defines the 3rd component of the value
  136705. * @param w defines the 4th component of the value
  136706. * @returns true if value was set
  136707. */
  136708. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136709. /**
  136710. * Sets the current alpha mode
  136711. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  136712. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136713. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136714. */
  136715. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136716. /**
  136717. * Bind webGl buffers directly to the webGL context
  136718. * @param vertexBuffers defines the vertex buffer to bind
  136719. * @param indexBuffer defines the index buffer to bind
  136720. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  136721. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  136722. * @param effect defines the effect associated with the vertex buffer
  136723. */
  136724. bindBuffers(vertexBuffers: {
  136725. [key: string]: VertexBuffer;
  136726. }, indexBuffer: DataBuffer, effect: Effect): void;
  136727. /**
  136728. * Force the entire cache to be cleared
  136729. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  136730. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  136731. */
  136732. wipeCaches(bruteForce?: boolean): void;
  136733. /**
  136734. * Send a draw order
  136735. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  136736. * @param indexStart defines the starting index
  136737. * @param indexCount defines the number of index to draw
  136738. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136739. */
  136740. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  136741. /**
  136742. * Draw a list of indexed primitives
  136743. * @param fillMode defines the primitive to use
  136744. * @param indexStart defines the starting index
  136745. * @param indexCount defines the number of index to draw
  136746. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136747. */
  136748. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136749. /**
  136750. * Draw a list of unindexed primitives
  136751. * @param fillMode defines the primitive to use
  136752. * @param verticesStart defines the index of first vertex to draw
  136753. * @param verticesCount defines the count of vertices to draw
  136754. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136755. */
  136756. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136757. /** @hidden */
  136758. _createTexture(): WebGLTexture;
  136759. /** @hidden */
  136760. _releaseTexture(texture: InternalTexture): void;
  136761. /**
  136762. * Usually called from Texture.ts.
  136763. * Passed information to create a WebGLTexture
  136764. * @param urlArg defines a value which contains one of the following:
  136765. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136766. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136767. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136768. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136769. * @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)
  136770. * @param scene needed for loading to the correct scene
  136771. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136772. * @param onLoad optional callback to be called upon successful completion
  136773. * @param onError optional callback to be called upon failure
  136774. * @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
  136775. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136776. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136777. * @param forcedExtension defines the extension to use to pick the right loader
  136778. * @param mimeType defines an optional mime type
  136779. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136780. */
  136781. 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;
  136782. /**
  136783. * Creates a new render target texture
  136784. * @param size defines the size of the texture
  136785. * @param options defines the options used to create the texture
  136786. * @returns a new render target texture stored in an InternalTexture
  136787. */
  136788. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  136789. /**
  136790. * Update the sampling mode of a given texture
  136791. * @param samplingMode defines the required sampling mode
  136792. * @param texture defines the texture to update
  136793. */
  136794. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136795. /**
  136796. * Binds the frame buffer to the specified texture.
  136797. * @param texture The texture to render to or null for the default canvas
  136798. * @param faceIndex The face of the texture to render to in case of cube texture
  136799. * @param requiredWidth The width of the target to render to
  136800. * @param requiredHeight The height of the target to render to
  136801. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  136802. * @param lodLevel defines le lod level to bind to the frame buffer
  136803. */
  136804. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136805. /**
  136806. * Unbind the current render target texture from the webGL context
  136807. * @param texture defines the render target texture to unbind
  136808. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  136809. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  136810. */
  136811. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136812. /**
  136813. * Creates a dynamic vertex buffer
  136814. * @param vertices the data for the dynamic vertex buffer
  136815. * @returns the new WebGL dynamic buffer
  136816. */
  136817. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  136818. /**
  136819. * Update the content of a dynamic texture
  136820. * @param texture defines the texture to update
  136821. * @param canvas defines the canvas containing the source
  136822. * @param invertY defines if data must be stored with Y axis inverted
  136823. * @param premulAlpha defines if alpha is stored as premultiplied
  136824. * @param format defines the format of the data
  136825. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136826. */
  136827. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136828. /**
  136829. * Gets a boolean indicating if all created effects are ready
  136830. * @returns true if all effects are ready
  136831. */
  136832. areAllEffectsReady(): boolean;
  136833. /**
  136834. * @hidden
  136835. * Get the current error code of the webGL context
  136836. * @returns the error code
  136837. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  136838. */
  136839. getError(): number;
  136840. /** @hidden */
  136841. _getUnpackAlignement(): number;
  136842. /** @hidden */
  136843. _unpackFlipY(value: boolean): void;
  136844. /**
  136845. * Update a dynamic index buffer
  136846. * @param indexBuffer defines the target index buffer
  136847. * @param indices defines the data to update
  136848. * @param offset defines the offset in the target index buffer where update should start
  136849. */
  136850. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  136851. /**
  136852. * Updates a dynamic vertex buffer.
  136853. * @param vertexBuffer the vertex buffer to update
  136854. * @param vertices the data used to update the vertex buffer
  136855. * @param byteOffset the byte offset of the data (optional)
  136856. * @param byteLength the byte length of the data (optional)
  136857. */
  136858. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  136859. /** @hidden */
  136860. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  136861. /** @hidden */
  136862. _bindTexture(channel: number, texture: InternalTexture): void;
  136863. protected _deleteBuffer(buffer: WebGLBuffer): void;
  136864. /**
  136865. * 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
  136866. */
  136867. releaseEffects(): void;
  136868. displayLoadingUI(): void;
  136869. hideLoadingUI(): void;
  136870. /** @hidden */
  136871. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136872. /** @hidden */
  136873. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136874. /** @hidden */
  136875. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136876. /** @hidden */
  136877. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136878. }
  136879. }
  136880. declare module BABYLON {
  136881. /**
  136882. * @hidden
  136883. **/
  136884. export class _TimeToken {
  136885. _startTimeQuery: Nullable<WebGLQuery>;
  136886. _endTimeQuery: Nullable<WebGLQuery>;
  136887. _timeElapsedQuery: Nullable<WebGLQuery>;
  136888. _timeElapsedQueryEnded: boolean;
  136889. }
  136890. }
  136891. declare module BABYLON {
  136892. /** @hidden */
  136893. export class _OcclusionDataStorage {
  136894. /** @hidden */
  136895. occlusionInternalRetryCounter: number;
  136896. /** @hidden */
  136897. isOcclusionQueryInProgress: boolean;
  136898. /** @hidden */
  136899. isOccluded: boolean;
  136900. /** @hidden */
  136901. occlusionRetryCount: number;
  136902. /** @hidden */
  136903. occlusionType: number;
  136904. /** @hidden */
  136905. occlusionQueryAlgorithmType: number;
  136906. }
  136907. interface Engine {
  136908. /**
  136909. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  136910. * @return the new query
  136911. */
  136912. createQuery(): WebGLQuery;
  136913. /**
  136914. * Delete and release a webGL query
  136915. * @param query defines the query to delete
  136916. * @return the current engine
  136917. */
  136918. deleteQuery(query: WebGLQuery): Engine;
  136919. /**
  136920. * Check if a given query has resolved and got its value
  136921. * @param query defines the query to check
  136922. * @returns true if the query got its value
  136923. */
  136924. isQueryResultAvailable(query: WebGLQuery): boolean;
  136925. /**
  136926. * Gets the value of a given query
  136927. * @param query defines the query to check
  136928. * @returns the value of the query
  136929. */
  136930. getQueryResult(query: WebGLQuery): number;
  136931. /**
  136932. * Initiates an occlusion query
  136933. * @param algorithmType defines the algorithm to use
  136934. * @param query defines the query to use
  136935. * @returns the current engine
  136936. * @see https://doc.babylonjs.com/features/occlusionquery
  136937. */
  136938. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  136939. /**
  136940. * Ends an occlusion query
  136941. * @see https://doc.babylonjs.com/features/occlusionquery
  136942. * @param algorithmType defines the algorithm to use
  136943. * @returns the current engine
  136944. */
  136945. endOcclusionQuery(algorithmType: number): Engine;
  136946. /**
  136947. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  136948. * Please note that only one query can be issued at a time
  136949. * @returns a time token used to track the time span
  136950. */
  136951. startTimeQuery(): Nullable<_TimeToken>;
  136952. /**
  136953. * Ends a time query
  136954. * @param token defines the token used to measure the time span
  136955. * @returns the time spent (in ns)
  136956. */
  136957. endTimeQuery(token: _TimeToken): int;
  136958. /** @hidden */
  136959. _currentNonTimestampToken: Nullable<_TimeToken>;
  136960. /** @hidden */
  136961. _createTimeQuery(): WebGLQuery;
  136962. /** @hidden */
  136963. _deleteTimeQuery(query: WebGLQuery): void;
  136964. /** @hidden */
  136965. _getGlAlgorithmType(algorithmType: number): number;
  136966. /** @hidden */
  136967. _getTimeQueryResult(query: WebGLQuery): any;
  136968. /** @hidden */
  136969. _getTimeQueryAvailability(query: WebGLQuery): any;
  136970. }
  136971. interface AbstractMesh {
  136972. /**
  136973. * Backing filed
  136974. * @hidden
  136975. */
  136976. __occlusionDataStorage: _OcclusionDataStorage;
  136977. /**
  136978. * Access property
  136979. * @hidden
  136980. */
  136981. _occlusionDataStorage: _OcclusionDataStorage;
  136982. /**
  136983. * 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.
  136984. * The default value is -1 which means don't break the query and wait till the result
  136985. * @see https://doc.babylonjs.com/features/occlusionquery
  136986. */
  136987. occlusionRetryCount: number;
  136988. /**
  136989. * 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:
  136990. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  136991. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  136992. * * 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.
  136993. * @see https://doc.babylonjs.com/features/occlusionquery
  136994. */
  136995. occlusionType: number;
  136996. /**
  136997. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  136998. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  136999. * * 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.
  137000. * @see https://doc.babylonjs.com/features/occlusionquery
  137001. */
  137002. occlusionQueryAlgorithmType: number;
  137003. /**
  137004. * 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
  137005. * @see https://doc.babylonjs.com/features/occlusionquery
  137006. */
  137007. isOccluded: boolean;
  137008. /**
  137009. * Flag to check the progress status of the query
  137010. * @see https://doc.babylonjs.com/features/occlusionquery
  137011. */
  137012. isOcclusionQueryInProgress: boolean;
  137013. }
  137014. }
  137015. declare module BABYLON {
  137016. /** @hidden */
  137017. export var _forceTransformFeedbackToBundle: boolean;
  137018. interface Engine {
  137019. /**
  137020. * Creates a webGL transform feedback object
  137021. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  137022. * @returns the webGL transform feedback object
  137023. */
  137024. createTransformFeedback(): WebGLTransformFeedback;
  137025. /**
  137026. * Delete a webGL transform feedback object
  137027. * @param value defines the webGL transform feedback object to delete
  137028. */
  137029. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  137030. /**
  137031. * Bind a webGL transform feedback object to the webgl context
  137032. * @param value defines the webGL transform feedback object to bind
  137033. */
  137034. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  137035. /**
  137036. * Begins a transform feedback operation
  137037. * @param usePoints defines if points or triangles must be used
  137038. */
  137039. beginTransformFeedback(usePoints: boolean): void;
  137040. /**
  137041. * Ends a transform feedback operation
  137042. */
  137043. endTransformFeedback(): void;
  137044. /**
  137045. * Specify the varyings to use with transform feedback
  137046. * @param program defines the associated webGL program
  137047. * @param value defines the list of strings representing the varying names
  137048. */
  137049. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  137050. /**
  137051. * Bind a webGL buffer for a transform feedback operation
  137052. * @param value defines the webGL buffer to bind
  137053. */
  137054. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  137055. }
  137056. }
  137057. declare module BABYLON {
  137058. /**
  137059. * Class used to define an additional view for the engine
  137060. * @see https://doc.babylonjs.com/how_to/multi_canvases
  137061. */
  137062. export class EngineView {
  137063. /** Defines the canvas where to render the view */
  137064. target: HTMLCanvasElement;
  137065. /** Defines an optional camera used to render the view (will use active camera else) */
  137066. camera?: Camera;
  137067. }
  137068. interface Engine {
  137069. /**
  137070. * Gets or sets the HTML element to use for attaching events
  137071. */
  137072. inputElement: Nullable<HTMLElement>;
  137073. /**
  137074. * Gets the current engine view
  137075. * @see https://doc.babylonjs.com/how_to/multi_canvases
  137076. */
  137077. activeView: Nullable<EngineView>;
  137078. /** Gets or sets the list of views */
  137079. views: EngineView[];
  137080. /**
  137081. * Register a new child canvas
  137082. * @param canvas defines the canvas to register
  137083. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  137084. * @returns the associated view
  137085. */
  137086. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  137087. /**
  137088. * Remove a registered child canvas
  137089. * @param canvas defines the canvas to remove
  137090. * @returns the current engine
  137091. */
  137092. unRegisterView(canvas: HTMLCanvasElement): Engine;
  137093. }
  137094. }
  137095. declare module BABYLON {
  137096. interface Engine {
  137097. /** @hidden */
  137098. _excludedCompressedTextures: string[];
  137099. /** @hidden */
  137100. _textureFormatInUse: string;
  137101. /**
  137102. * Gets the list of texture formats supported
  137103. */
  137104. readonly texturesSupported: Array<string>;
  137105. /**
  137106. * Gets the texture format in use
  137107. */
  137108. readonly textureFormatInUse: Nullable<string>;
  137109. /**
  137110. * Set the compressed texture extensions or file names to skip.
  137111. *
  137112. * @param skippedFiles defines the list of those texture files you want to skip
  137113. * Example: [".dds", ".env", "myfile.png"]
  137114. */
  137115. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  137116. /**
  137117. * Set the compressed texture format to use, based on the formats you have, and the formats
  137118. * supported by the hardware / browser.
  137119. *
  137120. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  137121. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  137122. * to API arguments needed to compressed textures. This puts the burden on the container
  137123. * generator to house the arcane code for determining these for current & future formats.
  137124. *
  137125. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  137126. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  137127. *
  137128. * Note: The result of this call is not taken into account when a texture is base64.
  137129. *
  137130. * @param formatsAvailable defines the list of those format families you have created
  137131. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  137132. *
  137133. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  137134. * @returns The extension selected.
  137135. */
  137136. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  137137. }
  137138. }
  137139. declare module BABYLON {
  137140. /** @hidden */
  137141. export var rgbdEncodePixelShader: {
  137142. name: string;
  137143. shader: string;
  137144. };
  137145. }
  137146. declare module BABYLON {
  137147. /**
  137148. * Raw texture data and descriptor sufficient for WebGL texture upload
  137149. */
  137150. export interface EnvironmentTextureInfo {
  137151. /**
  137152. * Version of the environment map
  137153. */
  137154. version: number;
  137155. /**
  137156. * Width of image
  137157. */
  137158. width: number;
  137159. /**
  137160. * Irradiance information stored in the file.
  137161. */
  137162. irradiance: any;
  137163. /**
  137164. * Specular information stored in the file.
  137165. */
  137166. specular: any;
  137167. }
  137168. /**
  137169. * Defines One Image in the file. It requires only the position in the file
  137170. * as well as the length.
  137171. */
  137172. interface BufferImageData {
  137173. /**
  137174. * Length of the image data.
  137175. */
  137176. length: number;
  137177. /**
  137178. * Position of the data from the null terminator delimiting the end of the JSON.
  137179. */
  137180. position: number;
  137181. }
  137182. /**
  137183. * Defines the specular data enclosed in the file.
  137184. * This corresponds to the version 1 of the data.
  137185. */
  137186. export interface EnvironmentTextureSpecularInfoV1 {
  137187. /**
  137188. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  137189. */
  137190. specularDataPosition?: number;
  137191. /**
  137192. * This contains all the images data needed to reconstruct the cubemap.
  137193. */
  137194. mipmaps: Array<BufferImageData>;
  137195. /**
  137196. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  137197. */
  137198. lodGenerationScale: number;
  137199. }
  137200. /**
  137201. * Sets of helpers addressing the serialization and deserialization of environment texture
  137202. * stored in a BabylonJS env file.
  137203. * Those files are usually stored as .env files.
  137204. */
  137205. export class EnvironmentTextureTools {
  137206. /**
  137207. * Magic number identifying the env file.
  137208. */
  137209. private static _MagicBytes;
  137210. /**
  137211. * Gets the environment info from an env file.
  137212. * @param data The array buffer containing the .env bytes.
  137213. * @returns the environment file info (the json header) if successfully parsed.
  137214. */
  137215. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  137216. /**
  137217. * Creates an environment texture from a loaded cube texture.
  137218. * @param texture defines the cube texture to convert in env file
  137219. * @return a promise containing the environment data if succesfull.
  137220. */
  137221. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  137222. /**
  137223. * Creates a JSON representation of the spherical data.
  137224. * @param texture defines the texture containing the polynomials
  137225. * @return the JSON representation of the spherical info
  137226. */
  137227. private static _CreateEnvTextureIrradiance;
  137228. /**
  137229. * Creates the ArrayBufferViews used for initializing environment texture image data.
  137230. * @param data the image data
  137231. * @param info parameters that determine what views will be created for accessing the underlying buffer
  137232. * @return the views described by info providing access to the underlying buffer
  137233. */
  137234. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  137235. /**
  137236. * Uploads the texture info contained in the env file to the GPU.
  137237. * @param texture defines the internal texture to upload to
  137238. * @param data defines the data to load
  137239. * @param info defines the texture info retrieved through the GetEnvInfo method
  137240. * @returns a promise
  137241. */
  137242. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  137243. private static _OnImageReadyAsync;
  137244. /**
  137245. * Uploads the levels of image data to the GPU.
  137246. * @param texture defines the internal texture to upload to
  137247. * @param imageData defines the array buffer views of image data [mipmap][face]
  137248. * @returns a promise
  137249. */
  137250. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  137251. /**
  137252. * Uploads spherical polynomials information to the texture.
  137253. * @param texture defines the texture we are trying to upload the information to
  137254. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  137255. */
  137256. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  137257. /** @hidden */
  137258. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  137259. }
  137260. }
  137261. declare module BABYLON {
  137262. /**
  137263. * Class used to inline functions in shader code
  137264. */
  137265. export class ShaderCodeInliner {
  137266. private static readonly _RegexpFindFunctionNameAndType;
  137267. private _sourceCode;
  137268. private _functionDescr;
  137269. private _numMaxIterations;
  137270. /** Gets or sets the token used to mark the functions to inline */
  137271. inlineToken: string;
  137272. /** Gets or sets the debug mode */
  137273. debug: boolean;
  137274. /** Gets the code after the inlining process */
  137275. get code(): string;
  137276. /**
  137277. * Initializes the inliner
  137278. * @param sourceCode shader code source to inline
  137279. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  137280. */
  137281. constructor(sourceCode: string, numMaxIterations?: number);
  137282. /**
  137283. * Start the processing of the shader code
  137284. */
  137285. processCode(): void;
  137286. private _collectFunctions;
  137287. private _processInlining;
  137288. private _extractBetweenMarkers;
  137289. private _skipWhitespaces;
  137290. private _removeComments;
  137291. private _replaceFunctionCallsByCode;
  137292. private _findBackward;
  137293. private _escapeRegExp;
  137294. private _replaceNames;
  137295. }
  137296. }
  137297. declare module BABYLON {
  137298. /**
  137299. * Container for accessors for natively-stored mesh data buffers.
  137300. */
  137301. class NativeDataBuffer extends DataBuffer {
  137302. /**
  137303. * Accessor value used to identify/retrieve a natively-stored index buffer.
  137304. */
  137305. nativeIndexBuffer?: any;
  137306. /**
  137307. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  137308. */
  137309. nativeVertexBuffer?: any;
  137310. }
  137311. /** @hidden */
  137312. class NativeTexture extends InternalTexture {
  137313. getInternalTexture(): InternalTexture;
  137314. getViewCount(): number;
  137315. }
  137316. /** @hidden */
  137317. export class NativeEngine extends Engine {
  137318. private readonly _native;
  137319. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  137320. private readonly INVALID_HANDLE;
  137321. private _boundBuffersVertexArray;
  137322. private _currentDepthTest;
  137323. getHardwareScalingLevel(): number;
  137324. constructor();
  137325. dispose(): void;
  137326. /**
  137327. * Can be used to override the current requestAnimationFrame requester.
  137328. * @hidden
  137329. */
  137330. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  137331. /**
  137332. * Override default engine behavior.
  137333. * @param color
  137334. * @param backBuffer
  137335. * @param depth
  137336. * @param stencil
  137337. */
  137338. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  137339. /**
  137340. * Gets host document
  137341. * @returns the host document object
  137342. */
  137343. getHostDocument(): Nullable<Document>;
  137344. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  137345. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  137346. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  137347. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  137348. [key: string]: VertexBuffer;
  137349. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  137350. bindBuffers(vertexBuffers: {
  137351. [key: string]: VertexBuffer;
  137352. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  137353. recordVertexArrayObject(vertexBuffers: {
  137354. [key: string]: VertexBuffer;
  137355. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  137356. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  137357. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  137358. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  137359. /**
  137360. * Draw a list of indexed primitives
  137361. * @param fillMode defines the primitive to use
  137362. * @param indexStart defines the starting index
  137363. * @param indexCount defines the number of index to draw
  137364. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137365. */
  137366. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  137367. /**
  137368. * Draw a list of unindexed primitives
  137369. * @param fillMode defines the primitive to use
  137370. * @param verticesStart defines the index of first vertex to draw
  137371. * @param verticesCount defines the count of vertices to draw
  137372. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137373. */
  137374. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  137375. createPipelineContext(): IPipelineContext;
  137376. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  137377. /** @hidden */
  137378. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  137379. /** @hidden */
  137380. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  137381. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  137382. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  137383. protected _setProgram(program: WebGLProgram): void;
  137384. _releaseEffect(effect: Effect): void;
  137385. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  137386. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  137387. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  137388. bindSamplers(effect: Effect): void;
  137389. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  137390. getRenderWidth(useScreen?: boolean): number;
  137391. getRenderHeight(useScreen?: boolean): number;
  137392. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  137393. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  137394. /**
  137395. * Set the z offset to apply to current rendering
  137396. * @param value defines the offset to apply
  137397. */
  137398. setZOffset(value: number): void;
  137399. /**
  137400. * Gets the current value of the zOffset
  137401. * @returns the current zOffset state
  137402. */
  137403. getZOffset(): number;
  137404. /**
  137405. * Enable or disable depth buffering
  137406. * @param enable defines the state to set
  137407. */
  137408. setDepthBuffer(enable: boolean): void;
  137409. /**
  137410. * Gets a boolean indicating if depth writing is enabled
  137411. * @returns the current depth writing state
  137412. */
  137413. getDepthWrite(): boolean;
  137414. setDepthFunctionToGreater(): void;
  137415. setDepthFunctionToGreaterOrEqual(): void;
  137416. setDepthFunctionToLess(): void;
  137417. setDepthFunctionToLessOrEqual(): void;
  137418. /**
  137419. * Enable or disable depth writing
  137420. * @param enable defines the state to set
  137421. */
  137422. setDepthWrite(enable: boolean): void;
  137423. /**
  137424. * Enable or disable color writing
  137425. * @param enable defines the state to set
  137426. */
  137427. setColorWrite(enable: boolean): void;
  137428. /**
  137429. * Gets a boolean indicating if color writing is enabled
  137430. * @returns the current color writing state
  137431. */
  137432. getColorWrite(): boolean;
  137433. /**
  137434. * Sets alpha constants used by some alpha blending modes
  137435. * @param r defines the red component
  137436. * @param g defines the green component
  137437. * @param b defines the blue component
  137438. * @param a defines the alpha component
  137439. */
  137440. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  137441. /**
  137442. * Sets the current alpha mode
  137443. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  137444. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  137445. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  137446. */
  137447. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  137448. /**
  137449. * Gets the current alpha mode
  137450. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  137451. * @returns the current alpha mode
  137452. */
  137453. getAlphaMode(): number;
  137454. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  137455. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137456. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137457. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137458. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137459. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137460. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137461. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137462. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137463. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  137464. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  137465. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  137466. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  137467. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  137468. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137469. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137470. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  137471. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  137472. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  137473. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  137474. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  137475. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  137476. wipeCaches(bruteForce?: boolean): void;
  137477. _createTexture(): WebGLTexture;
  137478. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  137479. /**
  137480. * Update the content of a dynamic texture
  137481. * @param texture defines the texture to update
  137482. * @param canvas defines the canvas containing the source
  137483. * @param invertY defines if data must be stored with Y axis inverted
  137484. * @param premulAlpha defines if alpha is stored as premultiplied
  137485. * @param format defines the format of the data
  137486. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  137487. */
  137488. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  137489. /**
  137490. * Usually called from Texture.ts.
  137491. * Passed information to create a WebGLTexture
  137492. * @param url defines a value which contains one of the following:
  137493. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  137494. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  137495. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  137496. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  137497. * @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)
  137498. * @param scene needed for loading to the correct scene
  137499. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  137500. * @param onLoad optional callback to be called upon successful completion
  137501. * @param onError optional callback to be called upon failure
  137502. * @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
  137503. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  137504. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  137505. * @param forcedExtension defines the extension to use to pick the right loader
  137506. * @param mimeType defines an optional mime type
  137507. * @param loaderOptions options to be passed to the loader
  137508. * @returns a InternalTexture for assignment back into BABYLON.Texture
  137509. */
  137510. 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;
  137511. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  137512. _releaseFramebufferObjects(texture: InternalTexture): void;
  137513. /**
  137514. * Creates a cube texture
  137515. * @param rootUrl defines the url where the files to load is located
  137516. * @param scene defines the current scene
  137517. * @param files defines the list of files to load (1 per face)
  137518. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  137519. * @param onLoad defines an optional callback raised when the texture is loaded
  137520. * @param onError defines an optional callback raised if there is an issue to load the texture
  137521. * @param format defines the format of the data
  137522. * @param forcedExtension defines the extension to use to pick the right loader
  137523. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  137524. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  137525. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  137526. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  137527. * @returns the cube texture as an InternalTexture
  137528. */
  137529. 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;
  137530. createRenderTargetTexture(size: number | {
  137531. width: number;
  137532. height: number;
  137533. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  137534. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  137535. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  137536. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  137537. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  137538. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  137539. /**
  137540. * Updates a dynamic vertex buffer.
  137541. * @param vertexBuffer the vertex buffer to update
  137542. * @param data the data used to update the vertex buffer
  137543. * @param byteOffset the byte offset of the data (optional)
  137544. * @param byteLength the byte length of the data (optional)
  137545. */
  137546. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  137547. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  137548. private _updateAnisotropicLevel;
  137549. private _getAddressMode;
  137550. /** @hidden */
  137551. _bindTexture(channel: number, texture: InternalTexture): void;
  137552. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  137553. releaseEffects(): void;
  137554. /** @hidden */
  137555. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137556. /** @hidden */
  137557. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137558. /** @hidden */
  137559. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137560. /** @hidden */
  137561. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  137562. private _getNativeSamplingMode;
  137563. private _getNativeTextureFormat;
  137564. private _getNativeAlphaMode;
  137565. private _getNativeAttribType;
  137566. }
  137567. }
  137568. declare module BABYLON {
  137569. /**
  137570. * Gather the list of clipboard event types as constants.
  137571. */
  137572. export class ClipboardEventTypes {
  137573. /**
  137574. * The clipboard event is fired when a copy command is active (pressed).
  137575. */
  137576. static readonly COPY: number;
  137577. /**
  137578. * The clipboard event is fired when a cut command is active (pressed).
  137579. */
  137580. static readonly CUT: number;
  137581. /**
  137582. * The clipboard event is fired when a paste command is active (pressed).
  137583. */
  137584. static readonly PASTE: number;
  137585. }
  137586. /**
  137587. * This class is used to store clipboard related info for the onClipboardObservable event.
  137588. */
  137589. export class ClipboardInfo {
  137590. /**
  137591. * Defines the type of event (BABYLON.ClipboardEventTypes)
  137592. */
  137593. type: number;
  137594. /**
  137595. * Defines the related dom event
  137596. */
  137597. event: ClipboardEvent;
  137598. /**
  137599. *Creates an instance of ClipboardInfo.
  137600. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  137601. * @param event Defines the related dom event
  137602. */
  137603. constructor(
  137604. /**
  137605. * Defines the type of event (BABYLON.ClipboardEventTypes)
  137606. */
  137607. type: number,
  137608. /**
  137609. * Defines the related dom event
  137610. */
  137611. event: ClipboardEvent);
  137612. /**
  137613. * Get the clipboard event's type from the keycode.
  137614. * @param keyCode Defines the keyCode for the current keyboard event.
  137615. * @return {number}
  137616. */
  137617. static GetTypeFromCharacter(keyCode: number): number;
  137618. }
  137619. }
  137620. declare module BABYLON {
  137621. /**
  137622. * Google Daydream controller
  137623. */
  137624. export class DaydreamController extends WebVRController {
  137625. /**
  137626. * Base Url for the controller model.
  137627. */
  137628. static MODEL_BASE_URL: string;
  137629. /**
  137630. * File name for the controller model.
  137631. */
  137632. static MODEL_FILENAME: string;
  137633. /**
  137634. * Gamepad Id prefix used to identify Daydream Controller.
  137635. */
  137636. static readonly GAMEPAD_ID_PREFIX: string;
  137637. /**
  137638. * Creates a new DaydreamController from a gamepad
  137639. * @param vrGamepad the gamepad that the controller should be created from
  137640. */
  137641. constructor(vrGamepad: any);
  137642. /**
  137643. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137644. * @param scene scene in which to add meshes
  137645. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137646. */
  137647. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137648. /**
  137649. * Called once for each button that changed state since the last frame
  137650. * @param buttonIdx Which button index changed
  137651. * @param state New state of the button
  137652. * @param changes Which properties on the state changed since last frame
  137653. */
  137654. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137655. }
  137656. }
  137657. declare module BABYLON {
  137658. /**
  137659. * Gear VR Controller
  137660. */
  137661. export class GearVRController extends WebVRController {
  137662. /**
  137663. * Base Url for the controller model.
  137664. */
  137665. static MODEL_BASE_URL: string;
  137666. /**
  137667. * File name for the controller model.
  137668. */
  137669. static MODEL_FILENAME: string;
  137670. /**
  137671. * Gamepad Id prefix used to identify this controller.
  137672. */
  137673. static readonly GAMEPAD_ID_PREFIX: string;
  137674. private readonly _buttonIndexToObservableNameMap;
  137675. /**
  137676. * Creates a new GearVRController from a gamepad
  137677. * @param vrGamepad the gamepad that the controller should be created from
  137678. */
  137679. constructor(vrGamepad: any);
  137680. /**
  137681. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137682. * @param scene scene in which to add meshes
  137683. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137684. */
  137685. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137686. /**
  137687. * Called once for each button that changed state since the last frame
  137688. * @param buttonIdx Which button index changed
  137689. * @param state New state of the button
  137690. * @param changes Which properties on the state changed since last frame
  137691. */
  137692. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137693. }
  137694. }
  137695. declare module BABYLON {
  137696. /**
  137697. * Generic Controller
  137698. */
  137699. export class GenericController extends WebVRController {
  137700. /**
  137701. * Base Url for the controller model.
  137702. */
  137703. static readonly MODEL_BASE_URL: string;
  137704. /**
  137705. * File name for the controller model.
  137706. */
  137707. static readonly MODEL_FILENAME: string;
  137708. /**
  137709. * Creates a new GenericController from a gamepad
  137710. * @param vrGamepad the gamepad that the controller should be created from
  137711. */
  137712. constructor(vrGamepad: any);
  137713. /**
  137714. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137715. * @param scene scene in which to add meshes
  137716. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137717. */
  137718. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137719. /**
  137720. * Called once for each button that changed state since the last frame
  137721. * @param buttonIdx Which button index changed
  137722. * @param state New state of the button
  137723. * @param changes Which properties on the state changed since last frame
  137724. */
  137725. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137726. }
  137727. }
  137728. declare module BABYLON {
  137729. /**
  137730. * Oculus Touch Controller
  137731. */
  137732. export class OculusTouchController extends WebVRController {
  137733. /**
  137734. * Base Url for the controller model.
  137735. */
  137736. static MODEL_BASE_URL: string;
  137737. /**
  137738. * File name for the left controller model.
  137739. */
  137740. static MODEL_LEFT_FILENAME: string;
  137741. /**
  137742. * File name for the right controller model.
  137743. */
  137744. static MODEL_RIGHT_FILENAME: string;
  137745. /**
  137746. * Base Url for the Quest controller model.
  137747. */
  137748. static QUEST_MODEL_BASE_URL: string;
  137749. /**
  137750. * @hidden
  137751. * If the controllers are running on a device that needs the updated Quest controller models
  137752. */
  137753. static _IsQuest: boolean;
  137754. /**
  137755. * Fired when the secondary trigger on this controller is modified
  137756. */
  137757. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  137758. /**
  137759. * Fired when the thumb rest on this controller is modified
  137760. */
  137761. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  137762. /**
  137763. * Creates a new OculusTouchController from a gamepad
  137764. * @param vrGamepad the gamepad that the controller should be created from
  137765. */
  137766. constructor(vrGamepad: any);
  137767. /**
  137768. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137769. * @param scene scene in which to add meshes
  137770. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137771. */
  137772. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137773. /**
  137774. * Fired when the A button on this controller is modified
  137775. */
  137776. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137777. /**
  137778. * Fired when the B button on this controller is modified
  137779. */
  137780. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137781. /**
  137782. * Fired when the X button on this controller is modified
  137783. */
  137784. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137785. /**
  137786. * Fired when the Y button on this controller is modified
  137787. */
  137788. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137789. /**
  137790. * Called once for each button that changed state since the last frame
  137791. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  137792. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  137793. * 2) secondary trigger (same)
  137794. * 3) A (right) X (left), touch, pressed = value
  137795. * 4) B / Y
  137796. * 5) thumb rest
  137797. * @param buttonIdx Which button index changed
  137798. * @param state New state of the button
  137799. * @param changes Which properties on the state changed since last frame
  137800. */
  137801. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137802. }
  137803. }
  137804. declare module BABYLON {
  137805. /**
  137806. * Vive Controller
  137807. */
  137808. export class ViveController extends WebVRController {
  137809. /**
  137810. * Base Url for the controller model.
  137811. */
  137812. static MODEL_BASE_URL: string;
  137813. /**
  137814. * File name for the controller model.
  137815. */
  137816. static MODEL_FILENAME: string;
  137817. /**
  137818. * Creates a new ViveController from a gamepad
  137819. * @param vrGamepad the gamepad that the controller should be created from
  137820. */
  137821. constructor(vrGamepad: any);
  137822. /**
  137823. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137824. * @param scene scene in which to add meshes
  137825. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137826. */
  137827. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137828. /**
  137829. * Fired when the left button on this controller is modified
  137830. */
  137831. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137832. /**
  137833. * Fired when the right button on this controller is modified
  137834. */
  137835. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137836. /**
  137837. * Fired when the menu button on this controller is modified
  137838. */
  137839. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137840. /**
  137841. * Called once for each button that changed state since the last frame
  137842. * Vive mapping:
  137843. * 0: touchpad
  137844. * 1: trigger
  137845. * 2: left AND right buttons
  137846. * 3: menu button
  137847. * @param buttonIdx Which button index changed
  137848. * @param state New state of the button
  137849. * @param changes Which properties on the state changed since last frame
  137850. */
  137851. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137852. }
  137853. }
  137854. declare module BABYLON {
  137855. /**
  137856. * Defines the WindowsMotionController object that the state of the windows motion controller
  137857. */
  137858. export class WindowsMotionController extends WebVRController {
  137859. /**
  137860. * The base url used to load the left and right controller models
  137861. */
  137862. static MODEL_BASE_URL: string;
  137863. /**
  137864. * The name of the left controller model file
  137865. */
  137866. static MODEL_LEFT_FILENAME: string;
  137867. /**
  137868. * The name of the right controller model file
  137869. */
  137870. static MODEL_RIGHT_FILENAME: string;
  137871. /**
  137872. * The controller name prefix for this controller type
  137873. */
  137874. static readonly GAMEPAD_ID_PREFIX: string;
  137875. /**
  137876. * The controller id pattern for this controller type
  137877. */
  137878. private static readonly GAMEPAD_ID_PATTERN;
  137879. private _loadedMeshInfo;
  137880. protected readonly _mapping: {
  137881. buttons: string[];
  137882. buttonMeshNames: {
  137883. trigger: string;
  137884. menu: string;
  137885. grip: string;
  137886. thumbstick: string;
  137887. trackpad: string;
  137888. };
  137889. buttonObservableNames: {
  137890. trigger: string;
  137891. menu: string;
  137892. grip: string;
  137893. thumbstick: string;
  137894. trackpad: string;
  137895. };
  137896. axisMeshNames: string[];
  137897. pointingPoseMeshName: string;
  137898. };
  137899. /**
  137900. * Fired when the trackpad on this controller is clicked
  137901. */
  137902. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137903. /**
  137904. * Fired when the trackpad on this controller is modified
  137905. */
  137906. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137907. /**
  137908. * The current x and y values of this controller's trackpad
  137909. */
  137910. trackpad: StickValues;
  137911. /**
  137912. * Creates a new WindowsMotionController from a gamepad
  137913. * @param vrGamepad the gamepad that the controller should be created from
  137914. */
  137915. constructor(vrGamepad: any);
  137916. /**
  137917. * Fired when the trigger on this controller is modified
  137918. */
  137919. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137920. /**
  137921. * Fired when the menu button on this controller is modified
  137922. */
  137923. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137924. /**
  137925. * Fired when the grip button on this controller is modified
  137926. */
  137927. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137928. /**
  137929. * Fired when the thumbstick button on this controller is modified
  137930. */
  137931. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137932. /**
  137933. * Fired when the touchpad button on this controller is modified
  137934. */
  137935. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137936. /**
  137937. * Fired when the touchpad values on this controller are modified
  137938. */
  137939. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  137940. protected _updateTrackpad(): void;
  137941. /**
  137942. * Called once per frame by the engine.
  137943. */
  137944. update(): void;
  137945. /**
  137946. * Called once for each button that changed state since the last frame
  137947. * @param buttonIdx Which button index changed
  137948. * @param state New state of the button
  137949. * @param changes Which properties on the state changed since last frame
  137950. */
  137951. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137952. /**
  137953. * Moves the buttons on the controller mesh based on their current state
  137954. * @param buttonName the name of the button to move
  137955. * @param buttonValue the value of the button which determines the buttons new position
  137956. */
  137957. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  137958. /**
  137959. * Moves the axis on the controller mesh based on its current state
  137960. * @param axis the index of the axis
  137961. * @param axisValue the value of the axis which determines the meshes new position
  137962. * @hidden
  137963. */
  137964. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  137965. /**
  137966. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137967. * @param scene scene in which to add meshes
  137968. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137969. */
  137970. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  137971. /**
  137972. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  137973. * can be transformed by button presses and axes values, based on this._mapping.
  137974. *
  137975. * @param scene scene in which the meshes exist
  137976. * @param meshes list of meshes that make up the controller model to process
  137977. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  137978. */
  137979. private processModel;
  137980. private createMeshInfo;
  137981. /**
  137982. * Gets the ray of the controller in the direction the controller is pointing
  137983. * @param length the length the resulting ray should be
  137984. * @returns a ray in the direction the controller is pointing
  137985. */
  137986. getForwardRay(length?: number): Ray;
  137987. /**
  137988. * Disposes of the controller
  137989. */
  137990. dispose(): void;
  137991. }
  137992. /**
  137993. * This class represents a new windows motion controller in XR.
  137994. */
  137995. export class XRWindowsMotionController extends WindowsMotionController {
  137996. /**
  137997. * Changing the original WIndowsMotionController mapping to fir the new mapping
  137998. */
  137999. protected readonly _mapping: {
  138000. buttons: string[];
  138001. buttonMeshNames: {
  138002. trigger: string;
  138003. menu: string;
  138004. grip: string;
  138005. thumbstick: string;
  138006. trackpad: string;
  138007. };
  138008. buttonObservableNames: {
  138009. trigger: string;
  138010. menu: string;
  138011. grip: string;
  138012. thumbstick: string;
  138013. trackpad: string;
  138014. };
  138015. axisMeshNames: string[];
  138016. pointingPoseMeshName: string;
  138017. };
  138018. /**
  138019. * Construct a new XR-Based windows motion controller
  138020. *
  138021. * @param gamepadInfo the gamepad object from the browser
  138022. */
  138023. constructor(gamepadInfo: any);
  138024. /**
  138025. * holds the thumbstick values (X,Y)
  138026. */
  138027. thumbstickValues: StickValues;
  138028. /**
  138029. * Fired when the thumbstick on this controller is clicked
  138030. */
  138031. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  138032. /**
  138033. * Fired when the thumbstick on this controller is modified
  138034. */
  138035. onThumbstickValuesChangedObservable: Observable<StickValues>;
  138036. /**
  138037. * Fired when the touchpad button on this controller is modified
  138038. */
  138039. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  138040. /**
  138041. * Fired when the touchpad values on this controller are modified
  138042. */
  138043. onTrackpadValuesChangedObservable: Observable<StickValues>;
  138044. /**
  138045. * Fired when the thumbstick button on this controller is modified
  138046. * here to prevent breaking changes
  138047. */
  138048. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138049. /**
  138050. * updating the thumbstick(!) and not the trackpad.
  138051. * This is named this way due to the difference between WebVR and XR and to avoid
  138052. * changing the parent class.
  138053. */
  138054. protected _updateTrackpad(): void;
  138055. /**
  138056. * Disposes the class with joy
  138057. */
  138058. dispose(): void;
  138059. }
  138060. }
  138061. declare module BABYLON {
  138062. /**
  138063. * Class containing static functions to help procedurally build meshes
  138064. */
  138065. export class PolyhedronBuilder {
  138066. /**
  138067. * Creates a polyhedron mesh
  138068. * * 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
  138069. * * The parameter `size` (positive float, default 1) sets the polygon size
  138070. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  138071. * * 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`
  138072. * * 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
  138073. * * 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)`)
  138074. * * 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
  138075. * * 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
  138076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138079. * @param name defines the name of the mesh
  138080. * @param options defines the options used to create the mesh
  138081. * @param scene defines the hosting scene
  138082. * @returns the polyhedron mesh
  138083. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  138084. */
  138085. static CreatePolyhedron(name: string, options: {
  138086. type?: number;
  138087. size?: number;
  138088. sizeX?: number;
  138089. sizeY?: number;
  138090. sizeZ?: number;
  138091. custom?: any;
  138092. faceUV?: Vector4[];
  138093. faceColors?: Color4[];
  138094. flat?: boolean;
  138095. updatable?: boolean;
  138096. sideOrientation?: number;
  138097. frontUVs?: Vector4;
  138098. backUVs?: Vector4;
  138099. }, scene?: Nullable<Scene>): Mesh;
  138100. }
  138101. }
  138102. declare module BABYLON {
  138103. /**
  138104. * Gizmo that enables scaling a mesh along 3 axis
  138105. */
  138106. export class ScaleGizmo extends Gizmo {
  138107. /**
  138108. * Internal gizmo used for interactions on the x axis
  138109. */
  138110. xGizmo: AxisScaleGizmo;
  138111. /**
  138112. * Internal gizmo used for interactions on the y axis
  138113. */
  138114. yGizmo: AxisScaleGizmo;
  138115. /**
  138116. * Internal gizmo used for interactions on the z axis
  138117. */
  138118. zGizmo: AxisScaleGizmo;
  138119. /**
  138120. * Internal gizmo used to scale all axis equally
  138121. */
  138122. uniformScaleGizmo: AxisScaleGizmo;
  138123. private _meshAttached;
  138124. private _nodeAttached;
  138125. private _snapDistance;
  138126. private _uniformScalingMesh;
  138127. private _octahedron;
  138128. private _sensitivity;
  138129. /** Fires an event when any of it's sub gizmos are dragged */
  138130. onDragStartObservable: Observable<unknown>;
  138131. /** Fires an event when any of it's sub gizmos are released from dragging */
  138132. onDragEndObservable: Observable<unknown>;
  138133. get attachedMesh(): Nullable<AbstractMesh>;
  138134. set attachedMesh(mesh: Nullable<AbstractMesh>);
  138135. get attachedNode(): Nullable<Node>;
  138136. set attachedNode(node: Nullable<Node>);
  138137. /**
  138138. * True when the mouse pointer is hovering a gizmo mesh
  138139. */
  138140. get isHovered(): boolean;
  138141. /**
  138142. * Creates a ScaleGizmo
  138143. * @param gizmoLayer The utility layer the gizmo will be added to
  138144. * @param thickness display gizmo axis thickness
  138145. */
  138146. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  138147. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  138148. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  138149. /**
  138150. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  138151. */
  138152. set snapDistance(value: number);
  138153. get snapDistance(): number;
  138154. /**
  138155. * Ratio for the scale of the gizmo (Default: 1)
  138156. */
  138157. set scaleRatio(value: number);
  138158. get scaleRatio(): number;
  138159. /**
  138160. * Sensitivity factor for dragging (Default: 1)
  138161. */
  138162. set sensitivity(value: number);
  138163. get sensitivity(): number;
  138164. /**
  138165. * Disposes of the gizmo
  138166. */
  138167. dispose(): void;
  138168. }
  138169. }
  138170. declare module BABYLON {
  138171. /**
  138172. * Single axis scale gizmo
  138173. */
  138174. export class AxisScaleGizmo extends Gizmo {
  138175. /**
  138176. * Drag behavior responsible for the gizmos dragging interactions
  138177. */
  138178. dragBehavior: PointerDragBehavior;
  138179. private _pointerObserver;
  138180. /**
  138181. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  138182. */
  138183. snapDistance: number;
  138184. /**
  138185. * Event that fires each time the gizmo snaps to a new location.
  138186. * * snapDistance is the the change in distance
  138187. */
  138188. onSnapObservable: Observable<{
  138189. snapDistance: number;
  138190. }>;
  138191. /**
  138192. * If the scaling operation should be done on all axis (default: false)
  138193. */
  138194. uniformScaling: boolean;
  138195. /**
  138196. * Custom sensitivity value for the drag strength
  138197. */
  138198. sensitivity: number;
  138199. private _isEnabled;
  138200. private _parent;
  138201. private _arrow;
  138202. private _coloredMaterial;
  138203. private _hoverMaterial;
  138204. /**
  138205. * Creates an AxisScaleGizmo
  138206. * @param gizmoLayer The utility layer the gizmo will be added to
  138207. * @param dragAxis The axis which the gizmo will be able to scale on
  138208. * @param color The color of the gizmo
  138209. * @param thickness display gizmo axis thickness
  138210. */
  138211. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  138212. protected _attachedNodeChanged(value: Nullable<Node>): void;
  138213. /**
  138214. * If the gizmo is enabled
  138215. */
  138216. set isEnabled(value: boolean);
  138217. get isEnabled(): boolean;
  138218. /**
  138219. * Disposes of the gizmo
  138220. */
  138221. dispose(): void;
  138222. /**
  138223. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  138224. * @param mesh The mesh to replace the default mesh of the gizmo
  138225. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  138226. */
  138227. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  138228. }
  138229. }
  138230. declare module BABYLON {
  138231. /**
  138232. * Bounding box gizmo
  138233. */
  138234. export class BoundingBoxGizmo extends Gizmo {
  138235. private _lineBoundingBox;
  138236. private _rotateSpheresParent;
  138237. private _scaleBoxesParent;
  138238. private _boundingDimensions;
  138239. private _renderObserver;
  138240. private _pointerObserver;
  138241. private _scaleDragSpeed;
  138242. private _tmpQuaternion;
  138243. private _tmpVector;
  138244. private _tmpRotationMatrix;
  138245. /**
  138246. * 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)
  138247. */
  138248. ignoreChildren: boolean;
  138249. /**
  138250. * 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)
  138251. */
  138252. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  138253. /**
  138254. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  138255. */
  138256. rotationSphereSize: number;
  138257. /**
  138258. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  138259. */
  138260. scaleBoxSize: number;
  138261. /**
  138262. * 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)
  138263. */
  138264. fixedDragMeshScreenSize: boolean;
  138265. /**
  138266. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  138267. */
  138268. fixedDragMeshScreenSizeDistanceFactor: number;
  138269. /**
  138270. * Fired when a rotation sphere or scale box is dragged
  138271. */
  138272. onDragStartObservable: Observable<{}>;
  138273. /**
  138274. * Fired when a scale box is dragged
  138275. */
  138276. onScaleBoxDragObservable: Observable<{}>;
  138277. /**
  138278. * Fired when a scale box drag is ended
  138279. */
  138280. onScaleBoxDragEndObservable: Observable<{}>;
  138281. /**
  138282. * Fired when a rotation sphere is dragged
  138283. */
  138284. onRotationSphereDragObservable: Observable<{}>;
  138285. /**
  138286. * Fired when a rotation sphere drag is ended
  138287. */
  138288. onRotationSphereDragEndObservable: Observable<{}>;
  138289. /**
  138290. * 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)
  138291. */
  138292. scalePivot: Nullable<Vector3>;
  138293. /**
  138294. * Mesh used as a pivot to rotate the attached node
  138295. */
  138296. private _anchorMesh;
  138297. private _existingMeshScale;
  138298. private _dragMesh;
  138299. private pointerDragBehavior;
  138300. private coloredMaterial;
  138301. private hoverColoredMaterial;
  138302. /**
  138303. * Sets the color of the bounding box gizmo
  138304. * @param color the color to set
  138305. */
  138306. setColor(color: Color3): void;
  138307. /**
  138308. * Creates an BoundingBoxGizmo
  138309. * @param gizmoLayer The utility layer the gizmo will be added to
  138310. * @param color The color of the gizmo
  138311. */
  138312. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  138313. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  138314. private _selectNode;
  138315. /**
  138316. * Updates the bounding box information for the Gizmo
  138317. */
  138318. updateBoundingBox(): void;
  138319. private _updateRotationSpheres;
  138320. private _updateScaleBoxes;
  138321. /**
  138322. * Enables rotation on the specified axis and disables rotation on the others
  138323. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  138324. */
  138325. setEnabledRotationAxis(axis: string): void;
  138326. /**
  138327. * Enables/disables scaling
  138328. * @param enable if scaling should be enabled
  138329. * @param homogeneousScaling defines if scaling should only be homogeneous
  138330. */
  138331. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  138332. private _updateDummy;
  138333. /**
  138334. * Enables a pointer drag behavior on the bounding box of the gizmo
  138335. */
  138336. enableDragBehavior(): void;
  138337. /**
  138338. * Disposes of the gizmo
  138339. */
  138340. dispose(): void;
  138341. /**
  138342. * 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)
  138343. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  138344. * @returns the bounding box mesh with the passed in mesh as a child
  138345. */
  138346. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  138347. /**
  138348. * CustomMeshes are not supported by this gizmo
  138349. * @param mesh The mesh to replace the default mesh of the gizmo
  138350. */
  138351. setCustomMesh(mesh: Mesh): void;
  138352. }
  138353. }
  138354. declare module BABYLON {
  138355. /**
  138356. * Single plane rotation gizmo
  138357. */
  138358. export class PlaneRotationGizmo extends Gizmo {
  138359. /**
  138360. * Drag behavior responsible for the gizmos dragging interactions
  138361. */
  138362. dragBehavior: PointerDragBehavior;
  138363. private _pointerObserver;
  138364. /**
  138365. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  138366. */
  138367. snapDistance: number;
  138368. /**
  138369. * Event that fires each time the gizmo snaps to a new location.
  138370. * * snapDistance is the the change in distance
  138371. */
  138372. onSnapObservable: Observable<{
  138373. snapDistance: number;
  138374. }>;
  138375. private _isEnabled;
  138376. private _parent;
  138377. /**
  138378. * Creates a PlaneRotationGizmo
  138379. * @param gizmoLayer The utility layer the gizmo will be added to
  138380. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  138381. * @param color The color of the gizmo
  138382. * @param tessellation Amount of tessellation to be used when creating rotation circles
  138383. * @param useEulerRotation Use and update Euler angle instead of quaternion
  138384. * @param thickness display gizmo axis thickness
  138385. */
  138386. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  138387. protected _attachedNodeChanged(value: Nullable<Node>): void;
  138388. /**
  138389. * If the gizmo is enabled
  138390. */
  138391. set isEnabled(value: boolean);
  138392. get isEnabled(): boolean;
  138393. /**
  138394. * Disposes of the gizmo
  138395. */
  138396. dispose(): void;
  138397. }
  138398. }
  138399. declare module BABYLON {
  138400. /**
  138401. * Gizmo that enables rotating a mesh along 3 axis
  138402. */
  138403. export class RotationGizmo extends Gizmo {
  138404. /**
  138405. * Internal gizmo used for interactions on the x axis
  138406. */
  138407. xGizmo: PlaneRotationGizmo;
  138408. /**
  138409. * Internal gizmo used for interactions on the y axis
  138410. */
  138411. yGizmo: PlaneRotationGizmo;
  138412. /**
  138413. * Internal gizmo used for interactions on the z axis
  138414. */
  138415. zGizmo: PlaneRotationGizmo;
  138416. /** Fires an event when any of it's sub gizmos are dragged */
  138417. onDragStartObservable: Observable<unknown>;
  138418. /** Fires an event when any of it's sub gizmos are released from dragging */
  138419. onDragEndObservable: Observable<unknown>;
  138420. private _meshAttached;
  138421. private _nodeAttached;
  138422. get attachedMesh(): Nullable<AbstractMesh>;
  138423. set attachedMesh(mesh: Nullable<AbstractMesh>);
  138424. get attachedNode(): Nullable<Node>;
  138425. set attachedNode(node: Nullable<Node>);
  138426. protected _checkBillboardTransform(): void;
  138427. /**
  138428. * True when the mouse pointer is hovering a gizmo mesh
  138429. */
  138430. get isHovered(): boolean;
  138431. /**
  138432. * Creates a RotationGizmo
  138433. * @param gizmoLayer The utility layer the gizmo will be added to
  138434. * @param tessellation Amount of tessellation to be used when creating rotation circles
  138435. * @param useEulerRotation Use and update Euler angle instead of quaternion
  138436. * @param thickness display gizmo axis thickness
  138437. */
  138438. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  138439. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  138440. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  138441. /**
  138442. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  138443. */
  138444. set snapDistance(value: number);
  138445. get snapDistance(): number;
  138446. /**
  138447. * Ratio for the scale of the gizmo (Default: 1)
  138448. */
  138449. set scaleRatio(value: number);
  138450. get scaleRatio(): number;
  138451. /**
  138452. * Disposes of the gizmo
  138453. */
  138454. dispose(): void;
  138455. /**
  138456. * CustomMeshes are not supported by this gizmo
  138457. * @param mesh The mesh to replace the default mesh of the gizmo
  138458. */
  138459. setCustomMesh(mesh: Mesh): void;
  138460. }
  138461. }
  138462. declare module BABYLON {
  138463. /**
  138464. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  138465. */
  138466. export class GizmoManager implements IDisposable {
  138467. private scene;
  138468. /**
  138469. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  138470. */
  138471. gizmos: {
  138472. positionGizmo: Nullable<PositionGizmo>;
  138473. rotationGizmo: Nullable<RotationGizmo>;
  138474. scaleGizmo: Nullable<ScaleGizmo>;
  138475. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  138476. };
  138477. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  138478. clearGizmoOnEmptyPointerEvent: boolean;
  138479. /** Fires an event when the manager is attached to a mesh */
  138480. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  138481. /** Fires an event when the manager is attached to a node */
  138482. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  138483. private _gizmosEnabled;
  138484. private _pointerObserver;
  138485. private _attachedMesh;
  138486. private _attachedNode;
  138487. private _boundingBoxColor;
  138488. private _defaultUtilityLayer;
  138489. private _defaultKeepDepthUtilityLayer;
  138490. private _thickness;
  138491. /**
  138492. * When bounding box gizmo is enabled, this can be used to track drag/end events
  138493. */
  138494. boundingBoxDragBehavior: SixDofDragBehavior;
  138495. /**
  138496. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  138497. */
  138498. attachableMeshes: Nullable<Array<AbstractMesh>>;
  138499. /**
  138500. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  138501. */
  138502. attachableNodes: Nullable<Array<Node>>;
  138503. /**
  138504. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  138505. */
  138506. usePointerToAttachGizmos: boolean;
  138507. /**
  138508. * Utility layer that the bounding box gizmo belongs to
  138509. */
  138510. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  138511. /**
  138512. * Utility layer that all gizmos besides bounding box belong to
  138513. */
  138514. get utilityLayer(): UtilityLayerRenderer;
  138515. /**
  138516. * True when the mouse pointer is hovering a gizmo mesh
  138517. */
  138518. get isHovered(): boolean;
  138519. /**
  138520. * Instatiates a gizmo manager
  138521. * @param scene the scene to overlay the gizmos on top of
  138522. * @param thickness display gizmo axis thickness
  138523. */
  138524. constructor(scene: Scene, thickness?: number);
  138525. /**
  138526. * Attaches a set of gizmos to the specified mesh
  138527. * @param mesh The mesh the gizmo's should be attached to
  138528. */
  138529. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  138530. /**
  138531. * Attaches a set of gizmos to the specified node
  138532. * @param node The node the gizmo's should be attached to
  138533. */
  138534. attachToNode(node: Nullable<Node>): void;
  138535. /**
  138536. * If the position gizmo is enabled
  138537. */
  138538. set positionGizmoEnabled(value: boolean);
  138539. get positionGizmoEnabled(): boolean;
  138540. /**
  138541. * If the rotation gizmo is enabled
  138542. */
  138543. set rotationGizmoEnabled(value: boolean);
  138544. get rotationGizmoEnabled(): boolean;
  138545. /**
  138546. * If the scale gizmo is enabled
  138547. */
  138548. set scaleGizmoEnabled(value: boolean);
  138549. get scaleGizmoEnabled(): boolean;
  138550. /**
  138551. * If the boundingBox gizmo is enabled
  138552. */
  138553. set boundingBoxGizmoEnabled(value: boolean);
  138554. get boundingBoxGizmoEnabled(): boolean;
  138555. /**
  138556. * Disposes of the gizmo manager
  138557. */
  138558. dispose(): void;
  138559. }
  138560. }
  138561. declare module BABYLON {
  138562. /**
  138563. * A directional light is defined by a direction (what a surprise!).
  138564. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  138565. * 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.
  138566. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138567. */
  138568. export class DirectionalLight extends ShadowLight {
  138569. private _shadowFrustumSize;
  138570. /**
  138571. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  138572. */
  138573. get shadowFrustumSize(): number;
  138574. /**
  138575. * Specifies a fix frustum size for the shadow generation.
  138576. */
  138577. set shadowFrustumSize(value: number);
  138578. private _shadowOrthoScale;
  138579. /**
  138580. * Gets the shadow projection scale against the optimal computed one.
  138581. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  138582. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  138583. */
  138584. get shadowOrthoScale(): number;
  138585. /**
  138586. * Sets the shadow projection scale against the optimal computed one.
  138587. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  138588. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  138589. */
  138590. set shadowOrthoScale(value: number);
  138591. /**
  138592. * Automatically compute the projection matrix to best fit (including all the casters)
  138593. * on each frame.
  138594. */
  138595. autoUpdateExtends: boolean;
  138596. /**
  138597. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  138598. * on each frame. autoUpdateExtends must be set to true for this to work
  138599. */
  138600. autoCalcShadowZBounds: boolean;
  138601. private _orthoLeft;
  138602. private _orthoRight;
  138603. private _orthoTop;
  138604. private _orthoBottom;
  138605. /**
  138606. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  138607. * The directional light is emitted from everywhere in the given direction.
  138608. * It can cast shadows.
  138609. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138610. * @param name The friendly name of the light
  138611. * @param direction The direction of the light
  138612. * @param scene The scene the light belongs to
  138613. */
  138614. constructor(name: string, direction: Vector3, scene: Scene);
  138615. /**
  138616. * Returns the string "DirectionalLight".
  138617. * @return The class name
  138618. */
  138619. getClassName(): string;
  138620. /**
  138621. * Returns the integer 1.
  138622. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138623. */
  138624. getTypeID(): number;
  138625. /**
  138626. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  138627. * Returns the DirectionalLight Shadow projection matrix.
  138628. */
  138629. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138630. /**
  138631. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  138632. * Returns the DirectionalLight Shadow projection matrix.
  138633. */
  138634. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  138635. /**
  138636. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  138637. * Returns the DirectionalLight Shadow projection matrix.
  138638. */
  138639. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138640. protected _buildUniformLayout(): void;
  138641. /**
  138642. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  138643. * @param effect The effect to update
  138644. * @param lightIndex The index of the light in the effect to update
  138645. * @returns The directional light
  138646. */
  138647. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  138648. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  138649. /**
  138650. * Gets the minZ used for shadow according to both the scene and the light.
  138651. *
  138652. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  138653. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  138654. * @param activeCamera The camera we are returning the min for
  138655. * @returns the depth min z
  138656. */
  138657. getDepthMinZ(activeCamera: Camera): number;
  138658. /**
  138659. * Gets the maxZ used for shadow according to both the scene and the light.
  138660. *
  138661. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  138662. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  138663. * @param activeCamera The camera we are returning the max for
  138664. * @returns the depth max z
  138665. */
  138666. getDepthMaxZ(activeCamera: Camera): number;
  138667. /**
  138668. * Prepares the list of defines specific to the light type.
  138669. * @param defines the list of defines
  138670. * @param lightIndex defines the index of the light for the effect
  138671. */
  138672. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138673. }
  138674. }
  138675. declare module BABYLON {
  138676. /**
  138677. * Class containing static functions to help procedurally build meshes
  138678. */
  138679. export class HemisphereBuilder {
  138680. /**
  138681. * Creates a hemisphere mesh
  138682. * @param name defines the name of the mesh
  138683. * @param options defines the options used to create the mesh
  138684. * @param scene defines the hosting scene
  138685. * @returns the hemisphere mesh
  138686. */
  138687. static CreateHemisphere(name: string, options: {
  138688. segments?: number;
  138689. diameter?: number;
  138690. sideOrientation?: number;
  138691. }, scene: any): Mesh;
  138692. }
  138693. }
  138694. declare module BABYLON {
  138695. /**
  138696. * A spot light is defined by a position, a direction, an angle, and an exponent.
  138697. * These values define a cone of light starting from the position, emitting toward the direction.
  138698. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  138699. * and the exponent defines the speed of the decay of the light with distance (reach).
  138700. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138701. */
  138702. export class SpotLight extends ShadowLight {
  138703. private _angle;
  138704. private _innerAngle;
  138705. private _cosHalfAngle;
  138706. private _lightAngleScale;
  138707. private _lightAngleOffset;
  138708. /**
  138709. * Gets the cone angle of the spot light in Radians.
  138710. */
  138711. get angle(): number;
  138712. /**
  138713. * Sets the cone angle of the spot light in Radians.
  138714. */
  138715. set angle(value: number);
  138716. /**
  138717. * Only used in gltf falloff mode, this defines the angle where
  138718. * the directional falloff will start before cutting at angle which could be seen
  138719. * as outer angle.
  138720. */
  138721. get innerAngle(): number;
  138722. /**
  138723. * Only used in gltf falloff mode, this defines the angle where
  138724. * the directional falloff will start before cutting at angle which could be seen
  138725. * as outer angle.
  138726. */
  138727. set innerAngle(value: number);
  138728. private _shadowAngleScale;
  138729. /**
  138730. * Allows scaling the angle of the light for shadow generation only.
  138731. */
  138732. get shadowAngleScale(): number;
  138733. /**
  138734. * Allows scaling the angle of the light for shadow generation only.
  138735. */
  138736. set shadowAngleScale(value: number);
  138737. /**
  138738. * The light decay speed with the distance from the emission spot.
  138739. */
  138740. exponent: number;
  138741. private _projectionTextureMatrix;
  138742. /**
  138743. * Allows reading the projecton texture
  138744. */
  138745. get projectionTextureMatrix(): Matrix;
  138746. protected _projectionTextureLightNear: number;
  138747. /**
  138748. * Gets the near clip of the Spotlight for texture projection.
  138749. */
  138750. get projectionTextureLightNear(): number;
  138751. /**
  138752. * Sets the near clip of the Spotlight for texture projection.
  138753. */
  138754. set projectionTextureLightNear(value: number);
  138755. protected _projectionTextureLightFar: number;
  138756. /**
  138757. * Gets the far clip of the Spotlight for texture projection.
  138758. */
  138759. get projectionTextureLightFar(): number;
  138760. /**
  138761. * Sets the far clip of the Spotlight for texture projection.
  138762. */
  138763. set projectionTextureLightFar(value: number);
  138764. protected _projectionTextureUpDirection: Vector3;
  138765. /**
  138766. * Gets the Up vector of the Spotlight for texture projection.
  138767. */
  138768. get projectionTextureUpDirection(): Vector3;
  138769. /**
  138770. * Sets the Up vector of the Spotlight for texture projection.
  138771. */
  138772. set projectionTextureUpDirection(value: Vector3);
  138773. private _projectionTexture;
  138774. /**
  138775. * Gets the projection texture of the light.
  138776. */
  138777. get projectionTexture(): Nullable<BaseTexture>;
  138778. /**
  138779. * Sets the projection texture of the light.
  138780. */
  138781. set projectionTexture(value: Nullable<BaseTexture>);
  138782. private static _IsProceduralTexture;
  138783. private static _IsTexture;
  138784. private _projectionTextureViewLightDirty;
  138785. private _projectionTextureProjectionLightDirty;
  138786. private _projectionTextureDirty;
  138787. private _projectionTextureViewTargetVector;
  138788. private _projectionTextureViewLightMatrix;
  138789. private _projectionTextureProjectionLightMatrix;
  138790. private _projectionTextureScalingMatrix;
  138791. /**
  138792. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  138793. * It can cast shadows.
  138794. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138795. * @param name The light friendly name
  138796. * @param position The position of the spot light in the scene
  138797. * @param direction The direction of the light in the scene
  138798. * @param angle The cone angle of the light in Radians
  138799. * @param exponent The light decay speed with the distance from the emission spot
  138800. * @param scene The scene the lights belongs to
  138801. */
  138802. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  138803. /**
  138804. * Returns the string "SpotLight".
  138805. * @returns the class name
  138806. */
  138807. getClassName(): string;
  138808. /**
  138809. * Returns the integer 2.
  138810. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138811. */
  138812. getTypeID(): number;
  138813. /**
  138814. * Overrides the direction setter to recompute the projection texture view light Matrix.
  138815. */
  138816. protected _setDirection(value: Vector3): void;
  138817. /**
  138818. * Overrides the position setter to recompute the projection texture view light Matrix.
  138819. */
  138820. protected _setPosition(value: Vector3): void;
  138821. /**
  138822. * 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.
  138823. * Returns the SpotLight.
  138824. */
  138825. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138826. protected _computeProjectionTextureViewLightMatrix(): void;
  138827. protected _computeProjectionTextureProjectionLightMatrix(): void;
  138828. /**
  138829. * Main function for light texture projection matrix computing.
  138830. */
  138831. protected _computeProjectionTextureMatrix(): void;
  138832. protected _buildUniformLayout(): void;
  138833. private _computeAngleValues;
  138834. /**
  138835. * Sets the passed Effect "effect" with the Light textures.
  138836. * @param effect The effect to update
  138837. * @param lightIndex The index of the light in the effect to update
  138838. * @returns The light
  138839. */
  138840. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  138841. /**
  138842. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  138843. * @param effect The effect to update
  138844. * @param lightIndex The index of the light in the effect to update
  138845. * @returns The spot light
  138846. */
  138847. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  138848. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138849. /**
  138850. * Disposes the light and the associated resources.
  138851. */
  138852. dispose(): void;
  138853. /**
  138854. * Prepares the list of defines specific to the light type.
  138855. * @param defines the list of defines
  138856. * @param lightIndex defines the index of the light for the effect
  138857. */
  138858. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138859. }
  138860. }
  138861. declare module BABYLON {
  138862. /**
  138863. * Gizmo that enables viewing a light
  138864. */
  138865. export class LightGizmo extends Gizmo {
  138866. private _lightMesh;
  138867. private _material;
  138868. private _cachedPosition;
  138869. private _cachedForward;
  138870. private _attachedMeshParent;
  138871. private _pointerObserver;
  138872. /**
  138873. * Event that fires each time the gizmo is clicked
  138874. */
  138875. onClickedObservable: Observable<Light>;
  138876. /**
  138877. * Creates a LightGizmo
  138878. * @param gizmoLayer The utility layer the gizmo will be added to
  138879. */
  138880. constructor(gizmoLayer?: UtilityLayerRenderer);
  138881. private _light;
  138882. /**
  138883. * The light that the gizmo is attached to
  138884. */
  138885. set light(light: Nullable<Light>);
  138886. get light(): Nullable<Light>;
  138887. /**
  138888. * Gets the material used to render the light gizmo
  138889. */
  138890. get material(): StandardMaterial;
  138891. /**
  138892. * @hidden
  138893. * Updates the gizmo to match the attached mesh's position/rotation
  138894. */
  138895. protected _update(): void;
  138896. private static _Scale;
  138897. /**
  138898. * Creates the lines for a light mesh
  138899. */
  138900. private static _CreateLightLines;
  138901. /**
  138902. * Disposes of the light gizmo
  138903. */
  138904. dispose(): void;
  138905. private static _CreateHemisphericLightMesh;
  138906. private static _CreatePointLightMesh;
  138907. private static _CreateSpotLightMesh;
  138908. private static _CreateDirectionalLightMesh;
  138909. }
  138910. }
  138911. declare module BABYLON {
  138912. /**
  138913. * Gizmo that enables viewing a camera
  138914. */
  138915. export class CameraGizmo extends Gizmo {
  138916. private _cameraMesh;
  138917. private _cameraLinesMesh;
  138918. private _material;
  138919. private _pointerObserver;
  138920. /**
  138921. * Event that fires each time the gizmo is clicked
  138922. */
  138923. onClickedObservable: Observable<Camera>;
  138924. /**
  138925. * Creates a CameraGizmo
  138926. * @param gizmoLayer The utility layer the gizmo will be added to
  138927. */
  138928. constructor(gizmoLayer?: UtilityLayerRenderer);
  138929. private _camera;
  138930. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  138931. get displayFrustum(): boolean;
  138932. set displayFrustum(value: boolean);
  138933. /**
  138934. * The camera that the gizmo is attached to
  138935. */
  138936. set camera(camera: Nullable<Camera>);
  138937. get camera(): Nullable<Camera>;
  138938. /**
  138939. * Gets the material used to render the camera gizmo
  138940. */
  138941. get material(): StandardMaterial;
  138942. /**
  138943. * @hidden
  138944. * Updates the gizmo to match the attached mesh's position/rotation
  138945. */
  138946. protected _update(): void;
  138947. private static _Scale;
  138948. private _invProjection;
  138949. /**
  138950. * Disposes of the camera gizmo
  138951. */
  138952. dispose(): void;
  138953. private static _CreateCameraMesh;
  138954. private static _CreateCameraFrustum;
  138955. }
  138956. }
  138957. declare module BABYLON {
  138958. /** @hidden */
  138959. export var backgroundFragmentDeclaration: {
  138960. name: string;
  138961. shader: string;
  138962. };
  138963. }
  138964. declare module BABYLON {
  138965. /** @hidden */
  138966. export var backgroundUboDeclaration: {
  138967. name: string;
  138968. shader: string;
  138969. };
  138970. }
  138971. declare module BABYLON {
  138972. /** @hidden */
  138973. export var backgroundPixelShader: {
  138974. name: string;
  138975. shader: string;
  138976. };
  138977. }
  138978. declare module BABYLON {
  138979. /** @hidden */
  138980. export var backgroundVertexDeclaration: {
  138981. name: string;
  138982. shader: string;
  138983. };
  138984. }
  138985. declare module BABYLON {
  138986. /** @hidden */
  138987. export var backgroundVertexShader: {
  138988. name: string;
  138989. shader: string;
  138990. };
  138991. }
  138992. declare module BABYLON {
  138993. /**
  138994. * Background material used to create an efficient environement around your scene.
  138995. */
  138996. export class BackgroundMaterial extends PushMaterial {
  138997. /**
  138998. * Standard reflectance value at parallel view angle.
  138999. */
  139000. static StandardReflectance0: number;
  139001. /**
  139002. * Standard reflectance value at grazing angle.
  139003. */
  139004. static StandardReflectance90: number;
  139005. protected _primaryColor: Color3;
  139006. /**
  139007. * Key light Color (multiply against the environement texture)
  139008. */
  139009. primaryColor: Color3;
  139010. protected __perceptualColor: Nullable<Color3>;
  139011. /**
  139012. * Experimental Internal Use Only.
  139013. *
  139014. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  139015. * This acts as a helper to set the primary color to a more "human friendly" value.
  139016. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  139017. * output color as close as possible from the chosen value.
  139018. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  139019. * part of lighting setup.)
  139020. */
  139021. get _perceptualColor(): Nullable<Color3>;
  139022. set _perceptualColor(value: Nullable<Color3>);
  139023. protected _primaryColorShadowLevel: float;
  139024. /**
  139025. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  139026. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  139027. */
  139028. get primaryColorShadowLevel(): float;
  139029. set primaryColorShadowLevel(value: float);
  139030. protected _primaryColorHighlightLevel: float;
  139031. /**
  139032. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  139033. * The primary color is used at the level chosen to define what the white area would look.
  139034. */
  139035. get primaryColorHighlightLevel(): float;
  139036. set primaryColorHighlightLevel(value: float);
  139037. protected _reflectionTexture: Nullable<BaseTexture>;
  139038. /**
  139039. * Reflection Texture used in the material.
  139040. * Should be author in a specific way for the best result (refer to the documentation).
  139041. */
  139042. reflectionTexture: Nullable<BaseTexture>;
  139043. protected _reflectionBlur: float;
  139044. /**
  139045. * Reflection Texture level of blur.
  139046. *
  139047. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  139048. * texture twice.
  139049. */
  139050. reflectionBlur: float;
  139051. protected _diffuseTexture: Nullable<BaseTexture>;
  139052. /**
  139053. * Diffuse Texture used in the material.
  139054. * Should be author in a specific way for the best result (refer to the documentation).
  139055. */
  139056. diffuseTexture: Nullable<BaseTexture>;
  139057. protected _shadowLights: Nullable<IShadowLight[]>;
  139058. /**
  139059. * Specify the list of lights casting shadow on the material.
  139060. * All scene shadow lights will be included if null.
  139061. */
  139062. shadowLights: Nullable<IShadowLight[]>;
  139063. protected _shadowLevel: float;
  139064. /**
  139065. * Helps adjusting the shadow to a softer level if required.
  139066. * 0 means black shadows and 1 means no shadows.
  139067. */
  139068. shadowLevel: float;
  139069. protected _sceneCenter: Vector3;
  139070. /**
  139071. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  139072. * It is usually zero but might be interesting to modify according to your setup.
  139073. */
  139074. sceneCenter: Vector3;
  139075. protected _opacityFresnel: boolean;
  139076. /**
  139077. * This helps specifying that the material is falling off to the sky box at grazing angle.
  139078. * This helps ensuring a nice transition when the camera goes under the ground.
  139079. */
  139080. opacityFresnel: boolean;
  139081. protected _reflectionFresnel: boolean;
  139082. /**
  139083. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  139084. * This helps adding a mirror texture on the ground.
  139085. */
  139086. reflectionFresnel: boolean;
  139087. protected _reflectionFalloffDistance: number;
  139088. /**
  139089. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  139090. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  139091. */
  139092. reflectionFalloffDistance: number;
  139093. protected _reflectionAmount: number;
  139094. /**
  139095. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  139096. */
  139097. reflectionAmount: number;
  139098. protected _reflectionReflectance0: number;
  139099. /**
  139100. * This specifies the weight of the reflection at grazing angle.
  139101. */
  139102. reflectionReflectance0: number;
  139103. protected _reflectionReflectance90: number;
  139104. /**
  139105. * This specifies the weight of the reflection at a perpendicular point of view.
  139106. */
  139107. reflectionReflectance90: number;
  139108. /**
  139109. * Sets the reflection reflectance fresnel values according to the default standard
  139110. * empirically know to work well :-)
  139111. */
  139112. set reflectionStandardFresnelWeight(value: number);
  139113. protected _useRGBColor: boolean;
  139114. /**
  139115. * Helps to directly use the maps channels instead of their level.
  139116. */
  139117. useRGBColor: boolean;
  139118. protected _enableNoise: boolean;
  139119. /**
  139120. * This helps reducing the banding effect that could occur on the background.
  139121. */
  139122. enableNoise: boolean;
  139123. /**
  139124. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139125. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  139126. * Recommended to be keep at 1.0 except for special cases.
  139127. */
  139128. get fovMultiplier(): number;
  139129. set fovMultiplier(value: number);
  139130. private _fovMultiplier;
  139131. /**
  139132. * Enable the FOV adjustment feature controlled by fovMultiplier.
  139133. */
  139134. useEquirectangularFOV: boolean;
  139135. private _maxSimultaneousLights;
  139136. /**
  139137. * Number of Simultaneous lights allowed on the material.
  139138. */
  139139. maxSimultaneousLights: int;
  139140. private _shadowOnly;
  139141. /**
  139142. * Make the material only render shadows
  139143. */
  139144. shadowOnly: boolean;
  139145. /**
  139146. * Default configuration related to image processing available in the Background Material.
  139147. */
  139148. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  139149. /**
  139150. * Keep track of the image processing observer to allow dispose and replace.
  139151. */
  139152. private _imageProcessingObserver;
  139153. /**
  139154. * Attaches a new image processing configuration to the PBR Material.
  139155. * @param configuration (if null the scene configuration will be use)
  139156. */
  139157. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  139158. /**
  139159. * Gets the image processing configuration used either in this material.
  139160. */
  139161. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  139162. /**
  139163. * Sets the Default image processing configuration used either in the this material.
  139164. *
  139165. * If sets to null, the scene one is in use.
  139166. */
  139167. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  139168. /**
  139169. * Gets wether the color curves effect is enabled.
  139170. */
  139171. get cameraColorCurvesEnabled(): boolean;
  139172. /**
  139173. * Sets wether the color curves effect is enabled.
  139174. */
  139175. set cameraColorCurvesEnabled(value: boolean);
  139176. /**
  139177. * Gets wether the color grading effect is enabled.
  139178. */
  139179. get cameraColorGradingEnabled(): boolean;
  139180. /**
  139181. * Gets wether the color grading effect is enabled.
  139182. */
  139183. set cameraColorGradingEnabled(value: boolean);
  139184. /**
  139185. * Gets wether tonemapping is enabled or not.
  139186. */
  139187. get cameraToneMappingEnabled(): boolean;
  139188. /**
  139189. * Sets wether tonemapping is enabled or not
  139190. */
  139191. set cameraToneMappingEnabled(value: boolean);
  139192. /**
  139193. * The camera exposure used on this material.
  139194. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139195. * This corresponds to a photographic exposure.
  139196. */
  139197. get cameraExposure(): float;
  139198. /**
  139199. * The camera exposure used on this material.
  139200. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139201. * This corresponds to a photographic exposure.
  139202. */
  139203. set cameraExposure(value: float);
  139204. /**
  139205. * Gets The camera contrast used on this material.
  139206. */
  139207. get cameraContrast(): float;
  139208. /**
  139209. * Sets The camera contrast used on this material.
  139210. */
  139211. set cameraContrast(value: float);
  139212. /**
  139213. * Gets the Color Grading 2D Lookup Texture.
  139214. */
  139215. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  139216. /**
  139217. * Sets the Color Grading 2D Lookup Texture.
  139218. */
  139219. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  139220. /**
  139221. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139222. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139223. * 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;
  139224. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139225. */
  139226. get cameraColorCurves(): Nullable<ColorCurves>;
  139227. /**
  139228. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139229. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139230. * 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;
  139231. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139232. */
  139233. set cameraColorCurves(value: Nullable<ColorCurves>);
  139234. /**
  139235. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  139236. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  139237. */
  139238. switchToBGR: boolean;
  139239. private _renderTargets;
  139240. private _reflectionControls;
  139241. private _white;
  139242. private _primaryShadowColor;
  139243. private _primaryHighlightColor;
  139244. /**
  139245. * Instantiates a Background Material in the given scene
  139246. * @param name The friendly name of the material
  139247. * @param scene The scene to add the material to
  139248. */
  139249. constructor(name: string, scene: Scene);
  139250. /**
  139251. * Gets a boolean indicating that current material needs to register RTT
  139252. */
  139253. get hasRenderTargetTextures(): boolean;
  139254. /**
  139255. * The entire material has been created in order to prevent overdraw.
  139256. * @returns false
  139257. */
  139258. needAlphaTesting(): boolean;
  139259. /**
  139260. * The entire material has been created in order to prevent overdraw.
  139261. * @returns true if blending is enable
  139262. */
  139263. needAlphaBlending(): boolean;
  139264. /**
  139265. * Checks wether the material is ready to be rendered for a given mesh.
  139266. * @param mesh The mesh to render
  139267. * @param subMesh The submesh to check against
  139268. * @param useInstances Specify wether or not the material is used with instances
  139269. * @returns true if all the dependencies are ready (Textures, Effects...)
  139270. */
  139271. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  139272. /**
  139273. * Compute the primary color according to the chosen perceptual color.
  139274. */
  139275. private _computePrimaryColorFromPerceptualColor;
  139276. /**
  139277. * Compute the highlights and shadow colors according to their chosen levels.
  139278. */
  139279. private _computePrimaryColors;
  139280. /**
  139281. * Build the uniform buffer used in the material.
  139282. */
  139283. buildUniformLayout(): void;
  139284. /**
  139285. * Unbind the material.
  139286. */
  139287. unbind(): void;
  139288. /**
  139289. * Bind only the world matrix to the material.
  139290. * @param world The world matrix to bind.
  139291. */
  139292. bindOnlyWorldMatrix(world: Matrix): void;
  139293. /**
  139294. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  139295. * @param world The world matrix to bind.
  139296. * @param subMesh The submesh to bind for.
  139297. */
  139298. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  139299. /**
  139300. * Checks to see if a texture is used in the material.
  139301. * @param texture - Base texture to use.
  139302. * @returns - Boolean specifying if a texture is used in the material.
  139303. */
  139304. hasTexture(texture: BaseTexture): boolean;
  139305. /**
  139306. * Dispose the material.
  139307. * @param forceDisposeEffect Force disposal of the associated effect.
  139308. * @param forceDisposeTextures Force disposal of the associated textures.
  139309. */
  139310. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  139311. /**
  139312. * Clones the material.
  139313. * @param name The cloned name.
  139314. * @returns The cloned material.
  139315. */
  139316. clone(name: string): BackgroundMaterial;
  139317. /**
  139318. * Serializes the current material to its JSON representation.
  139319. * @returns The JSON representation.
  139320. */
  139321. serialize(): any;
  139322. /**
  139323. * Gets the class name of the material
  139324. * @returns "BackgroundMaterial"
  139325. */
  139326. getClassName(): string;
  139327. /**
  139328. * Parse a JSON input to create back a background material.
  139329. * @param source The JSON data to parse
  139330. * @param scene The scene to create the parsed material in
  139331. * @param rootUrl The root url of the assets the material depends upon
  139332. * @returns the instantiated BackgroundMaterial.
  139333. */
  139334. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  139335. }
  139336. }
  139337. declare module BABYLON {
  139338. /**
  139339. * Represents the different options available during the creation of
  139340. * a Environment helper.
  139341. *
  139342. * This can control the default ground, skybox and image processing setup of your scene.
  139343. */
  139344. export interface IEnvironmentHelperOptions {
  139345. /**
  139346. * Specifies whether or not to create a ground.
  139347. * True by default.
  139348. */
  139349. createGround: boolean;
  139350. /**
  139351. * Specifies the ground size.
  139352. * 15 by default.
  139353. */
  139354. groundSize: number;
  139355. /**
  139356. * The texture used on the ground for the main color.
  139357. * Comes from the BabylonJS CDN by default.
  139358. *
  139359. * Remarks: Can be either a texture or a url.
  139360. */
  139361. groundTexture: string | BaseTexture;
  139362. /**
  139363. * The color mixed in the ground texture by default.
  139364. * BabylonJS clearColor by default.
  139365. */
  139366. groundColor: Color3;
  139367. /**
  139368. * Specifies the ground opacity.
  139369. * 1 by default.
  139370. */
  139371. groundOpacity: number;
  139372. /**
  139373. * Enables the ground to receive shadows.
  139374. * True by default.
  139375. */
  139376. enableGroundShadow: boolean;
  139377. /**
  139378. * Helps preventing the shadow to be fully black on the ground.
  139379. * 0.5 by default.
  139380. */
  139381. groundShadowLevel: number;
  139382. /**
  139383. * Creates a mirror texture attach to the ground.
  139384. * false by default.
  139385. */
  139386. enableGroundMirror: boolean;
  139387. /**
  139388. * Specifies the ground mirror size ratio.
  139389. * 0.3 by default as the default kernel is 64.
  139390. */
  139391. groundMirrorSizeRatio: number;
  139392. /**
  139393. * Specifies the ground mirror blur kernel size.
  139394. * 64 by default.
  139395. */
  139396. groundMirrorBlurKernel: number;
  139397. /**
  139398. * Specifies the ground mirror visibility amount.
  139399. * 1 by default
  139400. */
  139401. groundMirrorAmount: number;
  139402. /**
  139403. * Specifies the ground mirror reflectance weight.
  139404. * This uses the standard weight of the background material to setup the fresnel effect
  139405. * of the mirror.
  139406. * 1 by default.
  139407. */
  139408. groundMirrorFresnelWeight: number;
  139409. /**
  139410. * Specifies the ground mirror Falloff distance.
  139411. * This can helps reducing the size of the reflection.
  139412. * 0 by Default.
  139413. */
  139414. groundMirrorFallOffDistance: number;
  139415. /**
  139416. * Specifies the ground mirror texture type.
  139417. * Unsigned Int by Default.
  139418. */
  139419. groundMirrorTextureType: number;
  139420. /**
  139421. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  139422. * the shown objects.
  139423. */
  139424. groundYBias: number;
  139425. /**
  139426. * Specifies whether or not to create a skybox.
  139427. * True by default.
  139428. */
  139429. createSkybox: boolean;
  139430. /**
  139431. * Specifies the skybox size.
  139432. * 20 by default.
  139433. */
  139434. skyboxSize: number;
  139435. /**
  139436. * The texture used on the skybox for the main color.
  139437. * Comes from the BabylonJS CDN by default.
  139438. *
  139439. * Remarks: Can be either a texture or a url.
  139440. */
  139441. skyboxTexture: string | BaseTexture;
  139442. /**
  139443. * The color mixed in the skybox texture by default.
  139444. * BabylonJS clearColor by default.
  139445. */
  139446. skyboxColor: Color3;
  139447. /**
  139448. * The background rotation around the Y axis of the scene.
  139449. * This helps aligning the key lights of your scene with the background.
  139450. * 0 by default.
  139451. */
  139452. backgroundYRotation: number;
  139453. /**
  139454. * Compute automatically the size of the elements to best fit with the scene.
  139455. */
  139456. sizeAuto: boolean;
  139457. /**
  139458. * Default position of the rootMesh if autoSize is not true.
  139459. */
  139460. rootPosition: Vector3;
  139461. /**
  139462. * Sets up the image processing in the scene.
  139463. * true by default.
  139464. */
  139465. setupImageProcessing: boolean;
  139466. /**
  139467. * The texture used as your environment texture in the scene.
  139468. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  139469. *
  139470. * Remarks: Can be either a texture or a url.
  139471. */
  139472. environmentTexture: string | BaseTexture;
  139473. /**
  139474. * The value of the exposure to apply to the scene.
  139475. * 0.6 by default if setupImageProcessing is true.
  139476. */
  139477. cameraExposure: number;
  139478. /**
  139479. * The value of the contrast to apply to the scene.
  139480. * 1.6 by default if setupImageProcessing is true.
  139481. */
  139482. cameraContrast: number;
  139483. /**
  139484. * Specifies whether or not tonemapping should be enabled in the scene.
  139485. * true by default if setupImageProcessing is true.
  139486. */
  139487. toneMappingEnabled: boolean;
  139488. }
  139489. /**
  139490. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  139491. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  139492. * It also helps with the default setup of your imageProcessing configuration.
  139493. */
  139494. export class EnvironmentHelper {
  139495. /**
  139496. * Default ground texture URL.
  139497. */
  139498. private static _groundTextureCDNUrl;
  139499. /**
  139500. * Default skybox texture URL.
  139501. */
  139502. private static _skyboxTextureCDNUrl;
  139503. /**
  139504. * Default environment texture URL.
  139505. */
  139506. private static _environmentTextureCDNUrl;
  139507. /**
  139508. * Creates the default options for the helper.
  139509. */
  139510. private static _getDefaultOptions;
  139511. private _rootMesh;
  139512. /**
  139513. * Gets the root mesh created by the helper.
  139514. */
  139515. get rootMesh(): Mesh;
  139516. private _skybox;
  139517. /**
  139518. * Gets the skybox created by the helper.
  139519. */
  139520. get skybox(): Nullable<Mesh>;
  139521. private _skyboxTexture;
  139522. /**
  139523. * Gets the skybox texture created by the helper.
  139524. */
  139525. get skyboxTexture(): Nullable<BaseTexture>;
  139526. private _skyboxMaterial;
  139527. /**
  139528. * Gets the skybox material created by the helper.
  139529. */
  139530. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  139531. private _ground;
  139532. /**
  139533. * Gets the ground mesh created by the helper.
  139534. */
  139535. get ground(): Nullable<Mesh>;
  139536. private _groundTexture;
  139537. /**
  139538. * Gets the ground texture created by the helper.
  139539. */
  139540. get groundTexture(): Nullable<BaseTexture>;
  139541. private _groundMirror;
  139542. /**
  139543. * Gets the ground mirror created by the helper.
  139544. */
  139545. get groundMirror(): Nullable<MirrorTexture>;
  139546. /**
  139547. * Gets the ground mirror render list to helps pushing the meshes
  139548. * you wish in the ground reflection.
  139549. */
  139550. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  139551. private _groundMaterial;
  139552. /**
  139553. * Gets the ground material created by the helper.
  139554. */
  139555. get groundMaterial(): Nullable<BackgroundMaterial>;
  139556. /**
  139557. * Stores the creation options.
  139558. */
  139559. private readonly _scene;
  139560. private _options;
  139561. /**
  139562. * This observable will be notified with any error during the creation of the environment,
  139563. * mainly texture creation errors.
  139564. */
  139565. onErrorObservable: Observable<{
  139566. message?: string;
  139567. exception?: any;
  139568. }>;
  139569. /**
  139570. * constructor
  139571. * @param options Defines the options we want to customize the helper
  139572. * @param scene The scene to add the material to
  139573. */
  139574. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  139575. /**
  139576. * Updates the background according to the new options
  139577. * @param options
  139578. */
  139579. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  139580. /**
  139581. * Sets the primary color of all the available elements.
  139582. * @param color the main color to affect to the ground and the background
  139583. */
  139584. setMainColor(color: Color3): void;
  139585. /**
  139586. * Setup the image processing according to the specified options.
  139587. */
  139588. private _setupImageProcessing;
  139589. /**
  139590. * Setup the environment texture according to the specified options.
  139591. */
  139592. private _setupEnvironmentTexture;
  139593. /**
  139594. * Setup the background according to the specified options.
  139595. */
  139596. private _setupBackground;
  139597. /**
  139598. * Get the scene sizes according to the setup.
  139599. */
  139600. private _getSceneSize;
  139601. /**
  139602. * Setup the ground according to the specified options.
  139603. */
  139604. private _setupGround;
  139605. /**
  139606. * Setup the ground material according to the specified options.
  139607. */
  139608. private _setupGroundMaterial;
  139609. /**
  139610. * Setup the ground diffuse texture according to the specified options.
  139611. */
  139612. private _setupGroundDiffuseTexture;
  139613. /**
  139614. * Setup the ground mirror texture according to the specified options.
  139615. */
  139616. private _setupGroundMirrorTexture;
  139617. /**
  139618. * Setup the ground to receive the mirror texture.
  139619. */
  139620. private _setupMirrorInGroundMaterial;
  139621. /**
  139622. * Setup the skybox according to the specified options.
  139623. */
  139624. private _setupSkybox;
  139625. /**
  139626. * Setup the skybox material according to the specified options.
  139627. */
  139628. private _setupSkyboxMaterial;
  139629. /**
  139630. * Setup the skybox reflection texture according to the specified options.
  139631. */
  139632. private _setupSkyboxReflectionTexture;
  139633. private _errorHandler;
  139634. /**
  139635. * Dispose all the elements created by the Helper.
  139636. */
  139637. dispose(): void;
  139638. }
  139639. }
  139640. declare module BABYLON {
  139641. /**
  139642. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  139643. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  139644. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  139645. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139646. */
  139647. export abstract class TextureDome<T extends Texture> extends TransformNode {
  139648. protected onError: Nullable<(message?: string, exception?: any) => void>;
  139649. /**
  139650. * Define the source as a Monoscopic panoramic 360/180.
  139651. */
  139652. static readonly MODE_MONOSCOPIC: number;
  139653. /**
  139654. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  139655. */
  139656. static readonly MODE_TOPBOTTOM: number;
  139657. /**
  139658. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  139659. */
  139660. static readonly MODE_SIDEBYSIDE: number;
  139661. private _halfDome;
  139662. private _crossEye;
  139663. protected _useDirectMapping: boolean;
  139664. /**
  139665. * The texture being displayed on the sphere
  139666. */
  139667. protected _texture: T;
  139668. /**
  139669. * Gets the texture being displayed on the sphere
  139670. */
  139671. get texture(): T;
  139672. /**
  139673. * Sets the texture being displayed on the sphere
  139674. */
  139675. set texture(newTexture: T);
  139676. /**
  139677. * The skybox material
  139678. */
  139679. protected _material: BackgroundMaterial;
  139680. /**
  139681. * The surface used for the dome
  139682. */
  139683. protected _mesh: Mesh;
  139684. /**
  139685. * Gets the mesh used for the dome.
  139686. */
  139687. get mesh(): Mesh;
  139688. /**
  139689. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  139690. */
  139691. private _halfDomeMask;
  139692. /**
  139693. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139694. * Also see the options.resolution property.
  139695. */
  139696. get fovMultiplier(): number;
  139697. set fovMultiplier(value: number);
  139698. protected _textureMode: number;
  139699. /**
  139700. * Gets or set the current texture mode for the texture. It can be:
  139701. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139702. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139703. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139704. */
  139705. get textureMode(): number;
  139706. /**
  139707. * Sets the current texture mode for the texture. It can be:
  139708. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139709. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139710. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139711. */
  139712. set textureMode(value: number);
  139713. /**
  139714. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  139715. */
  139716. get halfDome(): boolean;
  139717. /**
  139718. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  139719. */
  139720. set halfDome(enabled: boolean);
  139721. /**
  139722. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  139723. */
  139724. set crossEye(enabled: boolean);
  139725. /**
  139726. * Is it a cross-eye texture?
  139727. */
  139728. get crossEye(): boolean;
  139729. /**
  139730. * The background material of this dome.
  139731. */
  139732. get material(): BackgroundMaterial;
  139733. /**
  139734. * Oberserver used in Stereoscopic VR Mode.
  139735. */
  139736. private _onBeforeCameraRenderObserver;
  139737. /**
  139738. * Observable raised when an error occured while loading the 360 image
  139739. */
  139740. onLoadErrorObservable: Observable<string>;
  139741. /**
  139742. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  139743. * @param name Element's name, child elements will append suffixes for their own names.
  139744. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  139745. * @param options An object containing optional or exposed sub element properties
  139746. */
  139747. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  139748. resolution?: number;
  139749. clickToPlay?: boolean;
  139750. autoPlay?: boolean;
  139751. loop?: boolean;
  139752. size?: number;
  139753. poster?: string;
  139754. faceForward?: boolean;
  139755. useDirectMapping?: boolean;
  139756. halfDomeMode?: boolean;
  139757. crossEyeMode?: boolean;
  139758. generateMipMaps?: boolean;
  139759. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  139760. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  139761. protected _changeTextureMode(value: number): void;
  139762. /**
  139763. * Releases resources associated with this node.
  139764. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  139765. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  139766. */
  139767. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  139768. }
  139769. }
  139770. declare module BABYLON {
  139771. /**
  139772. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  139773. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  139774. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  139775. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139776. */
  139777. export class PhotoDome extends TextureDome<Texture> {
  139778. /**
  139779. * Define the image as a Monoscopic panoramic 360 image.
  139780. */
  139781. static readonly MODE_MONOSCOPIC: number;
  139782. /**
  139783. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  139784. */
  139785. static readonly MODE_TOPBOTTOM: number;
  139786. /**
  139787. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  139788. */
  139789. static readonly MODE_SIDEBYSIDE: number;
  139790. /**
  139791. * Gets or sets the texture being displayed on the sphere
  139792. */
  139793. get photoTexture(): Texture;
  139794. /**
  139795. * sets the texture being displayed on the sphere
  139796. */
  139797. set photoTexture(value: Texture);
  139798. /**
  139799. * Gets the current video mode for the video. It can be:
  139800. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139801. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139802. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139803. */
  139804. get imageMode(): number;
  139805. /**
  139806. * Sets the current video mode for the video. It can be:
  139807. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139808. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139809. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139810. */
  139811. set imageMode(value: number);
  139812. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  139813. }
  139814. }
  139815. declare module BABYLON {
  139816. /**
  139817. * Direct draw surface info
  139818. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  139819. */
  139820. export interface DDSInfo {
  139821. /**
  139822. * Width of the texture
  139823. */
  139824. width: number;
  139825. /**
  139826. * Width of the texture
  139827. */
  139828. height: number;
  139829. /**
  139830. * Number of Mipmaps for the texture
  139831. * @see https://en.wikipedia.org/wiki/Mipmap
  139832. */
  139833. mipmapCount: number;
  139834. /**
  139835. * If the textures format is a known fourCC format
  139836. * @see https://www.fourcc.org/
  139837. */
  139838. isFourCC: boolean;
  139839. /**
  139840. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  139841. */
  139842. isRGB: boolean;
  139843. /**
  139844. * If the texture is a lumincance format
  139845. */
  139846. isLuminance: boolean;
  139847. /**
  139848. * If this is a cube texture
  139849. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  139850. */
  139851. isCube: boolean;
  139852. /**
  139853. * If the texture is a compressed format eg. FOURCC_DXT1
  139854. */
  139855. isCompressed: boolean;
  139856. /**
  139857. * The dxgiFormat of the texture
  139858. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  139859. */
  139860. dxgiFormat: number;
  139861. /**
  139862. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  139863. */
  139864. textureType: number;
  139865. /**
  139866. * Sphericle polynomial created for the dds texture
  139867. */
  139868. sphericalPolynomial?: SphericalPolynomial;
  139869. }
  139870. /**
  139871. * Class used to provide DDS decompression tools
  139872. */
  139873. export class DDSTools {
  139874. /**
  139875. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  139876. */
  139877. static StoreLODInAlphaChannel: boolean;
  139878. /**
  139879. * Gets DDS information from an array buffer
  139880. * @param data defines the array buffer view to read data from
  139881. * @returns the DDS information
  139882. */
  139883. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  139884. private static _FloatView;
  139885. private static _Int32View;
  139886. private static _ToHalfFloat;
  139887. private static _FromHalfFloat;
  139888. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  139889. private static _GetHalfFloatRGBAArrayBuffer;
  139890. private static _GetFloatRGBAArrayBuffer;
  139891. private static _GetFloatAsUIntRGBAArrayBuffer;
  139892. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  139893. private static _GetRGBAArrayBuffer;
  139894. private static _ExtractLongWordOrder;
  139895. private static _GetRGBArrayBuffer;
  139896. private static _GetLuminanceArrayBuffer;
  139897. /**
  139898. * Uploads DDS Levels to a Babylon Texture
  139899. * @hidden
  139900. */
  139901. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  139902. }
  139903. interface ThinEngine {
  139904. /**
  139905. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  139906. * @param rootUrl defines the url where the file to load is located
  139907. * @param scene defines the current scene
  139908. * @param lodScale defines scale to apply to the mip map selection
  139909. * @param lodOffset defines offset to apply to the mip map selection
  139910. * @param onLoad defines an optional callback raised when the texture is loaded
  139911. * @param onError defines an optional callback raised if there is an issue to load the texture
  139912. * @param format defines the format of the data
  139913. * @param forcedExtension defines the extension to use to pick the right loader
  139914. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  139915. * @returns the cube texture as an InternalTexture
  139916. */
  139917. 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;
  139918. }
  139919. }
  139920. declare module BABYLON {
  139921. /**
  139922. * Implementation of the DDS Texture Loader.
  139923. * @hidden
  139924. */
  139925. export class _DDSTextureLoader implements IInternalTextureLoader {
  139926. /**
  139927. * Defines wether the loader supports cascade loading the different faces.
  139928. */
  139929. readonly supportCascades: boolean;
  139930. /**
  139931. * This returns if the loader support the current file information.
  139932. * @param extension defines the file extension of the file being loaded
  139933. * @returns true if the loader can load the specified file
  139934. */
  139935. canLoad(extension: string): boolean;
  139936. /**
  139937. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139938. * @param data contains the texture data
  139939. * @param texture defines the BabylonJS internal texture
  139940. * @param createPolynomials will be true if polynomials have been requested
  139941. * @param onLoad defines the callback to trigger once the texture is ready
  139942. * @param onError defines the callback to trigger in case of error
  139943. */
  139944. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139945. /**
  139946. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139947. * @param data contains the texture data
  139948. * @param texture defines the BabylonJS internal texture
  139949. * @param callback defines the method to call once ready to upload
  139950. */
  139951. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139952. }
  139953. }
  139954. declare module BABYLON {
  139955. /**
  139956. * Implementation of the ENV Texture Loader.
  139957. * @hidden
  139958. */
  139959. export class _ENVTextureLoader implements IInternalTextureLoader {
  139960. /**
  139961. * Defines wether the loader supports cascade loading the different faces.
  139962. */
  139963. readonly supportCascades: boolean;
  139964. /**
  139965. * This returns if the loader support the current file information.
  139966. * @param extension defines the file extension of the file being loaded
  139967. * @returns true if the loader can load the specified file
  139968. */
  139969. canLoad(extension: string): boolean;
  139970. /**
  139971. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139972. * @param data contains the texture data
  139973. * @param texture defines the BabylonJS internal texture
  139974. * @param createPolynomials will be true if polynomials have been requested
  139975. * @param onLoad defines the callback to trigger once the texture is ready
  139976. * @param onError defines the callback to trigger in case of error
  139977. */
  139978. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139979. /**
  139980. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139981. * @param data contains the texture data
  139982. * @param texture defines the BabylonJS internal texture
  139983. * @param callback defines the method to call once ready to upload
  139984. */
  139985. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139986. }
  139987. }
  139988. declare module BABYLON {
  139989. /**
  139990. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  139991. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  139992. */
  139993. export class KhronosTextureContainer {
  139994. /** contents of the KTX container file */
  139995. data: ArrayBufferView;
  139996. private static HEADER_LEN;
  139997. private static COMPRESSED_2D;
  139998. private static COMPRESSED_3D;
  139999. private static TEX_2D;
  140000. private static TEX_3D;
  140001. /**
  140002. * Gets the openGL type
  140003. */
  140004. glType: number;
  140005. /**
  140006. * Gets the openGL type size
  140007. */
  140008. glTypeSize: number;
  140009. /**
  140010. * Gets the openGL format
  140011. */
  140012. glFormat: number;
  140013. /**
  140014. * Gets the openGL internal format
  140015. */
  140016. glInternalFormat: number;
  140017. /**
  140018. * Gets the base internal format
  140019. */
  140020. glBaseInternalFormat: number;
  140021. /**
  140022. * Gets image width in pixel
  140023. */
  140024. pixelWidth: number;
  140025. /**
  140026. * Gets image height in pixel
  140027. */
  140028. pixelHeight: number;
  140029. /**
  140030. * Gets image depth in pixels
  140031. */
  140032. pixelDepth: number;
  140033. /**
  140034. * Gets the number of array elements
  140035. */
  140036. numberOfArrayElements: number;
  140037. /**
  140038. * Gets the number of faces
  140039. */
  140040. numberOfFaces: number;
  140041. /**
  140042. * Gets the number of mipmap levels
  140043. */
  140044. numberOfMipmapLevels: number;
  140045. /**
  140046. * Gets the bytes of key value data
  140047. */
  140048. bytesOfKeyValueData: number;
  140049. /**
  140050. * Gets the load type
  140051. */
  140052. loadType: number;
  140053. /**
  140054. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  140055. */
  140056. isInvalid: boolean;
  140057. /**
  140058. * Creates a new KhronosTextureContainer
  140059. * @param data contents of the KTX container file
  140060. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  140061. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  140062. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  140063. */
  140064. constructor(
  140065. /** contents of the KTX container file */
  140066. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  140067. /**
  140068. * Uploads KTX content to a Babylon Texture.
  140069. * It is assumed that the texture has already been created & is currently bound
  140070. * @hidden
  140071. */
  140072. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  140073. private _upload2DCompressedLevels;
  140074. /**
  140075. * Checks if the given data starts with a KTX file identifier.
  140076. * @param data the data to check
  140077. * @returns true if the data is a KTX file or false otherwise
  140078. */
  140079. static IsValid(data: ArrayBufferView): boolean;
  140080. }
  140081. }
  140082. declare module BABYLON {
  140083. /**
  140084. * Helper class to push actions to a pool of workers.
  140085. */
  140086. export class WorkerPool implements IDisposable {
  140087. private _workerInfos;
  140088. private _pendingActions;
  140089. /**
  140090. * Constructor
  140091. * @param workers Array of workers to use for actions
  140092. */
  140093. constructor(workers: Array<Worker>);
  140094. /**
  140095. * Terminates all workers and clears any pending actions.
  140096. */
  140097. dispose(): void;
  140098. /**
  140099. * Pushes an action to the worker pool. If all the workers are active, the action will be
  140100. * pended until a worker has completed its action.
  140101. * @param action The action to perform. Call onComplete when the action is complete.
  140102. */
  140103. push(action: (worker: Worker, onComplete: () => void) => void): void;
  140104. private _execute;
  140105. }
  140106. }
  140107. declare module BABYLON {
  140108. /**
  140109. * Class for loading KTX2 files
  140110. */
  140111. export class KhronosTextureContainer2 {
  140112. private static _WorkerPoolPromise?;
  140113. private static _Initialized;
  140114. private static _Ktx2Decoder;
  140115. /**
  140116. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  140117. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  140118. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  140119. * Urls you can change:
  140120. * URLConfig.jsDecoderModule
  140121. * URLConfig.wasmUASTCToASTC
  140122. * URLConfig.wasmUASTCToBC7
  140123. * URLConfig.wasmUASTCToRGBA_UNORM
  140124. * URLConfig.wasmUASTCToRGBA_SRGB
  140125. * URLConfig.jsMSCTranscoder
  140126. * URLConfig.wasmMSCTranscoder
  140127. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  140128. */
  140129. static URLConfig: {
  140130. jsDecoderModule: string;
  140131. wasmUASTCToASTC: null;
  140132. wasmUASTCToBC7: null;
  140133. wasmUASTCToRGBA_UNORM: null;
  140134. wasmUASTCToRGBA_SRGB: null;
  140135. jsMSCTranscoder: null;
  140136. wasmMSCTranscoder: null;
  140137. };
  140138. /**
  140139. * Default number of workers used to handle data decoding
  140140. */
  140141. static DefaultNumWorkers: number;
  140142. private static GetDefaultNumWorkers;
  140143. private _engine;
  140144. private static _CreateWorkerPool;
  140145. /**
  140146. * Constructor
  140147. * @param engine The engine to use
  140148. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140149. */
  140150. constructor(engine: ThinEngine, numWorkers?: number);
  140151. /** @hidden */
  140152. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  140153. /**
  140154. * Stop all async operations and release resources.
  140155. */
  140156. dispose(): void;
  140157. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  140158. /**
  140159. * Checks if the given data starts with a KTX2 file identifier.
  140160. * @param data the data to check
  140161. * @returns true if the data is a KTX2 file or false otherwise
  140162. */
  140163. static IsValid(data: ArrayBufferView): boolean;
  140164. }
  140165. }
  140166. declare module BABYLON {
  140167. /**
  140168. * Implementation of the KTX Texture Loader.
  140169. * @hidden
  140170. */
  140171. export class _KTXTextureLoader implements IInternalTextureLoader {
  140172. /**
  140173. * Defines wether the loader supports cascade loading the different faces.
  140174. */
  140175. readonly supportCascades: boolean;
  140176. /**
  140177. * This returns if the loader support the current file information.
  140178. * @param extension defines the file extension of the file being loaded
  140179. * @param mimeType defines the optional mime type of the file being loaded
  140180. * @returns true if the loader can load the specified file
  140181. */
  140182. canLoad(extension: string, mimeType?: string): boolean;
  140183. /**
  140184. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140185. * @param data contains the texture data
  140186. * @param texture defines the BabylonJS internal texture
  140187. * @param createPolynomials will be true if polynomials have been requested
  140188. * @param onLoad defines the callback to trigger once the texture is ready
  140189. * @param onError defines the callback to trigger in case of error
  140190. */
  140191. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140192. /**
  140193. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140194. * @param data contains the texture data
  140195. * @param texture defines the BabylonJS internal texture
  140196. * @param callback defines the method to call once ready to upload
  140197. */
  140198. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  140199. }
  140200. }
  140201. declare module BABYLON {
  140202. /** @hidden */
  140203. export var _forceSceneHelpersToBundle: boolean;
  140204. interface Scene {
  140205. /**
  140206. * Creates a default light for the scene.
  140207. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  140208. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  140209. */
  140210. createDefaultLight(replace?: boolean): void;
  140211. /**
  140212. * Creates a default camera for the scene.
  140213. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  140214. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140215. * @param replace has default false, when true replaces the active camera in the scene
  140216. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  140217. */
  140218. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140219. /**
  140220. * Creates a default camera and a default light.
  140221. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  140222. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140223. * @param replace has the default false, when true replaces the active camera/light in the scene
  140224. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  140225. */
  140226. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140227. /**
  140228. * Creates a new sky box
  140229. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  140230. * @param environmentTexture defines the texture to use as environment texture
  140231. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  140232. * @param scale defines the overall scale of the skybox
  140233. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  140234. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  140235. * @returns a new mesh holding the sky box
  140236. */
  140237. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  140238. /**
  140239. * Creates a new environment
  140240. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  140241. * @param options defines the options you can use to configure the environment
  140242. * @returns the new EnvironmentHelper
  140243. */
  140244. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  140245. /**
  140246. * Creates a new VREXperienceHelper
  140247. * @see https://doc.babylonjs.com/how_to/webvr_helper
  140248. * @param webVROptions defines the options used to create the new VREXperienceHelper
  140249. * @returns a new VREXperienceHelper
  140250. */
  140251. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  140252. /**
  140253. * Creates a new WebXRDefaultExperience
  140254. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  140255. * @param options experience options
  140256. * @returns a promise for a new WebXRDefaultExperience
  140257. */
  140258. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  140259. }
  140260. }
  140261. declare module BABYLON {
  140262. /**
  140263. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  140264. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  140265. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  140266. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140267. */
  140268. export class VideoDome extends TextureDome<VideoTexture> {
  140269. /**
  140270. * Define the video source as a Monoscopic panoramic 360 video.
  140271. */
  140272. static readonly MODE_MONOSCOPIC: number;
  140273. /**
  140274. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  140275. */
  140276. static readonly MODE_TOPBOTTOM: number;
  140277. /**
  140278. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  140279. */
  140280. static readonly MODE_SIDEBYSIDE: number;
  140281. /**
  140282. * Get the video texture associated with this video dome
  140283. */
  140284. get videoTexture(): VideoTexture;
  140285. /**
  140286. * Get the video mode of this dome
  140287. */
  140288. get videoMode(): number;
  140289. /**
  140290. * Set the video mode of this dome.
  140291. * @see textureMode
  140292. */
  140293. set videoMode(value: number);
  140294. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  140295. }
  140296. }
  140297. declare module BABYLON {
  140298. /**
  140299. * This class can be used to get instrumentation data from a Babylon engine
  140300. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  140301. */
  140302. export class EngineInstrumentation implements IDisposable {
  140303. /**
  140304. * Define the instrumented engine.
  140305. */
  140306. engine: Engine;
  140307. private _captureGPUFrameTime;
  140308. private _gpuFrameTimeToken;
  140309. private _gpuFrameTime;
  140310. private _captureShaderCompilationTime;
  140311. private _shaderCompilationTime;
  140312. private _onBeginFrameObserver;
  140313. private _onEndFrameObserver;
  140314. private _onBeforeShaderCompilationObserver;
  140315. private _onAfterShaderCompilationObserver;
  140316. /**
  140317. * Gets the perf counter used for GPU frame time
  140318. */
  140319. get gpuFrameTimeCounter(): PerfCounter;
  140320. /**
  140321. * Gets the GPU frame time capture status
  140322. */
  140323. get captureGPUFrameTime(): boolean;
  140324. /**
  140325. * Enable or disable the GPU frame time capture
  140326. */
  140327. set captureGPUFrameTime(value: boolean);
  140328. /**
  140329. * Gets the perf counter used for shader compilation time
  140330. */
  140331. get shaderCompilationTimeCounter(): PerfCounter;
  140332. /**
  140333. * Gets the shader compilation time capture status
  140334. */
  140335. get captureShaderCompilationTime(): boolean;
  140336. /**
  140337. * Enable or disable the shader compilation time capture
  140338. */
  140339. set captureShaderCompilationTime(value: boolean);
  140340. /**
  140341. * Instantiates a new engine instrumentation.
  140342. * This class can be used to get instrumentation data from a Babylon engine
  140343. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  140344. * @param engine Defines the engine to instrument
  140345. */
  140346. constructor(
  140347. /**
  140348. * Define the instrumented engine.
  140349. */
  140350. engine: Engine);
  140351. /**
  140352. * Dispose and release associated resources.
  140353. */
  140354. dispose(): void;
  140355. }
  140356. }
  140357. declare module BABYLON {
  140358. /**
  140359. * This class can be used to get instrumentation data from a Babylon engine
  140360. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  140361. */
  140362. export class SceneInstrumentation implements IDisposable {
  140363. /**
  140364. * Defines the scene to instrument
  140365. */
  140366. scene: Scene;
  140367. private _captureActiveMeshesEvaluationTime;
  140368. private _activeMeshesEvaluationTime;
  140369. private _captureRenderTargetsRenderTime;
  140370. private _renderTargetsRenderTime;
  140371. private _captureFrameTime;
  140372. private _frameTime;
  140373. private _captureRenderTime;
  140374. private _renderTime;
  140375. private _captureInterFrameTime;
  140376. private _interFrameTime;
  140377. private _captureParticlesRenderTime;
  140378. private _particlesRenderTime;
  140379. private _captureSpritesRenderTime;
  140380. private _spritesRenderTime;
  140381. private _capturePhysicsTime;
  140382. private _physicsTime;
  140383. private _captureAnimationsTime;
  140384. private _animationsTime;
  140385. private _captureCameraRenderTime;
  140386. private _cameraRenderTime;
  140387. private _onBeforeActiveMeshesEvaluationObserver;
  140388. private _onAfterActiveMeshesEvaluationObserver;
  140389. private _onBeforeRenderTargetsRenderObserver;
  140390. private _onAfterRenderTargetsRenderObserver;
  140391. private _onAfterRenderObserver;
  140392. private _onBeforeDrawPhaseObserver;
  140393. private _onAfterDrawPhaseObserver;
  140394. private _onBeforeAnimationsObserver;
  140395. private _onBeforeParticlesRenderingObserver;
  140396. private _onAfterParticlesRenderingObserver;
  140397. private _onBeforeSpritesRenderingObserver;
  140398. private _onAfterSpritesRenderingObserver;
  140399. private _onBeforePhysicsObserver;
  140400. private _onAfterPhysicsObserver;
  140401. private _onAfterAnimationsObserver;
  140402. private _onBeforeCameraRenderObserver;
  140403. private _onAfterCameraRenderObserver;
  140404. /**
  140405. * Gets the perf counter used for active meshes evaluation time
  140406. */
  140407. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  140408. /**
  140409. * Gets the active meshes evaluation time capture status
  140410. */
  140411. get captureActiveMeshesEvaluationTime(): boolean;
  140412. /**
  140413. * Enable or disable the active meshes evaluation time capture
  140414. */
  140415. set captureActiveMeshesEvaluationTime(value: boolean);
  140416. /**
  140417. * Gets the perf counter used for render targets render time
  140418. */
  140419. get renderTargetsRenderTimeCounter(): PerfCounter;
  140420. /**
  140421. * Gets the render targets render time capture status
  140422. */
  140423. get captureRenderTargetsRenderTime(): boolean;
  140424. /**
  140425. * Enable or disable the render targets render time capture
  140426. */
  140427. set captureRenderTargetsRenderTime(value: boolean);
  140428. /**
  140429. * Gets the perf counter used for particles render time
  140430. */
  140431. get particlesRenderTimeCounter(): PerfCounter;
  140432. /**
  140433. * Gets the particles render time capture status
  140434. */
  140435. get captureParticlesRenderTime(): boolean;
  140436. /**
  140437. * Enable or disable the particles render time capture
  140438. */
  140439. set captureParticlesRenderTime(value: boolean);
  140440. /**
  140441. * Gets the perf counter used for sprites render time
  140442. */
  140443. get spritesRenderTimeCounter(): PerfCounter;
  140444. /**
  140445. * Gets the sprites render time capture status
  140446. */
  140447. get captureSpritesRenderTime(): boolean;
  140448. /**
  140449. * Enable or disable the sprites render time capture
  140450. */
  140451. set captureSpritesRenderTime(value: boolean);
  140452. /**
  140453. * Gets the perf counter used for physics time
  140454. */
  140455. get physicsTimeCounter(): PerfCounter;
  140456. /**
  140457. * Gets the physics time capture status
  140458. */
  140459. get capturePhysicsTime(): boolean;
  140460. /**
  140461. * Enable or disable the physics time capture
  140462. */
  140463. set capturePhysicsTime(value: boolean);
  140464. /**
  140465. * Gets the perf counter used for animations time
  140466. */
  140467. get animationsTimeCounter(): PerfCounter;
  140468. /**
  140469. * Gets the animations time capture status
  140470. */
  140471. get captureAnimationsTime(): boolean;
  140472. /**
  140473. * Enable or disable the animations time capture
  140474. */
  140475. set captureAnimationsTime(value: boolean);
  140476. /**
  140477. * Gets the perf counter used for frame time capture
  140478. */
  140479. get frameTimeCounter(): PerfCounter;
  140480. /**
  140481. * Gets the frame time capture status
  140482. */
  140483. get captureFrameTime(): boolean;
  140484. /**
  140485. * Enable or disable the frame time capture
  140486. */
  140487. set captureFrameTime(value: boolean);
  140488. /**
  140489. * Gets the perf counter used for inter-frames time capture
  140490. */
  140491. get interFrameTimeCounter(): PerfCounter;
  140492. /**
  140493. * Gets the inter-frames time capture status
  140494. */
  140495. get captureInterFrameTime(): boolean;
  140496. /**
  140497. * Enable or disable the inter-frames time capture
  140498. */
  140499. set captureInterFrameTime(value: boolean);
  140500. /**
  140501. * Gets the perf counter used for render time capture
  140502. */
  140503. get renderTimeCounter(): PerfCounter;
  140504. /**
  140505. * Gets the render time capture status
  140506. */
  140507. get captureRenderTime(): boolean;
  140508. /**
  140509. * Enable or disable the render time capture
  140510. */
  140511. set captureRenderTime(value: boolean);
  140512. /**
  140513. * Gets the perf counter used for camera render time capture
  140514. */
  140515. get cameraRenderTimeCounter(): PerfCounter;
  140516. /**
  140517. * Gets the camera render time capture status
  140518. */
  140519. get captureCameraRenderTime(): boolean;
  140520. /**
  140521. * Enable or disable the camera render time capture
  140522. */
  140523. set captureCameraRenderTime(value: boolean);
  140524. /**
  140525. * Gets the perf counter used for draw calls
  140526. */
  140527. get drawCallsCounter(): PerfCounter;
  140528. /**
  140529. * Instantiates a new scene instrumentation.
  140530. * This class can be used to get instrumentation data from a Babylon engine
  140531. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  140532. * @param scene Defines the scene to instrument
  140533. */
  140534. constructor(
  140535. /**
  140536. * Defines the scene to instrument
  140537. */
  140538. scene: Scene);
  140539. /**
  140540. * Dispose and release associated resources.
  140541. */
  140542. dispose(): void;
  140543. }
  140544. }
  140545. declare module BABYLON {
  140546. /** @hidden */
  140547. export var glowMapGenerationPixelShader: {
  140548. name: string;
  140549. shader: string;
  140550. };
  140551. }
  140552. declare module BABYLON {
  140553. /** @hidden */
  140554. export var glowMapGenerationVertexShader: {
  140555. name: string;
  140556. shader: string;
  140557. };
  140558. }
  140559. declare module BABYLON {
  140560. /**
  140561. * Effect layer options. This helps customizing the behaviour
  140562. * of the effect layer.
  140563. */
  140564. export interface IEffectLayerOptions {
  140565. /**
  140566. * Multiplication factor apply to the canvas size to compute the render target size
  140567. * used to generated the objects (the smaller the faster).
  140568. */
  140569. mainTextureRatio: number;
  140570. /**
  140571. * Enforces a fixed size texture to ensure effect stability across devices.
  140572. */
  140573. mainTextureFixedSize?: number;
  140574. /**
  140575. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  140576. */
  140577. alphaBlendingMode: number;
  140578. /**
  140579. * The camera attached to the layer.
  140580. */
  140581. camera: Nullable<Camera>;
  140582. /**
  140583. * The rendering group to draw the layer in.
  140584. */
  140585. renderingGroupId: number;
  140586. }
  140587. /**
  140588. * The effect layer Helps adding post process effect blended with the main pass.
  140589. *
  140590. * This can be for instance use to generate glow or higlight effects on the scene.
  140591. *
  140592. * The effect layer class can not be used directly and is intented to inherited from to be
  140593. * customized per effects.
  140594. */
  140595. export abstract class EffectLayer {
  140596. private _vertexBuffers;
  140597. private _indexBuffer;
  140598. private _cachedDefines;
  140599. private _effectLayerMapGenerationEffect;
  140600. private _effectLayerOptions;
  140601. private _mergeEffect;
  140602. protected _scene: Scene;
  140603. protected _engine: Engine;
  140604. protected _maxSize: number;
  140605. protected _mainTextureDesiredSize: ISize;
  140606. protected _mainTexture: RenderTargetTexture;
  140607. protected _shouldRender: boolean;
  140608. protected _postProcesses: PostProcess[];
  140609. protected _textures: BaseTexture[];
  140610. protected _emissiveTextureAndColor: {
  140611. texture: Nullable<BaseTexture>;
  140612. color: Color4;
  140613. };
  140614. /**
  140615. * The name of the layer
  140616. */
  140617. name: string;
  140618. /**
  140619. * The clear color of the texture used to generate the glow map.
  140620. */
  140621. neutralColor: Color4;
  140622. /**
  140623. * Specifies whether the highlight layer is enabled or not.
  140624. */
  140625. isEnabled: boolean;
  140626. /**
  140627. * Gets the camera attached to the layer.
  140628. */
  140629. get camera(): Nullable<Camera>;
  140630. /**
  140631. * Gets the rendering group id the layer should render in.
  140632. */
  140633. get renderingGroupId(): number;
  140634. set renderingGroupId(renderingGroupId: number);
  140635. /**
  140636. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  140637. */
  140638. disableBoundingBoxesFromEffectLayer: boolean;
  140639. /**
  140640. * An event triggered when the effect layer has been disposed.
  140641. */
  140642. onDisposeObservable: Observable<EffectLayer>;
  140643. /**
  140644. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  140645. */
  140646. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  140647. /**
  140648. * An event triggered when the generated texture is being merged in the scene.
  140649. */
  140650. onBeforeComposeObservable: Observable<EffectLayer>;
  140651. /**
  140652. * An event triggered when the mesh is rendered into the effect render target.
  140653. */
  140654. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  140655. /**
  140656. * An event triggered after the mesh has been rendered into the effect render target.
  140657. */
  140658. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  140659. /**
  140660. * An event triggered when the generated texture has been merged in the scene.
  140661. */
  140662. onAfterComposeObservable: Observable<EffectLayer>;
  140663. /**
  140664. * An event triggered when the efffect layer changes its size.
  140665. */
  140666. onSizeChangedObservable: Observable<EffectLayer>;
  140667. /** @hidden */
  140668. static _SceneComponentInitialization: (scene: Scene) => void;
  140669. /**
  140670. * Instantiates a new effect Layer and references it in the scene.
  140671. * @param name The name of the layer
  140672. * @param scene The scene to use the layer in
  140673. */
  140674. constructor(
  140675. /** The Friendly of the effect in the scene */
  140676. name: string, scene: Scene);
  140677. /**
  140678. * Get the effect name of the layer.
  140679. * @return The effect name
  140680. */
  140681. abstract getEffectName(): string;
  140682. /**
  140683. * Checks for the readiness of the element composing the layer.
  140684. * @param subMesh the mesh to check for
  140685. * @param useInstances specify whether or not to use instances to render the mesh
  140686. * @return true if ready otherwise, false
  140687. */
  140688. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140689. /**
  140690. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  140691. * @returns true if the effect requires stencil during the main canvas render pass.
  140692. */
  140693. abstract needStencil(): boolean;
  140694. /**
  140695. * Create the merge effect. This is the shader use to blit the information back
  140696. * to the main canvas at the end of the scene rendering.
  140697. * @returns The effect containing the shader used to merge the effect on the main canvas
  140698. */
  140699. protected abstract _createMergeEffect(): Effect;
  140700. /**
  140701. * Creates the render target textures and post processes used in the effect layer.
  140702. */
  140703. protected abstract _createTextureAndPostProcesses(): void;
  140704. /**
  140705. * Implementation specific of rendering the generating effect on the main canvas.
  140706. * @param effect The effect used to render through
  140707. */
  140708. protected abstract _internalRender(effect: Effect): void;
  140709. /**
  140710. * Sets the required values for both the emissive texture and and the main color.
  140711. */
  140712. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140713. /**
  140714. * Free any resources and references associated to a mesh.
  140715. * Internal use
  140716. * @param mesh The mesh to free.
  140717. */
  140718. abstract _disposeMesh(mesh: Mesh): void;
  140719. /**
  140720. * Serializes this layer (Glow or Highlight for example)
  140721. * @returns a serialized layer object
  140722. */
  140723. abstract serialize?(): any;
  140724. /**
  140725. * Initializes the effect layer with the required options.
  140726. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  140727. */
  140728. protected _init(options: Partial<IEffectLayerOptions>): void;
  140729. /**
  140730. * Generates the index buffer of the full screen quad blending to the main canvas.
  140731. */
  140732. private _generateIndexBuffer;
  140733. /**
  140734. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  140735. */
  140736. private _generateVertexBuffer;
  140737. /**
  140738. * Sets the main texture desired size which is the closest power of two
  140739. * of the engine canvas size.
  140740. */
  140741. private _setMainTextureSize;
  140742. /**
  140743. * Creates the main texture for the effect layer.
  140744. */
  140745. protected _createMainTexture(): void;
  140746. /**
  140747. * Adds specific effects defines.
  140748. * @param defines The defines to add specifics to.
  140749. */
  140750. protected _addCustomEffectDefines(defines: string[]): void;
  140751. /**
  140752. * Checks for the readiness of the element composing the layer.
  140753. * @param subMesh the mesh to check for
  140754. * @param useInstances specify whether or not to use instances to render the mesh
  140755. * @param emissiveTexture the associated emissive texture used to generate the glow
  140756. * @return true if ready otherwise, false
  140757. */
  140758. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  140759. /**
  140760. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  140761. */
  140762. render(): void;
  140763. /**
  140764. * Determine if a given mesh will be used in the current effect.
  140765. * @param mesh mesh to test
  140766. * @returns true if the mesh will be used
  140767. */
  140768. hasMesh(mesh: AbstractMesh): boolean;
  140769. /**
  140770. * Returns true if the layer contains information to display, otherwise false.
  140771. * @returns true if the glow layer should be rendered
  140772. */
  140773. shouldRender(): boolean;
  140774. /**
  140775. * Returns true if the mesh should render, otherwise false.
  140776. * @param mesh The mesh to render
  140777. * @returns true if it should render otherwise false
  140778. */
  140779. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  140780. /**
  140781. * Returns true if the mesh can be rendered, otherwise false.
  140782. * @param mesh The mesh to render
  140783. * @param material The material used on the mesh
  140784. * @returns true if it can be rendered otherwise false
  140785. */
  140786. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140787. /**
  140788. * Returns true if the mesh should render, otherwise false.
  140789. * @param mesh The mesh to render
  140790. * @returns true if it should render otherwise false
  140791. */
  140792. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  140793. /**
  140794. * Renders the submesh passed in parameter to the generation map.
  140795. */
  140796. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  140797. /**
  140798. * Defines whether the current material of the mesh should be use to render the effect.
  140799. * @param mesh defines the current mesh to render
  140800. */
  140801. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140802. /**
  140803. * Rebuild the required buffers.
  140804. * @hidden Internal use only.
  140805. */
  140806. _rebuild(): void;
  140807. /**
  140808. * Dispose only the render target textures and post process.
  140809. */
  140810. private _disposeTextureAndPostProcesses;
  140811. /**
  140812. * Dispose the highlight layer and free resources.
  140813. */
  140814. dispose(): void;
  140815. /**
  140816. * Gets the class name of the effect layer
  140817. * @returns the string with the class name of the effect layer
  140818. */
  140819. getClassName(): string;
  140820. /**
  140821. * Creates an effect layer from parsed effect layer data
  140822. * @param parsedEffectLayer defines effect layer data
  140823. * @param scene defines the current scene
  140824. * @param rootUrl defines the root URL containing the effect layer information
  140825. * @returns a parsed effect Layer
  140826. */
  140827. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  140828. }
  140829. }
  140830. declare module BABYLON {
  140831. interface AbstractScene {
  140832. /**
  140833. * The list of effect layers (highlights/glow) added to the scene
  140834. * @see https://doc.babylonjs.com/how_to/highlight_layer
  140835. * @see https://doc.babylonjs.com/how_to/glow_layer
  140836. */
  140837. effectLayers: Array<EffectLayer>;
  140838. /**
  140839. * Removes the given effect layer from this scene.
  140840. * @param toRemove defines the effect layer to remove
  140841. * @returns the index of the removed effect layer
  140842. */
  140843. removeEffectLayer(toRemove: EffectLayer): number;
  140844. /**
  140845. * Adds the given effect layer to this scene
  140846. * @param newEffectLayer defines the effect layer to add
  140847. */
  140848. addEffectLayer(newEffectLayer: EffectLayer): void;
  140849. }
  140850. /**
  140851. * Defines the layer scene component responsible to manage any effect layers
  140852. * in a given scene.
  140853. */
  140854. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  140855. /**
  140856. * The component name helpfull to identify the component in the list of scene components.
  140857. */
  140858. readonly name: string;
  140859. /**
  140860. * The scene the component belongs to.
  140861. */
  140862. scene: Scene;
  140863. private _engine;
  140864. private _renderEffects;
  140865. private _needStencil;
  140866. private _previousStencilState;
  140867. /**
  140868. * Creates a new instance of the component for the given scene
  140869. * @param scene Defines the scene to register the component in
  140870. */
  140871. constructor(scene: Scene);
  140872. /**
  140873. * Registers the component in a given scene
  140874. */
  140875. register(): void;
  140876. /**
  140877. * Rebuilds the elements related to this component in case of
  140878. * context lost for instance.
  140879. */
  140880. rebuild(): void;
  140881. /**
  140882. * Serializes the component data to the specified json object
  140883. * @param serializationObject The object to serialize to
  140884. */
  140885. serialize(serializationObject: any): void;
  140886. /**
  140887. * Adds all the elements from the container to the scene
  140888. * @param container the container holding the elements
  140889. */
  140890. addFromContainer(container: AbstractScene): void;
  140891. /**
  140892. * Removes all the elements in the container from the scene
  140893. * @param container contains the elements to remove
  140894. * @param dispose if the removed element should be disposed (default: false)
  140895. */
  140896. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140897. /**
  140898. * Disposes the component and the associated ressources.
  140899. */
  140900. dispose(): void;
  140901. private _isReadyForMesh;
  140902. private _renderMainTexture;
  140903. private _setStencil;
  140904. private _setStencilBack;
  140905. private _draw;
  140906. private _drawCamera;
  140907. private _drawRenderingGroup;
  140908. }
  140909. }
  140910. declare module BABYLON {
  140911. /** @hidden */
  140912. export var glowMapMergePixelShader: {
  140913. name: string;
  140914. shader: string;
  140915. };
  140916. }
  140917. declare module BABYLON {
  140918. /** @hidden */
  140919. export var glowMapMergeVertexShader: {
  140920. name: string;
  140921. shader: string;
  140922. };
  140923. }
  140924. declare module BABYLON {
  140925. interface AbstractScene {
  140926. /**
  140927. * Return a the first highlight layer of the scene with a given name.
  140928. * @param name The name of the highlight layer to look for.
  140929. * @return The highlight layer if found otherwise null.
  140930. */
  140931. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  140932. }
  140933. /**
  140934. * Glow layer options. This helps customizing the behaviour
  140935. * of the glow layer.
  140936. */
  140937. export interface IGlowLayerOptions {
  140938. /**
  140939. * Multiplication factor apply to the canvas size to compute the render target size
  140940. * used to generated the glowing objects (the smaller the faster).
  140941. */
  140942. mainTextureRatio: number;
  140943. /**
  140944. * Enforces a fixed size texture to ensure resize independant blur.
  140945. */
  140946. mainTextureFixedSize?: number;
  140947. /**
  140948. * How big is the kernel of the blur texture.
  140949. */
  140950. blurKernelSize: number;
  140951. /**
  140952. * The camera attached to the layer.
  140953. */
  140954. camera: Nullable<Camera>;
  140955. /**
  140956. * Enable MSAA by chosing the number of samples.
  140957. */
  140958. mainTextureSamples?: number;
  140959. /**
  140960. * The rendering group to draw the layer in.
  140961. */
  140962. renderingGroupId: number;
  140963. }
  140964. /**
  140965. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  140966. *
  140967. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  140968. *
  140969. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  140970. */
  140971. export class GlowLayer extends EffectLayer {
  140972. /**
  140973. * Effect Name of the layer.
  140974. */
  140975. static readonly EffectName: string;
  140976. /**
  140977. * The default blur kernel size used for the glow.
  140978. */
  140979. static DefaultBlurKernelSize: number;
  140980. /**
  140981. * The default texture size ratio used for the glow.
  140982. */
  140983. static DefaultTextureRatio: number;
  140984. /**
  140985. * Sets the kernel size of the blur.
  140986. */
  140987. set blurKernelSize(value: number);
  140988. /**
  140989. * Gets the kernel size of the blur.
  140990. */
  140991. get blurKernelSize(): number;
  140992. /**
  140993. * Sets the glow intensity.
  140994. */
  140995. set intensity(value: number);
  140996. /**
  140997. * Gets the glow intensity.
  140998. */
  140999. get intensity(): number;
  141000. private _options;
  141001. private _intensity;
  141002. private _horizontalBlurPostprocess1;
  141003. private _verticalBlurPostprocess1;
  141004. private _horizontalBlurPostprocess2;
  141005. private _verticalBlurPostprocess2;
  141006. private _blurTexture1;
  141007. private _blurTexture2;
  141008. private _postProcesses1;
  141009. private _postProcesses2;
  141010. private _includedOnlyMeshes;
  141011. private _excludedMeshes;
  141012. private _meshesUsingTheirOwnMaterials;
  141013. /**
  141014. * Callback used to let the user override the color selection on a per mesh basis
  141015. */
  141016. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  141017. /**
  141018. * Callback used to let the user override the texture selection on a per mesh basis
  141019. */
  141020. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  141021. /**
  141022. * Instantiates a new glow Layer and references it to the scene.
  141023. * @param name The name of the layer
  141024. * @param scene The scene to use the layer in
  141025. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  141026. */
  141027. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  141028. /**
  141029. * Get the effect name of the layer.
  141030. * @return The effect name
  141031. */
  141032. getEffectName(): string;
  141033. /**
  141034. * Create the merge effect. This is the shader use to blit the information back
  141035. * to the main canvas at the end of the scene rendering.
  141036. */
  141037. protected _createMergeEffect(): Effect;
  141038. /**
  141039. * Creates the render target textures and post processes used in the glow layer.
  141040. */
  141041. protected _createTextureAndPostProcesses(): void;
  141042. /**
  141043. * Checks for the readiness of the element composing the layer.
  141044. * @param subMesh the mesh to check for
  141045. * @param useInstances specify wether or not to use instances to render the mesh
  141046. * @param emissiveTexture the associated emissive texture used to generate the glow
  141047. * @return true if ready otherwise, false
  141048. */
  141049. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141050. /**
  141051. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141052. */
  141053. needStencil(): boolean;
  141054. /**
  141055. * Returns true if the mesh can be rendered, otherwise false.
  141056. * @param mesh The mesh to render
  141057. * @param material The material used on the mesh
  141058. * @returns true if it can be rendered otherwise false
  141059. */
  141060. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141061. /**
  141062. * Implementation specific of rendering the generating effect on the main canvas.
  141063. * @param effect The effect used to render through
  141064. */
  141065. protected _internalRender(effect: Effect): void;
  141066. /**
  141067. * Sets the required values for both the emissive texture and and the main color.
  141068. */
  141069. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141070. /**
  141071. * Returns true if the mesh should render, otherwise false.
  141072. * @param mesh The mesh to render
  141073. * @returns true if it should render otherwise false
  141074. */
  141075. protected _shouldRenderMesh(mesh: Mesh): boolean;
  141076. /**
  141077. * Adds specific effects defines.
  141078. * @param defines The defines to add specifics to.
  141079. */
  141080. protected _addCustomEffectDefines(defines: string[]): void;
  141081. /**
  141082. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  141083. * @param mesh The mesh to exclude from the glow layer
  141084. */
  141085. addExcludedMesh(mesh: Mesh): void;
  141086. /**
  141087. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  141088. * @param mesh The mesh to remove
  141089. */
  141090. removeExcludedMesh(mesh: Mesh): void;
  141091. /**
  141092. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  141093. * @param mesh The mesh to include in the glow layer
  141094. */
  141095. addIncludedOnlyMesh(mesh: Mesh): void;
  141096. /**
  141097. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  141098. * @param mesh The mesh to remove
  141099. */
  141100. removeIncludedOnlyMesh(mesh: Mesh): void;
  141101. /**
  141102. * Determine if a given mesh will be used in the glow layer
  141103. * @param mesh The mesh to test
  141104. * @returns true if the mesh will be highlighted by the current glow layer
  141105. */
  141106. hasMesh(mesh: AbstractMesh): boolean;
  141107. /**
  141108. * Defines whether the current material of the mesh should be use to render the effect.
  141109. * @param mesh defines the current mesh to render
  141110. */
  141111. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  141112. /**
  141113. * Add a mesh to be rendered through its own material and not with emissive only.
  141114. * @param mesh The mesh for which we need to use its material
  141115. */
  141116. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  141117. /**
  141118. * Remove a mesh from being rendered through its own material and not with emissive only.
  141119. * @param mesh The mesh for which we need to not use its material
  141120. */
  141121. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  141122. /**
  141123. * Free any resources and references associated to a mesh.
  141124. * Internal use
  141125. * @param mesh The mesh to free.
  141126. * @hidden
  141127. */
  141128. _disposeMesh(mesh: Mesh): void;
  141129. /**
  141130. * Gets the class name of the effect layer
  141131. * @returns the string with the class name of the effect layer
  141132. */
  141133. getClassName(): string;
  141134. /**
  141135. * Serializes this glow layer
  141136. * @returns a serialized glow layer object
  141137. */
  141138. serialize(): any;
  141139. /**
  141140. * Creates a Glow Layer from parsed glow layer data
  141141. * @param parsedGlowLayer defines glow layer data
  141142. * @param scene defines the current scene
  141143. * @param rootUrl defines the root URL containing the glow layer information
  141144. * @returns a parsed Glow Layer
  141145. */
  141146. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  141147. }
  141148. }
  141149. declare module BABYLON {
  141150. /** @hidden */
  141151. export var glowBlurPostProcessPixelShader: {
  141152. name: string;
  141153. shader: string;
  141154. };
  141155. }
  141156. declare module BABYLON {
  141157. interface AbstractScene {
  141158. /**
  141159. * Return a the first highlight layer of the scene with a given name.
  141160. * @param name The name of the highlight layer to look for.
  141161. * @return The highlight layer if found otherwise null.
  141162. */
  141163. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  141164. }
  141165. /**
  141166. * Highlight layer options. This helps customizing the behaviour
  141167. * of the highlight layer.
  141168. */
  141169. export interface IHighlightLayerOptions {
  141170. /**
  141171. * Multiplication factor apply to the canvas size to compute the render target size
  141172. * used to generated the glowing objects (the smaller the faster).
  141173. */
  141174. mainTextureRatio: number;
  141175. /**
  141176. * Enforces a fixed size texture to ensure resize independant blur.
  141177. */
  141178. mainTextureFixedSize?: number;
  141179. /**
  141180. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  141181. * of the picture to blur (the smaller the faster).
  141182. */
  141183. blurTextureSizeRatio: number;
  141184. /**
  141185. * How big in texel of the blur texture is the vertical blur.
  141186. */
  141187. blurVerticalSize: number;
  141188. /**
  141189. * How big in texel of the blur texture is the horizontal blur.
  141190. */
  141191. blurHorizontalSize: number;
  141192. /**
  141193. * Alpha blending mode used to apply the blur. Default is combine.
  141194. */
  141195. alphaBlendingMode: number;
  141196. /**
  141197. * The camera attached to the layer.
  141198. */
  141199. camera: Nullable<Camera>;
  141200. /**
  141201. * Should we display highlight as a solid stroke?
  141202. */
  141203. isStroke?: boolean;
  141204. /**
  141205. * The rendering group to draw the layer in.
  141206. */
  141207. renderingGroupId: number;
  141208. }
  141209. /**
  141210. * The highlight layer Helps adding a glow effect around a mesh.
  141211. *
  141212. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  141213. * glowy meshes to your scene.
  141214. *
  141215. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  141216. */
  141217. export class HighlightLayer extends EffectLayer {
  141218. name: string;
  141219. /**
  141220. * Effect Name of the highlight layer.
  141221. */
  141222. static readonly EffectName: string;
  141223. /**
  141224. * The neutral color used during the preparation of the glow effect.
  141225. * This is black by default as the blend operation is a blend operation.
  141226. */
  141227. static NeutralColor: Color4;
  141228. /**
  141229. * Stencil value used for glowing meshes.
  141230. */
  141231. static GlowingMeshStencilReference: number;
  141232. /**
  141233. * Stencil value used for the other meshes in the scene.
  141234. */
  141235. static NormalMeshStencilReference: number;
  141236. /**
  141237. * Specifies whether or not the inner glow is ACTIVE in the layer.
  141238. */
  141239. innerGlow: boolean;
  141240. /**
  141241. * Specifies whether or not the outer glow is ACTIVE in the layer.
  141242. */
  141243. outerGlow: boolean;
  141244. /**
  141245. * Specifies the horizontal size of the blur.
  141246. */
  141247. set blurHorizontalSize(value: number);
  141248. /**
  141249. * Specifies the vertical size of the blur.
  141250. */
  141251. set blurVerticalSize(value: number);
  141252. /**
  141253. * Gets the horizontal size of the blur.
  141254. */
  141255. get blurHorizontalSize(): number;
  141256. /**
  141257. * Gets the vertical size of the blur.
  141258. */
  141259. get blurVerticalSize(): number;
  141260. /**
  141261. * An event triggered when the highlight layer is being blurred.
  141262. */
  141263. onBeforeBlurObservable: Observable<HighlightLayer>;
  141264. /**
  141265. * An event triggered when the highlight layer has been blurred.
  141266. */
  141267. onAfterBlurObservable: Observable<HighlightLayer>;
  141268. private _instanceGlowingMeshStencilReference;
  141269. private _options;
  141270. private _downSamplePostprocess;
  141271. private _horizontalBlurPostprocess;
  141272. private _verticalBlurPostprocess;
  141273. private _blurTexture;
  141274. private _meshes;
  141275. private _excludedMeshes;
  141276. /**
  141277. * Instantiates a new highlight Layer and references it to the scene..
  141278. * @param name The name of the layer
  141279. * @param scene The scene to use the layer in
  141280. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  141281. */
  141282. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  141283. /**
  141284. * Get the effect name of the layer.
  141285. * @return The effect name
  141286. */
  141287. getEffectName(): string;
  141288. /**
  141289. * Create the merge effect. This is the shader use to blit the information back
  141290. * to the main canvas at the end of the scene rendering.
  141291. */
  141292. protected _createMergeEffect(): Effect;
  141293. /**
  141294. * Creates the render target textures and post processes used in the highlight layer.
  141295. */
  141296. protected _createTextureAndPostProcesses(): void;
  141297. /**
  141298. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  141299. */
  141300. needStencil(): boolean;
  141301. /**
  141302. * Checks for the readiness of the element composing the layer.
  141303. * @param subMesh the mesh to check for
  141304. * @param useInstances specify wether or not to use instances to render the mesh
  141305. * @param emissiveTexture the associated emissive texture used to generate the glow
  141306. * @return true if ready otherwise, false
  141307. */
  141308. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141309. /**
  141310. * Implementation specific of rendering the generating effect on the main canvas.
  141311. * @param effect The effect used to render through
  141312. */
  141313. protected _internalRender(effect: Effect): void;
  141314. /**
  141315. * Returns true if the layer contains information to display, otherwise false.
  141316. */
  141317. shouldRender(): boolean;
  141318. /**
  141319. * Returns true if the mesh should render, otherwise false.
  141320. * @param mesh The mesh to render
  141321. * @returns true if it should render otherwise false
  141322. */
  141323. protected _shouldRenderMesh(mesh: Mesh): boolean;
  141324. /**
  141325. * Returns true if the mesh can be rendered, otherwise false.
  141326. * @param mesh The mesh to render
  141327. * @param material The material used on the mesh
  141328. * @returns true if it can be rendered otherwise false
  141329. */
  141330. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141331. /**
  141332. * Adds specific effects defines.
  141333. * @param defines The defines to add specifics to.
  141334. */
  141335. protected _addCustomEffectDefines(defines: string[]): void;
  141336. /**
  141337. * Sets the required values for both the emissive texture and and the main color.
  141338. */
  141339. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141340. /**
  141341. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  141342. * @param mesh The mesh to exclude from the highlight layer
  141343. */
  141344. addExcludedMesh(mesh: Mesh): void;
  141345. /**
  141346. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  141347. * @param mesh The mesh to highlight
  141348. */
  141349. removeExcludedMesh(mesh: Mesh): void;
  141350. /**
  141351. * Determine if a given mesh will be highlighted by the current HighlightLayer
  141352. * @param mesh mesh to test
  141353. * @returns true if the mesh will be highlighted by the current HighlightLayer
  141354. */
  141355. hasMesh(mesh: AbstractMesh): boolean;
  141356. /**
  141357. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  141358. * @param mesh The mesh to highlight
  141359. * @param color The color of the highlight
  141360. * @param glowEmissiveOnly Extract the glow from the emissive texture
  141361. */
  141362. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  141363. /**
  141364. * Remove a mesh from the highlight layer in order to make it stop glowing.
  141365. * @param mesh The mesh to highlight
  141366. */
  141367. removeMesh(mesh: Mesh): void;
  141368. /**
  141369. * Remove all the meshes currently referenced in the highlight layer
  141370. */
  141371. removeAllMeshes(): void;
  141372. /**
  141373. * Force the stencil to the normal expected value for none glowing parts
  141374. */
  141375. private _defaultStencilReference;
  141376. /**
  141377. * Free any resources and references associated to a mesh.
  141378. * Internal use
  141379. * @param mesh The mesh to free.
  141380. * @hidden
  141381. */
  141382. _disposeMesh(mesh: Mesh): void;
  141383. /**
  141384. * Dispose the highlight layer and free resources.
  141385. */
  141386. dispose(): void;
  141387. /**
  141388. * Gets the class name of the effect layer
  141389. * @returns the string with the class name of the effect layer
  141390. */
  141391. getClassName(): string;
  141392. /**
  141393. * Serializes this Highlight layer
  141394. * @returns a serialized Highlight layer object
  141395. */
  141396. serialize(): any;
  141397. /**
  141398. * Creates a Highlight layer from parsed Highlight layer data
  141399. * @param parsedHightlightLayer defines the Highlight layer data
  141400. * @param scene defines the current scene
  141401. * @param rootUrl defines the root URL containing the Highlight layer information
  141402. * @returns a parsed Highlight layer
  141403. */
  141404. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  141405. }
  141406. }
  141407. declare module BABYLON {
  141408. interface AbstractScene {
  141409. /**
  141410. * The list of layers (background and foreground) of the scene
  141411. */
  141412. layers: Array<Layer>;
  141413. }
  141414. /**
  141415. * Defines the layer scene component responsible to manage any layers
  141416. * in a given scene.
  141417. */
  141418. export class LayerSceneComponent implements ISceneComponent {
  141419. /**
  141420. * The component name helpfull to identify the component in the list of scene components.
  141421. */
  141422. readonly name: string;
  141423. /**
  141424. * The scene the component belongs to.
  141425. */
  141426. scene: Scene;
  141427. private _engine;
  141428. /**
  141429. * Creates a new instance of the component for the given scene
  141430. * @param scene Defines the scene to register the component in
  141431. */
  141432. constructor(scene: Scene);
  141433. /**
  141434. * Registers the component in a given scene
  141435. */
  141436. register(): void;
  141437. /**
  141438. * Rebuilds the elements related to this component in case of
  141439. * context lost for instance.
  141440. */
  141441. rebuild(): void;
  141442. /**
  141443. * Disposes the component and the associated ressources.
  141444. */
  141445. dispose(): void;
  141446. private _draw;
  141447. private _drawCameraPredicate;
  141448. private _drawCameraBackground;
  141449. private _drawCameraForeground;
  141450. private _drawRenderTargetPredicate;
  141451. private _drawRenderTargetBackground;
  141452. private _drawRenderTargetForeground;
  141453. /**
  141454. * Adds all the elements from the container to the scene
  141455. * @param container the container holding the elements
  141456. */
  141457. addFromContainer(container: AbstractScene): void;
  141458. /**
  141459. * Removes all the elements in the container from the scene
  141460. * @param container contains the elements to remove
  141461. * @param dispose if the removed element should be disposed (default: false)
  141462. */
  141463. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141464. }
  141465. }
  141466. declare module BABYLON {
  141467. /** @hidden */
  141468. export var layerPixelShader: {
  141469. name: string;
  141470. shader: string;
  141471. };
  141472. }
  141473. declare module BABYLON {
  141474. /** @hidden */
  141475. export var layerVertexShader: {
  141476. name: string;
  141477. shader: string;
  141478. };
  141479. }
  141480. declare module BABYLON {
  141481. /**
  141482. * This represents a full screen 2d layer.
  141483. * This can be useful to display a picture in the background of your scene for instance.
  141484. * @see https://www.babylonjs-playground.com/#08A2BS#1
  141485. */
  141486. export class Layer {
  141487. /**
  141488. * Define the name of the layer.
  141489. */
  141490. name: string;
  141491. /**
  141492. * Define the texture the layer should display.
  141493. */
  141494. texture: Nullable<Texture>;
  141495. /**
  141496. * Is the layer in background or foreground.
  141497. */
  141498. isBackground: boolean;
  141499. /**
  141500. * Define the color of the layer (instead of texture).
  141501. */
  141502. color: Color4;
  141503. /**
  141504. * Define the scale of the layer in order to zoom in out of the texture.
  141505. */
  141506. scale: Vector2;
  141507. /**
  141508. * Define an offset for the layer in order to shift the texture.
  141509. */
  141510. offset: Vector2;
  141511. /**
  141512. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  141513. */
  141514. alphaBlendingMode: number;
  141515. /**
  141516. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  141517. * Alpha test will not mix with the background color in case of transparency.
  141518. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  141519. */
  141520. alphaTest: boolean;
  141521. /**
  141522. * Define a mask to restrict the layer to only some of the scene cameras.
  141523. */
  141524. layerMask: number;
  141525. /**
  141526. * Define the list of render target the layer is visible into.
  141527. */
  141528. renderTargetTextures: RenderTargetTexture[];
  141529. /**
  141530. * Define if the layer is only used in renderTarget or if it also
  141531. * renders in the main frame buffer of the canvas.
  141532. */
  141533. renderOnlyInRenderTargetTextures: boolean;
  141534. private _scene;
  141535. private _vertexBuffers;
  141536. private _indexBuffer;
  141537. private _effect;
  141538. private _previousDefines;
  141539. /**
  141540. * An event triggered when the layer is disposed.
  141541. */
  141542. onDisposeObservable: Observable<Layer>;
  141543. private _onDisposeObserver;
  141544. /**
  141545. * Back compatibility with callback before the onDisposeObservable existed.
  141546. * The set callback will be triggered when the layer has been disposed.
  141547. */
  141548. set onDispose(callback: () => void);
  141549. /**
  141550. * An event triggered before rendering the scene
  141551. */
  141552. onBeforeRenderObservable: Observable<Layer>;
  141553. private _onBeforeRenderObserver;
  141554. /**
  141555. * Back compatibility with callback before the onBeforeRenderObservable existed.
  141556. * The set callback will be triggered just before rendering the layer.
  141557. */
  141558. set onBeforeRender(callback: () => void);
  141559. /**
  141560. * An event triggered after rendering the scene
  141561. */
  141562. onAfterRenderObservable: Observable<Layer>;
  141563. private _onAfterRenderObserver;
  141564. /**
  141565. * Back compatibility with callback before the onAfterRenderObservable existed.
  141566. * The set callback will be triggered just after rendering the layer.
  141567. */
  141568. set onAfterRender(callback: () => void);
  141569. /**
  141570. * Instantiates a new layer.
  141571. * This represents a full screen 2d layer.
  141572. * This can be useful to display a picture in the background of your scene for instance.
  141573. * @see https://www.babylonjs-playground.com/#08A2BS#1
  141574. * @param name Define the name of the layer in the scene
  141575. * @param imgUrl Define the url of the texture to display in the layer
  141576. * @param scene Define the scene the layer belongs to
  141577. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  141578. * @param color Defines a color for the layer
  141579. */
  141580. constructor(
  141581. /**
  141582. * Define the name of the layer.
  141583. */
  141584. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  141585. private _createIndexBuffer;
  141586. /** @hidden */
  141587. _rebuild(): void;
  141588. /**
  141589. * Renders the layer in the scene.
  141590. */
  141591. render(): void;
  141592. /**
  141593. * Disposes and releases the associated ressources.
  141594. */
  141595. dispose(): void;
  141596. }
  141597. }
  141598. declare module BABYLON {
  141599. /** @hidden */
  141600. export var lensFlarePixelShader: {
  141601. name: string;
  141602. shader: string;
  141603. };
  141604. }
  141605. declare module BABYLON {
  141606. /** @hidden */
  141607. export var lensFlareVertexShader: {
  141608. name: string;
  141609. shader: string;
  141610. };
  141611. }
  141612. declare module BABYLON {
  141613. /**
  141614. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  141615. * It is usually composed of several `lensFlare`.
  141616. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141617. */
  141618. export class LensFlareSystem {
  141619. /**
  141620. * Define the name of the lens flare system
  141621. */
  141622. name: string;
  141623. /**
  141624. * List of lens flares used in this system.
  141625. */
  141626. lensFlares: LensFlare[];
  141627. /**
  141628. * Define a limit from the border the lens flare can be visible.
  141629. */
  141630. borderLimit: number;
  141631. /**
  141632. * Define a viewport border we do not want to see the lens flare in.
  141633. */
  141634. viewportBorder: number;
  141635. /**
  141636. * Define a predicate which could limit the list of meshes able to occlude the effect.
  141637. */
  141638. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  141639. /**
  141640. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  141641. */
  141642. layerMask: number;
  141643. /**
  141644. * Define the id of the lens flare system in the scene.
  141645. * (equal to name by default)
  141646. */
  141647. id: string;
  141648. private _scene;
  141649. private _emitter;
  141650. private _vertexBuffers;
  141651. private _indexBuffer;
  141652. private _effect;
  141653. private _positionX;
  141654. private _positionY;
  141655. private _isEnabled;
  141656. /** @hidden */
  141657. static _SceneComponentInitialization: (scene: Scene) => void;
  141658. /**
  141659. * Instantiates a lens flare system.
  141660. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  141661. * It is usually composed of several `lensFlare`.
  141662. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141663. * @param name Define the name of the lens flare system in the scene
  141664. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  141665. * @param scene Define the scene the lens flare system belongs to
  141666. */
  141667. constructor(
  141668. /**
  141669. * Define the name of the lens flare system
  141670. */
  141671. name: string, emitter: any, scene: Scene);
  141672. /**
  141673. * Define if the lens flare system is enabled.
  141674. */
  141675. get isEnabled(): boolean;
  141676. set isEnabled(value: boolean);
  141677. /**
  141678. * Get the scene the effects belongs to.
  141679. * @returns the scene holding the lens flare system
  141680. */
  141681. getScene(): Scene;
  141682. /**
  141683. * Get the emitter of the lens flare system.
  141684. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  141685. * @returns the emitter of the lens flare system
  141686. */
  141687. getEmitter(): any;
  141688. /**
  141689. * Set the emitter of the lens flare system.
  141690. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  141691. * @param newEmitter Define the new emitter of the system
  141692. */
  141693. setEmitter(newEmitter: any): void;
  141694. /**
  141695. * Get the lens flare system emitter position.
  141696. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  141697. * @returns the position
  141698. */
  141699. getEmitterPosition(): Vector3;
  141700. /**
  141701. * @hidden
  141702. */
  141703. computeEffectivePosition(globalViewport: Viewport): boolean;
  141704. /** @hidden */
  141705. _isVisible(): boolean;
  141706. /**
  141707. * @hidden
  141708. */
  141709. render(): boolean;
  141710. /**
  141711. * Dispose and release the lens flare with its associated resources.
  141712. */
  141713. dispose(): void;
  141714. /**
  141715. * Parse a lens flare system from a JSON repressentation
  141716. * @param parsedLensFlareSystem Define the JSON to parse
  141717. * @param scene Define the scene the parsed system should be instantiated in
  141718. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  141719. * @returns the parsed system
  141720. */
  141721. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  141722. /**
  141723. * Serialize the current Lens Flare System into a JSON representation.
  141724. * @returns the serialized JSON
  141725. */
  141726. serialize(): any;
  141727. }
  141728. }
  141729. declare module BABYLON {
  141730. /**
  141731. * This represents one of the lens effect in a `lensFlareSystem`.
  141732. * It controls one of the indiviual texture used in the effect.
  141733. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141734. */
  141735. export class LensFlare {
  141736. /**
  141737. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  141738. */
  141739. size: number;
  141740. /**
  141741. * 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.
  141742. */
  141743. position: number;
  141744. /**
  141745. * Define the lens color.
  141746. */
  141747. color: Color3;
  141748. /**
  141749. * Define the lens texture.
  141750. */
  141751. texture: Nullable<Texture>;
  141752. /**
  141753. * Define the alpha mode to render this particular lens.
  141754. */
  141755. alphaMode: number;
  141756. private _system;
  141757. /**
  141758. * Creates a new Lens Flare.
  141759. * This represents one of the lens effect in a `lensFlareSystem`.
  141760. * It controls one of the indiviual texture used in the effect.
  141761. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141762. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  141763. * @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.
  141764. * @param color Define the lens color
  141765. * @param imgUrl Define the lens texture url
  141766. * @param system Define the `lensFlareSystem` this flare is part of
  141767. * @returns The newly created Lens Flare
  141768. */
  141769. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  141770. /**
  141771. * Instantiates a new Lens Flare.
  141772. * This represents one of the lens effect in a `lensFlareSystem`.
  141773. * It controls one of the indiviual texture used in the effect.
  141774. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141775. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  141776. * @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.
  141777. * @param color Define the lens color
  141778. * @param imgUrl Define the lens texture url
  141779. * @param system Define the `lensFlareSystem` this flare is part of
  141780. */
  141781. constructor(
  141782. /**
  141783. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  141784. */
  141785. size: number,
  141786. /**
  141787. * 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.
  141788. */
  141789. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  141790. /**
  141791. * Dispose and release the lens flare with its associated resources.
  141792. */
  141793. dispose(): void;
  141794. }
  141795. }
  141796. declare module BABYLON {
  141797. interface AbstractScene {
  141798. /**
  141799. * The list of lens flare system added to the scene
  141800. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141801. */
  141802. lensFlareSystems: Array<LensFlareSystem>;
  141803. /**
  141804. * Removes the given lens flare system from this scene.
  141805. * @param toRemove The lens flare system to remove
  141806. * @returns The index of the removed lens flare system
  141807. */
  141808. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  141809. /**
  141810. * Adds the given lens flare system to this scene
  141811. * @param newLensFlareSystem The lens flare system to add
  141812. */
  141813. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  141814. /**
  141815. * Gets a lens flare system using its name
  141816. * @param name defines the name to look for
  141817. * @returns the lens flare system or null if not found
  141818. */
  141819. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  141820. /**
  141821. * Gets a lens flare system using its id
  141822. * @param id defines the id to look for
  141823. * @returns the lens flare system or null if not found
  141824. */
  141825. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  141826. }
  141827. /**
  141828. * Defines the lens flare scene component responsible to manage any lens flares
  141829. * in a given scene.
  141830. */
  141831. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  141832. /**
  141833. * The component name helpfull to identify the component in the list of scene components.
  141834. */
  141835. readonly name: string;
  141836. /**
  141837. * The scene the component belongs to.
  141838. */
  141839. scene: Scene;
  141840. /**
  141841. * Creates a new instance of the component for the given scene
  141842. * @param scene Defines the scene to register the component in
  141843. */
  141844. constructor(scene: Scene);
  141845. /**
  141846. * Registers the component in a given scene
  141847. */
  141848. register(): void;
  141849. /**
  141850. * Rebuilds the elements related to this component in case of
  141851. * context lost for instance.
  141852. */
  141853. rebuild(): void;
  141854. /**
  141855. * Adds all the elements from the container to the scene
  141856. * @param container the container holding the elements
  141857. */
  141858. addFromContainer(container: AbstractScene): void;
  141859. /**
  141860. * Removes all the elements in the container from the scene
  141861. * @param container contains the elements to remove
  141862. * @param dispose if the removed element should be disposed (default: false)
  141863. */
  141864. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141865. /**
  141866. * Serializes the component data to the specified json object
  141867. * @param serializationObject The object to serialize to
  141868. */
  141869. serialize(serializationObject: any): void;
  141870. /**
  141871. * Disposes the component and the associated ressources.
  141872. */
  141873. dispose(): void;
  141874. private _draw;
  141875. }
  141876. }
  141877. declare module BABYLON {
  141878. /** @hidden */
  141879. export var depthPixelShader: {
  141880. name: string;
  141881. shader: string;
  141882. };
  141883. }
  141884. declare module BABYLON {
  141885. /** @hidden */
  141886. export var depthVertexShader: {
  141887. name: string;
  141888. shader: string;
  141889. };
  141890. }
  141891. declare module BABYLON {
  141892. /**
  141893. * This represents a depth renderer in Babylon.
  141894. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  141895. */
  141896. export class DepthRenderer {
  141897. private _scene;
  141898. private _depthMap;
  141899. private _effect;
  141900. private readonly _storeNonLinearDepth;
  141901. private readonly _clearColor;
  141902. /** Get if the depth renderer is using packed depth or not */
  141903. readonly isPacked: boolean;
  141904. private _cachedDefines;
  141905. private _camera;
  141906. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  141907. enabled: boolean;
  141908. /**
  141909. * Specifiess that the depth renderer will only be used within
  141910. * the camera it is created for.
  141911. * This can help forcing its rendering during the camera processing.
  141912. */
  141913. useOnlyInActiveCamera: boolean;
  141914. /** @hidden */
  141915. static _SceneComponentInitialization: (scene: Scene) => void;
  141916. /**
  141917. * Instantiates a depth renderer
  141918. * @param scene The scene the renderer belongs to
  141919. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  141920. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  141921. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141922. */
  141923. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  141924. /**
  141925. * Creates the depth rendering effect and checks if the effect is ready.
  141926. * @param subMesh The submesh to be used to render the depth map of
  141927. * @param useInstances If multiple world instances should be used
  141928. * @returns if the depth renderer is ready to render the depth map
  141929. */
  141930. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141931. /**
  141932. * Gets the texture which the depth map will be written to.
  141933. * @returns The depth map texture
  141934. */
  141935. getDepthMap(): RenderTargetTexture;
  141936. /**
  141937. * Disposes of the depth renderer.
  141938. */
  141939. dispose(): void;
  141940. }
  141941. }
  141942. declare module BABYLON {
  141943. /** @hidden */
  141944. export var minmaxReduxPixelShader: {
  141945. name: string;
  141946. shader: string;
  141947. };
  141948. }
  141949. declare module BABYLON {
  141950. /**
  141951. * This class computes a min/max reduction from a texture: it means it computes the minimum
  141952. * and maximum values from all values of the texture.
  141953. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  141954. * The source values are read from the red channel of the texture.
  141955. */
  141956. export class MinMaxReducer {
  141957. /**
  141958. * Observable triggered when the computation has been performed
  141959. */
  141960. onAfterReductionPerformed: Observable<{
  141961. min: number;
  141962. max: number;
  141963. }>;
  141964. protected _camera: Camera;
  141965. protected _sourceTexture: Nullable<RenderTargetTexture>;
  141966. protected _reductionSteps: Nullable<Array<PostProcess>>;
  141967. protected _postProcessManager: PostProcessManager;
  141968. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  141969. protected _forceFullscreenViewport: boolean;
  141970. /**
  141971. * Creates a min/max reducer
  141972. * @param camera The camera to use for the post processes
  141973. */
  141974. constructor(camera: Camera);
  141975. /**
  141976. * Gets the texture used to read the values from.
  141977. */
  141978. get sourceTexture(): Nullable<RenderTargetTexture>;
  141979. /**
  141980. * Sets the source texture to read the values from.
  141981. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  141982. * because in such textures '1' value must not be taken into account to compute the maximum
  141983. * as this value is used to clear the texture.
  141984. * Note that the computation is not activated by calling this function, you must call activate() for that!
  141985. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  141986. * @param depthRedux Indicates if the texture is a depth texture or not
  141987. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  141988. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141989. */
  141990. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141991. /**
  141992. * Defines the refresh rate of the computation.
  141993. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141994. */
  141995. get refreshRate(): number;
  141996. set refreshRate(value: number);
  141997. protected _activated: boolean;
  141998. /**
  141999. * Gets the activation status of the reducer
  142000. */
  142001. get activated(): boolean;
  142002. /**
  142003. * Activates the reduction computation.
  142004. * When activated, the observers registered in onAfterReductionPerformed are
  142005. * called after the compuation is performed
  142006. */
  142007. activate(): void;
  142008. /**
  142009. * Deactivates the reduction computation.
  142010. */
  142011. deactivate(): void;
  142012. /**
  142013. * Disposes the min/max reducer
  142014. * @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.
  142015. */
  142016. dispose(disposeAll?: boolean): void;
  142017. }
  142018. }
  142019. declare module BABYLON {
  142020. /**
  142021. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  142022. */
  142023. export class DepthReducer extends MinMaxReducer {
  142024. private _depthRenderer;
  142025. private _depthRendererId;
  142026. /**
  142027. * Gets the depth renderer used for the computation.
  142028. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  142029. */
  142030. get depthRenderer(): Nullable<DepthRenderer>;
  142031. /**
  142032. * Creates a depth reducer
  142033. * @param camera The camera used to render the depth texture
  142034. */
  142035. constructor(camera: Camera);
  142036. /**
  142037. * Sets the depth renderer to use to generate the depth map
  142038. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  142039. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  142040. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142041. */
  142042. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  142043. /** @hidden */
  142044. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142045. /**
  142046. * Activates the reduction computation.
  142047. * When activated, the observers registered in onAfterReductionPerformed are
  142048. * called after the compuation is performed
  142049. */
  142050. activate(): void;
  142051. /**
  142052. * Deactivates the reduction computation.
  142053. */
  142054. deactivate(): void;
  142055. /**
  142056. * Disposes the depth reducer
  142057. * @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.
  142058. */
  142059. dispose(disposeAll?: boolean): void;
  142060. }
  142061. }
  142062. declare module BABYLON {
  142063. /**
  142064. * A CSM implementation allowing casting shadows on large scenes.
  142065. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142066. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  142067. */
  142068. export class CascadedShadowGenerator extends ShadowGenerator {
  142069. private static readonly frustumCornersNDCSpace;
  142070. /**
  142071. * Name of the CSM class
  142072. */
  142073. static CLASSNAME: string;
  142074. /**
  142075. * Defines the default number of cascades used by the CSM.
  142076. */
  142077. static readonly DEFAULT_CASCADES_COUNT: number;
  142078. /**
  142079. * Defines the minimum number of cascades used by the CSM.
  142080. */
  142081. static readonly MIN_CASCADES_COUNT: number;
  142082. /**
  142083. * Defines the maximum number of cascades used by the CSM.
  142084. */
  142085. static readonly MAX_CASCADES_COUNT: number;
  142086. protected _validateFilter(filter: number): number;
  142087. /**
  142088. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  142089. */
  142090. penumbraDarkness: number;
  142091. private _numCascades;
  142092. /**
  142093. * Gets or set the number of cascades used by the CSM.
  142094. */
  142095. get numCascades(): number;
  142096. set numCascades(value: number);
  142097. /**
  142098. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  142099. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  142100. */
  142101. stabilizeCascades: boolean;
  142102. private _freezeShadowCastersBoundingInfo;
  142103. private _freezeShadowCastersBoundingInfoObservable;
  142104. /**
  142105. * Enables or disables the shadow casters bounding info computation.
  142106. * If your shadow casters don't move, you can disable this feature.
  142107. * If it is enabled, the bounding box computation is done every frame.
  142108. */
  142109. get freezeShadowCastersBoundingInfo(): boolean;
  142110. set freezeShadowCastersBoundingInfo(freeze: boolean);
  142111. private _scbiMin;
  142112. private _scbiMax;
  142113. protected _computeShadowCastersBoundingInfo(): void;
  142114. protected _shadowCastersBoundingInfo: BoundingInfo;
  142115. /**
  142116. * Gets or sets the shadow casters bounding info.
  142117. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  142118. * so that the system won't overwrite the bounds you provide
  142119. */
  142120. get shadowCastersBoundingInfo(): BoundingInfo;
  142121. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  142122. protected _breaksAreDirty: boolean;
  142123. protected _minDistance: number;
  142124. protected _maxDistance: number;
  142125. /**
  142126. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  142127. *
  142128. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  142129. * If you don't know these values, simply leave them to their defaults and don't call this function.
  142130. * @param min minimal distance for the breaks (default to 0.)
  142131. * @param max maximal distance for the breaks (default to 1.)
  142132. */
  142133. setMinMaxDistance(min: number, max: number): void;
  142134. /** Gets the minimal distance used in the cascade break computation */
  142135. get minDistance(): number;
  142136. /** Gets the maximal distance used in the cascade break computation */
  142137. get maxDistance(): number;
  142138. /**
  142139. * Gets the class name of that object
  142140. * @returns "CascadedShadowGenerator"
  142141. */
  142142. getClassName(): string;
  142143. private _cascadeMinExtents;
  142144. private _cascadeMaxExtents;
  142145. /**
  142146. * Gets a cascade minimum extents
  142147. * @param cascadeIndex index of the cascade
  142148. * @returns the minimum cascade extents
  142149. */
  142150. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  142151. /**
  142152. * Gets a cascade maximum extents
  142153. * @param cascadeIndex index of the cascade
  142154. * @returns the maximum cascade extents
  142155. */
  142156. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  142157. private _cascades;
  142158. private _currentLayer;
  142159. private _viewSpaceFrustumsZ;
  142160. private _viewMatrices;
  142161. private _projectionMatrices;
  142162. private _transformMatrices;
  142163. private _transformMatricesAsArray;
  142164. private _frustumLengths;
  142165. private _lightSizeUVCorrection;
  142166. private _depthCorrection;
  142167. private _frustumCornersWorldSpace;
  142168. private _frustumCenter;
  142169. private _shadowCameraPos;
  142170. private _shadowMaxZ;
  142171. /**
  142172. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  142173. * It defaults to camera.maxZ
  142174. */
  142175. get shadowMaxZ(): number;
  142176. /**
  142177. * Sets the shadow max z distance.
  142178. */
  142179. set shadowMaxZ(value: number);
  142180. protected _debug: boolean;
  142181. /**
  142182. * Gets or sets the debug flag.
  142183. * When enabled, the cascades are materialized by different colors on the screen.
  142184. */
  142185. get debug(): boolean;
  142186. set debug(dbg: boolean);
  142187. private _depthClamp;
  142188. /**
  142189. * Gets or sets the depth clamping value.
  142190. *
  142191. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  142192. * to account for the shadow casters far away.
  142193. *
  142194. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  142195. */
  142196. get depthClamp(): boolean;
  142197. set depthClamp(value: boolean);
  142198. private _cascadeBlendPercentage;
  142199. /**
  142200. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  142201. * It defaults to 0.1 (10% blending).
  142202. */
  142203. get cascadeBlendPercentage(): number;
  142204. set cascadeBlendPercentage(value: number);
  142205. private _lambda;
  142206. /**
  142207. * Gets or set the lambda parameter.
  142208. * This parameter is used to split the camera frustum and create the cascades.
  142209. * 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.
  142210. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  142211. */
  142212. get lambda(): number;
  142213. set lambda(value: number);
  142214. /**
  142215. * Gets the view matrix corresponding to a given cascade
  142216. * @param cascadeNum cascade to retrieve the view matrix from
  142217. * @returns the cascade view matrix
  142218. */
  142219. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  142220. /**
  142221. * Gets the projection matrix corresponding to a given cascade
  142222. * @param cascadeNum cascade to retrieve the projection matrix from
  142223. * @returns the cascade projection matrix
  142224. */
  142225. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  142226. /**
  142227. * Gets the transformation matrix corresponding to a given cascade
  142228. * @param cascadeNum cascade to retrieve the transformation matrix from
  142229. * @returns the cascade transformation matrix
  142230. */
  142231. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  142232. private _depthRenderer;
  142233. /**
  142234. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  142235. *
  142236. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  142237. *
  142238. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  142239. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  142240. * @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
  142241. */
  142242. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  142243. private _depthReducer;
  142244. private _autoCalcDepthBounds;
  142245. /**
  142246. * Gets or sets the autoCalcDepthBounds property.
  142247. *
  142248. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  142249. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  142250. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  142251. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  142252. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  142253. */
  142254. get autoCalcDepthBounds(): boolean;
  142255. set autoCalcDepthBounds(value: boolean);
  142256. /**
  142257. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  142258. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142259. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  142260. * for setting the refresh rate on the renderer yourself!
  142261. */
  142262. get autoCalcDepthBoundsRefreshRate(): number;
  142263. set autoCalcDepthBoundsRefreshRate(value: number);
  142264. /**
  142265. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  142266. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  142267. * you change the camera near/far planes!
  142268. */
  142269. splitFrustum(): void;
  142270. private _splitFrustum;
  142271. private _computeMatrices;
  142272. private _computeFrustumInWorldSpace;
  142273. private _computeCascadeFrustum;
  142274. /**
  142275. * Support test.
  142276. */
  142277. static get IsSupported(): boolean;
  142278. /** @hidden */
  142279. static _SceneComponentInitialization: (scene: Scene) => void;
  142280. /**
  142281. * Creates a Cascaded Shadow Generator object.
  142282. * A ShadowGenerator is the required tool to use the shadows.
  142283. * Each directional light casting shadows needs to use its own ShadowGenerator.
  142284. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142285. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  142286. * @param light The directional light object generating the shadows.
  142287. * @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.
  142288. */
  142289. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  142290. protected _initializeGenerator(): void;
  142291. protected _createTargetRenderTexture(): void;
  142292. protected _initializeShadowMap(): void;
  142293. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  142294. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  142295. /**
  142296. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  142297. * @param defines Defines of the material we want to update
  142298. * @param lightIndex Index of the light in the enabled light list of the material
  142299. */
  142300. prepareDefines(defines: any, lightIndex: number): void;
  142301. /**
  142302. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  142303. * defined in the generator but impacting the effect).
  142304. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  142305. * @param effect The effect we are binfing the information for
  142306. */
  142307. bindShadowLight(lightIndex: string, effect: Effect): void;
  142308. /**
  142309. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  142310. * (eq to view projection * shadow projection matrices)
  142311. * @returns The transform matrix used to create the shadow map
  142312. */
  142313. getTransformMatrix(): Matrix;
  142314. /**
  142315. * Disposes the ShadowGenerator.
  142316. * Returns nothing.
  142317. */
  142318. dispose(): void;
  142319. /**
  142320. * Serializes the shadow generator setup to a json object.
  142321. * @returns The serialized JSON object
  142322. */
  142323. serialize(): any;
  142324. /**
  142325. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  142326. * @param parsedShadowGenerator The JSON object to parse
  142327. * @param scene The scene to create the shadow map for
  142328. * @returns The parsed shadow generator
  142329. */
  142330. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  142331. }
  142332. }
  142333. declare module BABYLON {
  142334. /**
  142335. * Defines the shadow generator component responsible to manage any shadow generators
  142336. * in a given scene.
  142337. */
  142338. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  142339. /**
  142340. * The component name helpfull to identify the component in the list of scene components.
  142341. */
  142342. readonly name: string;
  142343. /**
  142344. * The scene the component belongs to.
  142345. */
  142346. scene: Scene;
  142347. /**
  142348. * Creates a new instance of the component for the given scene
  142349. * @param scene Defines the scene to register the component in
  142350. */
  142351. constructor(scene: Scene);
  142352. /**
  142353. * Registers the component in a given scene
  142354. */
  142355. register(): void;
  142356. /**
  142357. * Rebuilds the elements related to this component in case of
  142358. * context lost for instance.
  142359. */
  142360. rebuild(): void;
  142361. /**
  142362. * Serializes the component data to the specified json object
  142363. * @param serializationObject The object to serialize to
  142364. */
  142365. serialize(serializationObject: any): void;
  142366. /**
  142367. * Adds all the elements from the container to the scene
  142368. * @param container the container holding the elements
  142369. */
  142370. addFromContainer(container: AbstractScene): void;
  142371. /**
  142372. * Removes all the elements in the container from the scene
  142373. * @param container contains the elements to remove
  142374. * @param dispose if the removed element should be disposed (default: false)
  142375. */
  142376. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142377. /**
  142378. * Rebuilds the elements related to this component in case of
  142379. * context lost for instance.
  142380. */
  142381. dispose(): void;
  142382. private _gatherRenderTargets;
  142383. }
  142384. }
  142385. declare module BABYLON {
  142386. /**
  142387. * A point light is a light defined by an unique point in world space.
  142388. * The light is emitted in every direction from this point.
  142389. * A good example of a point light is a standard light bulb.
  142390. * Documentation: https://doc.babylonjs.com/babylon101/lights
  142391. */
  142392. export class PointLight extends ShadowLight {
  142393. private _shadowAngle;
  142394. /**
  142395. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142396. * This specifies what angle the shadow will use to be created.
  142397. *
  142398. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  142399. */
  142400. get shadowAngle(): number;
  142401. /**
  142402. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142403. * This specifies what angle the shadow will use to be created.
  142404. *
  142405. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  142406. */
  142407. set shadowAngle(value: number);
  142408. /**
  142409. * Gets the direction if it has been set.
  142410. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142411. */
  142412. get direction(): Vector3;
  142413. /**
  142414. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142415. */
  142416. set direction(value: Vector3);
  142417. /**
  142418. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  142419. * A PointLight emits the light in every direction.
  142420. * It can cast shadows.
  142421. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  142422. * ```javascript
  142423. * var pointLight = new PointLight("pl", camera.position, scene);
  142424. * ```
  142425. * Documentation : https://doc.babylonjs.com/babylon101/lights
  142426. * @param name The light friendly name
  142427. * @param position The position of the point light in the scene
  142428. * @param scene The scene the lights belongs to
  142429. */
  142430. constructor(name: string, position: Vector3, scene: Scene);
  142431. /**
  142432. * Returns the string "PointLight"
  142433. * @returns the class name
  142434. */
  142435. getClassName(): string;
  142436. /**
  142437. * Returns the integer 0.
  142438. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  142439. */
  142440. getTypeID(): number;
  142441. /**
  142442. * Specifies wether or not the shadowmap should be a cube texture.
  142443. * @returns true if the shadowmap needs to be a cube texture.
  142444. */
  142445. needCube(): boolean;
  142446. /**
  142447. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  142448. * @param faceIndex The index of the face we are computed the direction to generate shadow
  142449. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  142450. */
  142451. getShadowDirection(faceIndex?: number): Vector3;
  142452. /**
  142453. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  142454. * - fov = PI / 2
  142455. * - aspect ratio : 1.0
  142456. * - z-near and far equal to the active camera minZ and maxZ.
  142457. * Returns the PointLight.
  142458. */
  142459. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  142460. protected _buildUniformLayout(): void;
  142461. /**
  142462. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  142463. * @param effect The effect to update
  142464. * @param lightIndex The index of the light in the effect to update
  142465. * @returns The point light
  142466. */
  142467. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  142468. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  142469. /**
  142470. * Prepares the list of defines specific to the light type.
  142471. * @param defines the list of defines
  142472. * @param lightIndex defines the index of the light for the effect
  142473. */
  142474. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  142475. }
  142476. }
  142477. declare module BABYLON {
  142478. /**
  142479. * Header information of HDR texture files.
  142480. */
  142481. export interface HDRInfo {
  142482. /**
  142483. * The height of the texture in pixels.
  142484. */
  142485. height: number;
  142486. /**
  142487. * The width of the texture in pixels.
  142488. */
  142489. width: number;
  142490. /**
  142491. * The index of the beginning of the data in the binary file.
  142492. */
  142493. dataPosition: number;
  142494. }
  142495. /**
  142496. * This groups tools to convert HDR texture to native colors array.
  142497. */
  142498. export class HDRTools {
  142499. private static Ldexp;
  142500. private static Rgbe2float;
  142501. private static readStringLine;
  142502. /**
  142503. * Reads header information from an RGBE texture stored in a native array.
  142504. * More information on this format are available here:
  142505. * https://en.wikipedia.org/wiki/RGBE_image_format
  142506. *
  142507. * @param uint8array The binary file stored in native array.
  142508. * @return The header information.
  142509. */
  142510. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  142511. /**
  142512. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  142513. * This RGBE texture needs to store the information as a panorama.
  142514. *
  142515. * More information on this format are available here:
  142516. * https://en.wikipedia.org/wiki/RGBE_image_format
  142517. *
  142518. * @param buffer The binary file stored in an array buffer.
  142519. * @param size The expected size of the extracted cubemap.
  142520. * @return The Cube Map information.
  142521. */
  142522. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  142523. /**
  142524. * Returns the pixels data extracted from an RGBE texture.
  142525. * This pixels will be stored left to right up to down in the R G B order in one array.
  142526. *
  142527. * More information on this format are available here:
  142528. * https://en.wikipedia.org/wiki/RGBE_image_format
  142529. *
  142530. * @param uint8array The binary file stored in an array buffer.
  142531. * @param hdrInfo The header information of the file.
  142532. * @return The pixels data in RGB right to left up to down order.
  142533. */
  142534. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  142535. private static RGBE_ReadPixels_RLE;
  142536. private static RGBE_ReadPixels_NOT_RLE;
  142537. }
  142538. }
  142539. declare module BABYLON {
  142540. /**
  142541. * Effect Render Options
  142542. */
  142543. export interface IEffectRendererOptions {
  142544. /**
  142545. * Defines the vertices positions.
  142546. */
  142547. positions?: number[];
  142548. /**
  142549. * Defines the indices.
  142550. */
  142551. indices?: number[];
  142552. }
  142553. /**
  142554. * Helper class to render one or more effects.
  142555. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  142556. */
  142557. export class EffectRenderer {
  142558. private engine;
  142559. private static _DefaultOptions;
  142560. private _vertexBuffers;
  142561. private _indexBuffer;
  142562. private _fullscreenViewport;
  142563. /**
  142564. * Creates an effect renderer
  142565. * @param engine the engine to use for rendering
  142566. * @param options defines the options of the effect renderer
  142567. */
  142568. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  142569. /**
  142570. * Sets the current viewport in normalized coordinates 0-1
  142571. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  142572. */
  142573. setViewport(viewport?: Viewport): void;
  142574. /**
  142575. * Binds the embedded attributes buffer to the effect.
  142576. * @param effect Defines the effect to bind the attributes for
  142577. */
  142578. bindBuffers(effect: Effect): void;
  142579. /**
  142580. * Sets the current effect wrapper to use during draw.
  142581. * The effect needs to be ready before calling this api.
  142582. * This also sets the default full screen position attribute.
  142583. * @param effectWrapper Defines the effect to draw with
  142584. */
  142585. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  142586. /**
  142587. * Restores engine states
  142588. */
  142589. restoreStates(): void;
  142590. /**
  142591. * Draws a full screen quad.
  142592. */
  142593. draw(): void;
  142594. private isRenderTargetTexture;
  142595. /**
  142596. * renders one or more effects to a specified texture
  142597. * @param effectWrapper the effect to renderer
  142598. * @param outputTexture texture to draw to, if null it will render to the screen.
  142599. */
  142600. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  142601. /**
  142602. * Disposes of the effect renderer
  142603. */
  142604. dispose(): void;
  142605. }
  142606. /**
  142607. * Options to create an EffectWrapper
  142608. */
  142609. interface EffectWrapperCreationOptions {
  142610. /**
  142611. * Engine to use to create the effect
  142612. */
  142613. engine: ThinEngine;
  142614. /**
  142615. * Fragment shader for the effect
  142616. */
  142617. fragmentShader: string;
  142618. /**
  142619. * Use the shader store instead of direct source code
  142620. */
  142621. useShaderStore?: boolean;
  142622. /**
  142623. * Vertex shader for the effect
  142624. */
  142625. vertexShader?: string;
  142626. /**
  142627. * Attributes to use in the shader
  142628. */
  142629. attributeNames?: Array<string>;
  142630. /**
  142631. * Uniforms to use in the shader
  142632. */
  142633. uniformNames?: Array<string>;
  142634. /**
  142635. * Texture sampler names to use in the shader
  142636. */
  142637. samplerNames?: Array<string>;
  142638. /**
  142639. * Defines to use in the shader
  142640. */
  142641. defines?: Array<string>;
  142642. /**
  142643. * Callback when effect is compiled
  142644. */
  142645. onCompiled?: Nullable<(effect: Effect) => void>;
  142646. /**
  142647. * The friendly name of the effect displayed in Spector.
  142648. */
  142649. name?: string;
  142650. }
  142651. /**
  142652. * Wraps an effect to be used for rendering
  142653. */
  142654. export class EffectWrapper {
  142655. /**
  142656. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  142657. */
  142658. onApplyObservable: Observable<{}>;
  142659. /**
  142660. * The underlying effect
  142661. */
  142662. effect: Effect;
  142663. /**
  142664. * Creates an effect to be renderer
  142665. * @param creationOptions options to create the effect
  142666. */
  142667. constructor(creationOptions: EffectWrapperCreationOptions);
  142668. /**
  142669. * Disposes of the effect wrapper
  142670. */
  142671. dispose(): void;
  142672. }
  142673. }
  142674. declare module BABYLON {
  142675. /** @hidden */
  142676. export var hdrFilteringVertexShader: {
  142677. name: string;
  142678. shader: string;
  142679. };
  142680. }
  142681. declare module BABYLON {
  142682. /** @hidden */
  142683. export var hdrFilteringPixelShader: {
  142684. name: string;
  142685. shader: string;
  142686. };
  142687. }
  142688. declare module BABYLON {
  142689. /**
  142690. * Options for texture filtering
  142691. */
  142692. interface IHDRFilteringOptions {
  142693. /**
  142694. * Scales pixel intensity for the input HDR map.
  142695. */
  142696. hdrScale?: number;
  142697. /**
  142698. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  142699. */
  142700. quality?: number;
  142701. }
  142702. /**
  142703. * Filters HDR maps to get correct renderings of PBR reflections
  142704. */
  142705. export class HDRFiltering {
  142706. private _engine;
  142707. private _effectRenderer;
  142708. private _effectWrapper;
  142709. private _lodGenerationOffset;
  142710. private _lodGenerationScale;
  142711. /**
  142712. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  142713. * you care about baking speed.
  142714. */
  142715. quality: number;
  142716. /**
  142717. * Scales pixel intensity for the input HDR map.
  142718. */
  142719. hdrScale: number;
  142720. /**
  142721. * Instantiates HDR filter for reflection maps
  142722. *
  142723. * @param engine Thin engine
  142724. * @param options Options
  142725. */
  142726. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  142727. private _createRenderTarget;
  142728. private _prefilterInternal;
  142729. private _createEffect;
  142730. /**
  142731. * Get a value indicating if the filter is ready to be used
  142732. * @param texture Texture to filter
  142733. * @returns true if the filter is ready
  142734. */
  142735. isReady(texture: BaseTexture): boolean;
  142736. /**
  142737. * Prefilters a cube texture to have mipmap levels representing roughness values.
  142738. * Prefiltering will be invoked at the end of next rendering pass.
  142739. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  142740. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  142741. * @param texture Texture to filter
  142742. * @param onFinished Callback when filtering is done
  142743. * @return Promise called when prefiltering is done
  142744. */
  142745. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  142746. }
  142747. }
  142748. declare module BABYLON {
  142749. /**
  142750. * This represents a texture coming from an HDR input.
  142751. *
  142752. * The only supported format is currently panorama picture stored in RGBE format.
  142753. * Example of such files can be found on HDRLib: http://hdrlib.com/
  142754. */
  142755. export class HDRCubeTexture extends BaseTexture {
  142756. private static _facesMapping;
  142757. private _generateHarmonics;
  142758. private _noMipmap;
  142759. private _prefilterOnLoad;
  142760. private _textureMatrix;
  142761. private _size;
  142762. private _onLoad;
  142763. private _onError;
  142764. /**
  142765. * The texture URL.
  142766. */
  142767. url: string;
  142768. protected _isBlocking: boolean;
  142769. /**
  142770. * Sets wether or not the texture is blocking during loading.
  142771. */
  142772. set isBlocking(value: boolean);
  142773. /**
  142774. * Gets wether or not the texture is blocking during loading.
  142775. */
  142776. get isBlocking(): boolean;
  142777. protected _rotationY: number;
  142778. /**
  142779. * Sets texture matrix rotation angle around Y axis in radians.
  142780. */
  142781. set rotationY(value: number);
  142782. /**
  142783. * Gets texture matrix rotation angle around Y axis radians.
  142784. */
  142785. get rotationY(): number;
  142786. /**
  142787. * Gets or sets the center of the bounding box associated with the cube texture
  142788. * It must define where the camera used to render the texture was set
  142789. */
  142790. boundingBoxPosition: Vector3;
  142791. private _boundingBoxSize;
  142792. /**
  142793. * Gets or sets the size of the bounding box associated with the cube texture
  142794. * When defined, the cubemap will switch to local mode
  142795. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  142796. * @example https://www.babylonjs-playground.com/#RNASML
  142797. */
  142798. set boundingBoxSize(value: Vector3);
  142799. get boundingBoxSize(): Vector3;
  142800. /**
  142801. * Instantiates an HDRTexture from the following parameters.
  142802. *
  142803. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  142804. * @param sceneOrEngine The scene or engine the texture will be used in
  142805. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142806. * @param noMipmap Forces to not generate the mipmap if true
  142807. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  142808. * @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)
  142809. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  142810. */
  142811. 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>);
  142812. /**
  142813. * Get the current class name of the texture useful for serialization or dynamic coding.
  142814. * @returns "HDRCubeTexture"
  142815. */
  142816. getClassName(): string;
  142817. /**
  142818. * Occurs when the file is raw .hdr file.
  142819. */
  142820. private loadTexture;
  142821. clone(): HDRCubeTexture;
  142822. delayLoad(): void;
  142823. /**
  142824. * Get the texture reflection matrix used to rotate/transform the reflection.
  142825. * @returns the reflection matrix
  142826. */
  142827. getReflectionTextureMatrix(): Matrix;
  142828. /**
  142829. * Set the texture reflection matrix used to rotate/transform the reflection.
  142830. * @param value Define the reflection matrix to set
  142831. */
  142832. setReflectionTextureMatrix(value: Matrix): void;
  142833. /**
  142834. * Parses a JSON representation of an HDR Texture in order to create the texture
  142835. * @param parsedTexture Define the JSON representation
  142836. * @param scene Define the scene the texture should be created in
  142837. * @param rootUrl Define the root url in case we need to load relative dependencies
  142838. * @returns the newly created texture after parsing
  142839. */
  142840. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  142841. serialize(): any;
  142842. }
  142843. }
  142844. declare module BABYLON {
  142845. /**
  142846. * Class used to control physics engine
  142847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142848. */
  142849. export class PhysicsEngine implements IPhysicsEngine {
  142850. private _physicsPlugin;
  142851. /**
  142852. * Global value used to control the smallest number supported by the simulation
  142853. */
  142854. static Epsilon: number;
  142855. private _impostors;
  142856. private _joints;
  142857. private _subTimeStep;
  142858. /**
  142859. * Gets the gravity vector used by the simulation
  142860. */
  142861. gravity: Vector3;
  142862. /**
  142863. * Factory used to create the default physics plugin.
  142864. * @returns The default physics plugin
  142865. */
  142866. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  142867. /**
  142868. * Creates a new Physics Engine
  142869. * @param gravity defines the gravity vector used by the simulation
  142870. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  142871. */
  142872. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  142873. /**
  142874. * Sets the gravity vector used by the simulation
  142875. * @param gravity defines the gravity vector to use
  142876. */
  142877. setGravity(gravity: Vector3): void;
  142878. /**
  142879. * Set the time step of the physics engine.
  142880. * Default is 1/60.
  142881. * To slow it down, enter 1/600 for example.
  142882. * To speed it up, 1/30
  142883. * @param newTimeStep defines the new timestep to apply to this world.
  142884. */
  142885. setTimeStep(newTimeStep?: number): void;
  142886. /**
  142887. * Get the time step of the physics engine.
  142888. * @returns the current time step
  142889. */
  142890. getTimeStep(): number;
  142891. /**
  142892. * Set the sub time step of the physics engine.
  142893. * Default is 0 meaning there is no sub steps
  142894. * To increase physics resolution precision, set a small value (like 1 ms)
  142895. * @param subTimeStep defines the new sub timestep used for physics resolution.
  142896. */
  142897. setSubTimeStep(subTimeStep?: number): void;
  142898. /**
  142899. * Get the sub time step of the physics engine.
  142900. * @returns the current sub time step
  142901. */
  142902. getSubTimeStep(): number;
  142903. /**
  142904. * Release all resources
  142905. */
  142906. dispose(): void;
  142907. /**
  142908. * Gets the name of the current physics plugin
  142909. * @returns the name of the plugin
  142910. */
  142911. getPhysicsPluginName(): string;
  142912. /**
  142913. * Adding a new impostor for the impostor tracking.
  142914. * This will be done by the impostor itself.
  142915. * @param impostor the impostor to add
  142916. */
  142917. addImpostor(impostor: PhysicsImpostor): void;
  142918. /**
  142919. * Remove an impostor from the engine.
  142920. * This impostor and its mesh will not longer be updated by the physics engine.
  142921. * @param impostor the impostor to remove
  142922. */
  142923. removeImpostor(impostor: PhysicsImpostor): void;
  142924. /**
  142925. * Add a joint to the physics engine
  142926. * @param mainImpostor defines the main impostor to which the joint is added.
  142927. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  142928. * @param joint defines the joint that will connect both impostors.
  142929. */
  142930. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142931. /**
  142932. * Removes a joint from the simulation
  142933. * @param mainImpostor defines the impostor used with the joint
  142934. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  142935. * @param joint defines the joint to remove
  142936. */
  142937. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142938. /**
  142939. * Called by the scene. No need to call it.
  142940. * @param delta defines the timespam between frames
  142941. */
  142942. _step(delta: number): void;
  142943. /**
  142944. * Gets the current plugin used to run the simulation
  142945. * @returns current plugin
  142946. */
  142947. getPhysicsPlugin(): IPhysicsEnginePlugin;
  142948. /**
  142949. * Gets the list of physic impostors
  142950. * @returns an array of PhysicsImpostor
  142951. */
  142952. getImpostors(): Array<PhysicsImpostor>;
  142953. /**
  142954. * Gets the impostor for a physics enabled object
  142955. * @param object defines the object impersonated by the impostor
  142956. * @returns the PhysicsImpostor or null if not found
  142957. */
  142958. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  142959. /**
  142960. * Gets the impostor for a physics body object
  142961. * @param body defines physics body used by the impostor
  142962. * @returns the PhysicsImpostor or null if not found
  142963. */
  142964. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  142965. /**
  142966. * Does a raycast in the physics world
  142967. * @param from when should the ray start?
  142968. * @param to when should the ray end?
  142969. * @returns PhysicsRaycastResult
  142970. */
  142971. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142972. }
  142973. }
  142974. declare module BABYLON {
  142975. /** @hidden */
  142976. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  142977. private _useDeltaForWorldStep;
  142978. world: any;
  142979. name: string;
  142980. private _physicsMaterials;
  142981. private _fixedTimeStep;
  142982. private _cannonRaycastResult;
  142983. private _raycastResult;
  142984. private _physicsBodysToRemoveAfterStep;
  142985. private _firstFrame;
  142986. BJSCANNON: any;
  142987. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  142988. setGravity(gravity: Vector3): void;
  142989. setTimeStep(timeStep: number): void;
  142990. getTimeStep(): number;
  142991. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142992. private _removeMarkedPhysicsBodiesFromWorld;
  142993. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142994. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142995. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142996. private _processChildMeshes;
  142997. removePhysicsBody(impostor: PhysicsImpostor): void;
  142998. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142999. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143000. private _addMaterial;
  143001. private _checkWithEpsilon;
  143002. private _createShape;
  143003. private _createHeightmap;
  143004. private _minus90X;
  143005. private _plus90X;
  143006. private _tmpPosition;
  143007. private _tmpDeltaPosition;
  143008. private _tmpUnityRotation;
  143009. private _updatePhysicsBodyTransformation;
  143010. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143011. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143012. isSupported(): boolean;
  143013. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143014. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143015. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143016. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143017. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143018. getBodyMass(impostor: PhysicsImpostor): number;
  143019. getBodyFriction(impostor: PhysicsImpostor): number;
  143020. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143021. getBodyRestitution(impostor: PhysicsImpostor): number;
  143022. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143023. sleepBody(impostor: PhysicsImpostor): void;
  143024. wakeUpBody(impostor: PhysicsImpostor): void;
  143025. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  143026. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  143027. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  143028. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143029. getRadius(impostor: PhysicsImpostor): number;
  143030. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143031. dispose(): void;
  143032. private _extendNamespace;
  143033. /**
  143034. * Does a raycast in the physics world
  143035. * @param from when should the ray start?
  143036. * @param to when should the ray end?
  143037. * @returns PhysicsRaycastResult
  143038. */
  143039. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143040. }
  143041. }
  143042. declare module BABYLON {
  143043. /** @hidden */
  143044. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  143045. private _useDeltaForWorldStep;
  143046. world: any;
  143047. name: string;
  143048. BJSOIMO: any;
  143049. private _raycastResult;
  143050. private _fixedTimeStep;
  143051. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  143052. setGravity(gravity: Vector3): void;
  143053. setTimeStep(timeStep: number): void;
  143054. getTimeStep(): number;
  143055. private _tmpImpostorsArray;
  143056. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143057. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143058. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143059. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143060. private _tmpPositionVector;
  143061. removePhysicsBody(impostor: PhysicsImpostor): void;
  143062. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143063. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143064. isSupported(): boolean;
  143065. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143066. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143067. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143068. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143069. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143070. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143071. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143072. getBodyMass(impostor: PhysicsImpostor): number;
  143073. getBodyFriction(impostor: PhysicsImpostor): number;
  143074. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143075. getBodyRestitution(impostor: PhysicsImpostor): number;
  143076. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143077. sleepBody(impostor: PhysicsImpostor): void;
  143078. wakeUpBody(impostor: PhysicsImpostor): void;
  143079. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  143080. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  143081. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  143082. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143083. getRadius(impostor: PhysicsImpostor): number;
  143084. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143085. dispose(): void;
  143086. /**
  143087. * Does a raycast in the physics world
  143088. * @param from when should the ray start?
  143089. * @param to when should the ray end?
  143090. * @returns PhysicsRaycastResult
  143091. */
  143092. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143093. }
  143094. }
  143095. declare module BABYLON {
  143096. /**
  143097. * AmmoJS Physics plugin
  143098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  143099. * @see https://github.com/kripken/ammo.js/
  143100. */
  143101. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  143102. private _useDeltaForWorldStep;
  143103. /**
  143104. * Reference to the Ammo library
  143105. */
  143106. bjsAMMO: any;
  143107. /**
  143108. * Created ammoJS world which physics bodies are added to
  143109. */
  143110. world: any;
  143111. /**
  143112. * Name of the plugin
  143113. */
  143114. name: string;
  143115. private _timeStep;
  143116. private _fixedTimeStep;
  143117. private _maxSteps;
  143118. private _tmpQuaternion;
  143119. private _tmpAmmoTransform;
  143120. private _tmpAmmoQuaternion;
  143121. private _tmpAmmoConcreteContactResultCallback;
  143122. private _collisionConfiguration;
  143123. private _dispatcher;
  143124. private _overlappingPairCache;
  143125. private _solver;
  143126. private _softBodySolver;
  143127. private _tmpAmmoVectorA;
  143128. private _tmpAmmoVectorB;
  143129. private _tmpAmmoVectorC;
  143130. private _tmpAmmoVectorD;
  143131. private _tmpContactCallbackResult;
  143132. private _tmpAmmoVectorRCA;
  143133. private _tmpAmmoVectorRCB;
  143134. private _raycastResult;
  143135. private _tmpContactPoint;
  143136. private static readonly DISABLE_COLLISION_FLAG;
  143137. private static readonly KINEMATIC_FLAG;
  143138. private static readonly DISABLE_DEACTIVATION_FLAG;
  143139. /**
  143140. * Initializes the ammoJS plugin
  143141. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  143142. * @param ammoInjection can be used to inject your own ammo reference
  143143. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  143144. */
  143145. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  143146. /**
  143147. * Sets the gravity of the physics world (m/(s^2))
  143148. * @param gravity Gravity to set
  143149. */
  143150. setGravity(gravity: Vector3): void;
  143151. /**
  143152. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  143153. * @param timeStep timestep to use in seconds
  143154. */
  143155. setTimeStep(timeStep: number): void;
  143156. /**
  143157. * 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)
  143158. * @param fixedTimeStep fixedTimeStep to use in seconds
  143159. */
  143160. setFixedTimeStep(fixedTimeStep: number): void;
  143161. /**
  143162. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  143163. * @param maxSteps the maximum number of steps by the physics engine per frame
  143164. */
  143165. setMaxSteps(maxSteps: number): void;
  143166. /**
  143167. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  143168. * @returns the current timestep in seconds
  143169. */
  143170. getTimeStep(): number;
  143171. /**
  143172. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  143173. */
  143174. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  143175. private _isImpostorInContact;
  143176. private _isImpostorPairInContact;
  143177. private _stepSimulation;
  143178. /**
  143179. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  143180. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  143181. * After the step the babylon meshes are set to the position of the physics imposters
  143182. * @param delta amount of time to step forward
  143183. * @param impostors array of imposters to update before/after the step
  143184. */
  143185. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143186. /**
  143187. * Update babylon mesh to match physics world object
  143188. * @param impostor imposter to match
  143189. */
  143190. private _afterSoftStep;
  143191. /**
  143192. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143193. * @param impostor imposter to match
  143194. */
  143195. private _ropeStep;
  143196. /**
  143197. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143198. * @param impostor imposter to match
  143199. */
  143200. private _softbodyOrClothStep;
  143201. private _tmpMatrix;
  143202. /**
  143203. * Applies an impulse on the imposter
  143204. * @param impostor imposter to apply impulse to
  143205. * @param force amount of force to be applied to the imposter
  143206. * @param contactPoint the location to apply the impulse on the imposter
  143207. */
  143208. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143209. /**
  143210. * Applies a force on the imposter
  143211. * @param impostor imposter to apply force
  143212. * @param force amount of force to be applied to the imposter
  143213. * @param contactPoint the location to apply the force on the imposter
  143214. */
  143215. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143216. /**
  143217. * Creates a physics body using the plugin
  143218. * @param impostor the imposter to create the physics body on
  143219. */
  143220. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143221. /**
  143222. * Removes the physics body from the imposter and disposes of the body's memory
  143223. * @param impostor imposter to remove the physics body from
  143224. */
  143225. removePhysicsBody(impostor: PhysicsImpostor): void;
  143226. /**
  143227. * Generates a joint
  143228. * @param impostorJoint the imposter joint to create the joint with
  143229. */
  143230. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143231. /**
  143232. * Removes a joint
  143233. * @param impostorJoint the imposter joint to remove the joint from
  143234. */
  143235. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143236. private _addMeshVerts;
  143237. /**
  143238. * Initialise the soft body vertices to match its object's (mesh) vertices
  143239. * Softbody vertices (nodes) are in world space and to match this
  143240. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  143241. * @param impostor to create the softbody for
  143242. */
  143243. private _softVertexData;
  143244. /**
  143245. * Create an impostor's soft body
  143246. * @param impostor to create the softbody for
  143247. */
  143248. private _createSoftbody;
  143249. /**
  143250. * Create cloth for an impostor
  143251. * @param impostor to create the softbody for
  143252. */
  143253. private _createCloth;
  143254. /**
  143255. * Create rope for an impostor
  143256. * @param impostor to create the softbody for
  143257. */
  143258. private _createRope;
  143259. /**
  143260. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  143261. * @param impostor to create the custom physics shape for
  143262. */
  143263. private _createCustom;
  143264. private _addHullVerts;
  143265. private _createShape;
  143266. /**
  143267. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  143268. * @param impostor imposter containing the physics body and babylon object
  143269. */
  143270. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143271. /**
  143272. * Sets the babylon object's position/rotation from the physics body's position/rotation
  143273. * @param impostor imposter containing the physics body and babylon object
  143274. * @param newPosition new position
  143275. * @param newRotation new rotation
  143276. */
  143277. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143278. /**
  143279. * If this plugin is supported
  143280. * @returns true if its supported
  143281. */
  143282. isSupported(): boolean;
  143283. /**
  143284. * Sets the linear velocity of the physics body
  143285. * @param impostor imposter to set the velocity on
  143286. * @param velocity velocity to set
  143287. */
  143288. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143289. /**
  143290. * Sets the angular velocity of the physics body
  143291. * @param impostor imposter to set the velocity on
  143292. * @param velocity velocity to set
  143293. */
  143294. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143295. /**
  143296. * gets the linear velocity
  143297. * @param impostor imposter to get linear velocity from
  143298. * @returns linear velocity
  143299. */
  143300. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143301. /**
  143302. * gets the angular velocity
  143303. * @param impostor imposter to get angular velocity from
  143304. * @returns angular velocity
  143305. */
  143306. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143307. /**
  143308. * Sets the mass of physics body
  143309. * @param impostor imposter to set the mass on
  143310. * @param mass mass to set
  143311. */
  143312. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143313. /**
  143314. * Gets the mass of the physics body
  143315. * @param impostor imposter to get the mass from
  143316. * @returns mass
  143317. */
  143318. getBodyMass(impostor: PhysicsImpostor): number;
  143319. /**
  143320. * Gets friction of the impostor
  143321. * @param impostor impostor to get friction from
  143322. * @returns friction value
  143323. */
  143324. getBodyFriction(impostor: PhysicsImpostor): number;
  143325. /**
  143326. * Sets friction of the impostor
  143327. * @param impostor impostor to set friction on
  143328. * @param friction friction value
  143329. */
  143330. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143331. /**
  143332. * Gets restitution of the impostor
  143333. * @param impostor impostor to get restitution from
  143334. * @returns restitution value
  143335. */
  143336. getBodyRestitution(impostor: PhysicsImpostor): number;
  143337. /**
  143338. * Sets resitution of the impostor
  143339. * @param impostor impostor to set resitution on
  143340. * @param restitution resitution value
  143341. */
  143342. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143343. /**
  143344. * Gets pressure inside the impostor
  143345. * @param impostor impostor to get pressure from
  143346. * @returns pressure value
  143347. */
  143348. getBodyPressure(impostor: PhysicsImpostor): number;
  143349. /**
  143350. * Sets pressure inside a soft body impostor
  143351. * Cloth and rope must remain 0 pressure
  143352. * @param impostor impostor to set pressure on
  143353. * @param pressure pressure value
  143354. */
  143355. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  143356. /**
  143357. * Gets stiffness of the impostor
  143358. * @param impostor impostor to get stiffness from
  143359. * @returns pressure value
  143360. */
  143361. getBodyStiffness(impostor: PhysicsImpostor): number;
  143362. /**
  143363. * Sets stiffness of the impostor
  143364. * @param impostor impostor to set stiffness on
  143365. * @param stiffness stiffness value from 0 to 1
  143366. */
  143367. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  143368. /**
  143369. * Gets velocityIterations of the impostor
  143370. * @param impostor impostor to get velocity iterations from
  143371. * @returns velocityIterations value
  143372. */
  143373. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  143374. /**
  143375. * Sets velocityIterations of the impostor
  143376. * @param impostor impostor to set velocity iterations on
  143377. * @param velocityIterations velocityIterations value
  143378. */
  143379. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  143380. /**
  143381. * Gets positionIterations of the impostor
  143382. * @param impostor impostor to get position iterations from
  143383. * @returns positionIterations value
  143384. */
  143385. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  143386. /**
  143387. * Sets positionIterations of the impostor
  143388. * @param impostor impostor to set position on
  143389. * @param positionIterations positionIterations value
  143390. */
  143391. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  143392. /**
  143393. * Append an anchor to a cloth object
  143394. * @param impostor is the cloth impostor to add anchor to
  143395. * @param otherImpostor is the rigid impostor to anchor to
  143396. * @param width ratio across width from 0 to 1
  143397. * @param height ratio up height from 0 to 1
  143398. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  143399. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  143400. */
  143401. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  143402. /**
  143403. * Append an hook to a rope object
  143404. * @param impostor is the rope impostor to add hook to
  143405. * @param otherImpostor is the rigid impostor to hook to
  143406. * @param length ratio along the rope from 0 to 1
  143407. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  143408. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  143409. */
  143410. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  143411. /**
  143412. * Sleeps the physics body and stops it from being active
  143413. * @param impostor impostor to sleep
  143414. */
  143415. sleepBody(impostor: PhysicsImpostor): void;
  143416. /**
  143417. * Activates the physics body
  143418. * @param impostor impostor to activate
  143419. */
  143420. wakeUpBody(impostor: PhysicsImpostor): void;
  143421. /**
  143422. * Updates the distance parameters of the joint
  143423. * @param joint joint to update
  143424. * @param maxDistance maximum distance of the joint
  143425. * @param minDistance minimum distance of the joint
  143426. */
  143427. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  143428. /**
  143429. * Sets a motor on the joint
  143430. * @param joint joint to set motor on
  143431. * @param speed speed of the motor
  143432. * @param maxForce maximum force of the motor
  143433. * @param motorIndex index of the motor
  143434. */
  143435. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  143436. /**
  143437. * Sets the motors limit
  143438. * @param joint joint to set limit on
  143439. * @param upperLimit upper limit
  143440. * @param lowerLimit lower limit
  143441. */
  143442. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  143443. /**
  143444. * Syncs the position and rotation of a mesh with the impostor
  143445. * @param mesh mesh to sync
  143446. * @param impostor impostor to update the mesh with
  143447. */
  143448. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143449. /**
  143450. * Gets the radius of the impostor
  143451. * @param impostor impostor to get radius from
  143452. * @returns the radius
  143453. */
  143454. getRadius(impostor: PhysicsImpostor): number;
  143455. /**
  143456. * Gets the box size of the impostor
  143457. * @param impostor impostor to get box size from
  143458. * @param result the resulting box size
  143459. */
  143460. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143461. /**
  143462. * Disposes of the impostor
  143463. */
  143464. dispose(): void;
  143465. /**
  143466. * Does a raycast in the physics world
  143467. * @param from when should the ray start?
  143468. * @param to when should the ray end?
  143469. * @returns PhysicsRaycastResult
  143470. */
  143471. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143472. }
  143473. }
  143474. declare module BABYLON {
  143475. interface AbstractScene {
  143476. /**
  143477. * The list of reflection probes added to the scene
  143478. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  143479. */
  143480. reflectionProbes: Array<ReflectionProbe>;
  143481. /**
  143482. * Removes the given reflection probe from this scene.
  143483. * @param toRemove The reflection probe to remove
  143484. * @returns The index of the removed reflection probe
  143485. */
  143486. removeReflectionProbe(toRemove: ReflectionProbe): number;
  143487. /**
  143488. * Adds the given reflection probe to this scene.
  143489. * @param newReflectionProbe The reflection probe to add
  143490. */
  143491. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  143492. }
  143493. /**
  143494. * Class used to generate realtime reflection / refraction cube textures
  143495. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  143496. */
  143497. export class ReflectionProbe {
  143498. /** defines the name of the probe */
  143499. name: string;
  143500. private _scene;
  143501. private _renderTargetTexture;
  143502. private _projectionMatrix;
  143503. private _viewMatrix;
  143504. private _target;
  143505. private _add;
  143506. private _attachedMesh;
  143507. private _invertYAxis;
  143508. /** Gets or sets probe position (center of the cube map) */
  143509. position: Vector3;
  143510. /**
  143511. * Creates a new reflection probe
  143512. * @param name defines the name of the probe
  143513. * @param size defines the texture resolution (for each face)
  143514. * @param scene defines the hosting scene
  143515. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  143516. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  143517. */
  143518. constructor(
  143519. /** defines the name of the probe */
  143520. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  143521. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  143522. get samples(): number;
  143523. set samples(value: number);
  143524. /** Gets or sets the refresh rate to use (on every frame by default) */
  143525. get refreshRate(): number;
  143526. set refreshRate(value: number);
  143527. /**
  143528. * Gets the hosting scene
  143529. * @returns a Scene
  143530. */
  143531. getScene(): Scene;
  143532. /** Gets the internal CubeTexture used to render to */
  143533. get cubeTexture(): RenderTargetTexture;
  143534. /** Gets the list of meshes to render */
  143535. get renderList(): Nullable<AbstractMesh[]>;
  143536. /**
  143537. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  143538. * @param mesh defines the mesh to attach to
  143539. */
  143540. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  143541. /**
  143542. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  143543. * @param renderingGroupId The rendering group id corresponding to its index
  143544. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  143545. */
  143546. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  143547. /**
  143548. * Clean all associated resources
  143549. */
  143550. dispose(): void;
  143551. /**
  143552. * Converts the reflection probe information to a readable string for debug purpose.
  143553. * @param fullDetails Supports for multiple levels of logging within scene loading
  143554. * @returns the human readable reflection probe info
  143555. */
  143556. toString(fullDetails?: boolean): string;
  143557. /**
  143558. * Get the class name of the relfection probe.
  143559. * @returns "ReflectionProbe"
  143560. */
  143561. getClassName(): string;
  143562. /**
  143563. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  143564. * @returns The JSON representation of the texture
  143565. */
  143566. serialize(): any;
  143567. /**
  143568. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  143569. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  143570. * @param scene Define the scene the parsed reflection probe should be instantiated in
  143571. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  143572. * @returns The parsed reflection probe if successful
  143573. */
  143574. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  143575. }
  143576. }
  143577. declare module BABYLON {
  143578. /** @hidden */
  143579. export var _BabylonLoaderRegistered: boolean;
  143580. /**
  143581. * Helps setting up some configuration for the babylon file loader.
  143582. */
  143583. export class BabylonFileLoaderConfiguration {
  143584. /**
  143585. * The loader does not allow injecting custom physix engine into the plugins.
  143586. * Unfortunately in ES6, we need to manually inject them into the plugin.
  143587. * So you could set this variable to your engine import to make it work.
  143588. */
  143589. static LoaderInjectedPhysicsEngine: any;
  143590. }
  143591. }
  143592. declare module BABYLON {
  143593. /**
  143594. * The Physically based simple base material of BJS.
  143595. *
  143596. * This enables better naming and convention enforcements on top of the pbrMaterial.
  143597. * It is used as the base class for both the specGloss and metalRough conventions.
  143598. */
  143599. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  143600. /**
  143601. * Number of Simultaneous lights allowed on the material.
  143602. */
  143603. maxSimultaneousLights: number;
  143604. /**
  143605. * If sets to true, disables all the lights affecting the material.
  143606. */
  143607. disableLighting: boolean;
  143608. /**
  143609. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  143610. */
  143611. environmentTexture: BaseTexture;
  143612. /**
  143613. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  143614. */
  143615. invertNormalMapX: boolean;
  143616. /**
  143617. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  143618. */
  143619. invertNormalMapY: boolean;
  143620. /**
  143621. * Normal map used in the model.
  143622. */
  143623. normalTexture: BaseTexture;
  143624. /**
  143625. * Emissivie color used to self-illuminate the model.
  143626. */
  143627. emissiveColor: Color3;
  143628. /**
  143629. * Emissivie texture used to self-illuminate the model.
  143630. */
  143631. emissiveTexture: BaseTexture;
  143632. /**
  143633. * Occlusion Channel Strenght.
  143634. */
  143635. occlusionStrength: number;
  143636. /**
  143637. * Occlusion Texture of the material (adding extra occlusion effects).
  143638. */
  143639. occlusionTexture: BaseTexture;
  143640. /**
  143641. * Defines the alpha limits in alpha test mode.
  143642. */
  143643. alphaCutOff: number;
  143644. /**
  143645. * Gets the current double sided mode.
  143646. */
  143647. get doubleSided(): boolean;
  143648. /**
  143649. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  143650. */
  143651. set doubleSided(value: boolean);
  143652. /**
  143653. * Stores the pre-calculated light information of a mesh in a texture.
  143654. */
  143655. lightmapTexture: BaseTexture;
  143656. /**
  143657. * If true, the light map contains occlusion information instead of lighting info.
  143658. */
  143659. useLightmapAsShadowmap: boolean;
  143660. /**
  143661. * Instantiates a new PBRMaterial instance.
  143662. *
  143663. * @param name The material name
  143664. * @param scene The scene the material will be use in.
  143665. */
  143666. constructor(name: string, scene: Scene);
  143667. getClassName(): string;
  143668. }
  143669. }
  143670. declare module BABYLON {
  143671. /**
  143672. * The PBR material of BJS following the metal roughness convention.
  143673. *
  143674. * This fits to the PBR convention in the GLTF definition:
  143675. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  143676. */
  143677. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  143678. /**
  143679. * The base color has two different interpretations depending on the value of metalness.
  143680. * When the material is a metal, the base color is the specific measured reflectance value
  143681. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  143682. * of the material.
  143683. */
  143684. baseColor: Color3;
  143685. /**
  143686. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  143687. * well as opacity information in the alpha channel.
  143688. */
  143689. baseTexture: BaseTexture;
  143690. /**
  143691. * Specifies the metallic scalar value of the material.
  143692. * Can also be used to scale the metalness values of the metallic texture.
  143693. */
  143694. metallic: number;
  143695. /**
  143696. * Specifies the roughness scalar value of the material.
  143697. * Can also be used to scale the roughness values of the metallic texture.
  143698. */
  143699. roughness: number;
  143700. /**
  143701. * Texture containing both the metallic value in the B channel and the
  143702. * roughness value in the G channel to keep better precision.
  143703. */
  143704. metallicRoughnessTexture: BaseTexture;
  143705. /**
  143706. * Instantiates a new PBRMetalRoughnessMaterial instance.
  143707. *
  143708. * @param name The material name
  143709. * @param scene The scene the material will be use in.
  143710. */
  143711. constructor(name: string, scene: Scene);
  143712. /**
  143713. * Return the currrent class name of the material.
  143714. */
  143715. getClassName(): string;
  143716. /**
  143717. * Makes a duplicate of the current material.
  143718. * @param name - name to use for the new material.
  143719. */
  143720. clone(name: string): PBRMetallicRoughnessMaterial;
  143721. /**
  143722. * Serialize the material to a parsable JSON object.
  143723. */
  143724. serialize(): any;
  143725. /**
  143726. * Parses a JSON object correponding to the serialize function.
  143727. */
  143728. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  143729. }
  143730. }
  143731. declare module BABYLON {
  143732. /**
  143733. * The PBR material of BJS following the specular glossiness convention.
  143734. *
  143735. * This fits to the PBR convention in the GLTF definition:
  143736. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  143737. */
  143738. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  143739. /**
  143740. * Specifies the diffuse color of the material.
  143741. */
  143742. diffuseColor: Color3;
  143743. /**
  143744. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  143745. * channel.
  143746. */
  143747. diffuseTexture: BaseTexture;
  143748. /**
  143749. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  143750. */
  143751. specularColor: Color3;
  143752. /**
  143753. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  143754. */
  143755. glossiness: number;
  143756. /**
  143757. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  143758. */
  143759. specularGlossinessTexture: BaseTexture;
  143760. /**
  143761. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  143762. *
  143763. * @param name The material name
  143764. * @param scene The scene the material will be use in.
  143765. */
  143766. constructor(name: string, scene: Scene);
  143767. /**
  143768. * Return the currrent class name of the material.
  143769. */
  143770. getClassName(): string;
  143771. /**
  143772. * Makes a duplicate of the current material.
  143773. * @param name - name to use for the new material.
  143774. */
  143775. clone(name: string): PBRSpecularGlossinessMaterial;
  143776. /**
  143777. * Serialize the material to a parsable JSON object.
  143778. */
  143779. serialize(): any;
  143780. /**
  143781. * Parses a JSON object correponding to the serialize function.
  143782. */
  143783. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  143784. }
  143785. }
  143786. declare module BABYLON {
  143787. /**
  143788. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  143789. * It can help converting any input color in a desired output one. This can then be used to create effects
  143790. * from sepia, black and white to sixties or futuristic rendering...
  143791. *
  143792. * The only supported format is currently 3dl.
  143793. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  143794. */
  143795. export class ColorGradingTexture extends BaseTexture {
  143796. /**
  143797. * The texture URL.
  143798. */
  143799. url: string;
  143800. /**
  143801. * Empty line regex stored for GC.
  143802. */
  143803. private static _noneEmptyLineRegex;
  143804. private _textureMatrix;
  143805. private _onLoad;
  143806. /**
  143807. * Instantiates a ColorGradingTexture from the following parameters.
  143808. *
  143809. * @param url The location of the color gradind data (currently only supporting 3dl)
  143810. * @param sceneOrEngine The scene or engine the texture will be used in
  143811. * @param onLoad defines a callback triggered when the texture has been loaded
  143812. */
  143813. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  143814. /**
  143815. * Fires the onload event from the constructor if requested.
  143816. */
  143817. private _triggerOnLoad;
  143818. /**
  143819. * Returns the texture matrix used in most of the material.
  143820. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  143821. */
  143822. getTextureMatrix(): Matrix;
  143823. /**
  143824. * Occurs when the file being loaded is a .3dl LUT file.
  143825. */
  143826. private load3dlTexture;
  143827. /**
  143828. * Starts the loading process of the texture.
  143829. */
  143830. private loadTexture;
  143831. /**
  143832. * Clones the color gradind texture.
  143833. */
  143834. clone(): ColorGradingTexture;
  143835. /**
  143836. * Called during delayed load for textures.
  143837. */
  143838. delayLoad(): void;
  143839. /**
  143840. * Parses a color grading texture serialized by Babylon.
  143841. * @param parsedTexture The texture information being parsedTexture
  143842. * @param scene The scene to load the texture in
  143843. * @param rootUrl The root url of the data assets to load
  143844. * @return A color gradind texture
  143845. */
  143846. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  143847. /**
  143848. * Serializes the LUT texture to json format.
  143849. */
  143850. serialize(): any;
  143851. }
  143852. }
  143853. declare module BABYLON {
  143854. /**
  143855. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  143856. */
  143857. export class EquiRectangularCubeTexture extends BaseTexture {
  143858. /** The six faces of the cube. */
  143859. private static _FacesMapping;
  143860. private _noMipmap;
  143861. private _onLoad;
  143862. private _onError;
  143863. /** The size of the cubemap. */
  143864. private _size;
  143865. /** The buffer of the image. */
  143866. private _buffer;
  143867. /** The width of the input image. */
  143868. private _width;
  143869. /** The height of the input image. */
  143870. private _height;
  143871. /** The URL to the image. */
  143872. url: string;
  143873. /**
  143874. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  143875. * @param url The location of the image
  143876. * @param scene The scene the texture will be used in
  143877. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143878. * @param noMipmap Forces to not generate the mipmap if true
  143879. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  143880. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  143881. * @param onLoad — defines a callback called when texture is loaded
  143882. * @param onError — defines a callback called if there is an error
  143883. */
  143884. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  143885. /**
  143886. * Load the image data, by putting the image on a canvas and extracting its buffer.
  143887. */
  143888. private loadImage;
  143889. /**
  143890. * Convert the image buffer into a cubemap and create a CubeTexture.
  143891. */
  143892. private loadTexture;
  143893. /**
  143894. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  143895. * @param buffer The ArrayBuffer that should be converted.
  143896. * @returns The buffer as Float32Array.
  143897. */
  143898. private getFloat32ArrayFromArrayBuffer;
  143899. /**
  143900. * Get the current class name of the texture useful for serialization or dynamic coding.
  143901. * @returns "EquiRectangularCubeTexture"
  143902. */
  143903. getClassName(): string;
  143904. /**
  143905. * Create a clone of the current EquiRectangularCubeTexture and return it.
  143906. * @returns A clone of the current EquiRectangularCubeTexture.
  143907. */
  143908. clone(): EquiRectangularCubeTexture;
  143909. }
  143910. }
  143911. declare module BABYLON {
  143912. /**
  143913. * Defines the options related to the creation of an HtmlElementTexture
  143914. */
  143915. export interface IHtmlElementTextureOptions {
  143916. /**
  143917. * Defines wether mip maps should be created or not.
  143918. */
  143919. generateMipMaps?: boolean;
  143920. /**
  143921. * Defines the sampling mode of the texture.
  143922. */
  143923. samplingMode?: number;
  143924. /**
  143925. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  143926. */
  143927. engine: Nullable<ThinEngine>;
  143928. /**
  143929. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  143930. */
  143931. scene: Nullable<Scene>;
  143932. }
  143933. /**
  143934. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  143935. * To be as efficient as possible depending on your constraints nothing aside the first upload
  143936. * is automatically managed.
  143937. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  143938. * in your application.
  143939. *
  143940. * As the update is not automatic, you need to call them manually.
  143941. */
  143942. export class HtmlElementTexture extends BaseTexture {
  143943. /**
  143944. * The texture URL.
  143945. */
  143946. element: HTMLVideoElement | HTMLCanvasElement;
  143947. private static readonly DefaultOptions;
  143948. private _textureMatrix;
  143949. private _isVideo;
  143950. private _generateMipMaps;
  143951. private _samplingMode;
  143952. /**
  143953. * Instantiates a HtmlElementTexture from the following parameters.
  143954. *
  143955. * @param name Defines the name of the texture
  143956. * @param element Defines the video or canvas the texture is filled with
  143957. * @param options Defines the other none mandatory texture creation options
  143958. */
  143959. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  143960. private _createInternalTexture;
  143961. /**
  143962. * Returns the texture matrix used in most of the material.
  143963. */
  143964. getTextureMatrix(): Matrix;
  143965. /**
  143966. * Updates the content of the texture.
  143967. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  143968. */
  143969. update(invertY?: Nullable<boolean>): void;
  143970. }
  143971. }
  143972. declare module BABYLON {
  143973. /**
  143974. * Based on jsTGALoader - Javascript loader for TGA file
  143975. * By Vincent Thibault
  143976. * @see http://blog.robrowser.com/javascript-tga-loader.html
  143977. */
  143978. export class TGATools {
  143979. private static _TYPE_INDEXED;
  143980. private static _TYPE_RGB;
  143981. private static _TYPE_GREY;
  143982. private static _TYPE_RLE_INDEXED;
  143983. private static _TYPE_RLE_RGB;
  143984. private static _TYPE_RLE_GREY;
  143985. private static _ORIGIN_MASK;
  143986. private static _ORIGIN_SHIFT;
  143987. private static _ORIGIN_BL;
  143988. private static _ORIGIN_BR;
  143989. private static _ORIGIN_UL;
  143990. private static _ORIGIN_UR;
  143991. /**
  143992. * Gets the header of a TGA file
  143993. * @param data defines the TGA data
  143994. * @returns the header
  143995. */
  143996. static GetTGAHeader(data: Uint8Array): any;
  143997. /**
  143998. * Uploads TGA content to a Babylon Texture
  143999. * @hidden
  144000. */
  144001. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  144002. /** @hidden */
  144003. 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;
  144004. /** @hidden */
  144005. 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;
  144006. /** @hidden */
  144007. 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;
  144008. /** @hidden */
  144009. 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;
  144010. /** @hidden */
  144011. 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;
  144012. /** @hidden */
  144013. 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;
  144014. }
  144015. }
  144016. declare module BABYLON {
  144017. /**
  144018. * Implementation of the TGA Texture Loader.
  144019. * @hidden
  144020. */
  144021. export class _TGATextureLoader implements IInternalTextureLoader {
  144022. /**
  144023. * Defines wether the loader supports cascade loading the different faces.
  144024. */
  144025. readonly supportCascades: boolean;
  144026. /**
  144027. * This returns if the loader support the current file information.
  144028. * @param extension defines the file extension of the file being loaded
  144029. * @returns true if the loader can load the specified file
  144030. */
  144031. canLoad(extension: string): boolean;
  144032. /**
  144033. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144034. * @param data contains the texture data
  144035. * @param texture defines the BabylonJS internal texture
  144036. * @param createPolynomials will be true if polynomials have been requested
  144037. * @param onLoad defines the callback to trigger once the texture is ready
  144038. * @param onError defines the callback to trigger in case of error
  144039. */
  144040. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144041. /**
  144042. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144043. * @param data contains the texture data
  144044. * @param texture defines the BabylonJS internal texture
  144045. * @param callback defines the method to call once ready to upload
  144046. */
  144047. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144048. }
  144049. }
  144050. declare module BABYLON {
  144051. /**
  144052. * Info about the .basis files
  144053. */
  144054. class BasisFileInfo {
  144055. /**
  144056. * If the file has alpha
  144057. */
  144058. hasAlpha: boolean;
  144059. /**
  144060. * Info about each image of the basis file
  144061. */
  144062. images: Array<{
  144063. levels: Array<{
  144064. width: number;
  144065. height: number;
  144066. transcodedPixels: ArrayBufferView;
  144067. }>;
  144068. }>;
  144069. }
  144070. /**
  144071. * Result of transcoding a basis file
  144072. */
  144073. class TranscodeResult {
  144074. /**
  144075. * Info about the .basis file
  144076. */
  144077. fileInfo: BasisFileInfo;
  144078. /**
  144079. * Format to use when loading the file
  144080. */
  144081. format: number;
  144082. }
  144083. /**
  144084. * Configuration options for the Basis transcoder
  144085. */
  144086. export class BasisTranscodeConfiguration {
  144087. /**
  144088. * Supported compression formats used to determine the supported output format of the transcoder
  144089. */
  144090. supportedCompressionFormats?: {
  144091. /**
  144092. * etc1 compression format
  144093. */
  144094. etc1?: boolean;
  144095. /**
  144096. * s3tc compression format
  144097. */
  144098. s3tc?: boolean;
  144099. /**
  144100. * pvrtc compression format
  144101. */
  144102. pvrtc?: boolean;
  144103. /**
  144104. * etc2 compression format
  144105. */
  144106. etc2?: boolean;
  144107. };
  144108. /**
  144109. * If mipmap levels should be loaded for transcoded images (Default: true)
  144110. */
  144111. loadMipmapLevels?: boolean;
  144112. /**
  144113. * Index of a single image to load (Default: all images)
  144114. */
  144115. loadSingleImage?: number;
  144116. }
  144117. /**
  144118. * Used to load .Basis files
  144119. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  144120. */
  144121. export class BasisTools {
  144122. private static _IgnoreSupportedFormats;
  144123. /**
  144124. * URL to use when loading the basis transcoder
  144125. */
  144126. static JSModuleURL: string;
  144127. /**
  144128. * URL to use when loading the wasm module for the transcoder
  144129. */
  144130. static WasmModuleURL: string;
  144131. /**
  144132. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  144133. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  144134. * @returns internal format corresponding to the Basis format
  144135. */
  144136. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  144137. private static _WorkerPromise;
  144138. private static _Worker;
  144139. private static _actionId;
  144140. private static _CreateWorkerAsync;
  144141. /**
  144142. * Transcodes a loaded image file to compressed pixel data
  144143. * @param data image data to transcode
  144144. * @param config configuration options for the transcoding
  144145. * @returns a promise resulting in the transcoded image
  144146. */
  144147. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  144148. /**
  144149. * Loads a texture from the transcode result
  144150. * @param texture texture load to
  144151. * @param transcodeResult the result of transcoding the basis file to load from
  144152. */
  144153. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  144154. }
  144155. }
  144156. declare module BABYLON {
  144157. /**
  144158. * Loader for .basis file format
  144159. */
  144160. export class _BasisTextureLoader implements IInternalTextureLoader {
  144161. /**
  144162. * Defines whether the loader supports cascade loading the different faces.
  144163. */
  144164. readonly supportCascades: boolean;
  144165. /**
  144166. * This returns if the loader support the current file information.
  144167. * @param extension defines the file extension of the file being loaded
  144168. * @returns true if the loader can load the specified file
  144169. */
  144170. canLoad(extension: string): boolean;
  144171. /**
  144172. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144173. * @param data contains the texture data
  144174. * @param texture defines the BabylonJS internal texture
  144175. * @param createPolynomials will be true if polynomials have been requested
  144176. * @param onLoad defines the callback to trigger once the texture is ready
  144177. * @param onError defines the callback to trigger in case of error
  144178. */
  144179. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144180. /**
  144181. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144182. * @param data contains the texture data
  144183. * @param texture defines the BabylonJS internal texture
  144184. * @param callback defines the method to call once ready to upload
  144185. */
  144186. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144187. }
  144188. }
  144189. declare module BABYLON {
  144190. /**
  144191. * Defines the basic options interface of a TexturePacker Frame
  144192. */
  144193. export interface ITexturePackerFrame {
  144194. /**
  144195. * The frame ID
  144196. */
  144197. id: number;
  144198. /**
  144199. * The frames Scale
  144200. */
  144201. scale: Vector2;
  144202. /**
  144203. * The Frames offset
  144204. */
  144205. offset: Vector2;
  144206. }
  144207. /**
  144208. * This is a support class for frame Data on texture packer sets.
  144209. */
  144210. export class TexturePackerFrame implements ITexturePackerFrame {
  144211. /**
  144212. * The frame ID
  144213. */
  144214. id: number;
  144215. /**
  144216. * The frames Scale
  144217. */
  144218. scale: Vector2;
  144219. /**
  144220. * The Frames offset
  144221. */
  144222. offset: Vector2;
  144223. /**
  144224. * Initializes a texture package frame.
  144225. * @param id The numerical frame identifier
  144226. * @param scale Scalar Vector2 for UV frame
  144227. * @param offset Vector2 for the frame position in UV units.
  144228. * @returns TexturePackerFrame
  144229. */
  144230. constructor(id: number, scale: Vector2, offset: Vector2);
  144231. }
  144232. }
  144233. declare module BABYLON {
  144234. /**
  144235. * Defines the basic options interface of a TexturePacker
  144236. */
  144237. export interface ITexturePackerOptions {
  144238. /**
  144239. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  144240. */
  144241. map?: string[];
  144242. /**
  144243. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144244. */
  144245. uvsIn?: string;
  144246. /**
  144247. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144248. */
  144249. uvsOut?: string;
  144250. /**
  144251. * number representing the layout style. Defaults to LAYOUT_STRIP
  144252. */
  144253. layout?: number;
  144254. /**
  144255. * number of columns if using custom column count layout(2). This defaults to 4.
  144256. */
  144257. colnum?: number;
  144258. /**
  144259. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  144260. */
  144261. updateInputMeshes?: boolean;
  144262. /**
  144263. * boolean flag to dispose all the source textures. Defaults to true.
  144264. */
  144265. disposeSources?: boolean;
  144266. /**
  144267. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  144268. */
  144269. fillBlanks?: boolean;
  144270. /**
  144271. * string value representing the context fill style color. Defaults to 'black'.
  144272. */
  144273. customFillColor?: string;
  144274. /**
  144275. * Width and Height Value of each Frame in the TexturePacker Sets
  144276. */
  144277. frameSize?: number;
  144278. /**
  144279. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  144280. */
  144281. paddingRatio?: number;
  144282. /**
  144283. * Number that declares the fill method for the padding gutter.
  144284. */
  144285. paddingMode?: number;
  144286. /**
  144287. * If in SUBUV_COLOR padding mode what color to use.
  144288. */
  144289. paddingColor?: Color3 | Color4;
  144290. }
  144291. /**
  144292. * Defines the basic interface of a TexturePacker JSON File
  144293. */
  144294. export interface ITexturePackerJSON {
  144295. /**
  144296. * The frame ID
  144297. */
  144298. name: string;
  144299. /**
  144300. * The base64 channel data
  144301. */
  144302. sets: any;
  144303. /**
  144304. * The options of the Packer
  144305. */
  144306. options: ITexturePackerOptions;
  144307. /**
  144308. * The frame data of the Packer
  144309. */
  144310. frames: Array<number>;
  144311. }
  144312. /**
  144313. * This is a support class that generates a series of packed texture sets.
  144314. * @see https://doc.babylonjs.com/babylon101/materials
  144315. */
  144316. export class TexturePacker {
  144317. /** Packer Layout Constant 0 */
  144318. static readonly LAYOUT_STRIP: number;
  144319. /** Packer Layout Constant 1 */
  144320. static readonly LAYOUT_POWER2: number;
  144321. /** Packer Layout Constant 2 */
  144322. static readonly LAYOUT_COLNUM: number;
  144323. /** Packer Layout Constant 0 */
  144324. static readonly SUBUV_WRAP: number;
  144325. /** Packer Layout Constant 1 */
  144326. static readonly SUBUV_EXTEND: number;
  144327. /** Packer Layout Constant 2 */
  144328. static readonly SUBUV_COLOR: number;
  144329. /** The Name of the Texture Package */
  144330. name: string;
  144331. /** The scene scope of the TexturePacker */
  144332. scene: Scene;
  144333. /** The Meshes to target */
  144334. meshes: AbstractMesh[];
  144335. /** Arguments passed with the Constructor */
  144336. options: ITexturePackerOptions;
  144337. /** The promise that is started upon initialization */
  144338. promise: Nullable<Promise<TexturePacker | string>>;
  144339. /** The Container object for the channel sets that are generated */
  144340. sets: object;
  144341. /** The Container array for the frames that are generated */
  144342. frames: TexturePackerFrame[];
  144343. /** The expected number of textures the system is parsing. */
  144344. private _expecting;
  144345. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  144346. private _paddingValue;
  144347. /**
  144348. * Initializes a texture package series from an array of meshes or a single mesh.
  144349. * @param name The name of the package
  144350. * @param meshes The target meshes to compose the package from
  144351. * @param options The arguments that texture packer should follow while building.
  144352. * @param scene The scene which the textures are scoped to.
  144353. * @returns TexturePacker
  144354. */
  144355. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  144356. /**
  144357. * Starts the package process
  144358. * @param resolve The promises resolution function
  144359. * @returns TexturePacker
  144360. */
  144361. private _createFrames;
  144362. /**
  144363. * Calculates the Size of the Channel Sets
  144364. * @returns Vector2
  144365. */
  144366. private _calculateSize;
  144367. /**
  144368. * Calculates the UV data for the frames.
  144369. * @param baseSize the base frameSize
  144370. * @param padding the base frame padding
  144371. * @param dtSize size of the Dynamic Texture for that channel
  144372. * @param dtUnits is 1/dtSize
  144373. * @param update flag to update the input meshes
  144374. */
  144375. private _calculateMeshUVFrames;
  144376. /**
  144377. * Calculates the frames Offset.
  144378. * @param index of the frame
  144379. * @returns Vector2
  144380. */
  144381. private _getFrameOffset;
  144382. /**
  144383. * Updates a Mesh to the frame data
  144384. * @param mesh that is the target
  144385. * @param frameID or the frame index
  144386. */
  144387. private _updateMeshUV;
  144388. /**
  144389. * Updates a Meshes materials to use the texture packer channels
  144390. * @param m is the mesh to target
  144391. * @param force all channels on the packer to be set.
  144392. */
  144393. private _updateTextureReferences;
  144394. /**
  144395. * Public method to set a Mesh to a frame
  144396. * @param m that is the target
  144397. * @param frameID or the frame index
  144398. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  144399. */
  144400. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  144401. /**
  144402. * Starts the async promise to compile the texture packer.
  144403. * @returns Promise<void>
  144404. */
  144405. processAsync(): Promise<void>;
  144406. /**
  144407. * Disposes all textures associated with this packer
  144408. */
  144409. dispose(): void;
  144410. /**
  144411. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  144412. * @param imageType is the image type to use.
  144413. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  144414. */
  144415. download(imageType?: string, quality?: number): void;
  144416. /**
  144417. * Public method to load a texturePacker JSON file.
  144418. * @param data of the JSON file in string format.
  144419. */
  144420. updateFromJSON(data: string): void;
  144421. }
  144422. }
  144423. declare module BABYLON {
  144424. /**
  144425. * 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.
  144426. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  144427. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  144428. */
  144429. export class CustomProceduralTexture extends ProceduralTexture {
  144430. private _animate;
  144431. private _time;
  144432. private _config;
  144433. private _texturePath;
  144434. /**
  144435. * Instantiates a new Custom Procedural Texture.
  144436. * 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.
  144437. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  144438. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  144439. * @param name Define the name of the texture
  144440. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  144441. * @param size Define the size of the texture to create
  144442. * @param scene Define the scene the texture belongs to
  144443. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  144444. * @param generateMipMaps Define if the texture should creates mip maps or not
  144445. */
  144446. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  144447. private _loadJson;
  144448. /**
  144449. * Is the texture ready to be used ? (rendered at least once)
  144450. * @returns true if ready, otherwise, false.
  144451. */
  144452. isReady(): boolean;
  144453. /**
  144454. * Render the texture to its associated render target.
  144455. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  144456. */
  144457. render(useCameraPostProcess?: boolean): void;
  144458. /**
  144459. * Update the list of dependant textures samplers in the shader.
  144460. */
  144461. updateTextures(): void;
  144462. /**
  144463. * Update the uniform values of the procedural texture in the shader.
  144464. */
  144465. updateShaderUniforms(): void;
  144466. /**
  144467. * Define if the texture animates or not.
  144468. */
  144469. get animate(): boolean;
  144470. set animate(value: boolean);
  144471. }
  144472. }
  144473. declare module BABYLON {
  144474. /** @hidden */
  144475. export var noisePixelShader: {
  144476. name: string;
  144477. shader: string;
  144478. };
  144479. }
  144480. declare module BABYLON {
  144481. /**
  144482. * Class used to generate noise procedural textures
  144483. */
  144484. export class NoiseProceduralTexture extends ProceduralTexture {
  144485. /** Gets or sets the start time (default is 0) */
  144486. time: number;
  144487. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  144488. brightness: number;
  144489. /** Defines the number of octaves to process */
  144490. octaves: number;
  144491. /** Defines the level of persistence (0.8 by default) */
  144492. persistence: number;
  144493. /** Gets or sets animation speed factor (default is 1) */
  144494. animationSpeedFactor: number;
  144495. /**
  144496. * Creates a new NoiseProceduralTexture
  144497. * @param name defines the name fo the texture
  144498. * @param size defines the size of the texture (default is 256)
  144499. * @param scene defines the hosting scene
  144500. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  144501. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  144502. */
  144503. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  144504. private _updateShaderUniforms;
  144505. protected _getDefines(): string;
  144506. /** Generate the current state of the procedural texture */
  144507. render(useCameraPostProcess?: boolean): void;
  144508. /**
  144509. * Serializes this noise procedural texture
  144510. * @returns a serialized noise procedural texture object
  144511. */
  144512. serialize(): any;
  144513. /**
  144514. * Clone the texture.
  144515. * @returns the cloned texture
  144516. */
  144517. clone(): NoiseProceduralTexture;
  144518. /**
  144519. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  144520. * @param parsedTexture defines parsed texture data
  144521. * @param scene defines the current scene
  144522. * @param rootUrl defines the root URL containing noise procedural texture information
  144523. * @returns a parsed NoiseProceduralTexture
  144524. */
  144525. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  144526. }
  144527. }
  144528. declare module BABYLON {
  144529. /**
  144530. * Raw cube texture where the raw buffers are passed in
  144531. */
  144532. export class RawCubeTexture extends CubeTexture {
  144533. /**
  144534. * Creates a cube texture where the raw buffers are passed in.
  144535. * @param scene defines the scene the texture is attached to
  144536. * @param data defines the array of data to use to create each face
  144537. * @param size defines the size of the textures
  144538. * @param format defines the format of the data
  144539. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  144540. * @param generateMipMaps defines if the engine should generate the mip levels
  144541. * @param invertY defines if data must be stored with Y axis inverted
  144542. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  144543. * @param compression defines the compression used (null by default)
  144544. */
  144545. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  144546. /**
  144547. * Updates the raw cube texture.
  144548. * @param data defines the data to store
  144549. * @param format defines the data format
  144550. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  144551. * @param invertY defines if data must be stored with Y axis inverted
  144552. * @param compression defines the compression used (null by default)
  144553. * @param level defines which level of the texture to update
  144554. */
  144555. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  144556. /**
  144557. * Updates a raw cube texture with RGBD encoded data.
  144558. * @param data defines the array of data [mipmap][face] to use to create each face
  144559. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  144560. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  144561. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  144562. * @returns a promsie that resolves when the operation is complete
  144563. */
  144564. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  144565. /**
  144566. * Clones the raw cube texture.
  144567. * @return a new cube texture
  144568. */
  144569. clone(): CubeTexture;
  144570. /** @hidden */
  144571. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  144572. }
  144573. }
  144574. declare module BABYLON {
  144575. /**
  144576. * Class used to store 2D array textures containing user data
  144577. */
  144578. export class RawTexture2DArray extends Texture {
  144579. /** Gets or sets the texture format to use */
  144580. format: number;
  144581. /**
  144582. * Create a new RawTexture2DArray
  144583. * @param data defines the data of the texture
  144584. * @param width defines the width of the texture
  144585. * @param height defines the height of the texture
  144586. * @param depth defines the number of layers of the texture
  144587. * @param format defines the texture format to use
  144588. * @param scene defines the hosting scene
  144589. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  144590. * @param invertY defines if texture must be stored with Y axis inverted
  144591. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  144592. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  144593. */
  144594. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  144595. /** Gets or sets the texture format to use */
  144596. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  144597. /**
  144598. * Update the texture with new data
  144599. * @param data defines the data to store in the texture
  144600. */
  144601. update(data: ArrayBufferView): void;
  144602. }
  144603. }
  144604. declare module BABYLON {
  144605. /**
  144606. * Class used to store 3D textures containing user data
  144607. */
  144608. export class RawTexture3D extends Texture {
  144609. /** Gets or sets the texture format to use */
  144610. format: number;
  144611. /**
  144612. * Create a new RawTexture3D
  144613. * @param data defines the data of the texture
  144614. * @param width defines the width of the texture
  144615. * @param height defines the height of the texture
  144616. * @param depth defines the depth of the texture
  144617. * @param format defines the texture format to use
  144618. * @param scene defines the hosting scene
  144619. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  144620. * @param invertY defines if texture must be stored with Y axis inverted
  144621. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  144622. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  144623. */
  144624. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  144625. /** Gets or sets the texture format to use */
  144626. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  144627. /**
  144628. * Update the texture with new data
  144629. * @param data defines the data to store in the texture
  144630. */
  144631. update(data: ArrayBufferView): void;
  144632. }
  144633. }
  144634. declare module BABYLON {
  144635. /**
  144636. * Creates a refraction texture used by refraction channel of the standard material.
  144637. * It is like a mirror but to see through a material.
  144638. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  144639. */
  144640. export class RefractionTexture extends RenderTargetTexture {
  144641. /**
  144642. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  144643. * 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.
  144644. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  144645. */
  144646. refractionPlane: Plane;
  144647. /**
  144648. * Define how deep under the surface we should see.
  144649. */
  144650. depth: number;
  144651. /**
  144652. * Creates a refraction texture used by refraction channel of the standard material.
  144653. * It is like a mirror but to see through a material.
  144654. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  144655. * @param name Define the texture name
  144656. * @param size Define the size of the underlying texture
  144657. * @param scene Define the scene the refraction belongs to
  144658. * @param generateMipMaps Define if we need to generate mips level for the refraction
  144659. */
  144660. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  144661. /**
  144662. * Clone the refraction texture.
  144663. * @returns the cloned texture
  144664. */
  144665. clone(): RefractionTexture;
  144666. /**
  144667. * Serialize the texture to a JSON representation you could use in Parse later on
  144668. * @returns the serialized JSON representation
  144669. */
  144670. serialize(): any;
  144671. }
  144672. }
  144673. declare module BABYLON {
  144674. /**
  144675. * Block used to add support for vertex skinning (bones)
  144676. */
  144677. export class BonesBlock extends NodeMaterialBlock {
  144678. /**
  144679. * Creates a new BonesBlock
  144680. * @param name defines the block name
  144681. */
  144682. constructor(name: string);
  144683. /**
  144684. * Initialize the block and prepare the context for build
  144685. * @param state defines the state that will be used for the build
  144686. */
  144687. initialize(state: NodeMaterialBuildState): void;
  144688. /**
  144689. * Gets the current class name
  144690. * @returns the class name
  144691. */
  144692. getClassName(): string;
  144693. /**
  144694. * Gets the matrix indices input component
  144695. */
  144696. get matricesIndices(): NodeMaterialConnectionPoint;
  144697. /**
  144698. * Gets the matrix weights input component
  144699. */
  144700. get matricesWeights(): NodeMaterialConnectionPoint;
  144701. /**
  144702. * Gets the extra matrix indices input component
  144703. */
  144704. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  144705. /**
  144706. * Gets the extra matrix weights input component
  144707. */
  144708. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  144709. /**
  144710. * Gets the world input component
  144711. */
  144712. get world(): NodeMaterialConnectionPoint;
  144713. /**
  144714. * Gets the output component
  144715. */
  144716. get output(): NodeMaterialConnectionPoint;
  144717. autoConfigure(material: NodeMaterial): void;
  144718. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  144719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144720. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144721. protected _buildBlock(state: NodeMaterialBuildState): this;
  144722. }
  144723. }
  144724. declare module BABYLON {
  144725. /**
  144726. * Block used to add support for instances
  144727. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  144728. */
  144729. export class InstancesBlock extends NodeMaterialBlock {
  144730. /**
  144731. * Creates a new InstancesBlock
  144732. * @param name defines the block name
  144733. */
  144734. constructor(name: string);
  144735. /**
  144736. * Gets the current class name
  144737. * @returns the class name
  144738. */
  144739. getClassName(): string;
  144740. /**
  144741. * Gets the first world row input component
  144742. */
  144743. get world0(): NodeMaterialConnectionPoint;
  144744. /**
  144745. * Gets the second world row input component
  144746. */
  144747. get world1(): NodeMaterialConnectionPoint;
  144748. /**
  144749. * Gets the third world row input component
  144750. */
  144751. get world2(): NodeMaterialConnectionPoint;
  144752. /**
  144753. * Gets the forth world row input component
  144754. */
  144755. get world3(): NodeMaterialConnectionPoint;
  144756. /**
  144757. * Gets the world input component
  144758. */
  144759. get world(): NodeMaterialConnectionPoint;
  144760. /**
  144761. * Gets the output component
  144762. */
  144763. get output(): NodeMaterialConnectionPoint;
  144764. /**
  144765. * Gets the isntanceID component
  144766. */
  144767. get instanceID(): NodeMaterialConnectionPoint;
  144768. autoConfigure(material: NodeMaterial): void;
  144769. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  144770. protected _buildBlock(state: NodeMaterialBuildState): this;
  144771. }
  144772. }
  144773. declare module BABYLON {
  144774. /**
  144775. * Block used to add morph targets support to vertex shader
  144776. */
  144777. export class MorphTargetsBlock extends NodeMaterialBlock {
  144778. private _repeatableContentAnchor;
  144779. /**
  144780. * Create a new MorphTargetsBlock
  144781. * @param name defines the block name
  144782. */
  144783. constructor(name: string);
  144784. /**
  144785. * Gets the current class name
  144786. * @returns the class name
  144787. */
  144788. getClassName(): string;
  144789. /**
  144790. * Gets the position input component
  144791. */
  144792. get position(): NodeMaterialConnectionPoint;
  144793. /**
  144794. * Gets the normal input component
  144795. */
  144796. get normal(): NodeMaterialConnectionPoint;
  144797. /**
  144798. * Gets the tangent input component
  144799. */
  144800. get tangent(): NodeMaterialConnectionPoint;
  144801. /**
  144802. * Gets the tangent input component
  144803. */
  144804. get uv(): NodeMaterialConnectionPoint;
  144805. /**
  144806. * Gets the position output component
  144807. */
  144808. get positionOutput(): NodeMaterialConnectionPoint;
  144809. /**
  144810. * Gets the normal output component
  144811. */
  144812. get normalOutput(): NodeMaterialConnectionPoint;
  144813. /**
  144814. * Gets the tangent output component
  144815. */
  144816. get tangentOutput(): NodeMaterialConnectionPoint;
  144817. /**
  144818. * Gets the tangent output component
  144819. */
  144820. get uvOutput(): NodeMaterialConnectionPoint;
  144821. initialize(state: NodeMaterialBuildState): void;
  144822. autoConfigure(material: NodeMaterial): void;
  144823. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144824. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144825. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  144826. protected _buildBlock(state: NodeMaterialBuildState): this;
  144827. }
  144828. }
  144829. declare module BABYLON {
  144830. /**
  144831. * Block used to get data information from a light
  144832. */
  144833. export class LightInformationBlock extends NodeMaterialBlock {
  144834. private _lightDataUniformName;
  144835. private _lightColorUniformName;
  144836. private _lightTypeDefineName;
  144837. /**
  144838. * Gets or sets the light associated with this block
  144839. */
  144840. light: Nullable<Light>;
  144841. /**
  144842. * Creates a new LightInformationBlock
  144843. * @param name defines the block name
  144844. */
  144845. constructor(name: string);
  144846. /**
  144847. * Gets the current class name
  144848. * @returns the class name
  144849. */
  144850. getClassName(): string;
  144851. /**
  144852. * Gets the world position input component
  144853. */
  144854. get worldPosition(): NodeMaterialConnectionPoint;
  144855. /**
  144856. * Gets the direction output component
  144857. */
  144858. get direction(): NodeMaterialConnectionPoint;
  144859. /**
  144860. * Gets the direction output component
  144861. */
  144862. get color(): NodeMaterialConnectionPoint;
  144863. /**
  144864. * Gets the direction output component
  144865. */
  144866. get intensity(): NodeMaterialConnectionPoint;
  144867. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144868. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144869. protected _buildBlock(state: NodeMaterialBuildState): this;
  144870. serialize(): any;
  144871. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144872. }
  144873. }
  144874. declare module BABYLON {
  144875. /**
  144876. * Block used to add image processing support to fragment shader
  144877. */
  144878. export class ImageProcessingBlock extends NodeMaterialBlock {
  144879. /**
  144880. * Create a new ImageProcessingBlock
  144881. * @param name defines the block name
  144882. */
  144883. constructor(name: string);
  144884. /**
  144885. * Gets the current class name
  144886. * @returns the class name
  144887. */
  144888. getClassName(): string;
  144889. /**
  144890. * Gets the color input component
  144891. */
  144892. get color(): NodeMaterialConnectionPoint;
  144893. /**
  144894. * Gets the output component
  144895. */
  144896. get output(): NodeMaterialConnectionPoint;
  144897. /**
  144898. * Initialize the block and prepare the context for build
  144899. * @param state defines the state that will be used for the build
  144900. */
  144901. initialize(state: NodeMaterialBuildState): void;
  144902. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  144903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144904. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144905. protected _buildBlock(state: NodeMaterialBuildState): this;
  144906. }
  144907. }
  144908. declare module BABYLON {
  144909. /**
  144910. * Block used to pertub normals based on a normal map
  144911. */
  144912. export class PerturbNormalBlock extends NodeMaterialBlock {
  144913. private _tangentSpaceParameterName;
  144914. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144915. invertX: boolean;
  144916. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  144917. invertY: boolean;
  144918. /**
  144919. * Create a new PerturbNormalBlock
  144920. * @param name defines the block name
  144921. */
  144922. constructor(name: string);
  144923. /**
  144924. * Gets the current class name
  144925. * @returns the class name
  144926. */
  144927. getClassName(): string;
  144928. /**
  144929. * Gets the world position input component
  144930. */
  144931. get worldPosition(): NodeMaterialConnectionPoint;
  144932. /**
  144933. * Gets the world normal input component
  144934. */
  144935. get worldNormal(): NodeMaterialConnectionPoint;
  144936. /**
  144937. * Gets the world tangent input component
  144938. */
  144939. get worldTangent(): NodeMaterialConnectionPoint;
  144940. /**
  144941. * Gets the uv input component
  144942. */
  144943. get uv(): NodeMaterialConnectionPoint;
  144944. /**
  144945. * Gets the normal map color input component
  144946. */
  144947. get normalMapColor(): NodeMaterialConnectionPoint;
  144948. /**
  144949. * Gets the strength input component
  144950. */
  144951. get strength(): NodeMaterialConnectionPoint;
  144952. /**
  144953. * Gets the output component
  144954. */
  144955. get output(): NodeMaterialConnectionPoint;
  144956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144957. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144958. autoConfigure(material: NodeMaterial): void;
  144959. protected _buildBlock(state: NodeMaterialBuildState): this;
  144960. protected _dumpPropertiesCode(): string;
  144961. serialize(): any;
  144962. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144963. }
  144964. }
  144965. declare module BABYLON {
  144966. /**
  144967. * Block used to discard a pixel if a value is smaller than a cutoff
  144968. */
  144969. export class DiscardBlock extends NodeMaterialBlock {
  144970. /**
  144971. * Create a new DiscardBlock
  144972. * @param name defines the block name
  144973. */
  144974. constructor(name: string);
  144975. /**
  144976. * Gets the current class name
  144977. * @returns the class name
  144978. */
  144979. getClassName(): string;
  144980. /**
  144981. * Gets the color input component
  144982. */
  144983. get value(): NodeMaterialConnectionPoint;
  144984. /**
  144985. * Gets the cutoff input component
  144986. */
  144987. get cutoff(): NodeMaterialConnectionPoint;
  144988. protected _buildBlock(state: NodeMaterialBuildState): this;
  144989. }
  144990. }
  144991. declare module BABYLON {
  144992. /**
  144993. * Block used to test if the fragment shader is front facing
  144994. */
  144995. export class FrontFacingBlock extends NodeMaterialBlock {
  144996. /**
  144997. * Creates a new FrontFacingBlock
  144998. * @param name defines the block name
  144999. */
  145000. constructor(name: string);
  145001. /**
  145002. * Gets the current class name
  145003. * @returns the class name
  145004. */
  145005. getClassName(): string;
  145006. /**
  145007. * Gets the output component
  145008. */
  145009. get output(): NodeMaterialConnectionPoint;
  145010. protected _buildBlock(state: NodeMaterialBuildState): this;
  145011. }
  145012. }
  145013. declare module BABYLON {
  145014. /**
  145015. * Block used to get the derivative value on x and y of a given input
  145016. */
  145017. export class DerivativeBlock extends NodeMaterialBlock {
  145018. /**
  145019. * Create a new DerivativeBlock
  145020. * @param name defines the block name
  145021. */
  145022. constructor(name: string);
  145023. /**
  145024. * Gets the current class name
  145025. * @returns the class name
  145026. */
  145027. getClassName(): string;
  145028. /**
  145029. * Gets the input component
  145030. */
  145031. get input(): NodeMaterialConnectionPoint;
  145032. /**
  145033. * Gets the derivative output on x
  145034. */
  145035. get dx(): NodeMaterialConnectionPoint;
  145036. /**
  145037. * Gets the derivative output on y
  145038. */
  145039. get dy(): NodeMaterialConnectionPoint;
  145040. protected _buildBlock(state: NodeMaterialBuildState): this;
  145041. }
  145042. }
  145043. declare module BABYLON {
  145044. /**
  145045. * Block used to make gl_FragCoord available
  145046. */
  145047. export class FragCoordBlock extends NodeMaterialBlock {
  145048. /**
  145049. * Creates a new FragCoordBlock
  145050. * @param name defines the block name
  145051. */
  145052. constructor(name: string);
  145053. /**
  145054. * Gets the current class name
  145055. * @returns the class name
  145056. */
  145057. getClassName(): string;
  145058. /**
  145059. * Gets the xy component
  145060. */
  145061. get xy(): NodeMaterialConnectionPoint;
  145062. /**
  145063. * Gets the xyz component
  145064. */
  145065. get xyz(): NodeMaterialConnectionPoint;
  145066. /**
  145067. * Gets the xyzw component
  145068. */
  145069. get xyzw(): NodeMaterialConnectionPoint;
  145070. /**
  145071. * Gets the x component
  145072. */
  145073. get x(): NodeMaterialConnectionPoint;
  145074. /**
  145075. * Gets the y component
  145076. */
  145077. get y(): NodeMaterialConnectionPoint;
  145078. /**
  145079. * Gets the z component
  145080. */
  145081. get z(): NodeMaterialConnectionPoint;
  145082. /**
  145083. * Gets the w component
  145084. */
  145085. get output(): NodeMaterialConnectionPoint;
  145086. protected writeOutputs(state: NodeMaterialBuildState): string;
  145087. protected _buildBlock(state: NodeMaterialBuildState): this;
  145088. }
  145089. }
  145090. declare module BABYLON {
  145091. /**
  145092. * Block used to get the screen sizes
  145093. */
  145094. export class ScreenSizeBlock extends NodeMaterialBlock {
  145095. private _varName;
  145096. private _scene;
  145097. /**
  145098. * Creates a new ScreenSizeBlock
  145099. * @param name defines the block name
  145100. */
  145101. constructor(name: string);
  145102. /**
  145103. * Gets the current class name
  145104. * @returns the class name
  145105. */
  145106. getClassName(): string;
  145107. /**
  145108. * Gets the xy component
  145109. */
  145110. get xy(): NodeMaterialConnectionPoint;
  145111. /**
  145112. * Gets the x component
  145113. */
  145114. get x(): NodeMaterialConnectionPoint;
  145115. /**
  145116. * Gets the y component
  145117. */
  145118. get y(): NodeMaterialConnectionPoint;
  145119. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145120. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  145121. protected _buildBlock(state: NodeMaterialBuildState): this;
  145122. }
  145123. }
  145124. declare module BABYLON {
  145125. /**
  145126. * Block used to add support for scene fog
  145127. */
  145128. export class FogBlock extends NodeMaterialBlock {
  145129. private _fogDistanceName;
  145130. private _fogParameters;
  145131. /**
  145132. * Create a new FogBlock
  145133. * @param name defines the block name
  145134. */
  145135. constructor(name: string);
  145136. /**
  145137. * Gets the current class name
  145138. * @returns the class name
  145139. */
  145140. getClassName(): string;
  145141. /**
  145142. * Gets the world position input component
  145143. */
  145144. get worldPosition(): NodeMaterialConnectionPoint;
  145145. /**
  145146. * Gets the view input component
  145147. */
  145148. get view(): NodeMaterialConnectionPoint;
  145149. /**
  145150. * Gets the color input component
  145151. */
  145152. get input(): NodeMaterialConnectionPoint;
  145153. /**
  145154. * Gets the fog color input component
  145155. */
  145156. get fogColor(): NodeMaterialConnectionPoint;
  145157. /**
  145158. * Gets the output component
  145159. */
  145160. get output(): NodeMaterialConnectionPoint;
  145161. autoConfigure(material: NodeMaterial): void;
  145162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145164. protected _buildBlock(state: NodeMaterialBuildState): this;
  145165. }
  145166. }
  145167. declare module BABYLON {
  145168. /**
  145169. * Block used to add light in the fragment shader
  145170. */
  145171. export class LightBlock extends NodeMaterialBlock {
  145172. private _lightId;
  145173. /**
  145174. * Gets or sets the light associated with this block
  145175. */
  145176. light: Nullable<Light>;
  145177. /**
  145178. * Create a new LightBlock
  145179. * @param name defines the block name
  145180. */
  145181. constructor(name: string);
  145182. /**
  145183. * Gets the current class name
  145184. * @returns the class name
  145185. */
  145186. getClassName(): string;
  145187. /**
  145188. * Gets the world position input component
  145189. */
  145190. get worldPosition(): NodeMaterialConnectionPoint;
  145191. /**
  145192. * Gets the world normal input component
  145193. */
  145194. get worldNormal(): NodeMaterialConnectionPoint;
  145195. /**
  145196. * Gets the camera (or eye) position component
  145197. */
  145198. get cameraPosition(): NodeMaterialConnectionPoint;
  145199. /**
  145200. * Gets the glossiness component
  145201. */
  145202. get glossiness(): NodeMaterialConnectionPoint;
  145203. /**
  145204. * Gets the glossinness power component
  145205. */
  145206. get glossPower(): NodeMaterialConnectionPoint;
  145207. /**
  145208. * Gets the diffuse color component
  145209. */
  145210. get diffuseColor(): NodeMaterialConnectionPoint;
  145211. /**
  145212. * Gets the specular color component
  145213. */
  145214. get specularColor(): NodeMaterialConnectionPoint;
  145215. /**
  145216. * Gets the view matrix component
  145217. */
  145218. get view(): NodeMaterialConnectionPoint;
  145219. /**
  145220. * Gets the diffuse output component
  145221. */
  145222. get diffuseOutput(): NodeMaterialConnectionPoint;
  145223. /**
  145224. * Gets the specular output component
  145225. */
  145226. get specularOutput(): NodeMaterialConnectionPoint;
  145227. /**
  145228. * Gets the shadow output component
  145229. */
  145230. get shadow(): NodeMaterialConnectionPoint;
  145231. autoConfigure(material: NodeMaterial): void;
  145232. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145233. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145234. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145235. private _injectVertexCode;
  145236. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145237. serialize(): any;
  145238. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145239. }
  145240. }
  145241. declare module BABYLON {
  145242. /**
  145243. * Block used to read a reflection texture from a sampler
  145244. */
  145245. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  145246. /**
  145247. * Create a new ReflectionTextureBlock
  145248. * @param name defines the block name
  145249. */
  145250. constructor(name: string);
  145251. /**
  145252. * Gets the current class name
  145253. * @returns the class name
  145254. */
  145255. getClassName(): string;
  145256. /**
  145257. * Gets the world position input component
  145258. */
  145259. get position(): NodeMaterialConnectionPoint;
  145260. /**
  145261. * Gets the world position input component
  145262. */
  145263. get worldPosition(): NodeMaterialConnectionPoint;
  145264. /**
  145265. * Gets the world normal input component
  145266. */
  145267. get worldNormal(): NodeMaterialConnectionPoint;
  145268. /**
  145269. * Gets the world input component
  145270. */
  145271. get world(): NodeMaterialConnectionPoint;
  145272. /**
  145273. * Gets the camera (or eye) position component
  145274. */
  145275. get cameraPosition(): NodeMaterialConnectionPoint;
  145276. /**
  145277. * Gets the view input component
  145278. */
  145279. get view(): NodeMaterialConnectionPoint;
  145280. /**
  145281. * Gets the rgb output component
  145282. */
  145283. get rgb(): NodeMaterialConnectionPoint;
  145284. /**
  145285. * Gets the rgba output component
  145286. */
  145287. get rgba(): NodeMaterialConnectionPoint;
  145288. /**
  145289. * Gets the r output component
  145290. */
  145291. get r(): NodeMaterialConnectionPoint;
  145292. /**
  145293. * Gets the g output component
  145294. */
  145295. get g(): NodeMaterialConnectionPoint;
  145296. /**
  145297. * Gets the b output component
  145298. */
  145299. get b(): NodeMaterialConnectionPoint;
  145300. /**
  145301. * Gets the a output component
  145302. */
  145303. get a(): NodeMaterialConnectionPoint;
  145304. autoConfigure(material: NodeMaterial): void;
  145305. protected _buildBlock(state: NodeMaterialBuildState): this;
  145306. }
  145307. }
  145308. declare module BABYLON {
  145309. /**
  145310. * Block used to add 2 vectors
  145311. */
  145312. export class AddBlock extends NodeMaterialBlock {
  145313. /**
  145314. * Creates a new AddBlock
  145315. * @param name defines the block name
  145316. */
  145317. constructor(name: string);
  145318. /**
  145319. * Gets the current class name
  145320. * @returns the class name
  145321. */
  145322. getClassName(): string;
  145323. /**
  145324. * Gets the left operand input component
  145325. */
  145326. get left(): NodeMaterialConnectionPoint;
  145327. /**
  145328. * Gets the right operand input component
  145329. */
  145330. get right(): NodeMaterialConnectionPoint;
  145331. /**
  145332. * Gets the output component
  145333. */
  145334. get output(): NodeMaterialConnectionPoint;
  145335. protected _buildBlock(state: NodeMaterialBuildState): this;
  145336. }
  145337. }
  145338. declare module BABYLON {
  145339. /**
  145340. * Block used to scale a vector by a float
  145341. */
  145342. export class ScaleBlock extends NodeMaterialBlock {
  145343. /**
  145344. * Creates a new ScaleBlock
  145345. * @param name defines the block name
  145346. */
  145347. constructor(name: string);
  145348. /**
  145349. * Gets the current class name
  145350. * @returns the class name
  145351. */
  145352. getClassName(): string;
  145353. /**
  145354. * Gets the input component
  145355. */
  145356. get input(): NodeMaterialConnectionPoint;
  145357. /**
  145358. * Gets the factor input component
  145359. */
  145360. get factor(): NodeMaterialConnectionPoint;
  145361. /**
  145362. * Gets the output component
  145363. */
  145364. get output(): NodeMaterialConnectionPoint;
  145365. protected _buildBlock(state: NodeMaterialBuildState): this;
  145366. }
  145367. }
  145368. declare module BABYLON {
  145369. /**
  145370. * Block used to clamp a float
  145371. */
  145372. export class ClampBlock extends NodeMaterialBlock {
  145373. /** Gets or sets the minimum range */
  145374. minimum: number;
  145375. /** Gets or sets the maximum range */
  145376. maximum: number;
  145377. /**
  145378. * Creates a new ClampBlock
  145379. * @param name defines the block name
  145380. */
  145381. constructor(name: string);
  145382. /**
  145383. * Gets the current class name
  145384. * @returns the class name
  145385. */
  145386. getClassName(): string;
  145387. /**
  145388. * Gets the value input component
  145389. */
  145390. get value(): NodeMaterialConnectionPoint;
  145391. /**
  145392. * Gets the output component
  145393. */
  145394. get output(): NodeMaterialConnectionPoint;
  145395. protected _buildBlock(state: NodeMaterialBuildState): this;
  145396. protected _dumpPropertiesCode(): string;
  145397. serialize(): any;
  145398. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145399. }
  145400. }
  145401. declare module BABYLON {
  145402. /**
  145403. * Block used to apply a cross product between 2 vectors
  145404. */
  145405. export class CrossBlock extends NodeMaterialBlock {
  145406. /**
  145407. * Creates a new CrossBlock
  145408. * @param name defines the block name
  145409. */
  145410. constructor(name: string);
  145411. /**
  145412. * Gets the current class name
  145413. * @returns the class name
  145414. */
  145415. getClassName(): string;
  145416. /**
  145417. * Gets the left operand input component
  145418. */
  145419. get left(): NodeMaterialConnectionPoint;
  145420. /**
  145421. * Gets the right operand input component
  145422. */
  145423. get right(): NodeMaterialConnectionPoint;
  145424. /**
  145425. * Gets the output component
  145426. */
  145427. get output(): NodeMaterialConnectionPoint;
  145428. protected _buildBlock(state: NodeMaterialBuildState): this;
  145429. }
  145430. }
  145431. declare module BABYLON {
  145432. /**
  145433. * Block used to apply a dot product between 2 vectors
  145434. */
  145435. export class DotBlock extends NodeMaterialBlock {
  145436. /**
  145437. * Creates a new DotBlock
  145438. * @param name defines the block name
  145439. */
  145440. constructor(name: string);
  145441. /**
  145442. * Gets the current class name
  145443. * @returns the class name
  145444. */
  145445. getClassName(): string;
  145446. /**
  145447. * Gets the left operand input component
  145448. */
  145449. get left(): NodeMaterialConnectionPoint;
  145450. /**
  145451. * Gets the right operand input component
  145452. */
  145453. get right(): NodeMaterialConnectionPoint;
  145454. /**
  145455. * Gets the output component
  145456. */
  145457. get output(): NodeMaterialConnectionPoint;
  145458. protected _buildBlock(state: NodeMaterialBuildState): this;
  145459. }
  145460. }
  145461. declare module BABYLON {
  145462. /**
  145463. * Block used to normalize a vector
  145464. */
  145465. export class NormalizeBlock extends NodeMaterialBlock {
  145466. /**
  145467. * Creates a new NormalizeBlock
  145468. * @param name defines the block name
  145469. */
  145470. constructor(name: string);
  145471. /**
  145472. * Gets the current class name
  145473. * @returns the class name
  145474. */
  145475. getClassName(): string;
  145476. /**
  145477. * Gets the input component
  145478. */
  145479. get input(): NodeMaterialConnectionPoint;
  145480. /**
  145481. * Gets the output component
  145482. */
  145483. get output(): NodeMaterialConnectionPoint;
  145484. protected _buildBlock(state: NodeMaterialBuildState): this;
  145485. }
  145486. }
  145487. declare module BABYLON {
  145488. /**
  145489. * Block used to create a Color3/4 out of individual inputs (one for each component)
  145490. */
  145491. export class ColorMergerBlock extends NodeMaterialBlock {
  145492. /**
  145493. * Create a new ColorMergerBlock
  145494. * @param name defines the block name
  145495. */
  145496. constructor(name: string);
  145497. /**
  145498. * Gets the current class name
  145499. * @returns the class name
  145500. */
  145501. getClassName(): string;
  145502. /**
  145503. * Gets the rgb component (input)
  145504. */
  145505. get rgbIn(): NodeMaterialConnectionPoint;
  145506. /**
  145507. * Gets the r component (input)
  145508. */
  145509. get r(): NodeMaterialConnectionPoint;
  145510. /**
  145511. * Gets the g component (input)
  145512. */
  145513. get g(): NodeMaterialConnectionPoint;
  145514. /**
  145515. * Gets the b component (input)
  145516. */
  145517. get b(): NodeMaterialConnectionPoint;
  145518. /**
  145519. * Gets the a component (input)
  145520. */
  145521. get a(): NodeMaterialConnectionPoint;
  145522. /**
  145523. * Gets the rgba component (output)
  145524. */
  145525. get rgba(): NodeMaterialConnectionPoint;
  145526. /**
  145527. * Gets the rgb component (output)
  145528. */
  145529. get rgbOut(): NodeMaterialConnectionPoint;
  145530. /**
  145531. * Gets the rgb component (output)
  145532. * @deprecated Please use rgbOut instead.
  145533. */
  145534. get rgb(): NodeMaterialConnectionPoint;
  145535. protected _buildBlock(state: NodeMaterialBuildState): this;
  145536. }
  145537. }
  145538. declare module BABYLON {
  145539. /**
  145540. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  145541. */
  145542. export class VectorSplitterBlock extends NodeMaterialBlock {
  145543. /**
  145544. * Create a new VectorSplitterBlock
  145545. * @param name defines the block name
  145546. */
  145547. constructor(name: string);
  145548. /**
  145549. * Gets the current class name
  145550. * @returns the class name
  145551. */
  145552. getClassName(): string;
  145553. /**
  145554. * Gets the xyzw component (input)
  145555. */
  145556. get xyzw(): NodeMaterialConnectionPoint;
  145557. /**
  145558. * Gets the xyz component (input)
  145559. */
  145560. get xyzIn(): NodeMaterialConnectionPoint;
  145561. /**
  145562. * Gets the xy component (input)
  145563. */
  145564. get xyIn(): NodeMaterialConnectionPoint;
  145565. /**
  145566. * Gets the xyz component (output)
  145567. */
  145568. get xyzOut(): NodeMaterialConnectionPoint;
  145569. /**
  145570. * Gets the xy component (output)
  145571. */
  145572. get xyOut(): NodeMaterialConnectionPoint;
  145573. /**
  145574. * Gets the x component (output)
  145575. */
  145576. get x(): NodeMaterialConnectionPoint;
  145577. /**
  145578. * Gets the y component (output)
  145579. */
  145580. get y(): NodeMaterialConnectionPoint;
  145581. /**
  145582. * Gets the z component (output)
  145583. */
  145584. get z(): NodeMaterialConnectionPoint;
  145585. /**
  145586. * Gets the w component (output)
  145587. */
  145588. get w(): NodeMaterialConnectionPoint;
  145589. protected _inputRename(name: string): string;
  145590. protected _outputRename(name: string): string;
  145591. protected _buildBlock(state: NodeMaterialBuildState): this;
  145592. }
  145593. }
  145594. declare module BABYLON {
  145595. /**
  145596. * Block used to lerp between 2 values
  145597. */
  145598. export class LerpBlock extends NodeMaterialBlock {
  145599. /**
  145600. * Creates a new LerpBlock
  145601. * @param name defines the block name
  145602. */
  145603. constructor(name: string);
  145604. /**
  145605. * Gets the current class name
  145606. * @returns the class name
  145607. */
  145608. getClassName(): string;
  145609. /**
  145610. * Gets the left operand input component
  145611. */
  145612. get left(): NodeMaterialConnectionPoint;
  145613. /**
  145614. * Gets the right operand input component
  145615. */
  145616. get right(): NodeMaterialConnectionPoint;
  145617. /**
  145618. * Gets the gradient operand input component
  145619. */
  145620. get gradient(): NodeMaterialConnectionPoint;
  145621. /**
  145622. * Gets the output component
  145623. */
  145624. get output(): NodeMaterialConnectionPoint;
  145625. protected _buildBlock(state: NodeMaterialBuildState): this;
  145626. }
  145627. }
  145628. declare module BABYLON {
  145629. /**
  145630. * Block used to divide 2 vectors
  145631. */
  145632. export class DivideBlock extends NodeMaterialBlock {
  145633. /**
  145634. * Creates a new DivideBlock
  145635. * @param name defines the block name
  145636. */
  145637. constructor(name: string);
  145638. /**
  145639. * Gets the current class name
  145640. * @returns the class name
  145641. */
  145642. getClassName(): string;
  145643. /**
  145644. * Gets the left operand input component
  145645. */
  145646. get left(): NodeMaterialConnectionPoint;
  145647. /**
  145648. * Gets the right operand input component
  145649. */
  145650. get right(): NodeMaterialConnectionPoint;
  145651. /**
  145652. * Gets the output component
  145653. */
  145654. get output(): NodeMaterialConnectionPoint;
  145655. protected _buildBlock(state: NodeMaterialBuildState): this;
  145656. }
  145657. }
  145658. declare module BABYLON {
  145659. /**
  145660. * Block used to subtract 2 vectors
  145661. */
  145662. export class SubtractBlock extends NodeMaterialBlock {
  145663. /**
  145664. * Creates a new SubtractBlock
  145665. * @param name defines the block name
  145666. */
  145667. constructor(name: string);
  145668. /**
  145669. * Gets the current class name
  145670. * @returns the class name
  145671. */
  145672. getClassName(): string;
  145673. /**
  145674. * Gets the left operand input component
  145675. */
  145676. get left(): NodeMaterialConnectionPoint;
  145677. /**
  145678. * Gets the right operand input component
  145679. */
  145680. get right(): NodeMaterialConnectionPoint;
  145681. /**
  145682. * Gets the output component
  145683. */
  145684. get output(): NodeMaterialConnectionPoint;
  145685. protected _buildBlock(state: NodeMaterialBuildState): this;
  145686. }
  145687. }
  145688. declare module BABYLON {
  145689. /**
  145690. * Block used to step a value
  145691. */
  145692. export class StepBlock extends NodeMaterialBlock {
  145693. /**
  145694. * Creates a new StepBlock
  145695. * @param name defines the block name
  145696. */
  145697. constructor(name: string);
  145698. /**
  145699. * Gets the current class name
  145700. * @returns the class name
  145701. */
  145702. getClassName(): string;
  145703. /**
  145704. * Gets the value operand input component
  145705. */
  145706. get value(): NodeMaterialConnectionPoint;
  145707. /**
  145708. * Gets the edge operand input component
  145709. */
  145710. get edge(): NodeMaterialConnectionPoint;
  145711. /**
  145712. * Gets the output component
  145713. */
  145714. get output(): NodeMaterialConnectionPoint;
  145715. protected _buildBlock(state: NodeMaterialBuildState): this;
  145716. }
  145717. }
  145718. declare module BABYLON {
  145719. /**
  145720. * Block used to get the opposite (1 - x) of a value
  145721. */
  145722. export class OneMinusBlock extends NodeMaterialBlock {
  145723. /**
  145724. * Creates a new OneMinusBlock
  145725. * @param name defines the block name
  145726. */
  145727. constructor(name: string);
  145728. /**
  145729. * Gets the current class name
  145730. * @returns the class name
  145731. */
  145732. getClassName(): string;
  145733. /**
  145734. * Gets the input component
  145735. */
  145736. get input(): NodeMaterialConnectionPoint;
  145737. /**
  145738. * Gets the output component
  145739. */
  145740. get output(): NodeMaterialConnectionPoint;
  145741. protected _buildBlock(state: NodeMaterialBuildState): this;
  145742. }
  145743. }
  145744. declare module BABYLON {
  145745. /**
  145746. * Block used to get the view direction
  145747. */
  145748. export class ViewDirectionBlock extends NodeMaterialBlock {
  145749. /**
  145750. * Creates a new ViewDirectionBlock
  145751. * @param name defines the block name
  145752. */
  145753. constructor(name: string);
  145754. /**
  145755. * Gets the current class name
  145756. * @returns the class name
  145757. */
  145758. getClassName(): string;
  145759. /**
  145760. * Gets the world position component
  145761. */
  145762. get worldPosition(): NodeMaterialConnectionPoint;
  145763. /**
  145764. * Gets the camera position component
  145765. */
  145766. get cameraPosition(): NodeMaterialConnectionPoint;
  145767. /**
  145768. * Gets the output component
  145769. */
  145770. get output(): NodeMaterialConnectionPoint;
  145771. autoConfigure(material: NodeMaterial): void;
  145772. protected _buildBlock(state: NodeMaterialBuildState): this;
  145773. }
  145774. }
  145775. declare module BABYLON {
  145776. /**
  145777. * Block used to compute fresnel value
  145778. */
  145779. export class FresnelBlock extends NodeMaterialBlock {
  145780. /**
  145781. * Create a new FresnelBlock
  145782. * @param name defines the block name
  145783. */
  145784. constructor(name: string);
  145785. /**
  145786. * Gets the current class name
  145787. * @returns the class name
  145788. */
  145789. getClassName(): string;
  145790. /**
  145791. * Gets the world normal input component
  145792. */
  145793. get worldNormal(): NodeMaterialConnectionPoint;
  145794. /**
  145795. * Gets the view direction input component
  145796. */
  145797. get viewDirection(): NodeMaterialConnectionPoint;
  145798. /**
  145799. * Gets the bias input component
  145800. */
  145801. get bias(): NodeMaterialConnectionPoint;
  145802. /**
  145803. * Gets the camera (or eye) position component
  145804. */
  145805. get power(): NodeMaterialConnectionPoint;
  145806. /**
  145807. * Gets the fresnel output component
  145808. */
  145809. get fresnel(): NodeMaterialConnectionPoint;
  145810. autoConfigure(material: NodeMaterial): void;
  145811. protected _buildBlock(state: NodeMaterialBuildState): this;
  145812. }
  145813. }
  145814. declare module BABYLON {
  145815. /**
  145816. * Block used to get the max of 2 values
  145817. */
  145818. export class MaxBlock extends NodeMaterialBlock {
  145819. /**
  145820. * Creates a new MaxBlock
  145821. * @param name defines the block name
  145822. */
  145823. constructor(name: string);
  145824. /**
  145825. * Gets the current class name
  145826. * @returns the class name
  145827. */
  145828. getClassName(): string;
  145829. /**
  145830. * Gets the left operand input component
  145831. */
  145832. get left(): NodeMaterialConnectionPoint;
  145833. /**
  145834. * Gets the right operand input component
  145835. */
  145836. get right(): NodeMaterialConnectionPoint;
  145837. /**
  145838. * Gets the output component
  145839. */
  145840. get output(): NodeMaterialConnectionPoint;
  145841. protected _buildBlock(state: NodeMaterialBuildState): this;
  145842. }
  145843. }
  145844. declare module BABYLON {
  145845. /**
  145846. * Block used to get the min of 2 values
  145847. */
  145848. export class MinBlock extends NodeMaterialBlock {
  145849. /**
  145850. * Creates a new MinBlock
  145851. * @param name defines the block name
  145852. */
  145853. constructor(name: string);
  145854. /**
  145855. * Gets the current class name
  145856. * @returns the class name
  145857. */
  145858. getClassName(): string;
  145859. /**
  145860. * Gets the left operand input component
  145861. */
  145862. get left(): NodeMaterialConnectionPoint;
  145863. /**
  145864. * Gets the right operand input component
  145865. */
  145866. get right(): NodeMaterialConnectionPoint;
  145867. /**
  145868. * Gets the output component
  145869. */
  145870. get output(): NodeMaterialConnectionPoint;
  145871. protected _buildBlock(state: NodeMaterialBuildState): this;
  145872. }
  145873. }
  145874. declare module BABYLON {
  145875. /**
  145876. * Block used to get the distance between 2 values
  145877. */
  145878. export class DistanceBlock extends NodeMaterialBlock {
  145879. /**
  145880. * Creates a new DistanceBlock
  145881. * @param name defines the block name
  145882. */
  145883. constructor(name: string);
  145884. /**
  145885. * Gets the current class name
  145886. * @returns the class name
  145887. */
  145888. getClassName(): string;
  145889. /**
  145890. * Gets the left operand input component
  145891. */
  145892. get left(): NodeMaterialConnectionPoint;
  145893. /**
  145894. * Gets the right operand input component
  145895. */
  145896. get right(): NodeMaterialConnectionPoint;
  145897. /**
  145898. * Gets the output component
  145899. */
  145900. get output(): NodeMaterialConnectionPoint;
  145901. protected _buildBlock(state: NodeMaterialBuildState): this;
  145902. }
  145903. }
  145904. declare module BABYLON {
  145905. /**
  145906. * Block used to get the length of a vector
  145907. */
  145908. export class LengthBlock extends NodeMaterialBlock {
  145909. /**
  145910. * Creates a new LengthBlock
  145911. * @param name defines the block name
  145912. */
  145913. constructor(name: string);
  145914. /**
  145915. * Gets the current class name
  145916. * @returns the class name
  145917. */
  145918. getClassName(): string;
  145919. /**
  145920. * Gets the value input component
  145921. */
  145922. get value(): NodeMaterialConnectionPoint;
  145923. /**
  145924. * Gets the output component
  145925. */
  145926. get output(): NodeMaterialConnectionPoint;
  145927. protected _buildBlock(state: NodeMaterialBuildState): this;
  145928. }
  145929. }
  145930. declare module BABYLON {
  145931. /**
  145932. * Block used to get negative version of a value (i.e. x * -1)
  145933. */
  145934. export class NegateBlock extends NodeMaterialBlock {
  145935. /**
  145936. * Creates a new NegateBlock
  145937. * @param name defines the block name
  145938. */
  145939. constructor(name: string);
  145940. /**
  145941. * Gets the current class name
  145942. * @returns the class name
  145943. */
  145944. getClassName(): string;
  145945. /**
  145946. * Gets the value input component
  145947. */
  145948. get value(): NodeMaterialConnectionPoint;
  145949. /**
  145950. * Gets the output component
  145951. */
  145952. get output(): NodeMaterialConnectionPoint;
  145953. protected _buildBlock(state: NodeMaterialBuildState): this;
  145954. }
  145955. }
  145956. declare module BABYLON {
  145957. /**
  145958. * Block used to get the value of the first parameter raised to the power of the second
  145959. */
  145960. export class PowBlock extends NodeMaterialBlock {
  145961. /**
  145962. * Creates a new PowBlock
  145963. * @param name defines the block name
  145964. */
  145965. constructor(name: string);
  145966. /**
  145967. * Gets the current class name
  145968. * @returns the class name
  145969. */
  145970. getClassName(): string;
  145971. /**
  145972. * Gets the value operand input component
  145973. */
  145974. get value(): NodeMaterialConnectionPoint;
  145975. /**
  145976. * Gets the power operand input component
  145977. */
  145978. get power(): NodeMaterialConnectionPoint;
  145979. /**
  145980. * Gets the output component
  145981. */
  145982. get output(): NodeMaterialConnectionPoint;
  145983. protected _buildBlock(state: NodeMaterialBuildState): this;
  145984. }
  145985. }
  145986. declare module BABYLON {
  145987. /**
  145988. * Block used to get a random number
  145989. */
  145990. export class RandomNumberBlock extends NodeMaterialBlock {
  145991. /**
  145992. * Creates a new RandomNumberBlock
  145993. * @param name defines the block name
  145994. */
  145995. constructor(name: string);
  145996. /**
  145997. * Gets the current class name
  145998. * @returns the class name
  145999. */
  146000. getClassName(): string;
  146001. /**
  146002. * Gets the seed input component
  146003. */
  146004. get seed(): NodeMaterialConnectionPoint;
  146005. /**
  146006. * Gets the output component
  146007. */
  146008. get output(): NodeMaterialConnectionPoint;
  146009. protected _buildBlock(state: NodeMaterialBuildState): this;
  146010. }
  146011. }
  146012. declare module BABYLON {
  146013. /**
  146014. * Block used to compute arc tangent of 2 values
  146015. */
  146016. export class ArcTan2Block extends NodeMaterialBlock {
  146017. /**
  146018. * Creates a new ArcTan2Block
  146019. * @param name defines the block name
  146020. */
  146021. constructor(name: string);
  146022. /**
  146023. * Gets the current class name
  146024. * @returns the class name
  146025. */
  146026. getClassName(): string;
  146027. /**
  146028. * Gets the x operand input component
  146029. */
  146030. get x(): NodeMaterialConnectionPoint;
  146031. /**
  146032. * Gets the y operand input component
  146033. */
  146034. get y(): NodeMaterialConnectionPoint;
  146035. /**
  146036. * Gets the output component
  146037. */
  146038. get output(): NodeMaterialConnectionPoint;
  146039. protected _buildBlock(state: NodeMaterialBuildState): this;
  146040. }
  146041. }
  146042. declare module BABYLON {
  146043. /**
  146044. * Block used to smooth step a value
  146045. */
  146046. export class SmoothStepBlock extends NodeMaterialBlock {
  146047. /**
  146048. * Creates a new SmoothStepBlock
  146049. * @param name defines the block name
  146050. */
  146051. constructor(name: string);
  146052. /**
  146053. * Gets the current class name
  146054. * @returns the class name
  146055. */
  146056. getClassName(): string;
  146057. /**
  146058. * Gets the value operand input component
  146059. */
  146060. get value(): NodeMaterialConnectionPoint;
  146061. /**
  146062. * Gets the first edge operand input component
  146063. */
  146064. get edge0(): NodeMaterialConnectionPoint;
  146065. /**
  146066. * Gets the second edge operand input component
  146067. */
  146068. get edge1(): NodeMaterialConnectionPoint;
  146069. /**
  146070. * Gets the output component
  146071. */
  146072. get output(): NodeMaterialConnectionPoint;
  146073. protected _buildBlock(state: NodeMaterialBuildState): this;
  146074. }
  146075. }
  146076. declare module BABYLON {
  146077. /**
  146078. * Block used to get the reciprocal (1 / x) of a value
  146079. */
  146080. export class ReciprocalBlock extends NodeMaterialBlock {
  146081. /**
  146082. * Creates a new ReciprocalBlock
  146083. * @param name defines the block name
  146084. */
  146085. constructor(name: string);
  146086. /**
  146087. * Gets the current class name
  146088. * @returns the class name
  146089. */
  146090. getClassName(): string;
  146091. /**
  146092. * Gets the input component
  146093. */
  146094. get input(): NodeMaterialConnectionPoint;
  146095. /**
  146096. * Gets the output component
  146097. */
  146098. get output(): NodeMaterialConnectionPoint;
  146099. protected _buildBlock(state: NodeMaterialBuildState): this;
  146100. }
  146101. }
  146102. declare module BABYLON {
  146103. /**
  146104. * Block used to replace a color by another one
  146105. */
  146106. export class ReplaceColorBlock extends NodeMaterialBlock {
  146107. /**
  146108. * Creates a new ReplaceColorBlock
  146109. * @param name defines the block name
  146110. */
  146111. constructor(name: string);
  146112. /**
  146113. * Gets the current class name
  146114. * @returns the class name
  146115. */
  146116. getClassName(): string;
  146117. /**
  146118. * Gets the value input component
  146119. */
  146120. get value(): NodeMaterialConnectionPoint;
  146121. /**
  146122. * Gets the reference input component
  146123. */
  146124. get reference(): NodeMaterialConnectionPoint;
  146125. /**
  146126. * Gets the distance input component
  146127. */
  146128. get distance(): NodeMaterialConnectionPoint;
  146129. /**
  146130. * Gets the replacement input component
  146131. */
  146132. get replacement(): NodeMaterialConnectionPoint;
  146133. /**
  146134. * Gets the output component
  146135. */
  146136. get output(): NodeMaterialConnectionPoint;
  146137. protected _buildBlock(state: NodeMaterialBuildState): this;
  146138. }
  146139. }
  146140. declare module BABYLON {
  146141. /**
  146142. * Block used to posterize a value
  146143. * @see https://en.wikipedia.org/wiki/Posterization
  146144. */
  146145. export class PosterizeBlock extends NodeMaterialBlock {
  146146. /**
  146147. * Creates a new PosterizeBlock
  146148. * @param name defines the block name
  146149. */
  146150. constructor(name: string);
  146151. /**
  146152. * Gets the current class name
  146153. * @returns the class name
  146154. */
  146155. getClassName(): string;
  146156. /**
  146157. * Gets the value input component
  146158. */
  146159. get value(): NodeMaterialConnectionPoint;
  146160. /**
  146161. * Gets the steps input component
  146162. */
  146163. get steps(): NodeMaterialConnectionPoint;
  146164. /**
  146165. * Gets the output component
  146166. */
  146167. get output(): NodeMaterialConnectionPoint;
  146168. protected _buildBlock(state: NodeMaterialBuildState): this;
  146169. }
  146170. }
  146171. declare module BABYLON {
  146172. /**
  146173. * Operations supported by the Wave block
  146174. */
  146175. export enum WaveBlockKind {
  146176. /** SawTooth */
  146177. SawTooth = 0,
  146178. /** Square */
  146179. Square = 1,
  146180. /** Triangle */
  146181. Triangle = 2
  146182. }
  146183. /**
  146184. * Block used to apply wave operation to floats
  146185. */
  146186. export class WaveBlock extends NodeMaterialBlock {
  146187. /**
  146188. * Gets or sets the kibnd of wave to be applied by the block
  146189. */
  146190. kind: WaveBlockKind;
  146191. /**
  146192. * Creates a new WaveBlock
  146193. * @param name defines the block name
  146194. */
  146195. constructor(name: string);
  146196. /**
  146197. * Gets the current class name
  146198. * @returns the class name
  146199. */
  146200. getClassName(): string;
  146201. /**
  146202. * Gets the input component
  146203. */
  146204. get input(): NodeMaterialConnectionPoint;
  146205. /**
  146206. * Gets the output component
  146207. */
  146208. get output(): NodeMaterialConnectionPoint;
  146209. protected _buildBlock(state: NodeMaterialBuildState): this;
  146210. serialize(): any;
  146211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146212. }
  146213. }
  146214. declare module BABYLON {
  146215. /**
  146216. * Class used to store a color step for the GradientBlock
  146217. */
  146218. export class GradientBlockColorStep {
  146219. private _step;
  146220. /**
  146221. * Gets value indicating which step this color is associated with (between 0 and 1)
  146222. */
  146223. get step(): number;
  146224. /**
  146225. * Sets a value indicating which step this color is associated with (between 0 and 1)
  146226. */
  146227. set step(val: number);
  146228. private _color;
  146229. /**
  146230. * Gets the color associated with this step
  146231. */
  146232. get color(): Color3;
  146233. /**
  146234. * Sets the color associated with this step
  146235. */
  146236. set color(val: Color3);
  146237. /**
  146238. * Creates a new GradientBlockColorStep
  146239. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  146240. * @param color defines the color associated with this step
  146241. */
  146242. constructor(step: number, color: Color3);
  146243. }
  146244. /**
  146245. * Block used to return a color from a gradient based on an input value between 0 and 1
  146246. */
  146247. export class GradientBlock extends NodeMaterialBlock {
  146248. /**
  146249. * Gets or sets the list of color steps
  146250. */
  146251. colorSteps: GradientBlockColorStep[];
  146252. /** Gets an observable raised when the value is changed */
  146253. onValueChangedObservable: Observable<GradientBlock>;
  146254. /** calls observable when the value is changed*/
  146255. colorStepsUpdated(): void;
  146256. /**
  146257. * Creates a new GradientBlock
  146258. * @param name defines the block name
  146259. */
  146260. constructor(name: string);
  146261. /**
  146262. * Gets the current class name
  146263. * @returns the class name
  146264. */
  146265. getClassName(): string;
  146266. /**
  146267. * Gets the gradient input component
  146268. */
  146269. get gradient(): NodeMaterialConnectionPoint;
  146270. /**
  146271. * Gets the output component
  146272. */
  146273. get output(): NodeMaterialConnectionPoint;
  146274. private _writeColorConstant;
  146275. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146276. serialize(): any;
  146277. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146278. protected _dumpPropertiesCode(): string;
  146279. }
  146280. }
  146281. declare module BABYLON {
  146282. /**
  146283. * Block used to normalize lerp between 2 values
  146284. */
  146285. export class NLerpBlock extends NodeMaterialBlock {
  146286. /**
  146287. * Creates a new NLerpBlock
  146288. * @param name defines the block name
  146289. */
  146290. constructor(name: string);
  146291. /**
  146292. * Gets the current class name
  146293. * @returns the class name
  146294. */
  146295. getClassName(): string;
  146296. /**
  146297. * Gets the left operand input component
  146298. */
  146299. get left(): NodeMaterialConnectionPoint;
  146300. /**
  146301. * Gets the right operand input component
  146302. */
  146303. get right(): NodeMaterialConnectionPoint;
  146304. /**
  146305. * Gets the gradient operand input component
  146306. */
  146307. get gradient(): NodeMaterialConnectionPoint;
  146308. /**
  146309. * Gets the output component
  146310. */
  146311. get output(): NodeMaterialConnectionPoint;
  146312. protected _buildBlock(state: NodeMaterialBuildState): this;
  146313. }
  146314. }
  146315. declare module BABYLON {
  146316. /**
  146317. * block used to Generate a Worley Noise 3D Noise Pattern
  146318. */
  146319. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  146320. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  146321. manhattanDistance: boolean;
  146322. /**
  146323. * Creates a new WorleyNoise3DBlock
  146324. * @param name defines the block name
  146325. */
  146326. constructor(name: string);
  146327. /**
  146328. * Gets the current class name
  146329. * @returns the class name
  146330. */
  146331. getClassName(): string;
  146332. /**
  146333. * Gets the seed input component
  146334. */
  146335. get seed(): NodeMaterialConnectionPoint;
  146336. /**
  146337. * Gets the jitter input component
  146338. */
  146339. get jitter(): NodeMaterialConnectionPoint;
  146340. /**
  146341. * Gets the output component
  146342. */
  146343. get output(): NodeMaterialConnectionPoint;
  146344. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146345. /**
  146346. * Exposes the properties to the UI?
  146347. */
  146348. protected _dumpPropertiesCode(): string;
  146349. /**
  146350. * Exposes the properties to the Seralize?
  146351. */
  146352. serialize(): any;
  146353. /**
  146354. * Exposes the properties to the deseralize?
  146355. */
  146356. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146357. }
  146358. }
  146359. declare module BABYLON {
  146360. /**
  146361. * block used to Generate a Simplex Perlin 3d Noise Pattern
  146362. */
  146363. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  146364. /**
  146365. * Creates a new SimplexPerlin3DBlock
  146366. * @param name defines the block name
  146367. */
  146368. constructor(name: string);
  146369. /**
  146370. * Gets the current class name
  146371. * @returns the class name
  146372. */
  146373. getClassName(): string;
  146374. /**
  146375. * Gets the seed operand input component
  146376. */
  146377. get seed(): NodeMaterialConnectionPoint;
  146378. /**
  146379. * Gets the output component
  146380. */
  146381. get output(): NodeMaterialConnectionPoint;
  146382. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146383. }
  146384. }
  146385. declare module BABYLON {
  146386. /**
  146387. * Block used to blend normals
  146388. */
  146389. export class NormalBlendBlock extends NodeMaterialBlock {
  146390. /**
  146391. * Creates a new NormalBlendBlock
  146392. * @param name defines the block name
  146393. */
  146394. constructor(name: string);
  146395. /**
  146396. * Gets the current class name
  146397. * @returns the class name
  146398. */
  146399. getClassName(): string;
  146400. /**
  146401. * Gets the first input component
  146402. */
  146403. get normalMap0(): NodeMaterialConnectionPoint;
  146404. /**
  146405. * Gets the second input component
  146406. */
  146407. get normalMap1(): NodeMaterialConnectionPoint;
  146408. /**
  146409. * Gets the output component
  146410. */
  146411. get output(): NodeMaterialConnectionPoint;
  146412. protected _buildBlock(state: NodeMaterialBuildState): this;
  146413. }
  146414. }
  146415. declare module BABYLON {
  146416. /**
  146417. * Block used to rotate a 2d vector by a given angle
  146418. */
  146419. export class Rotate2dBlock extends NodeMaterialBlock {
  146420. /**
  146421. * Creates a new Rotate2dBlock
  146422. * @param name defines the block name
  146423. */
  146424. constructor(name: string);
  146425. /**
  146426. * Gets the current class name
  146427. * @returns the class name
  146428. */
  146429. getClassName(): string;
  146430. /**
  146431. * Gets the input vector
  146432. */
  146433. get input(): NodeMaterialConnectionPoint;
  146434. /**
  146435. * Gets the input angle
  146436. */
  146437. get angle(): NodeMaterialConnectionPoint;
  146438. /**
  146439. * Gets the output component
  146440. */
  146441. get output(): NodeMaterialConnectionPoint;
  146442. autoConfigure(material: NodeMaterial): void;
  146443. protected _buildBlock(state: NodeMaterialBuildState): this;
  146444. }
  146445. }
  146446. declare module BABYLON {
  146447. /**
  146448. * Block used to get the reflected vector from a direction and a normal
  146449. */
  146450. export class ReflectBlock extends NodeMaterialBlock {
  146451. /**
  146452. * Creates a new ReflectBlock
  146453. * @param name defines the block name
  146454. */
  146455. constructor(name: string);
  146456. /**
  146457. * Gets the current class name
  146458. * @returns the class name
  146459. */
  146460. getClassName(): string;
  146461. /**
  146462. * Gets the incident component
  146463. */
  146464. get incident(): NodeMaterialConnectionPoint;
  146465. /**
  146466. * Gets the normal component
  146467. */
  146468. get normal(): NodeMaterialConnectionPoint;
  146469. /**
  146470. * Gets the output component
  146471. */
  146472. get output(): NodeMaterialConnectionPoint;
  146473. protected _buildBlock(state: NodeMaterialBuildState): this;
  146474. }
  146475. }
  146476. declare module BABYLON {
  146477. /**
  146478. * Block used to get the refracted vector from a direction and a normal
  146479. */
  146480. export class RefractBlock extends NodeMaterialBlock {
  146481. /**
  146482. * Creates a new RefractBlock
  146483. * @param name defines the block name
  146484. */
  146485. constructor(name: string);
  146486. /**
  146487. * Gets the current class name
  146488. * @returns the class name
  146489. */
  146490. getClassName(): string;
  146491. /**
  146492. * Gets the incident component
  146493. */
  146494. get incident(): NodeMaterialConnectionPoint;
  146495. /**
  146496. * Gets the normal component
  146497. */
  146498. get normal(): NodeMaterialConnectionPoint;
  146499. /**
  146500. * Gets the index of refraction component
  146501. */
  146502. get ior(): NodeMaterialConnectionPoint;
  146503. /**
  146504. * Gets the output component
  146505. */
  146506. get output(): NodeMaterialConnectionPoint;
  146507. protected _buildBlock(state: NodeMaterialBuildState): this;
  146508. }
  146509. }
  146510. declare module BABYLON {
  146511. /**
  146512. * Block used to desaturate a color
  146513. */
  146514. export class DesaturateBlock extends NodeMaterialBlock {
  146515. /**
  146516. * Creates a new DesaturateBlock
  146517. * @param name defines the block name
  146518. */
  146519. constructor(name: string);
  146520. /**
  146521. * Gets the current class name
  146522. * @returns the class name
  146523. */
  146524. getClassName(): string;
  146525. /**
  146526. * Gets the color operand input component
  146527. */
  146528. get color(): NodeMaterialConnectionPoint;
  146529. /**
  146530. * Gets the level operand input component
  146531. */
  146532. get level(): NodeMaterialConnectionPoint;
  146533. /**
  146534. * Gets the output component
  146535. */
  146536. get output(): NodeMaterialConnectionPoint;
  146537. protected _buildBlock(state: NodeMaterialBuildState): this;
  146538. }
  146539. }
  146540. declare module BABYLON {
  146541. /**
  146542. * Block used to implement the ambient occlusion module of the PBR material
  146543. */
  146544. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  146545. /**
  146546. * Create a new AmbientOcclusionBlock
  146547. * @param name defines the block name
  146548. */
  146549. constructor(name: string);
  146550. /**
  146551. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  146552. */
  146553. useAmbientInGrayScale: boolean;
  146554. /**
  146555. * Initialize the block and prepare the context for build
  146556. * @param state defines the state that will be used for the build
  146557. */
  146558. initialize(state: NodeMaterialBuildState): void;
  146559. /**
  146560. * Gets the current class name
  146561. * @returns the class name
  146562. */
  146563. getClassName(): string;
  146564. /**
  146565. * Gets the texture input component
  146566. */
  146567. get texture(): NodeMaterialConnectionPoint;
  146568. /**
  146569. * Gets the texture intensity component
  146570. */
  146571. get intensity(): NodeMaterialConnectionPoint;
  146572. /**
  146573. * Gets the direct light intensity input component
  146574. */
  146575. get directLightIntensity(): NodeMaterialConnectionPoint;
  146576. /**
  146577. * Gets the ambient occlusion object output component
  146578. */
  146579. get ambientOcc(): NodeMaterialConnectionPoint;
  146580. /**
  146581. * Gets the main code of the block (fragment side)
  146582. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  146583. * @returns the shader code
  146584. */
  146585. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  146586. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146587. protected _buildBlock(state: NodeMaterialBuildState): this;
  146588. protected _dumpPropertiesCode(): string;
  146589. serialize(): any;
  146590. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146591. }
  146592. }
  146593. declare module BABYLON {
  146594. /**
  146595. * Block used to implement the reflection module of the PBR material
  146596. */
  146597. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  146598. /** @hidden */
  146599. _defineLODReflectionAlpha: string;
  146600. /** @hidden */
  146601. _defineLinearSpecularReflection: string;
  146602. private _vEnvironmentIrradianceName;
  146603. /** @hidden */
  146604. _vReflectionMicrosurfaceInfosName: string;
  146605. /** @hidden */
  146606. _vReflectionInfosName: string;
  146607. /** @hidden */
  146608. _vReflectionFilteringInfoName: string;
  146609. private _scene;
  146610. /**
  146611. * The three properties below are set by the main PBR block prior to calling methods of this class.
  146612. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  146613. * It's less burden on the user side in the editor part.
  146614. */
  146615. /** @hidden */
  146616. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  146617. /** @hidden */
  146618. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  146619. /** @hidden */
  146620. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  146621. /**
  146622. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  146623. * diffuse part of the IBL.
  146624. */
  146625. useSphericalHarmonics: boolean;
  146626. /**
  146627. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  146628. */
  146629. forceIrradianceInFragment: boolean;
  146630. /**
  146631. * Create a new ReflectionBlock
  146632. * @param name defines the block name
  146633. */
  146634. constructor(name: string);
  146635. /**
  146636. * Gets the current class name
  146637. * @returns the class name
  146638. */
  146639. getClassName(): string;
  146640. /**
  146641. * Gets the position input component
  146642. */
  146643. get position(): NodeMaterialConnectionPoint;
  146644. /**
  146645. * Gets the world position input component
  146646. */
  146647. get worldPosition(): NodeMaterialConnectionPoint;
  146648. /**
  146649. * Gets the world normal input component
  146650. */
  146651. get worldNormal(): NodeMaterialConnectionPoint;
  146652. /**
  146653. * Gets the world input component
  146654. */
  146655. get world(): NodeMaterialConnectionPoint;
  146656. /**
  146657. * Gets the camera (or eye) position component
  146658. */
  146659. get cameraPosition(): NodeMaterialConnectionPoint;
  146660. /**
  146661. * Gets the view input component
  146662. */
  146663. get view(): NodeMaterialConnectionPoint;
  146664. /**
  146665. * Gets the color input component
  146666. */
  146667. get color(): NodeMaterialConnectionPoint;
  146668. /**
  146669. * Gets the reflection object output component
  146670. */
  146671. get reflection(): NodeMaterialConnectionPoint;
  146672. /**
  146673. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  146674. */
  146675. get hasTexture(): boolean;
  146676. /**
  146677. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  146678. */
  146679. get reflectionColor(): string;
  146680. protected _getTexture(): Nullable<BaseTexture>;
  146681. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146682. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146683. /**
  146684. * Gets the code to inject in the vertex shader
  146685. * @param state current state of the node material building
  146686. * @returns the shader code
  146687. */
  146688. handleVertexSide(state: NodeMaterialBuildState): string;
  146689. /**
  146690. * Gets the main code of the block (fragment side)
  146691. * @param state current state of the node material building
  146692. * @param normalVarName name of the existing variable corresponding to the normal
  146693. * @returns the shader code
  146694. */
  146695. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  146696. protected _buildBlock(state: NodeMaterialBuildState): this;
  146697. protected _dumpPropertiesCode(): string;
  146698. serialize(): any;
  146699. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146700. }
  146701. }
  146702. declare module BABYLON {
  146703. /**
  146704. * Block used to implement the sheen module of the PBR material
  146705. */
  146706. export class SheenBlock extends NodeMaterialBlock {
  146707. /**
  146708. * Create a new SheenBlock
  146709. * @param name defines the block name
  146710. */
  146711. constructor(name: string);
  146712. /**
  146713. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  146714. * It allows the strength of the sheen effect to not depend on the base color of the material,
  146715. * making it easier to setup and tweak the effect
  146716. */
  146717. albedoScaling: boolean;
  146718. /**
  146719. * Defines if the sheen is linked to the sheen color.
  146720. */
  146721. linkSheenWithAlbedo: boolean;
  146722. /**
  146723. * Initialize the block and prepare the context for build
  146724. * @param state defines the state that will be used for the build
  146725. */
  146726. initialize(state: NodeMaterialBuildState): void;
  146727. /**
  146728. * Gets the current class name
  146729. * @returns the class name
  146730. */
  146731. getClassName(): string;
  146732. /**
  146733. * Gets the intensity input component
  146734. */
  146735. get intensity(): NodeMaterialConnectionPoint;
  146736. /**
  146737. * Gets the color input component
  146738. */
  146739. get color(): NodeMaterialConnectionPoint;
  146740. /**
  146741. * Gets the roughness input component
  146742. */
  146743. get roughness(): NodeMaterialConnectionPoint;
  146744. /**
  146745. * Gets the sheen object output component
  146746. */
  146747. get sheen(): NodeMaterialConnectionPoint;
  146748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146749. /**
  146750. * Gets the main code of the block (fragment side)
  146751. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146752. * @returns the shader code
  146753. */
  146754. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  146755. protected _buildBlock(state: NodeMaterialBuildState): this;
  146756. protected _dumpPropertiesCode(): string;
  146757. serialize(): any;
  146758. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146759. }
  146760. }
  146761. declare module BABYLON {
  146762. /**
  146763. * Block used to implement the reflectivity module of the PBR material
  146764. */
  146765. export class ReflectivityBlock extends NodeMaterialBlock {
  146766. private _metallicReflectanceColor;
  146767. private _metallicF0Factor;
  146768. /** @hidden */
  146769. _vMetallicReflectanceFactorsName: string;
  146770. /**
  146771. * The property below is set by the main PBR block prior to calling methods of this class.
  146772. */
  146773. /** @hidden */
  146774. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  146775. /**
  146776. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  146777. */
  146778. useAmbientOcclusionFromMetallicTextureRed: boolean;
  146779. /**
  146780. * Specifies if the metallic texture contains the metallness information in its blue channel.
  146781. */
  146782. useMetallnessFromMetallicTextureBlue: boolean;
  146783. /**
  146784. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  146785. */
  146786. useRoughnessFromMetallicTextureAlpha: boolean;
  146787. /**
  146788. * Specifies if the metallic texture contains the roughness information in its green channel.
  146789. */
  146790. useRoughnessFromMetallicTextureGreen: boolean;
  146791. /**
  146792. * Create a new ReflectivityBlock
  146793. * @param name defines the block name
  146794. */
  146795. constructor(name: string);
  146796. /**
  146797. * Initialize the block and prepare the context for build
  146798. * @param state defines the state that will be used for the build
  146799. */
  146800. initialize(state: NodeMaterialBuildState): void;
  146801. /**
  146802. * Gets the current class name
  146803. * @returns the class name
  146804. */
  146805. getClassName(): string;
  146806. /**
  146807. * Gets the metallic input component
  146808. */
  146809. get metallic(): NodeMaterialConnectionPoint;
  146810. /**
  146811. * Gets the roughness input component
  146812. */
  146813. get roughness(): NodeMaterialConnectionPoint;
  146814. /**
  146815. * Gets the texture input component
  146816. */
  146817. get texture(): NodeMaterialConnectionPoint;
  146818. /**
  146819. * Gets the reflectivity object output component
  146820. */
  146821. get reflectivity(): NodeMaterialConnectionPoint;
  146822. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146823. /**
  146824. * Gets the main code of the block (fragment side)
  146825. * @param state current state of the node material building
  146826. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  146827. * @returns the shader code
  146828. */
  146829. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  146830. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146831. protected _buildBlock(state: NodeMaterialBuildState): this;
  146832. protected _dumpPropertiesCode(): string;
  146833. serialize(): any;
  146834. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146835. }
  146836. }
  146837. declare module BABYLON {
  146838. /**
  146839. * Block used to implement the anisotropy module of the PBR material
  146840. */
  146841. export class AnisotropyBlock extends NodeMaterialBlock {
  146842. /**
  146843. * The two properties below are set by the main PBR block prior to calling methods of this class.
  146844. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  146845. * It's less burden on the user side in the editor part.
  146846. */
  146847. /** @hidden */
  146848. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  146849. /** @hidden */
  146850. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  146851. /**
  146852. * Create a new AnisotropyBlock
  146853. * @param name defines the block name
  146854. */
  146855. constructor(name: string);
  146856. /**
  146857. * Initialize the block and prepare the context for build
  146858. * @param state defines the state that will be used for the build
  146859. */
  146860. initialize(state: NodeMaterialBuildState): void;
  146861. /**
  146862. * Gets the current class name
  146863. * @returns the class name
  146864. */
  146865. getClassName(): string;
  146866. /**
  146867. * Gets the intensity input component
  146868. */
  146869. get intensity(): NodeMaterialConnectionPoint;
  146870. /**
  146871. * Gets the direction input component
  146872. */
  146873. get direction(): NodeMaterialConnectionPoint;
  146874. /**
  146875. * Gets the texture input component
  146876. */
  146877. get texture(): NodeMaterialConnectionPoint;
  146878. /**
  146879. * Gets the uv input component
  146880. */
  146881. get uv(): NodeMaterialConnectionPoint;
  146882. /**
  146883. * Gets the worldTangent input component
  146884. */
  146885. get worldTangent(): NodeMaterialConnectionPoint;
  146886. /**
  146887. * Gets the anisotropy object output component
  146888. */
  146889. get anisotropy(): NodeMaterialConnectionPoint;
  146890. private _generateTBNSpace;
  146891. /**
  146892. * Gets the main code of the block (fragment side)
  146893. * @param state current state of the node material building
  146894. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146895. * @returns the shader code
  146896. */
  146897. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  146898. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146899. protected _buildBlock(state: NodeMaterialBuildState): this;
  146900. }
  146901. }
  146902. declare module BABYLON {
  146903. /**
  146904. * Block used to implement the clear coat module of the PBR material
  146905. */
  146906. export class ClearCoatBlock extends NodeMaterialBlock {
  146907. private _scene;
  146908. /**
  146909. * Create a new ClearCoatBlock
  146910. * @param name defines the block name
  146911. */
  146912. constructor(name: string);
  146913. /**
  146914. * Initialize the block and prepare the context for build
  146915. * @param state defines the state that will be used for the build
  146916. */
  146917. initialize(state: NodeMaterialBuildState): void;
  146918. /**
  146919. * Gets the current class name
  146920. * @returns the class name
  146921. */
  146922. getClassName(): string;
  146923. /**
  146924. * Gets the intensity input component
  146925. */
  146926. get intensity(): NodeMaterialConnectionPoint;
  146927. /**
  146928. * Gets the roughness input component
  146929. */
  146930. get roughness(): NodeMaterialConnectionPoint;
  146931. /**
  146932. * Gets the ior input component
  146933. */
  146934. get ior(): NodeMaterialConnectionPoint;
  146935. /**
  146936. * Gets the texture input component
  146937. */
  146938. get texture(): NodeMaterialConnectionPoint;
  146939. /**
  146940. * Gets the bump texture input component
  146941. */
  146942. get bumpTexture(): NodeMaterialConnectionPoint;
  146943. /**
  146944. * Gets the uv input component
  146945. */
  146946. get uv(): NodeMaterialConnectionPoint;
  146947. /**
  146948. * Gets the tint color input component
  146949. */
  146950. get tintColor(): NodeMaterialConnectionPoint;
  146951. /**
  146952. * Gets the tint "at distance" input component
  146953. */
  146954. get tintAtDistance(): NodeMaterialConnectionPoint;
  146955. /**
  146956. * Gets the tint thickness input component
  146957. */
  146958. get tintThickness(): NodeMaterialConnectionPoint;
  146959. /**
  146960. * Gets the world tangent input component
  146961. */
  146962. get worldTangent(): NodeMaterialConnectionPoint;
  146963. /**
  146964. * Gets the clear coat object output component
  146965. */
  146966. get clearcoat(): NodeMaterialConnectionPoint;
  146967. autoConfigure(material: NodeMaterial): void;
  146968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146969. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146970. private _generateTBNSpace;
  146971. /**
  146972. * Gets the main code of the block (fragment side)
  146973. * @param state current state of the node material building
  146974. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  146975. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146976. * @param worldPosVarName name of the variable holding the world position
  146977. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146978. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  146979. * @param worldNormalVarName name of the variable holding the world normal
  146980. * @returns the shader code
  146981. */
  146982. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  146983. protected _buildBlock(state: NodeMaterialBuildState): this;
  146984. }
  146985. }
  146986. declare module BABYLON {
  146987. /**
  146988. * Block used to implement the sub surface module of the PBR material
  146989. */
  146990. export class SubSurfaceBlock extends NodeMaterialBlock {
  146991. /**
  146992. * Create a new SubSurfaceBlock
  146993. * @param name defines the block name
  146994. */
  146995. constructor(name: string);
  146996. /**
  146997. * Stores the intensity of the different subsurface effects in the thickness texture.
  146998. * * the green channel is the translucency intensity.
  146999. * * the blue channel is the scattering intensity.
  147000. * * the alpha channel is the refraction intensity.
  147001. */
  147002. useMaskFromThicknessTexture: boolean;
  147003. /**
  147004. * Initialize the block and prepare the context for build
  147005. * @param state defines the state that will be used for the build
  147006. */
  147007. initialize(state: NodeMaterialBuildState): void;
  147008. /**
  147009. * Gets the current class name
  147010. * @returns the class name
  147011. */
  147012. getClassName(): string;
  147013. /**
  147014. * Gets the min thickness input component
  147015. */
  147016. get minThickness(): NodeMaterialConnectionPoint;
  147017. /**
  147018. * Gets the max thickness input component
  147019. */
  147020. get maxThickness(): NodeMaterialConnectionPoint;
  147021. /**
  147022. * Gets the thickness texture component
  147023. */
  147024. get thicknessTexture(): NodeMaterialConnectionPoint;
  147025. /**
  147026. * Gets the tint color input component
  147027. */
  147028. get tintColor(): NodeMaterialConnectionPoint;
  147029. /**
  147030. * Gets the translucency intensity input component
  147031. */
  147032. get translucencyIntensity(): NodeMaterialConnectionPoint;
  147033. /**
  147034. * Gets the translucency diffusion distance input component
  147035. */
  147036. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  147037. /**
  147038. * Gets the refraction object parameters
  147039. */
  147040. get refraction(): NodeMaterialConnectionPoint;
  147041. /**
  147042. * Gets the sub surface object output component
  147043. */
  147044. get subsurface(): NodeMaterialConnectionPoint;
  147045. autoConfigure(material: NodeMaterial): void;
  147046. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147047. /**
  147048. * Gets the main code of the block (fragment side)
  147049. * @param state current state of the node material building
  147050. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  147051. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147052. * @param worldPosVarName name of the variable holding the world position
  147053. * @returns the shader code
  147054. */
  147055. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  147056. protected _buildBlock(state: NodeMaterialBuildState): this;
  147057. }
  147058. }
  147059. declare module BABYLON {
  147060. /**
  147061. * Block used to implement the PBR metallic/roughness model
  147062. */
  147063. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  147064. /**
  147065. * Gets or sets the light associated with this block
  147066. */
  147067. light: Nullable<Light>;
  147068. private _lightId;
  147069. private _scene;
  147070. private _environmentBRDFTexture;
  147071. private _environmentBrdfSamplerName;
  147072. private _vNormalWName;
  147073. private _invertNormalName;
  147074. /**
  147075. * Create a new ReflectionBlock
  147076. * @param name defines the block name
  147077. */
  147078. constructor(name: string);
  147079. /**
  147080. * Intensity of the direct lights e.g. the four lights available in your scene.
  147081. * This impacts both the direct diffuse and specular highlights.
  147082. */
  147083. directIntensity: number;
  147084. /**
  147085. * Intensity of the environment e.g. how much the environment will light the object
  147086. * either through harmonics for rough material or through the refelction for shiny ones.
  147087. */
  147088. environmentIntensity: number;
  147089. /**
  147090. * This is a special control allowing the reduction of the specular highlights coming from the
  147091. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  147092. */
  147093. specularIntensity: number;
  147094. /**
  147095. * Defines the falloff type used in this material.
  147096. * It by default is Physical.
  147097. */
  147098. lightFalloff: number;
  147099. /**
  147100. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  147101. */
  147102. useAlphaFromAlbedoTexture: boolean;
  147103. /**
  147104. * Specifies that alpha test should be used
  147105. */
  147106. useAlphaTest: boolean;
  147107. /**
  147108. * Defines the alpha limits in alpha test mode.
  147109. */
  147110. alphaTestCutoff: number;
  147111. /**
  147112. * Specifies that alpha blending should be used
  147113. */
  147114. useAlphaBlending: boolean;
  147115. /**
  147116. * Defines if the alpha value should be determined via the rgb values.
  147117. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  147118. */
  147119. opacityRGB: boolean;
  147120. /**
  147121. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  147122. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  147123. */
  147124. useRadianceOverAlpha: boolean;
  147125. /**
  147126. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  147127. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  147128. */
  147129. useSpecularOverAlpha: boolean;
  147130. /**
  147131. * Enables specular anti aliasing in the PBR shader.
  147132. * It will both interacts on the Geometry for analytical and IBL lighting.
  147133. * It also prefilter the roughness map based on the bump values.
  147134. */
  147135. enableSpecularAntiAliasing: boolean;
  147136. /**
  147137. * Enables realtime filtering on the texture.
  147138. */
  147139. realTimeFiltering: boolean;
  147140. /**
  147141. * Quality switch for realtime filtering
  147142. */
  147143. realTimeFilteringQuality: number;
  147144. /**
  147145. * Defines if the material uses energy conservation.
  147146. */
  147147. useEnergyConservation: boolean;
  147148. /**
  147149. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  147150. * too much the area relying on ambient texture to define their ambient occlusion.
  147151. */
  147152. useRadianceOcclusion: boolean;
  147153. /**
  147154. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  147155. * makes the reflect vector face the model (under horizon).
  147156. */
  147157. useHorizonOcclusion: boolean;
  147158. /**
  147159. * If set to true, no lighting calculations will be applied.
  147160. */
  147161. unlit: boolean;
  147162. /**
  147163. * Force normal to face away from face.
  147164. */
  147165. forceNormalForward: boolean;
  147166. /**
  147167. * Defines the material debug mode.
  147168. * It helps seeing only some components of the material while troubleshooting.
  147169. */
  147170. debugMode: number;
  147171. /**
  147172. * Specify from where on screen the debug mode should start.
  147173. * The value goes from -1 (full screen) to 1 (not visible)
  147174. * It helps with side by side comparison against the final render
  147175. * This defaults to 0
  147176. */
  147177. debugLimit: number;
  147178. /**
  147179. * As the default viewing range might not be enough (if the ambient is really small for instance)
  147180. * You can use the factor to better multiply the final value.
  147181. */
  147182. debugFactor: number;
  147183. /**
  147184. * Initialize the block and prepare the context for build
  147185. * @param state defines the state that will be used for the build
  147186. */
  147187. initialize(state: NodeMaterialBuildState): void;
  147188. /**
  147189. * Gets the current class name
  147190. * @returns the class name
  147191. */
  147192. getClassName(): string;
  147193. /**
  147194. * Gets the world position input component
  147195. */
  147196. get worldPosition(): NodeMaterialConnectionPoint;
  147197. /**
  147198. * Gets the world normal input component
  147199. */
  147200. get worldNormal(): NodeMaterialConnectionPoint;
  147201. /**
  147202. * Gets the perturbed normal input component
  147203. */
  147204. get perturbedNormal(): NodeMaterialConnectionPoint;
  147205. /**
  147206. * Gets the camera position input component
  147207. */
  147208. get cameraPosition(): NodeMaterialConnectionPoint;
  147209. /**
  147210. * Gets the base color input component
  147211. */
  147212. get baseColor(): NodeMaterialConnectionPoint;
  147213. /**
  147214. * Gets the opacity texture input component
  147215. */
  147216. get opacityTexture(): NodeMaterialConnectionPoint;
  147217. /**
  147218. * Gets the ambient color input component
  147219. */
  147220. get ambientColor(): NodeMaterialConnectionPoint;
  147221. /**
  147222. * Gets the reflectivity object parameters
  147223. */
  147224. get reflectivity(): NodeMaterialConnectionPoint;
  147225. /**
  147226. * Gets the ambient occlusion object parameters
  147227. */
  147228. get ambientOcc(): NodeMaterialConnectionPoint;
  147229. /**
  147230. * Gets the reflection object parameters
  147231. */
  147232. get reflection(): NodeMaterialConnectionPoint;
  147233. /**
  147234. * Gets the sheen object parameters
  147235. */
  147236. get sheen(): NodeMaterialConnectionPoint;
  147237. /**
  147238. * Gets the clear coat object parameters
  147239. */
  147240. get clearcoat(): NodeMaterialConnectionPoint;
  147241. /**
  147242. * Gets the sub surface object parameters
  147243. */
  147244. get subsurface(): NodeMaterialConnectionPoint;
  147245. /**
  147246. * Gets the anisotropy object parameters
  147247. */
  147248. get anisotropy(): NodeMaterialConnectionPoint;
  147249. /**
  147250. * Gets the view matrix parameter
  147251. */
  147252. get view(): NodeMaterialConnectionPoint;
  147253. /**
  147254. * Gets the ambient output component
  147255. */
  147256. get ambient(): NodeMaterialConnectionPoint;
  147257. /**
  147258. * Gets the diffuse output component
  147259. */
  147260. get diffuse(): NodeMaterialConnectionPoint;
  147261. /**
  147262. * Gets the specular output component
  147263. */
  147264. get specular(): NodeMaterialConnectionPoint;
  147265. /**
  147266. * Gets the sheen output component
  147267. */
  147268. get sheenDir(): NodeMaterialConnectionPoint;
  147269. /**
  147270. * Gets the clear coat output component
  147271. */
  147272. get clearcoatDir(): NodeMaterialConnectionPoint;
  147273. /**
  147274. * Gets the indirect diffuse output component
  147275. */
  147276. get diffuseIndirect(): NodeMaterialConnectionPoint;
  147277. /**
  147278. * Gets the indirect specular output component
  147279. */
  147280. get specularIndirect(): NodeMaterialConnectionPoint;
  147281. /**
  147282. * Gets the indirect sheen output component
  147283. */
  147284. get sheenIndirect(): NodeMaterialConnectionPoint;
  147285. /**
  147286. * Gets the indirect clear coat output component
  147287. */
  147288. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  147289. /**
  147290. * Gets the refraction output component
  147291. */
  147292. get refraction(): NodeMaterialConnectionPoint;
  147293. /**
  147294. * Gets the global lighting output component
  147295. */
  147296. get lighting(): NodeMaterialConnectionPoint;
  147297. /**
  147298. * Gets the shadow output component
  147299. */
  147300. get shadow(): NodeMaterialConnectionPoint;
  147301. /**
  147302. * Gets the alpha output component
  147303. */
  147304. get alpha(): NodeMaterialConnectionPoint;
  147305. autoConfigure(material: NodeMaterial): void;
  147306. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147307. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  147308. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  147309. private _injectVertexCode;
  147310. /**
  147311. * Gets the code corresponding to the albedo/opacity module
  147312. * @returns the shader code
  147313. */
  147314. getAlbedoOpacityCode(): string;
  147315. protected _buildBlock(state: NodeMaterialBuildState): this;
  147316. protected _dumpPropertiesCode(): string;
  147317. serialize(): any;
  147318. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147319. }
  147320. }
  147321. declare module BABYLON {
  147322. /**
  147323. * Block used to compute value of one parameter modulo another
  147324. */
  147325. export class ModBlock extends NodeMaterialBlock {
  147326. /**
  147327. * Creates a new ModBlock
  147328. * @param name defines the block name
  147329. */
  147330. constructor(name: string);
  147331. /**
  147332. * Gets the current class name
  147333. * @returns the class name
  147334. */
  147335. getClassName(): string;
  147336. /**
  147337. * Gets the left operand input component
  147338. */
  147339. get left(): NodeMaterialConnectionPoint;
  147340. /**
  147341. * Gets the right operand input component
  147342. */
  147343. get right(): NodeMaterialConnectionPoint;
  147344. /**
  147345. * Gets the output component
  147346. */
  147347. get output(): NodeMaterialConnectionPoint;
  147348. protected _buildBlock(state: NodeMaterialBuildState): this;
  147349. }
  147350. }
  147351. declare module BABYLON {
  147352. /**
  147353. * Configuration for Draco compression
  147354. */
  147355. export interface IDracoCompressionConfiguration {
  147356. /**
  147357. * Configuration for the decoder.
  147358. */
  147359. decoder: {
  147360. /**
  147361. * The url to the WebAssembly module.
  147362. */
  147363. wasmUrl?: string;
  147364. /**
  147365. * The url to the WebAssembly binary.
  147366. */
  147367. wasmBinaryUrl?: string;
  147368. /**
  147369. * The url to the fallback JavaScript module.
  147370. */
  147371. fallbackUrl?: string;
  147372. };
  147373. }
  147374. /**
  147375. * Draco compression (https://google.github.io/draco/)
  147376. *
  147377. * This class wraps the Draco module.
  147378. *
  147379. * **Encoder**
  147380. *
  147381. * The encoder is not currently implemented.
  147382. *
  147383. * **Decoder**
  147384. *
  147385. * 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.
  147386. *
  147387. * To update the configuration, use the following code:
  147388. * ```javascript
  147389. * DracoCompression.Configuration = {
  147390. * decoder: {
  147391. * wasmUrl: "<url to the WebAssembly library>",
  147392. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  147393. * fallbackUrl: "<url to the fallback JavaScript library>",
  147394. * }
  147395. * };
  147396. * ```
  147397. *
  147398. * 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.
  147399. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  147400. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  147401. *
  147402. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  147403. * ```javascript
  147404. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  147405. * ```
  147406. *
  147407. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  147408. */
  147409. export class DracoCompression implements IDisposable {
  147410. private _workerPoolPromise?;
  147411. private _decoderModulePromise?;
  147412. /**
  147413. * The configuration. Defaults to the following urls:
  147414. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  147415. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  147416. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  147417. */
  147418. static Configuration: IDracoCompressionConfiguration;
  147419. /**
  147420. * Returns true if the decoder configuration is available.
  147421. */
  147422. static get DecoderAvailable(): boolean;
  147423. /**
  147424. * Default number of workers to create when creating the draco compression object.
  147425. */
  147426. static DefaultNumWorkers: number;
  147427. private static GetDefaultNumWorkers;
  147428. private static _Default;
  147429. /**
  147430. * Default instance for the draco compression object.
  147431. */
  147432. static get Default(): DracoCompression;
  147433. /**
  147434. * Constructor
  147435. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  147436. */
  147437. constructor(numWorkers?: number);
  147438. /**
  147439. * Stop all async operations and release resources.
  147440. */
  147441. dispose(): void;
  147442. /**
  147443. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  147444. * @returns a promise that resolves when ready
  147445. */
  147446. whenReadyAsync(): Promise<void>;
  147447. /**
  147448. * Decode Draco compressed mesh data to vertex data.
  147449. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  147450. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  147451. * @returns A promise that resolves with the decoded vertex data
  147452. */
  147453. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  147454. [kind: string]: number;
  147455. }): Promise<VertexData>;
  147456. }
  147457. }
  147458. declare module BABYLON {
  147459. /**
  147460. * Class for building Constructive Solid Geometry
  147461. */
  147462. export class CSG {
  147463. private polygons;
  147464. /**
  147465. * The world matrix
  147466. */
  147467. matrix: Matrix;
  147468. /**
  147469. * Stores the position
  147470. */
  147471. position: Vector3;
  147472. /**
  147473. * Stores the rotation
  147474. */
  147475. rotation: Vector3;
  147476. /**
  147477. * Stores the rotation quaternion
  147478. */
  147479. rotationQuaternion: Nullable<Quaternion>;
  147480. /**
  147481. * Stores the scaling vector
  147482. */
  147483. scaling: Vector3;
  147484. /**
  147485. * Convert the Mesh to CSG
  147486. * @param mesh The Mesh to convert to CSG
  147487. * @returns A new CSG from the Mesh
  147488. */
  147489. static FromMesh(mesh: Mesh): CSG;
  147490. /**
  147491. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  147492. * @param polygons Polygons used to construct a CSG solid
  147493. */
  147494. private static FromPolygons;
  147495. /**
  147496. * Clones, or makes a deep copy, of the CSG
  147497. * @returns A new CSG
  147498. */
  147499. clone(): CSG;
  147500. /**
  147501. * Unions this CSG with another CSG
  147502. * @param csg The CSG to union against this CSG
  147503. * @returns The unioned CSG
  147504. */
  147505. union(csg: CSG): CSG;
  147506. /**
  147507. * Unions this CSG with another CSG in place
  147508. * @param csg The CSG to union against this CSG
  147509. */
  147510. unionInPlace(csg: CSG): void;
  147511. /**
  147512. * Subtracts this CSG with another CSG
  147513. * @param csg The CSG to subtract against this CSG
  147514. * @returns A new CSG
  147515. */
  147516. subtract(csg: CSG): CSG;
  147517. /**
  147518. * Subtracts this CSG with another CSG in place
  147519. * @param csg The CSG to subtact against this CSG
  147520. */
  147521. subtractInPlace(csg: CSG): void;
  147522. /**
  147523. * Intersect this CSG with another CSG
  147524. * @param csg The CSG to intersect against this CSG
  147525. * @returns A new CSG
  147526. */
  147527. intersect(csg: CSG): CSG;
  147528. /**
  147529. * Intersects this CSG with another CSG in place
  147530. * @param csg The CSG to intersect against this CSG
  147531. */
  147532. intersectInPlace(csg: CSG): void;
  147533. /**
  147534. * Return a new CSG solid with solid and empty space switched. This solid is
  147535. * not modified.
  147536. * @returns A new CSG solid with solid and empty space switched
  147537. */
  147538. inverse(): CSG;
  147539. /**
  147540. * Inverses the CSG in place
  147541. */
  147542. inverseInPlace(): void;
  147543. /**
  147544. * This is used to keep meshes transformations so they can be restored
  147545. * when we build back a Babylon Mesh
  147546. * NB : All CSG operations are performed in world coordinates
  147547. * @param csg The CSG to copy the transform attributes from
  147548. * @returns This CSG
  147549. */
  147550. copyTransformAttributes(csg: CSG): CSG;
  147551. /**
  147552. * Build Raw mesh from CSG
  147553. * Coordinates here are in world space
  147554. * @param name The name of the mesh geometry
  147555. * @param scene The Scene
  147556. * @param keepSubMeshes Specifies if the submeshes should be kept
  147557. * @returns A new Mesh
  147558. */
  147559. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  147560. /**
  147561. * Build Mesh from CSG taking material and transforms into account
  147562. * @param name The name of the Mesh
  147563. * @param material The material of the Mesh
  147564. * @param scene The Scene
  147565. * @param keepSubMeshes Specifies if submeshes should be kept
  147566. * @returns The new Mesh
  147567. */
  147568. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  147569. }
  147570. }
  147571. declare module BABYLON {
  147572. /**
  147573. * Class used to create a trail following a mesh
  147574. */
  147575. export class TrailMesh extends Mesh {
  147576. private _generator;
  147577. private _autoStart;
  147578. private _running;
  147579. private _diameter;
  147580. private _length;
  147581. private _sectionPolygonPointsCount;
  147582. private _sectionVectors;
  147583. private _sectionNormalVectors;
  147584. private _beforeRenderObserver;
  147585. /**
  147586. * @constructor
  147587. * @param name The value used by scene.getMeshByName() to do a lookup.
  147588. * @param generator The mesh or transform node to generate a trail.
  147589. * @param scene The scene to add this mesh to.
  147590. * @param diameter Diameter of trailing mesh. Default is 1.
  147591. * @param length Length of trailing mesh. Default is 60.
  147592. * @param autoStart Automatically start trailing mesh. Default true.
  147593. */
  147594. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  147595. /**
  147596. * "TrailMesh"
  147597. * @returns "TrailMesh"
  147598. */
  147599. getClassName(): string;
  147600. private _createMesh;
  147601. /**
  147602. * Start trailing mesh.
  147603. */
  147604. start(): void;
  147605. /**
  147606. * Stop trailing mesh.
  147607. */
  147608. stop(): void;
  147609. /**
  147610. * Update trailing mesh geometry.
  147611. */
  147612. update(): void;
  147613. /**
  147614. * Returns a new TrailMesh object.
  147615. * @param name is a string, the name given to the new mesh
  147616. * @param newGenerator use new generator object for cloned trail mesh
  147617. * @returns a new mesh
  147618. */
  147619. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  147620. /**
  147621. * Serializes this trail mesh
  147622. * @param serializationObject object to write serialization to
  147623. */
  147624. serialize(serializationObject: any): void;
  147625. /**
  147626. * Parses a serialized trail mesh
  147627. * @param parsedMesh the serialized mesh
  147628. * @param scene the scene to create the trail mesh in
  147629. * @returns the created trail mesh
  147630. */
  147631. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  147632. }
  147633. }
  147634. declare module BABYLON {
  147635. /**
  147636. * Class containing static functions to help procedurally build meshes
  147637. */
  147638. export class TiledBoxBuilder {
  147639. /**
  147640. * Creates a box mesh
  147641. * 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)
  147642. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147646. * @param name defines the name of the mesh
  147647. * @param options defines the options used to create the mesh
  147648. * @param scene defines the hosting scene
  147649. * @returns the box mesh
  147650. */
  147651. static CreateTiledBox(name: string, options: {
  147652. pattern?: number;
  147653. width?: number;
  147654. height?: number;
  147655. depth?: number;
  147656. tileSize?: number;
  147657. tileWidth?: number;
  147658. tileHeight?: number;
  147659. alignHorizontal?: number;
  147660. alignVertical?: number;
  147661. faceUV?: Vector4[];
  147662. faceColors?: Color4[];
  147663. sideOrientation?: number;
  147664. updatable?: boolean;
  147665. }, scene?: Nullable<Scene>): Mesh;
  147666. }
  147667. }
  147668. declare module BABYLON {
  147669. /**
  147670. * Class containing static functions to help procedurally build meshes
  147671. */
  147672. export class TorusKnotBuilder {
  147673. /**
  147674. * Creates a torus knot mesh
  147675. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  147676. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  147677. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  147678. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  147679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147682. * @param name defines the name of the mesh
  147683. * @param options defines the options used to create the mesh
  147684. * @param scene defines the hosting scene
  147685. * @returns the torus knot mesh
  147686. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  147687. */
  147688. static CreateTorusKnot(name: string, options: {
  147689. radius?: number;
  147690. tube?: number;
  147691. radialSegments?: number;
  147692. tubularSegments?: number;
  147693. p?: number;
  147694. q?: number;
  147695. updatable?: boolean;
  147696. sideOrientation?: number;
  147697. frontUVs?: Vector4;
  147698. backUVs?: Vector4;
  147699. }, scene: any): Mesh;
  147700. }
  147701. }
  147702. declare module BABYLON {
  147703. /**
  147704. * Polygon
  147705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  147706. */
  147707. export class Polygon {
  147708. /**
  147709. * Creates a rectangle
  147710. * @param xmin bottom X coord
  147711. * @param ymin bottom Y coord
  147712. * @param xmax top X coord
  147713. * @param ymax top Y coord
  147714. * @returns points that make the resulting rectation
  147715. */
  147716. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  147717. /**
  147718. * Creates a circle
  147719. * @param radius radius of circle
  147720. * @param cx scale in x
  147721. * @param cy scale in y
  147722. * @param numberOfSides number of sides that make up the circle
  147723. * @returns points that make the resulting circle
  147724. */
  147725. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  147726. /**
  147727. * Creates a polygon from input string
  147728. * @param input Input polygon data
  147729. * @returns the parsed points
  147730. */
  147731. static Parse(input: string): Vector2[];
  147732. /**
  147733. * Starts building a polygon from x and y coordinates
  147734. * @param x x coordinate
  147735. * @param y y coordinate
  147736. * @returns the started path2
  147737. */
  147738. static StartingAt(x: number, y: number): Path2;
  147739. }
  147740. /**
  147741. * Builds a polygon
  147742. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  147743. */
  147744. export class PolygonMeshBuilder {
  147745. private _points;
  147746. private _outlinepoints;
  147747. private _holes;
  147748. private _name;
  147749. private _scene;
  147750. private _epoints;
  147751. private _eholes;
  147752. private _addToepoint;
  147753. /**
  147754. * Babylon reference to the earcut plugin.
  147755. */
  147756. bjsEarcut: any;
  147757. /**
  147758. * Creates a PolygonMeshBuilder
  147759. * @param name name of the builder
  147760. * @param contours Path of the polygon
  147761. * @param scene scene to add to when creating the mesh
  147762. * @param earcutInjection can be used to inject your own earcut reference
  147763. */
  147764. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  147765. /**
  147766. * Adds a whole within the polygon
  147767. * @param hole Array of points defining the hole
  147768. * @returns this
  147769. */
  147770. addHole(hole: Vector2[]): PolygonMeshBuilder;
  147771. /**
  147772. * Creates the polygon
  147773. * @param updatable If the mesh should be updatable
  147774. * @param depth The depth of the mesh created
  147775. * @returns the created mesh
  147776. */
  147777. build(updatable?: boolean, depth?: number): Mesh;
  147778. /**
  147779. * Creates the polygon
  147780. * @param depth The depth of the mesh created
  147781. * @returns the created VertexData
  147782. */
  147783. buildVertexData(depth?: number): VertexData;
  147784. /**
  147785. * Adds a side to the polygon
  147786. * @param positions points that make the polygon
  147787. * @param normals normals of the polygon
  147788. * @param uvs uvs of the polygon
  147789. * @param indices indices of the polygon
  147790. * @param bounds bounds of the polygon
  147791. * @param points points of the polygon
  147792. * @param depth depth of the polygon
  147793. * @param flip flip of the polygon
  147794. */
  147795. private addSide;
  147796. }
  147797. }
  147798. declare module BABYLON {
  147799. /**
  147800. * Class containing static functions to help procedurally build meshes
  147801. */
  147802. export class PolygonBuilder {
  147803. /**
  147804. * Creates a polygon mesh
  147805. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147806. * * 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
  147807. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147810. * * Remember you can only change the shape positions, not their number when updating a polygon
  147811. * @param name defines the name of the mesh
  147812. * @param options defines the options used to create the mesh
  147813. * @param scene defines the hosting scene
  147814. * @param earcutInjection can be used to inject your own earcut reference
  147815. * @returns the polygon mesh
  147816. */
  147817. static CreatePolygon(name: string, options: {
  147818. shape: Vector3[];
  147819. holes?: Vector3[][];
  147820. depth?: number;
  147821. faceUV?: Vector4[];
  147822. faceColors?: Color4[];
  147823. updatable?: boolean;
  147824. sideOrientation?: number;
  147825. frontUVs?: Vector4;
  147826. backUVs?: Vector4;
  147827. wrap?: boolean;
  147828. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147829. /**
  147830. * Creates an extruded polygon mesh, with depth in the Y direction.
  147831. * * 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)
  147832. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147833. * @param name defines the name of the mesh
  147834. * @param options defines the options used to create the mesh
  147835. * @param scene defines the hosting scene
  147836. * @param earcutInjection can be used to inject your own earcut reference
  147837. * @returns the polygon mesh
  147838. */
  147839. static ExtrudePolygon(name: string, options: {
  147840. shape: Vector3[];
  147841. holes?: Vector3[][];
  147842. depth?: number;
  147843. faceUV?: Vector4[];
  147844. faceColors?: Color4[];
  147845. updatable?: boolean;
  147846. sideOrientation?: number;
  147847. frontUVs?: Vector4;
  147848. backUVs?: Vector4;
  147849. wrap?: boolean;
  147850. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147851. }
  147852. }
  147853. declare module BABYLON {
  147854. /**
  147855. * Class containing static functions to help procedurally build meshes
  147856. */
  147857. export class LatheBuilder {
  147858. /**
  147859. * Creates lathe mesh.
  147860. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147861. * * 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
  147862. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147863. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147864. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147865. * * 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
  147866. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147867. * * 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
  147868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147870. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147872. * @param name defines the name of the mesh
  147873. * @param options defines the options used to create the mesh
  147874. * @param scene defines the hosting scene
  147875. * @returns the lathe mesh
  147876. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147877. */
  147878. static CreateLathe(name: string, options: {
  147879. shape: Vector3[];
  147880. radius?: number;
  147881. tessellation?: number;
  147882. clip?: number;
  147883. arc?: number;
  147884. closed?: boolean;
  147885. updatable?: boolean;
  147886. sideOrientation?: number;
  147887. frontUVs?: Vector4;
  147888. backUVs?: Vector4;
  147889. cap?: number;
  147890. invertUV?: boolean;
  147891. }, scene?: Nullable<Scene>): Mesh;
  147892. }
  147893. }
  147894. declare module BABYLON {
  147895. /**
  147896. * Class containing static functions to help procedurally build meshes
  147897. */
  147898. export class TiledPlaneBuilder {
  147899. /**
  147900. * Creates a tiled plane mesh
  147901. * * The parameter `pattern` will, depending on value, do nothing or
  147902. * * * flip (reflect about central vertical) alternate tiles across and up
  147903. * * * flip every tile on alternate rows
  147904. * * * rotate (180 degs) alternate tiles across and up
  147905. * * * rotate every tile on alternate rows
  147906. * * * flip and rotate alternate tiles across and up
  147907. * * * flip and rotate every tile on alternate rows
  147908. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  147909. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  147910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147911. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147912. * * 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)
  147913. * * 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)
  147914. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147915. * @param name defines the name of the mesh
  147916. * @param options defines the options used to create the mesh
  147917. * @param scene defines the hosting scene
  147918. * @returns the box mesh
  147919. */
  147920. static CreateTiledPlane(name: string, options: {
  147921. pattern?: number;
  147922. tileSize?: number;
  147923. tileWidth?: number;
  147924. tileHeight?: number;
  147925. size?: number;
  147926. width?: number;
  147927. height?: number;
  147928. alignHorizontal?: number;
  147929. alignVertical?: number;
  147930. sideOrientation?: number;
  147931. frontUVs?: Vector4;
  147932. backUVs?: Vector4;
  147933. updatable?: boolean;
  147934. }, scene?: Nullable<Scene>): Mesh;
  147935. }
  147936. }
  147937. declare module BABYLON {
  147938. /**
  147939. * Class containing static functions to help procedurally build meshes
  147940. */
  147941. export class TubeBuilder {
  147942. /**
  147943. * Creates a tube mesh.
  147944. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147945. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147946. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147947. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147948. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147949. * * 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)
  147950. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147951. * * 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
  147952. * * 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
  147953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147955. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147957. * @param name defines the name of the mesh
  147958. * @param options defines the options used to create the mesh
  147959. * @param scene defines the hosting scene
  147960. * @returns the tube mesh
  147961. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147962. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147963. */
  147964. static CreateTube(name: string, options: {
  147965. path: Vector3[];
  147966. radius?: number;
  147967. tessellation?: number;
  147968. radiusFunction?: {
  147969. (i: number, distance: number): number;
  147970. };
  147971. cap?: number;
  147972. arc?: number;
  147973. updatable?: boolean;
  147974. sideOrientation?: number;
  147975. frontUVs?: Vector4;
  147976. backUVs?: Vector4;
  147977. instance?: Mesh;
  147978. invertUV?: boolean;
  147979. }, scene?: Nullable<Scene>): Mesh;
  147980. }
  147981. }
  147982. declare module BABYLON {
  147983. /**
  147984. * Class containing static functions to help procedurally build meshes
  147985. */
  147986. export class IcoSphereBuilder {
  147987. /**
  147988. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147989. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147990. * * 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`)
  147991. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147992. * * 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
  147993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147996. * @param name defines the name of the mesh
  147997. * @param options defines the options used to create the mesh
  147998. * @param scene defines the hosting scene
  147999. * @returns the icosahedron mesh
  148000. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148001. */
  148002. static CreateIcoSphere(name: string, options: {
  148003. radius?: number;
  148004. radiusX?: number;
  148005. radiusY?: number;
  148006. radiusZ?: number;
  148007. flat?: boolean;
  148008. subdivisions?: number;
  148009. sideOrientation?: number;
  148010. frontUVs?: Vector4;
  148011. backUVs?: Vector4;
  148012. updatable?: boolean;
  148013. }, scene?: Nullable<Scene>): Mesh;
  148014. }
  148015. }
  148016. declare module BABYLON {
  148017. /**
  148018. * Class containing static functions to help procedurally build meshes
  148019. */
  148020. export class DecalBuilder {
  148021. /**
  148022. * Creates a decal mesh.
  148023. * 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
  148024. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148025. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148026. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148027. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148028. * @param name defines the name of the mesh
  148029. * @param sourceMesh defines the mesh where the decal must be applied
  148030. * @param options defines the options used to create the mesh
  148031. * @param scene defines the hosting scene
  148032. * @returns the decal mesh
  148033. * @see https://doc.babylonjs.com/how_to/decals
  148034. */
  148035. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148036. position?: Vector3;
  148037. normal?: Vector3;
  148038. size?: Vector3;
  148039. angle?: number;
  148040. }): Mesh;
  148041. }
  148042. }
  148043. declare module BABYLON {
  148044. /**
  148045. * Class containing static functions to help procedurally build meshes
  148046. */
  148047. export class MeshBuilder {
  148048. /**
  148049. * Creates a box mesh
  148050. * * The parameter `size` sets the size (float) of each box side (default 1)
  148051. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  148052. * * 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)
  148053. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148057. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148058. * @param name defines the name of the mesh
  148059. * @param options defines the options used to create the mesh
  148060. * @param scene defines the hosting scene
  148061. * @returns the box mesh
  148062. */
  148063. static CreateBox(name: string, options: {
  148064. size?: number;
  148065. width?: number;
  148066. height?: number;
  148067. depth?: number;
  148068. faceUV?: Vector4[];
  148069. faceColors?: Color4[];
  148070. sideOrientation?: number;
  148071. frontUVs?: Vector4;
  148072. backUVs?: Vector4;
  148073. wrap?: boolean;
  148074. topBaseAt?: number;
  148075. bottomBaseAt?: number;
  148076. updatable?: boolean;
  148077. }, scene?: Nullable<Scene>): Mesh;
  148078. /**
  148079. * Creates a tiled box mesh
  148080. * * faceTiles sets the pattern, tile size and number of tiles for a face
  148081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148082. * @param name defines the name of the mesh
  148083. * @param options defines the options used to create the mesh
  148084. * @param scene defines the hosting scene
  148085. * @returns the tiled box mesh
  148086. */
  148087. static CreateTiledBox(name: string, options: {
  148088. pattern?: number;
  148089. size?: number;
  148090. width?: number;
  148091. height?: number;
  148092. depth: number;
  148093. tileSize?: number;
  148094. tileWidth?: number;
  148095. tileHeight?: number;
  148096. faceUV?: Vector4[];
  148097. faceColors?: Color4[];
  148098. alignHorizontal?: number;
  148099. alignVertical?: number;
  148100. sideOrientation?: number;
  148101. updatable?: boolean;
  148102. }, scene?: Nullable<Scene>): Mesh;
  148103. /**
  148104. * Creates a sphere mesh
  148105. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  148106. * * 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`)
  148107. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  148108. * * 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
  148109. * * 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)
  148110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148113. * @param name defines the name of the mesh
  148114. * @param options defines the options used to create the mesh
  148115. * @param scene defines the hosting scene
  148116. * @returns the sphere mesh
  148117. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  148118. */
  148119. static CreateSphere(name: string, options: {
  148120. segments?: number;
  148121. diameter?: number;
  148122. diameterX?: number;
  148123. diameterY?: number;
  148124. diameterZ?: number;
  148125. arc?: number;
  148126. slice?: number;
  148127. sideOrientation?: number;
  148128. frontUVs?: Vector4;
  148129. backUVs?: Vector4;
  148130. updatable?: boolean;
  148131. }, scene?: Nullable<Scene>): Mesh;
  148132. /**
  148133. * Creates a plane polygonal mesh. By default, this is a disc
  148134. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  148135. * * 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
  148136. * * 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
  148137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148140. * @param name defines the name of the mesh
  148141. * @param options defines the options used to create the mesh
  148142. * @param scene defines the hosting scene
  148143. * @returns the plane polygonal mesh
  148144. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  148145. */
  148146. static CreateDisc(name: string, options: {
  148147. radius?: number;
  148148. tessellation?: number;
  148149. arc?: number;
  148150. updatable?: boolean;
  148151. sideOrientation?: number;
  148152. frontUVs?: Vector4;
  148153. backUVs?: Vector4;
  148154. }, scene?: Nullable<Scene>): Mesh;
  148155. /**
  148156. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148157. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148158. * * 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`)
  148159. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148160. * * 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
  148161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148164. * @param name defines the name of the mesh
  148165. * @param options defines the options used to create the mesh
  148166. * @param scene defines the hosting scene
  148167. * @returns the icosahedron mesh
  148168. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148169. */
  148170. static CreateIcoSphere(name: string, options: {
  148171. radius?: number;
  148172. radiusX?: number;
  148173. radiusY?: number;
  148174. radiusZ?: number;
  148175. flat?: boolean;
  148176. subdivisions?: number;
  148177. sideOrientation?: number;
  148178. frontUVs?: Vector4;
  148179. backUVs?: Vector4;
  148180. updatable?: boolean;
  148181. }, scene?: Nullable<Scene>): Mesh;
  148182. /**
  148183. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148184. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  148185. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  148186. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  148187. * * 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
  148188. * * 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
  148189. * * 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
  148190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148192. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148193. * * 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
  148194. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  148195. * * 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
  148196. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  148197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148198. * @param name defines the name of the mesh
  148199. * @param options defines the options used to create the mesh
  148200. * @param scene defines the hosting scene
  148201. * @returns the ribbon mesh
  148202. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  148203. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148204. */
  148205. static CreateRibbon(name: string, options: {
  148206. pathArray: Vector3[][];
  148207. closeArray?: boolean;
  148208. closePath?: boolean;
  148209. offset?: number;
  148210. updatable?: boolean;
  148211. sideOrientation?: number;
  148212. frontUVs?: Vector4;
  148213. backUVs?: Vector4;
  148214. instance?: Mesh;
  148215. invertUV?: boolean;
  148216. uvs?: Vector2[];
  148217. colors?: Color4[];
  148218. }, scene?: Nullable<Scene>): Mesh;
  148219. /**
  148220. * Creates a cylinder or a cone mesh
  148221. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  148222. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  148223. * * 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.
  148224. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  148225. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  148226. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  148227. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  148228. * * 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).
  148229. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  148230. * * 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).
  148231. * * 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
  148232. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  148233. * * 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
  148234. * * 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.
  148235. * * If `enclose` is false, a ring surface is one element.
  148236. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  148237. * * 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
  148238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148241. * @param name defines the name of the mesh
  148242. * @param options defines the options used to create the mesh
  148243. * @param scene defines the hosting scene
  148244. * @returns the cylinder mesh
  148245. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  148246. */
  148247. static CreateCylinder(name: string, options: {
  148248. height?: number;
  148249. diameterTop?: number;
  148250. diameterBottom?: number;
  148251. diameter?: number;
  148252. tessellation?: number;
  148253. subdivisions?: number;
  148254. arc?: number;
  148255. faceColors?: Color4[];
  148256. faceUV?: Vector4[];
  148257. updatable?: boolean;
  148258. hasRings?: boolean;
  148259. enclose?: boolean;
  148260. cap?: number;
  148261. sideOrientation?: number;
  148262. frontUVs?: Vector4;
  148263. backUVs?: Vector4;
  148264. }, scene?: Nullable<Scene>): Mesh;
  148265. /**
  148266. * Creates a torus mesh
  148267. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  148268. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  148269. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  148270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148273. * @param name defines the name of the mesh
  148274. * @param options defines the options used to create the mesh
  148275. * @param scene defines the hosting scene
  148276. * @returns the torus mesh
  148277. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  148278. */
  148279. static CreateTorus(name: string, options: {
  148280. diameter?: number;
  148281. thickness?: number;
  148282. tessellation?: number;
  148283. updatable?: boolean;
  148284. sideOrientation?: number;
  148285. frontUVs?: Vector4;
  148286. backUVs?: Vector4;
  148287. }, scene?: Nullable<Scene>): Mesh;
  148288. /**
  148289. * Creates a torus knot mesh
  148290. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148291. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148292. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148293. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148297. * @param name defines the name of the mesh
  148298. * @param options defines the options used to create the mesh
  148299. * @param scene defines the hosting scene
  148300. * @returns the torus knot mesh
  148301. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  148302. */
  148303. static CreateTorusKnot(name: string, options: {
  148304. radius?: number;
  148305. tube?: number;
  148306. radialSegments?: number;
  148307. tubularSegments?: number;
  148308. p?: number;
  148309. q?: number;
  148310. updatable?: boolean;
  148311. sideOrientation?: number;
  148312. frontUVs?: Vector4;
  148313. backUVs?: Vector4;
  148314. }, scene?: Nullable<Scene>): Mesh;
  148315. /**
  148316. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  148317. * * 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
  148318. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  148319. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  148320. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  148321. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  148322. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  148323. * * 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
  148324. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  148325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148326. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  148327. * @param name defines the name of the new line system
  148328. * @param options defines the options used to create the line system
  148329. * @param scene defines the hosting scene
  148330. * @returns a new line system mesh
  148331. */
  148332. static CreateLineSystem(name: string, options: {
  148333. lines: Vector3[][];
  148334. updatable?: boolean;
  148335. instance?: Nullable<LinesMesh>;
  148336. colors?: Nullable<Color4[][]>;
  148337. useVertexAlpha?: boolean;
  148338. }, scene: Nullable<Scene>): LinesMesh;
  148339. /**
  148340. * Creates a line mesh
  148341. * 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
  148342. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148343. * * The parameter `points` is an array successive Vector3
  148344. * * 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
  148345. * * The optional parameter `colors` is an array of successive Color4, one per line point
  148346. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  148347. * * When updating an instance, remember that only point positions can change, not the number of points
  148348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148349. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  148350. * @param name defines the name of the new line system
  148351. * @param options defines the options used to create the line system
  148352. * @param scene defines the hosting scene
  148353. * @returns a new line mesh
  148354. */
  148355. static CreateLines(name: string, options: {
  148356. points: Vector3[];
  148357. updatable?: boolean;
  148358. instance?: Nullable<LinesMesh>;
  148359. colors?: Color4[];
  148360. useVertexAlpha?: boolean;
  148361. }, scene?: Nullable<Scene>): LinesMesh;
  148362. /**
  148363. * Creates a dashed line mesh
  148364. * * 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
  148365. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148366. * * The parameter `points` is an array successive Vector3
  148367. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  148368. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  148369. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  148370. * * 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
  148371. * * When updating an instance, remember that only point positions can change, not the number of points
  148372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148373. * @param name defines the name of the mesh
  148374. * @param options defines the options used to create the mesh
  148375. * @param scene defines the hosting scene
  148376. * @returns the dashed line mesh
  148377. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  148378. */
  148379. static CreateDashedLines(name: string, options: {
  148380. points: Vector3[];
  148381. dashSize?: number;
  148382. gapSize?: number;
  148383. dashNb?: number;
  148384. updatable?: boolean;
  148385. instance?: LinesMesh;
  148386. }, scene?: Nullable<Scene>): LinesMesh;
  148387. /**
  148388. * 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.
  148389. * * 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.
  148390. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  148391. * * 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.
  148392. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  148393. * * 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
  148394. * * 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
  148395. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  148396. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148398. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  148399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148400. * @param name defines the name of the mesh
  148401. * @param options defines the options used to create the mesh
  148402. * @param scene defines the hosting scene
  148403. * @returns the extruded shape mesh
  148404. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148405. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  148406. */
  148407. static ExtrudeShape(name: string, options: {
  148408. shape: Vector3[];
  148409. path: Vector3[];
  148410. scale?: number;
  148411. rotation?: number;
  148412. cap?: number;
  148413. updatable?: boolean;
  148414. sideOrientation?: number;
  148415. frontUVs?: Vector4;
  148416. backUVs?: Vector4;
  148417. instance?: Mesh;
  148418. invertUV?: boolean;
  148419. }, scene?: Nullable<Scene>): Mesh;
  148420. /**
  148421. * Creates an custom extruded shape mesh.
  148422. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  148423. * * 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.
  148424. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  148425. * * 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
  148426. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  148427. * * 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
  148428. * * It must returns a float value that will be the scale value applied to the shape on each path point
  148429. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  148430. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  148431. * * 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
  148432. * * 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
  148433. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  148434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148436. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148438. * @param name defines the name of the mesh
  148439. * @param options defines the options used to create the mesh
  148440. * @param scene defines the hosting scene
  148441. * @returns the custom extruded shape mesh
  148442. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  148443. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  148445. */
  148446. static ExtrudeShapeCustom(name: string, options: {
  148447. shape: Vector3[];
  148448. path: Vector3[];
  148449. scaleFunction?: any;
  148450. rotationFunction?: any;
  148451. ribbonCloseArray?: boolean;
  148452. ribbonClosePath?: boolean;
  148453. cap?: number;
  148454. updatable?: boolean;
  148455. sideOrientation?: number;
  148456. frontUVs?: Vector4;
  148457. backUVs?: Vector4;
  148458. instance?: Mesh;
  148459. invertUV?: boolean;
  148460. }, scene?: Nullable<Scene>): Mesh;
  148461. /**
  148462. * Creates lathe mesh.
  148463. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  148464. * * 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
  148465. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  148466. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  148467. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  148468. * * 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
  148469. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  148470. * * 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
  148471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148475. * @param name defines the name of the mesh
  148476. * @param options defines the options used to create the mesh
  148477. * @param scene defines the hosting scene
  148478. * @returns the lathe mesh
  148479. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  148480. */
  148481. static CreateLathe(name: string, options: {
  148482. shape: Vector3[];
  148483. radius?: number;
  148484. tessellation?: number;
  148485. clip?: number;
  148486. arc?: number;
  148487. closed?: boolean;
  148488. updatable?: boolean;
  148489. sideOrientation?: number;
  148490. frontUVs?: Vector4;
  148491. backUVs?: Vector4;
  148492. cap?: number;
  148493. invertUV?: boolean;
  148494. }, scene?: Nullable<Scene>): Mesh;
  148495. /**
  148496. * Creates a tiled plane mesh
  148497. * * You can set a limited pattern arrangement with the tiles
  148498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148501. * @param name defines the name of the mesh
  148502. * @param options defines the options used to create the mesh
  148503. * @param scene defines the hosting scene
  148504. * @returns the plane mesh
  148505. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  148506. */
  148507. static CreateTiledPlane(name: string, options: {
  148508. pattern?: number;
  148509. tileSize?: number;
  148510. tileWidth?: number;
  148511. tileHeight?: number;
  148512. size?: number;
  148513. width?: number;
  148514. height?: number;
  148515. alignHorizontal?: number;
  148516. alignVertical?: number;
  148517. sideOrientation?: number;
  148518. frontUVs?: Vector4;
  148519. backUVs?: Vector4;
  148520. updatable?: boolean;
  148521. }, scene?: Nullable<Scene>): Mesh;
  148522. /**
  148523. * Creates a plane mesh
  148524. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  148525. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  148526. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  148527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148530. * @param name defines the name of the mesh
  148531. * @param options defines the options used to create the mesh
  148532. * @param scene defines the hosting scene
  148533. * @returns the plane mesh
  148534. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  148535. */
  148536. static CreatePlane(name: string, options: {
  148537. size?: number;
  148538. width?: number;
  148539. height?: number;
  148540. sideOrientation?: number;
  148541. frontUVs?: Vector4;
  148542. backUVs?: Vector4;
  148543. updatable?: boolean;
  148544. sourcePlane?: Plane;
  148545. }, scene?: Nullable<Scene>): Mesh;
  148546. /**
  148547. * Creates a ground mesh
  148548. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  148549. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  148550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148551. * @param name defines the name of the mesh
  148552. * @param options defines the options used to create the mesh
  148553. * @param scene defines the hosting scene
  148554. * @returns the ground mesh
  148555. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  148556. */
  148557. static CreateGround(name: string, options: {
  148558. width?: number;
  148559. height?: number;
  148560. subdivisions?: number;
  148561. subdivisionsX?: number;
  148562. subdivisionsY?: number;
  148563. updatable?: boolean;
  148564. }, scene?: Nullable<Scene>): Mesh;
  148565. /**
  148566. * Creates a tiled ground mesh
  148567. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  148568. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  148569. * * 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
  148570. * * 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
  148571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148572. * @param name defines the name of the mesh
  148573. * @param options defines the options used to create the mesh
  148574. * @param scene defines the hosting scene
  148575. * @returns the tiled ground mesh
  148576. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  148577. */
  148578. static CreateTiledGround(name: string, options: {
  148579. xmin: number;
  148580. zmin: number;
  148581. xmax: number;
  148582. zmax: number;
  148583. subdivisions?: {
  148584. w: number;
  148585. h: number;
  148586. };
  148587. precision?: {
  148588. w: number;
  148589. h: number;
  148590. };
  148591. updatable?: boolean;
  148592. }, scene?: Nullable<Scene>): Mesh;
  148593. /**
  148594. * Creates a ground mesh from a height map
  148595. * * The parameter `url` sets the URL of the height map image resource.
  148596. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  148597. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  148598. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  148599. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  148600. * * 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.
  148601. * * 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).
  148602. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  148603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148604. * @param name defines the name of the mesh
  148605. * @param url defines the url to the height map
  148606. * @param options defines the options used to create the mesh
  148607. * @param scene defines the hosting scene
  148608. * @returns the ground mesh
  148609. * @see https://doc.babylonjs.com/babylon101/height_map
  148610. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  148611. */
  148612. static CreateGroundFromHeightMap(name: string, url: string, options: {
  148613. width?: number;
  148614. height?: number;
  148615. subdivisions?: number;
  148616. minHeight?: number;
  148617. maxHeight?: number;
  148618. colorFilter?: Color3;
  148619. alphaFilter?: number;
  148620. updatable?: boolean;
  148621. onReady?: (mesh: GroundMesh) => void;
  148622. }, scene?: Nullable<Scene>): GroundMesh;
  148623. /**
  148624. * Creates a polygon mesh
  148625. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  148626. * * 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
  148627. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148629. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  148630. * * Remember you can only change the shape positions, not their number when updating a polygon
  148631. * @param name defines the name of the mesh
  148632. * @param options defines the options used to create the mesh
  148633. * @param scene defines the hosting scene
  148634. * @param earcutInjection can be used to inject your own earcut reference
  148635. * @returns the polygon mesh
  148636. */
  148637. static CreatePolygon(name: string, options: {
  148638. shape: Vector3[];
  148639. holes?: Vector3[][];
  148640. depth?: number;
  148641. faceUV?: Vector4[];
  148642. faceColors?: Color4[];
  148643. updatable?: boolean;
  148644. sideOrientation?: number;
  148645. frontUVs?: Vector4;
  148646. backUVs?: Vector4;
  148647. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148648. /**
  148649. * Creates an extruded polygon mesh, with depth in the Y direction.
  148650. * * 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)
  148651. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148652. * @param name defines the name of the mesh
  148653. * @param options defines the options used to create the mesh
  148654. * @param scene defines the hosting scene
  148655. * @param earcutInjection can be used to inject your own earcut reference
  148656. * @returns the polygon mesh
  148657. */
  148658. static ExtrudePolygon(name: string, options: {
  148659. shape: Vector3[];
  148660. holes?: Vector3[][];
  148661. depth?: number;
  148662. faceUV?: Vector4[];
  148663. faceColors?: Color4[];
  148664. updatable?: boolean;
  148665. sideOrientation?: number;
  148666. frontUVs?: Vector4;
  148667. backUVs?: Vector4;
  148668. wrap?: boolean;
  148669. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148670. /**
  148671. * Creates a tube mesh.
  148672. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148673. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  148674. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  148675. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  148676. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  148677. * * 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)
  148678. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  148679. * * 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
  148680. * * 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
  148681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148683. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148685. * @param name defines the name of the mesh
  148686. * @param options defines the options used to create the mesh
  148687. * @param scene defines the hosting scene
  148688. * @returns the tube mesh
  148689. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148690. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  148691. */
  148692. static CreateTube(name: string, options: {
  148693. path: Vector3[];
  148694. radius?: number;
  148695. tessellation?: number;
  148696. radiusFunction?: {
  148697. (i: number, distance: number): number;
  148698. };
  148699. cap?: number;
  148700. arc?: number;
  148701. updatable?: boolean;
  148702. sideOrientation?: number;
  148703. frontUVs?: Vector4;
  148704. backUVs?: Vector4;
  148705. instance?: Mesh;
  148706. invertUV?: boolean;
  148707. }, scene?: Nullable<Scene>): Mesh;
  148708. /**
  148709. * Creates a polyhedron mesh
  148710. * * 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
  148711. * * The parameter `size` (positive float, default 1) sets the polygon size
  148712. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  148713. * * 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`
  148714. * * 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
  148715. * * 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)`)
  148716. * * 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
  148717. * * 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
  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 polyhedron mesh
  148725. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  148726. */
  148727. static CreatePolyhedron(name: string, options: {
  148728. type?: number;
  148729. size?: number;
  148730. sizeX?: number;
  148731. sizeY?: number;
  148732. sizeZ?: number;
  148733. custom?: any;
  148734. faceUV?: Vector4[];
  148735. faceColors?: Color4[];
  148736. flat?: boolean;
  148737. updatable?: boolean;
  148738. sideOrientation?: number;
  148739. frontUVs?: Vector4;
  148740. backUVs?: Vector4;
  148741. }, scene?: Nullable<Scene>): Mesh;
  148742. /**
  148743. * Creates a decal mesh.
  148744. * 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
  148745. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148746. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148747. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148748. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148749. * @param name defines the name of the mesh
  148750. * @param sourceMesh defines the mesh where the decal must be applied
  148751. * @param options defines the options used to create the mesh
  148752. * @param scene defines the hosting scene
  148753. * @returns the decal mesh
  148754. * @see https://doc.babylonjs.com/how_to/decals
  148755. */
  148756. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148757. position?: Vector3;
  148758. normal?: Vector3;
  148759. size?: Vector3;
  148760. angle?: number;
  148761. }): Mesh;
  148762. /**
  148763. * Creates a Capsule Mesh
  148764. * @param name defines the name of the mesh.
  148765. * @param options the constructors options used to shape the mesh.
  148766. * @param scene defines the scene the mesh is scoped to.
  148767. * @returns the capsule mesh
  148768. * @see https://doc.babylonjs.com/how_to/capsule_shape
  148769. */
  148770. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  148771. }
  148772. }
  148773. declare module BABYLON {
  148774. /**
  148775. * A simplifier interface for future simplification implementations
  148776. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148777. */
  148778. export interface ISimplifier {
  148779. /**
  148780. * Simplification of a given mesh according to the given settings.
  148781. * Since this requires computation, it is assumed that the function runs async.
  148782. * @param settings The settings of the simplification, including quality and distance
  148783. * @param successCallback A callback that will be called after the mesh was simplified.
  148784. * @param errorCallback in case of an error, this callback will be called. optional.
  148785. */
  148786. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  148787. }
  148788. /**
  148789. * Expected simplification settings.
  148790. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  148791. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148792. */
  148793. export interface ISimplificationSettings {
  148794. /**
  148795. * Gets or sets the expected quality
  148796. */
  148797. quality: number;
  148798. /**
  148799. * Gets or sets the distance when this optimized version should be used
  148800. */
  148801. distance: number;
  148802. /**
  148803. * Gets an already optimized mesh
  148804. */
  148805. optimizeMesh?: boolean;
  148806. }
  148807. /**
  148808. * Class used to specify simplification options
  148809. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148810. */
  148811. export class SimplificationSettings implements ISimplificationSettings {
  148812. /** expected quality */
  148813. quality: number;
  148814. /** distance when this optimized version should be used */
  148815. distance: number;
  148816. /** already optimized mesh */
  148817. optimizeMesh?: boolean | undefined;
  148818. /**
  148819. * Creates a SimplificationSettings
  148820. * @param quality expected quality
  148821. * @param distance distance when this optimized version should be used
  148822. * @param optimizeMesh already optimized mesh
  148823. */
  148824. constructor(
  148825. /** expected quality */
  148826. quality: number,
  148827. /** distance when this optimized version should be used */
  148828. distance: number,
  148829. /** already optimized mesh */
  148830. optimizeMesh?: boolean | undefined);
  148831. }
  148832. /**
  148833. * Interface used to define a simplification task
  148834. */
  148835. export interface ISimplificationTask {
  148836. /**
  148837. * Array of settings
  148838. */
  148839. settings: Array<ISimplificationSettings>;
  148840. /**
  148841. * Simplification type
  148842. */
  148843. simplificationType: SimplificationType;
  148844. /**
  148845. * Mesh to simplify
  148846. */
  148847. mesh: Mesh;
  148848. /**
  148849. * Callback called on success
  148850. */
  148851. successCallback?: () => void;
  148852. /**
  148853. * Defines if parallel processing can be used
  148854. */
  148855. parallelProcessing: boolean;
  148856. }
  148857. /**
  148858. * Queue used to order the simplification tasks
  148859. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148860. */
  148861. export class SimplificationQueue {
  148862. private _simplificationArray;
  148863. /**
  148864. * Gets a boolean indicating that the process is still running
  148865. */
  148866. running: boolean;
  148867. /**
  148868. * Creates a new queue
  148869. */
  148870. constructor();
  148871. /**
  148872. * Adds a new simplification task
  148873. * @param task defines a task to add
  148874. */
  148875. addTask(task: ISimplificationTask): void;
  148876. /**
  148877. * Execute next task
  148878. */
  148879. executeNext(): void;
  148880. /**
  148881. * Execute a simplification task
  148882. * @param task defines the task to run
  148883. */
  148884. runSimplification(task: ISimplificationTask): void;
  148885. private getSimplifier;
  148886. }
  148887. /**
  148888. * The implemented types of simplification
  148889. * At the moment only Quadratic Error Decimation is implemented
  148890. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148891. */
  148892. export enum SimplificationType {
  148893. /** Quadratic error decimation */
  148894. QUADRATIC = 0
  148895. }
  148896. /**
  148897. * An implementation of the Quadratic Error simplification algorithm.
  148898. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  148899. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  148900. * @author RaananW
  148901. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148902. */
  148903. export class QuadraticErrorSimplification implements ISimplifier {
  148904. private _mesh;
  148905. private triangles;
  148906. private vertices;
  148907. private references;
  148908. private _reconstructedMesh;
  148909. /** Gets or sets the number pf sync interations */
  148910. syncIterations: number;
  148911. /** Gets or sets the aggressiveness of the simplifier */
  148912. aggressiveness: number;
  148913. /** Gets or sets the number of allowed iterations for decimation */
  148914. decimationIterations: number;
  148915. /** Gets or sets the espilon to use for bounding box computation */
  148916. boundingBoxEpsilon: number;
  148917. /**
  148918. * Creates a new QuadraticErrorSimplification
  148919. * @param _mesh defines the target mesh
  148920. */
  148921. constructor(_mesh: Mesh);
  148922. /**
  148923. * Simplification of a given mesh according to the given settings.
  148924. * Since this requires computation, it is assumed that the function runs async.
  148925. * @param settings The settings of the simplification, including quality and distance
  148926. * @param successCallback A callback that will be called after the mesh was simplified.
  148927. */
  148928. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  148929. private runDecimation;
  148930. private initWithMesh;
  148931. private init;
  148932. private reconstructMesh;
  148933. private initDecimatedMesh;
  148934. private isFlipped;
  148935. private updateTriangles;
  148936. private identifyBorder;
  148937. private updateMesh;
  148938. private vertexError;
  148939. private calculateError;
  148940. }
  148941. }
  148942. declare module BABYLON {
  148943. interface Scene {
  148944. /** @hidden (Backing field) */
  148945. _simplificationQueue: SimplificationQueue;
  148946. /**
  148947. * Gets or sets the simplification queue attached to the scene
  148948. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148949. */
  148950. simplificationQueue: SimplificationQueue;
  148951. }
  148952. interface Mesh {
  148953. /**
  148954. * Simplify the mesh according to the given array of settings.
  148955. * Function will return immediately and will simplify async
  148956. * @param settings a collection of simplification settings
  148957. * @param parallelProcessing should all levels calculate parallel or one after the other
  148958. * @param simplificationType the type of simplification to run
  148959. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  148960. * @returns the current mesh
  148961. */
  148962. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  148963. }
  148964. /**
  148965. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  148966. * created in a scene
  148967. */
  148968. export class SimplicationQueueSceneComponent implements ISceneComponent {
  148969. /**
  148970. * The component name helpfull to identify the component in the list of scene components.
  148971. */
  148972. readonly name: string;
  148973. /**
  148974. * The scene the component belongs to.
  148975. */
  148976. scene: Scene;
  148977. /**
  148978. * Creates a new instance of the component for the given scene
  148979. * @param scene Defines the scene to register the component in
  148980. */
  148981. constructor(scene: Scene);
  148982. /**
  148983. * Registers the component in a given scene
  148984. */
  148985. register(): void;
  148986. /**
  148987. * Rebuilds the elements related to this component in case of
  148988. * context lost for instance.
  148989. */
  148990. rebuild(): void;
  148991. /**
  148992. * Disposes the component and the associated ressources
  148993. */
  148994. dispose(): void;
  148995. private _beforeCameraUpdate;
  148996. }
  148997. }
  148998. declare module BABYLON {
  148999. interface Mesh {
  149000. /**
  149001. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  149002. */
  149003. thinInstanceEnablePicking: boolean;
  149004. /**
  149005. * Creates a new thin instance
  149006. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  149007. * @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
  149008. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  149009. */
  149010. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  149011. /**
  149012. * Adds the transformation (matrix) of the current mesh as a thin instance
  149013. * @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
  149014. * @returns the thin instance index number
  149015. */
  149016. thinInstanceAddSelf(refresh: boolean): number;
  149017. /**
  149018. * Registers a custom attribute to be used with thin instances
  149019. * @param kind name of the attribute
  149020. * @param stride size in floats of the attribute
  149021. */
  149022. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  149023. /**
  149024. * Sets the matrix of a thin instance
  149025. * @param index index of the thin instance
  149026. * @param matrix matrix to set
  149027. * @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
  149028. */
  149029. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  149030. /**
  149031. * Sets the value of a custom attribute for a thin instance
  149032. * @param kind name of the attribute
  149033. * @param index index of the thin instance
  149034. * @param value value to set
  149035. * @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
  149036. */
  149037. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  149038. /**
  149039. * 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.
  149040. */
  149041. thinInstanceCount: number;
  149042. /**
  149043. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  149044. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  149045. * @param buffer buffer to set
  149046. * @param stride size in floats of each value of the buffer
  149047. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  149048. */
  149049. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  149050. /**
  149051. * Gets the list of world matrices
  149052. * @return an array containing all the world matrices from the thin instances
  149053. */
  149054. thinInstanceGetWorldMatrices(): Matrix[];
  149055. /**
  149056. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  149057. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149058. */
  149059. thinInstanceBufferUpdated(kind: string): void;
  149060. /**
  149061. * Applies a partial update to a buffer directly on the GPU
  149062. * 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
  149063. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149064. * @param data the data to set in the GPU buffer
  149065. * @param offset the offset in the GPU buffer where to update the data
  149066. */
  149067. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  149068. /**
  149069. * Refreshes the bounding info, taking into account all the thin instances defined
  149070. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  149071. */
  149072. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  149073. /** @hidden */
  149074. _thinInstanceInitializeUserStorage(): void;
  149075. /** @hidden */
  149076. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  149077. /** @hidden */
  149078. _userThinInstanceBuffersStorage: {
  149079. data: {
  149080. [key: string]: Float32Array;
  149081. };
  149082. sizes: {
  149083. [key: string]: number;
  149084. };
  149085. vertexBuffers: {
  149086. [key: string]: Nullable<VertexBuffer>;
  149087. };
  149088. strides: {
  149089. [key: string]: number;
  149090. };
  149091. };
  149092. }
  149093. }
  149094. declare module BABYLON {
  149095. /**
  149096. * Navigation plugin interface to add navigation constrained by a navigation mesh
  149097. */
  149098. export interface INavigationEnginePlugin {
  149099. /**
  149100. * plugin name
  149101. */
  149102. name: string;
  149103. /**
  149104. * Creates a navigation mesh
  149105. * @param meshes array of all the geometry used to compute the navigatio mesh
  149106. * @param parameters bunch of parameters used to filter geometry
  149107. */
  149108. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149109. /**
  149110. * Create a navigation mesh debug mesh
  149111. * @param scene is where the mesh will be added
  149112. * @returns debug display mesh
  149113. */
  149114. createDebugNavMesh(scene: Scene): Mesh;
  149115. /**
  149116. * Get a navigation mesh constrained position, closest to the parameter position
  149117. * @param position world position
  149118. * @returns the closest point to position constrained by the navigation mesh
  149119. */
  149120. getClosestPoint(position: Vector3): Vector3;
  149121. /**
  149122. * Get a navigation mesh constrained position, closest to the parameter position
  149123. * @param position world position
  149124. * @param result output the closest point to position constrained by the navigation mesh
  149125. */
  149126. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149127. /**
  149128. * Get a navigation mesh constrained position, within a particular radius
  149129. * @param position world position
  149130. * @param maxRadius the maximum distance to the constrained world position
  149131. * @returns the closest point to position constrained by the navigation mesh
  149132. */
  149133. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149134. /**
  149135. * Get a navigation mesh constrained position, within a particular radius
  149136. * @param position world position
  149137. * @param maxRadius the maximum distance to the constrained world position
  149138. * @param result output the closest point to position constrained by the navigation mesh
  149139. */
  149140. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149141. /**
  149142. * Compute the final position from a segment made of destination-position
  149143. * @param position world position
  149144. * @param destination world position
  149145. * @returns the resulting point along the navmesh
  149146. */
  149147. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149148. /**
  149149. * Compute the final position from a segment made of destination-position
  149150. * @param position world position
  149151. * @param destination world position
  149152. * @param result output the resulting point along the navmesh
  149153. */
  149154. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149155. /**
  149156. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149157. * @param start world position
  149158. * @param end world position
  149159. * @returns array containing world position composing the path
  149160. */
  149161. computePath(start: Vector3, end: Vector3): Vector3[];
  149162. /**
  149163. * If this plugin is supported
  149164. * @returns true if plugin is supported
  149165. */
  149166. isSupported(): boolean;
  149167. /**
  149168. * Create a new Crowd so you can add agents
  149169. * @param maxAgents the maximum agent count in the crowd
  149170. * @param maxAgentRadius the maximum radius an agent can have
  149171. * @param scene to attach the crowd to
  149172. * @returns the crowd you can add agents to
  149173. */
  149174. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149175. /**
  149176. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149177. * The queries will try to find a solution within those bounds
  149178. * default is (1,1,1)
  149179. * @param extent x,y,z value that define the extent around the queries point of reference
  149180. */
  149181. setDefaultQueryExtent(extent: Vector3): void;
  149182. /**
  149183. * Get the Bounding box extent specified by setDefaultQueryExtent
  149184. * @returns the box extent values
  149185. */
  149186. getDefaultQueryExtent(): Vector3;
  149187. /**
  149188. * build the navmesh from a previously saved state using getNavmeshData
  149189. * @param data the Uint8Array returned by getNavmeshData
  149190. */
  149191. buildFromNavmeshData(data: Uint8Array): void;
  149192. /**
  149193. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149194. * @returns data the Uint8Array that can be saved and reused
  149195. */
  149196. getNavmeshData(): Uint8Array;
  149197. /**
  149198. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149199. * @param result output the box extent values
  149200. */
  149201. getDefaultQueryExtentToRef(result: Vector3): void;
  149202. /**
  149203. * Release all resources
  149204. */
  149205. dispose(): void;
  149206. }
  149207. /**
  149208. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  149209. */
  149210. export interface ICrowd {
  149211. /**
  149212. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149213. * You can attach anything to that node. The node position is updated in the scene update tick.
  149214. * @param pos world position that will be constrained by the navigation mesh
  149215. * @param parameters agent parameters
  149216. * @param transform hooked to the agent that will be update by the scene
  149217. * @returns agent index
  149218. */
  149219. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149220. /**
  149221. * Returns the agent position in world space
  149222. * @param index agent index returned by addAgent
  149223. * @returns world space position
  149224. */
  149225. getAgentPosition(index: number): Vector3;
  149226. /**
  149227. * Gets the agent position result in world space
  149228. * @param index agent index returned by addAgent
  149229. * @param result output world space position
  149230. */
  149231. getAgentPositionToRef(index: number, result: Vector3): void;
  149232. /**
  149233. * Gets the agent velocity in world space
  149234. * @param index agent index returned by addAgent
  149235. * @returns world space velocity
  149236. */
  149237. getAgentVelocity(index: number): Vector3;
  149238. /**
  149239. * Gets the agent velocity result in world space
  149240. * @param index agent index returned by addAgent
  149241. * @param result output world space velocity
  149242. */
  149243. getAgentVelocityToRef(index: number, result: Vector3): void;
  149244. /**
  149245. * Gets the agent next target point on the path
  149246. * @param index agent index returned by addAgent
  149247. * @returns world space position
  149248. */
  149249. getAgentNextTargetPath(index: number): Vector3;
  149250. /**
  149251. * Gets the agent state
  149252. * @param index agent index returned by addAgent
  149253. * @returns agent state
  149254. */
  149255. getAgentState(index: number): number;
  149256. /**
  149257. * returns true if the agent in over an off mesh link connection
  149258. * @param index agent index returned by addAgent
  149259. * @returns true if over an off mesh link connection
  149260. */
  149261. overOffmeshConnection(index: number): boolean;
  149262. /**
  149263. * Gets the agent next target point on the path
  149264. * @param index agent index returned by addAgent
  149265. * @param result output world space position
  149266. */
  149267. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  149268. /**
  149269. * remove a particular agent previously created
  149270. * @param index agent index returned by addAgent
  149271. */
  149272. removeAgent(index: number): void;
  149273. /**
  149274. * get the list of all agents attached to this crowd
  149275. * @returns list of agent indices
  149276. */
  149277. getAgents(): number[];
  149278. /**
  149279. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  149280. * @param deltaTime in seconds
  149281. */
  149282. update(deltaTime: number): void;
  149283. /**
  149284. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  149285. * @param index agent index returned by addAgent
  149286. * @param destination targeted world position
  149287. */
  149288. agentGoto(index: number, destination: Vector3): void;
  149289. /**
  149290. * Teleport the agent to a new position
  149291. * @param index agent index returned by addAgent
  149292. * @param destination targeted world position
  149293. */
  149294. agentTeleport(index: number, destination: Vector3): void;
  149295. /**
  149296. * Update agent parameters
  149297. * @param index agent index returned by addAgent
  149298. * @param parameters agent parameters
  149299. */
  149300. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  149301. /**
  149302. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149303. * The queries will try to find a solution within those bounds
  149304. * default is (1,1,1)
  149305. * @param extent x,y,z value that define the extent around the queries point of reference
  149306. */
  149307. setDefaultQueryExtent(extent: Vector3): void;
  149308. /**
  149309. * Get the Bounding box extent specified by setDefaultQueryExtent
  149310. * @returns the box extent values
  149311. */
  149312. getDefaultQueryExtent(): Vector3;
  149313. /**
  149314. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149315. * @param result output the box extent values
  149316. */
  149317. getDefaultQueryExtentToRef(result: Vector3): void;
  149318. /**
  149319. * Release all resources
  149320. */
  149321. dispose(): void;
  149322. }
  149323. /**
  149324. * Configures an agent
  149325. */
  149326. export interface IAgentParameters {
  149327. /**
  149328. * Agent radius. [Limit: >= 0]
  149329. */
  149330. radius: number;
  149331. /**
  149332. * Agent height. [Limit: > 0]
  149333. */
  149334. height: number;
  149335. /**
  149336. * Maximum allowed acceleration. [Limit: >= 0]
  149337. */
  149338. maxAcceleration: number;
  149339. /**
  149340. * Maximum allowed speed. [Limit: >= 0]
  149341. */
  149342. maxSpeed: number;
  149343. /**
  149344. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  149345. */
  149346. collisionQueryRange: number;
  149347. /**
  149348. * The path visibility optimization range. [Limit: > 0]
  149349. */
  149350. pathOptimizationRange: number;
  149351. /**
  149352. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  149353. */
  149354. separationWeight: number;
  149355. }
  149356. /**
  149357. * Configures the navigation mesh creation
  149358. */
  149359. export interface INavMeshParameters {
  149360. /**
  149361. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  149362. */
  149363. cs: number;
  149364. /**
  149365. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  149366. */
  149367. ch: number;
  149368. /**
  149369. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  149370. */
  149371. walkableSlopeAngle: number;
  149372. /**
  149373. * Minimum floor to 'ceiling' height that will still allow the floor area to
  149374. * be considered walkable. [Limit: >= 3] [Units: vx]
  149375. */
  149376. walkableHeight: number;
  149377. /**
  149378. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  149379. */
  149380. walkableClimb: number;
  149381. /**
  149382. * The distance to erode/shrink the walkable area of the heightfield away from
  149383. * obstructions. [Limit: >=0] [Units: vx]
  149384. */
  149385. walkableRadius: number;
  149386. /**
  149387. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  149388. */
  149389. maxEdgeLen: number;
  149390. /**
  149391. * The maximum distance a simplfied contour's border edges should deviate
  149392. * the original raw contour. [Limit: >=0] [Units: vx]
  149393. */
  149394. maxSimplificationError: number;
  149395. /**
  149396. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  149397. */
  149398. minRegionArea: number;
  149399. /**
  149400. * Any regions with a span count smaller than this value will, if possible,
  149401. * be merged with larger regions. [Limit: >=0] [Units: vx]
  149402. */
  149403. mergeRegionArea: number;
  149404. /**
  149405. * The maximum number of vertices allowed for polygons generated during the
  149406. * contour to polygon conversion process. [Limit: >= 3]
  149407. */
  149408. maxVertsPerPoly: number;
  149409. /**
  149410. * Sets the sampling distance to use when generating the detail mesh.
  149411. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  149412. */
  149413. detailSampleDist: number;
  149414. /**
  149415. * The maximum distance the detail mesh surface should deviate from heightfield
  149416. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  149417. */
  149418. detailSampleMaxError: number;
  149419. }
  149420. }
  149421. declare module BABYLON {
  149422. /**
  149423. * RecastJS navigation plugin
  149424. */
  149425. export class RecastJSPlugin implements INavigationEnginePlugin {
  149426. /**
  149427. * Reference to the Recast library
  149428. */
  149429. bjsRECAST: any;
  149430. /**
  149431. * plugin name
  149432. */
  149433. name: string;
  149434. /**
  149435. * the first navmesh created. We might extend this to support multiple navmeshes
  149436. */
  149437. navMesh: any;
  149438. /**
  149439. * Initializes the recastJS plugin
  149440. * @param recastInjection can be used to inject your own recast reference
  149441. */
  149442. constructor(recastInjection?: any);
  149443. /**
  149444. * Creates a navigation mesh
  149445. * @param meshes array of all the geometry used to compute the navigatio mesh
  149446. * @param parameters bunch of parameters used to filter geometry
  149447. */
  149448. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149449. /**
  149450. * Create a navigation mesh debug mesh
  149451. * @param scene is where the mesh will be added
  149452. * @returns debug display mesh
  149453. */
  149454. createDebugNavMesh(scene: Scene): Mesh;
  149455. /**
  149456. * Get a navigation mesh constrained position, closest to the parameter position
  149457. * @param position world position
  149458. * @returns the closest point to position constrained by the navigation mesh
  149459. */
  149460. getClosestPoint(position: Vector3): Vector3;
  149461. /**
  149462. * Get a navigation mesh constrained position, closest to the parameter position
  149463. * @param position world position
  149464. * @param result output the closest point to position constrained by the navigation mesh
  149465. */
  149466. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149467. /**
  149468. * Get a navigation mesh constrained position, within a particular radius
  149469. * @param position world position
  149470. * @param maxRadius the maximum distance to the constrained world position
  149471. * @returns the closest point to position constrained by the navigation mesh
  149472. */
  149473. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149474. /**
  149475. * Get a navigation mesh constrained position, within a particular radius
  149476. * @param position world position
  149477. * @param maxRadius the maximum distance to the constrained world position
  149478. * @param result output the closest point to position constrained by the navigation mesh
  149479. */
  149480. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149481. /**
  149482. * Compute the final position from a segment made of destination-position
  149483. * @param position world position
  149484. * @param destination world position
  149485. * @returns the resulting point along the navmesh
  149486. */
  149487. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149488. /**
  149489. * Compute the final position from a segment made of destination-position
  149490. * @param position world position
  149491. * @param destination world position
  149492. * @param result output the resulting point along the navmesh
  149493. */
  149494. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149495. /**
  149496. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149497. * @param start world position
  149498. * @param end world position
  149499. * @returns array containing world position composing the path
  149500. */
  149501. computePath(start: Vector3, end: Vector3): Vector3[];
  149502. /**
  149503. * Create a new Crowd so you can add agents
  149504. * @param maxAgents the maximum agent count in the crowd
  149505. * @param maxAgentRadius the maximum radius an agent can have
  149506. * @param scene to attach the crowd to
  149507. * @returns the crowd you can add agents to
  149508. */
  149509. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149510. /**
  149511. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149512. * The queries will try to find a solution within those bounds
  149513. * default is (1,1,1)
  149514. * @param extent x,y,z value that define the extent around the queries point of reference
  149515. */
  149516. setDefaultQueryExtent(extent: Vector3): void;
  149517. /**
  149518. * Get the Bounding box extent specified by setDefaultQueryExtent
  149519. * @returns the box extent values
  149520. */
  149521. getDefaultQueryExtent(): Vector3;
  149522. /**
  149523. * build the navmesh from a previously saved state using getNavmeshData
  149524. * @param data the Uint8Array returned by getNavmeshData
  149525. */
  149526. buildFromNavmeshData(data: Uint8Array): void;
  149527. /**
  149528. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149529. * @returns data the Uint8Array that can be saved and reused
  149530. */
  149531. getNavmeshData(): Uint8Array;
  149532. /**
  149533. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149534. * @param result output the box extent values
  149535. */
  149536. getDefaultQueryExtentToRef(result: Vector3): void;
  149537. /**
  149538. * Disposes
  149539. */
  149540. dispose(): void;
  149541. /**
  149542. * If this plugin is supported
  149543. * @returns true if plugin is supported
  149544. */
  149545. isSupported(): boolean;
  149546. }
  149547. /**
  149548. * Recast detour crowd implementation
  149549. */
  149550. export class RecastJSCrowd implements ICrowd {
  149551. /**
  149552. * Recast/detour plugin
  149553. */
  149554. bjsRECASTPlugin: RecastJSPlugin;
  149555. /**
  149556. * Link to the detour crowd
  149557. */
  149558. recastCrowd: any;
  149559. /**
  149560. * One transform per agent
  149561. */
  149562. transforms: TransformNode[];
  149563. /**
  149564. * All agents created
  149565. */
  149566. agents: number[];
  149567. /**
  149568. * Link to the scene is kept to unregister the crowd from the scene
  149569. */
  149570. private _scene;
  149571. /**
  149572. * Observer for crowd updates
  149573. */
  149574. private _onBeforeAnimationsObserver;
  149575. /**
  149576. * Constructor
  149577. * @param plugin recastJS plugin
  149578. * @param maxAgents the maximum agent count in the crowd
  149579. * @param maxAgentRadius the maximum radius an agent can have
  149580. * @param scene to attach the crowd to
  149581. * @returns the crowd you can add agents to
  149582. */
  149583. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  149584. /**
  149585. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149586. * You can attach anything to that node. The node position is updated in the scene update tick.
  149587. * @param pos world position that will be constrained by the navigation mesh
  149588. * @param parameters agent parameters
  149589. * @param transform hooked to the agent that will be update by the scene
  149590. * @returns agent index
  149591. */
  149592. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149593. /**
  149594. * Returns the agent position in world space
  149595. * @param index agent index returned by addAgent
  149596. * @returns world space position
  149597. */
  149598. getAgentPosition(index: number): Vector3;
  149599. /**
  149600. * Returns the agent position result in world space
  149601. * @param index agent index returned by addAgent
  149602. * @param result output world space position
  149603. */
  149604. getAgentPositionToRef(index: number, result: Vector3): void;
  149605. /**
  149606. * Returns the agent velocity in world space
  149607. * @param index agent index returned by addAgent
  149608. * @returns world space velocity
  149609. */
  149610. getAgentVelocity(index: number): Vector3;
  149611. /**
  149612. * Returns the agent velocity result in world space
  149613. * @param index agent index returned by addAgent
  149614. * @param result output world space velocity
  149615. */
  149616. getAgentVelocityToRef(index: number, result: Vector3): void;
  149617. /**
  149618. * Returns the agent next target point on the path
  149619. * @param index agent index returned by addAgent
  149620. * @returns world space position
  149621. */
  149622. getAgentNextTargetPath(index: number): Vector3;
  149623. /**
  149624. * Returns the agent next target point on the path
  149625. * @param index agent index returned by addAgent
  149626. * @param result output world space position
  149627. */
  149628. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  149629. /**
  149630. * Gets the agent state
  149631. * @param index agent index returned by addAgent
  149632. * @returns agent state
  149633. */
  149634. getAgentState(index: number): number;
  149635. /**
  149636. * returns true if the agent in over an off mesh link connection
  149637. * @param index agent index returned by addAgent
  149638. * @returns true if over an off mesh link connection
  149639. */
  149640. overOffmeshConnection(index: number): boolean;
  149641. /**
  149642. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  149643. * @param index agent index returned by addAgent
  149644. * @param destination targeted world position
  149645. */
  149646. agentGoto(index: number, destination: Vector3): void;
  149647. /**
  149648. * Teleport the agent to a new position
  149649. * @param index agent index returned by addAgent
  149650. * @param destination targeted world position
  149651. */
  149652. agentTeleport(index: number, destination: Vector3): void;
  149653. /**
  149654. * Update agent parameters
  149655. * @param index agent index returned by addAgent
  149656. * @param parameters agent parameters
  149657. */
  149658. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  149659. /**
  149660. * remove a particular agent previously created
  149661. * @param index agent index returned by addAgent
  149662. */
  149663. removeAgent(index: number): void;
  149664. /**
  149665. * get the list of all agents attached to this crowd
  149666. * @returns list of agent indices
  149667. */
  149668. getAgents(): number[];
  149669. /**
  149670. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  149671. * @param deltaTime in seconds
  149672. */
  149673. update(deltaTime: number): void;
  149674. /**
  149675. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149676. * The queries will try to find a solution within those bounds
  149677. * default is (1,1,1)
  149678. * @param extent x,y,z value that define the extent around the queries point of reference
  149679. */
  149680. setDefaultQueryExtent(extent: Vector3): void;
  149681. /**
  149682. * Get the Bounding box extent specified by setDefaultQueryExtent
  149683. * @returns the box extent values
  149684. */
  149685. getDefaultQueryExtent(): Vector3;
  149686. /**
  149687. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149688. * @param result output the box extent values
  149689. */
  149690. getDefaultQueryExtentToRef(result: Vector3): void;
  149691. /**
  149692. * Release all resources
  149693. */
  149694. dispose(): void;
  149695. }
  149696. }
  149697. declare module BABYLON {
  149698. /**
  149699. * Class used to enable access to IndexedDB
  149700. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  149701. */
  149702. export class Database implements IOfflineProvider {
  149703. private _callbackManifestChecked;
  149704. private _currentSceneUrl;
  149705. private _db;
  149706. private _enableSceneOffline;
  149707. private _enableTexturesOffline;
  149708. private _manifestVersionFound;
  149709. private _mustUpdateRessources;
  149710. private _hasReachedQuota;
  149711. private _isSupported;
  149712. private _idbFactory;
  149713. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  149714. private static IsUASupportingBlobStorage;
  149715. /**
  149716. * Gets a boolean indicating if Database storate is enabled (off by default)
  149717. */
  149718. static IDBStorageEnabled: boolean;
  149719. /**
  149720. * Gets a boolean indicating if scene must be saved in the database
  149721. */
  149722. get enableSceneOffline(): boolean;
  149723. /**
  149724. * Gets a boolean indicating if textures must be saved in the database
  149725. */
  149726. get enableTexturesOffline(): boolean;
  149727. /**
  149728. * Creates a new Database
  149729. * @param urlToScene defines the url to load the scene
  149730. * @param callbackManifestChecked defines the callback to use when manifest is checked
  149731. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  149732. */
  149733. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  149734. private static _ParseURL;
  149735. private static _ReturnFullUrlLocation;
  149736. private _checkManifestFile;
  149737. /**
  149738. * Open the database and make it available
  149739. * @param successCallback defines the callback to call on success
  149740. * @param errorCallback defines the callback to call on error
  149741. */
  149742. open(successCallback: () => void, errorCallback: () => void): void;
  149743. /**
  149744. * Loads an image from the database
  149745. * @param url defines the url to load from
  149746. * @param image defines the target DOM image
  149747. */
  149748. loadImage(url: string, image: HTMLImageElement): void;
  149749. private _loadImageFromDBAsync;
  149750. private _saveImageIntoDBAsync;
  149751. private _checkVersionFromDB;
  149752. private _loadVersionFromDBAsync;
  149753. private _saveVersionIntoDBAsync;
  149754. /**
  149755. * Loads a file from database
  149756. * @param url defines the URL to load from
  149757. * @param sceneLoaded defines a callback to call on success
  149758. * @param progressCallBack defines a callback to call when progress changed
  149759. * @param errorCallback defines a callback to call on error
  149760. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  149761. */
  149762. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  149763. private _loadFileAsync;
  149764. private _saveFileAsync;
  149765. /**
  149766. * Validates if xhr data is correct
  149767. * @param xhr defines the request to validate
  149768. * @param dataType defines the expected data type
  149769. * @returns true if data is correct
  149770. */
  149771. private static _ValidateXHRData;
  149772. }
  149773. }
  149774. declare module BABYLON {
  149775. /** @hidden */
  149776. export var gpuUpdateParticlesPixelShader: {
  149777. name: string;
  149778. shader: string;
  149779. };
  149780. }
  149781. declare module BABYLON {
  149782. /** @hidden */
  149783. export var gpuUpdateParticlesVertexShader: {
  149784. name: string;
  149785. shader: string;
  149786. };
  149787. }
  149788. declare module BABYLON {
  149789. /** @hidden */
  149790. export var clipPlaneFragmentDeclaration2: {
  149791. name: string;
  149792. shader: string;
  149793. };
  149794. }
  149795. declare module BABYLON {
  149796. /** @hidden */
  149797. export var gpuRenderParticlesPixelShader: {
  149798. name: string;
  149799. shader: string;
  149800. };
  149801. }
  149802. declare module BABYLON {
  149803. /** @hidden */
  149804. export var clipPlaneVertexDeclaration2: {
  149805. name: string;
  149806. shader: string;
  149807. };
  149808. }
  149809. declare module BABYLON {
  149810. /** @hidden */
  149811. export var gpuRenderParticlesVertexShader: {
  149812. name: string;
  149813. shader: string;
  149814. };
  149815. }
  149816. declare module BABYLON {
  149817. /**
  149818. * This represents a GPU particle system in Babylon
  149819. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  149820. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  149821. */
  149822. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  149823. /**
  149824. * The layer mask we are rendering the particles through.
  149825. */
  149826. layerMask: number;
  149827. private _capacity;
  149828. private _activeCount;
  149829. private _currentActiveCount;
  149830. private _accumulatedCount;
  149831. private _renderEffect;
  149832. private _updateEffect;
  149833. private _buffer0;
  149834. private _buffer1;
  149835. private _spriteBuffer;
  149836. private _updateVAO;
  149837. private _renderVAO;
  149838. private _targetIndex;
  149839. private _sourceBuffer;
  149840. private _targetBuffer;
  149841. private _currentRenderId;
  149842. private _started;
  149843. private _stopped;
  149844. private _timeDelta;
  149845. private _randomTexture;
  149846. private _randomTexture2;
  149847. private _attributesStrideSize;
  149848. private _updateEffectOptions;
  149849. private _randomTextureSize;
  149850. private _actualFrame;
  149851. private _customEffect;
  149852. private readonly _rawTextureWidth;
  149853. /**
  149854. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  149855. */
  149856. static get IsSupported(): boolean;
  149857. /**
  149858. * An event triggered when the system is disposed.
  149859. */
  149860. onDisposeObservable: Observable<IParticleSystem>;
  149861. /**
  149862. * An event triggered when the system is stopped
  149863. */
  149864. onStoppedObservable: Observable<IParticleSystem>;
  149865. /**
  149866. * Gets the maximum number of particles active at the same time.
  149867. * @returns The max number of active particles.
  149868. */
  149869. getCapacity(): number;
  149870. /**
  149871. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  149872. * to override the particles.
  149873. */
  149874. forceDepthWrite: boolean;
  149875. /**
  149876. * Gets or set the number of active particles
  149877. */
  149878. get activeParticleCount(): number;
  149879. set activeParticleCount(value: number);
  149880. private _preWarmDone;
  149881. /**
  149882. * Specifies if the particles are updated in emitter local space or world space.
  149883. */
  149884. isLocal: boolean;
  149885. /** Gets or sets a matrix to use to compute projection */
  149886. defaultProjectionMatrix: Matrix;
  149887. /**
  149888. * Is this system ready to be used/rendered
  149889. * @return true if the system is ready
  149890. */
  149891. isReady(): boolean;
  149892. /**
  149893. * Gets if the system has been started. (Note: this will still be true after stop is called)
  149894. * @returns True if it has been started, otherwise false.
  149895. */
  149896. isStarted(): boolean;
  149897. /**
  149898. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  149899. * @returns True if it has been stopped, otherwise false.
  149900. */
  149901. isStopped(): boolean;
  149902. /**
  149903. * Gets a boolean indicating that the system is stopping
  149904. * @returns true if the system is currently stopping
  149905. */
  149906. isStopping(): boolean;
  149907. /**
  149908. * Gets the number of particles active at the same time.
  149909. * @returns The number of active particles.
  149910. */
  149911. getActiveCount(): number;
  149912. /**
  149913. * Starts the particle system and begins to emit
  149914. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  149915. */
  149916. start(delay?: number): void;
  149917. /**
  149918. * Stops the particle system.
  149919. */
  149920. stop(): void;
  149921. /**
  149922. * Remove all active particles
  149923. */
  149924. reset(): void;
  149925. /**
  149926. * Returns the string "GPUParticleSystem"
  149927. * @returns a string containing the class name
  149928. */
  149929. getClassName(): string;
  149930. /**
  149931. * Gets the custom effect used to render the particles
  149932. * @param blendMode Blend mode for which the effect should be retrieved
  149933. * @returns The effect
  149934. */
  149935. getCustomEffect(blendMode?: number): Nullable<Effect>;
  149936. /**
  149937. * Sets the custom effect used to render the particles
  149938. * @param effect The effect to set
  149939. * @param blendMode Blend mode for which the effect should be set
  149940. */
  149941. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  149942. /** @hidden */
  149943. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  149944. /**
  149945. * Observable that will be called just before the particles are drawn
  149946. */
  149947. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  149948. /**
  149949. * Gets the name of the particle vertex shader
  149950. */
  149951. get vertexShaderName(): string;
  149952. private _colorGradientsTexture;
  149953. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  149954. /**
  149955. * Adds a new color gradient
  149956. * @param gradient defines the gradient to use (between 0 and 1)
  149957. * @param color1 defines the color to affect to the specified gradient
  149958. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  149959. * @returns the current particle system
  149960. */
  149961. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  149962. private _refreshColorGradient;
  149963. /** Force the system to rebuild all gradients that need to be resync */
  149964. forceRefreshGradients(): void;
  149965. /**
  149966. * Remove a specific color gradient
  149967. * @param gradient defines the gradient to remove
  149968. * @returns the current particle system
  149969. */
  149970. removeColorGradient(gradient: number): GPUParticleSystem;
  149971. private _angularSpeedGradientsTexture;
  149972. private _sizeGradientsTexture;
  149973. private _velocityGradientsTexture;
  149974. private _limitVelocityGradientsTexture;
  149975. private _dragGradientsTexture;
  149976. private _addFactorGradient;
  149977. /**
  149978. * Adds a new size gradient
  149979. * @param gradient defines the gradient to use (between 0 and 1)
  149980. * @param factor defines the size factor to affect to the specified gradient
  149981. * @returns the current particle system
  149982. */
  149983. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  149984. /**
  149985. * Remove a specific size gradient
  149986. * @param gradient defines the gradient to remove
  149987. * @returns the current particle system
  149988. */
  149989. removeSizeGradient(gradient: number): GPUParticleSystem;
  149990. private _refreshFactorGradient;
  149991. /**
  149992. * Adds a new angular speed gradient
  149993. * @param gradient defines the gradient to use (between 0 and 1)
  149994. * @param factor defines the angular speed to affect to the specified gradient
  149995. * @returns the current particle system
  149996. */
  149997. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  149998. /**
  149999. * Remove a specific angular speed gradient
  150000. * @param gradient defines the gradient to remove
  150001. * @returns the current particle system
  150002. */
  150003. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  150004. /**
  150005. * Adds a new velocity gradient
  150006. * @param gradient defines the gradient to use (between 0 and 1)
  150007. * @param factor defines the velocity to affect to the specified gradient
  150008. * @returns the current particle system
  150009. */
  150010. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150011. /**
  150012. * Remove a specific velocity gradient
  150013. * @param gradient defines the gradient to remove
  150014. * @returns the current particle system
  150015. */
  150016. removeVelocityGradient(gradient: number): GPUParticleSystem;
  150017. /**
  150018. * Adds a new limit velocity gradient
  150019. * @param gradient defines the gradient to use (between 0 and 1)
  150020. * @param factor defines the limit velocity value to affect to the specified gradient
  150021. * @returns the current particle system
  150022. */
  150023. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150024. /**
  150025. * Remove a specific limit velocity gradient
  150026. * @param gradient defines the gradient to remove
  150027. * @returns the current particle system
  150028. */
  150029. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  150030. /**
  150031. * Adds a new drag gradient
  150032. * @param gradient defines the gradient to use (between 0 and 1)
  150033. * @param factor defines the drag value to affect to the specified gradient
  150034. * @returns the current particle system
  150035. */
  150036. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  150037. /**
  150038. * Remove a specific drag gradient
  150039. * @param gradient defines the gradient to remove
  150040. * @returns the current particle system
  150041. */
  150042. removeDragGradient(gradient: number): GPUParticleSystem;
  150043. /**
  150044. * Not supported by GPUParticleSystem
  150045. * @param gradient defines the gradient to use (between 0 and 1)
  150046. * @param factor defines the emit rate value to affect to the specified gradient
  150047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150048. * @returns the current particle system
  150049. */
  150050. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150051. /**
  150052. * Not supported by GPUParticleSystem
  150053. * @param gradient defines the gradient to remove
  150054. * @returns the current particle system
  150055. */
  150056. removeEmitRateGradient(gradient: number): IParticleSystem;
  150057. /**
  150058. * Not supported by GPUParticleSystem
  150059. * @param gradient defines the gradient to use (between 0 and 1)
  150060. * @param factor defines the start size value to affect to the specified gradient
  150061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150062. * @returns the current particle system
  150063. */
  150064. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150065. /**
  150066. * Not supported by GPUParticleSystem
  150067. * @param gradient defines the gradient to remove
  150068. * @returns the current particle system
  150069. */
  150070. removeStartSizeGradient(gradient: number): IParticleSystem;
  150071. /**
  150072. * Not supported by GPUParticleSystem
  150073. * @param gradient defines the gradient to use (between 0 and 1)
  150074. * @param min defines the color remap minimal range
  150075. * @param max defines the color remap maximal range
  150076. * @returns the current particle system
  150077. */
  150078. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150079. /**
  150080. * Not supported by GPUParticleSystem
  150081. * @param gradient defines the gradient to remove
  150082. * @returns the current particle system
  150083. */
  150084. removeColorRemapGradient(): IParticleSystem;
  150085. /**
  150086. * Not supported by GPUParticleSystem
  150087. * @param gradient defines the gradient to use (between 0 and 1)
  150088. * @param min defines the alpha remap minimal range
  150089. * @param max defines the alpha remap maximal range
  150090. * @returns the current particle system
  150091. */
  150092. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150093. /**
  150094. * Not supported by GPUParticleSystem
  150095. * @param gradient defines the gradient to remove
  150096. * @returns the current particle system
  150097. */
  150098. removeAlphaRemapGradient(): IParticleSystem;
  150099. /**
  150100. * Not supported by GPUParticleSystem
  150101. * @param gradient defines the gradient to use (between 0 and 1)
  150102. * @param color defines the color to affect to the specified gradient
  150103. * @returns the current particle system
  150104. */
  150105. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  150106. /**
  150107. * Not supported by GPUParticleSystem
  150108. * @param gradient defines the gradient to remove
  150109. * @returns the current particle system
  150110. */
  150111. removeRampGradient(): IParticleSystem;
  150112. /**
  150113. * Not supported by GPUParticleSystem
  150114. * @returns the list of ramp gradients
  150115. */
  150116. getRampGradients(): Nullable<Array<Color3Gradient>>;
  150117. /**
  150118. * Not supported by GPUParticleSystem
  150119. * Gets or sets a boolean indicating that ramp gradients must be used
  150120. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  150121. */
  150122. get useRampGradients(): boolean;
  150123. set useRampGradients(value: boolean);
  150124. /**
  150125. * Not supported by GPUParticleSystem
  150126. * @param gradient defines the gradient to use (between 0 and 1)
  150127. * @param factor defines the life time factor to affect to the specified gradient
  150128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150129. * @returns the current particle system
  150130. */
  150131. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150132. /**
  150133. * Not supported by GPUParticleSystem
  150134. * @param gradient defines the gradient to remove
  150135. * @returns the current particle system
  150136. */
  150137. removeLifeTimeGradient(gradient: number): IParticleSystem;
  150138. /**
  150139. * Instantiates a GPU particle system.
  150140. * 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.
  150141. * @param name The name of the particle system
  150142. * @param options The options used to create the system
  150143. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  150144. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  150145. * @param customEffect a custom effect used to change the way particles are rendered by default
  150146. */
  150147. constructor(name: string, options: Partial<{
  150148. capacity: number;
  150149. randomTextureSize: number;
  150150. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  150151. protected _reset(): void;
  150152. private _createUpdateVAO;
  150153. private _createRenderVAO;
  150154. private _initialize;
  150155. /** @hidden */
  150156. _recreateUpdateEffect(): void;
  150157. private _getEffect;
  150158. /**
  150159. * Fill the defines array according to the current settings of the particle system
  150160. * @param defines Array to be updated
  150161. * @param blendMode blend mode to take into account when updating the array
  150162. */
  150163. fillDefines(defines: Array<string>, blendMode?: number): void;
  150164. /**
  150165. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  150166. * @param uniforms Uniforms array to fill
  150167. * @param attributes Attributes array to fill
  150168. * @param samplers Samplers array to fill
  150169. */
  150170. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  150171. /** @hidden */
  150172. _recreateRenderEffect(): Effect;
  150173. /**
  150174. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  150175. * @param preWarm defines if we are in the pre-warmimg phase
  150176. */
  150177. animate(preWarm?: boolean): void;
  150178. private _createFactorGradientTexture;
  150179. private _createSizeGradientTexture;
  150180. private _createAngularSpeedGradientTexture;
  150181. private _createVelocityGradientTexture;
  150182. private _createLimitVelocityGradientTexture;
  150183. private _createDragGradientTexture;
  150184. private _createColorGradientTexture;
  150185. /**
  150186. * Renders the particle system in its current state
  150187. * @param preWarm defines if the system should only update the particles but not render them
  150188. * @returns the current number of particles
  150189. */
  150190. render(preWarm?: boolean): number;
  150191. /**
  150192. * Rebuilds the particle system
  150193. */
  150194. rebuild(): void;
  150195. private _releaseBuffers;
  150196. private _releaseVAOs;
  150197. /**
  150198. * Disposes the particle system and free the associated resources
  150199. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  150200. */
  150201. dispose(disposeTexture?: boolean): void;
  150202. /**
  150203. * Clones the particle system.
  150204. * @param name The name of the cloned object
  150205. * @param newEmitter The new emitter to use
  150206. * @returns the cloned particle system
  150207. */
  150208. clone(name: string, newEmitter: any): GPUParticleSystem;
  150209. /**
  150210. * Serializes the particle system to a JSON object
  150211. * @param serializeTexture defines if the texture must be serialized as well
  150212. * @returns the JSON object
  150213. */
  150214. serialize(serializeTexture?: boolean): any;
  150215. /**
  150216. * Parses a JSON object to create a GPU particle system.
  150217. * @param parsedParticleSystem The JSON object to parse
  150218. * @param sceneOrEngine The scene or the engine to create the particle system in
  150219. * @param rootUrl The root url to use to load external dependencies like texture
  150220. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  150221. * @returns the parsed GPU particle system
  150222. */
  150223. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  150224. }
  150225. }
  150226. declare module BABYLON {
  150227. /**
  150228. * Represents a set of particle systems working together to create a specific effect
  150229. */
  150230. export class ParticleSystemSet implements IDisposable {
  150231. /**
  150232. * Gets or sets base Assets URL
  150233. */
  150234. static BaseAssetsUrl: string;
  150235. private _emitterCreationOptions;
  150236. private _emitterNode;
  150237. /**
  150238. * Gets the particle system list
  150239. */
  150240. systems: IParticleSystem[];
  150241. /**
  150242. * Gets the emitter node used with this set
  150243. */
  150244. get emitterNode(): Nullable<TransformNode>;
  150245. /**
  150246. * Creates a new emitter mesh as a sphere
  150247. * @param options defines the options used to create the sphere
  150248. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  150249. * @param scene defines the hosting scene
  150250. */
  150251. setEmitterAsSphere(options: {
  150252. diameter: number;
  150253. segments: number;
  150254. color: Color3;
  150255. }, renderingGroupId: number, scene: Scene): void;
  150256. /**
  150257. * Starts all particle systems of the set
  150258. * @param emitter defines an optional mesh to use as emitter for the particle systems
  150259. */
  150260. start(emitter?: AbstractMesh): void;
  150261. /**
  150262. * Release all associated resources
  150263. */
  150264. dispose(): void;
  150265. /**
  150266. * Serialize the set into a JSON compatible object
  150267. * @param serializeTexture defines if the texture must be serialized as well
  150268. * @returns a JSON compatible representation of the set
  150269. */
  150270. serialize(serializeTexture?: boolean): any;
  150271. /**
  150272. * Parse a new ParticleSystemSet from a serialized source
  150273. * @param data defines a JSON compatible representation of the set
  150274. * @param scene defines the hosting scene
  150275. * @param gpu defines if we want GPU particles or CPU particles
  150276. * @returns a new ParticleSystemSet
  150277. */
  150278. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  150279. }
  150280. }
  150281. declare module BABYLON {
  150282. /**
  150283. * This class is made for on one-liner static method to help creating particle system set.
  150284. */
  150285. export class ParticleHelper {
  150286. /**
  150287. * Gets or sets base Assets URL
  150288. */
  150289. static BaseAssetsUrl: string;
  150290. /** Define the Url to load snippets */
  150291. static SnippetUrl: string;
  150292. /**
  150293. * Create a default particle system that you can tweak
  150294. * @param emitter defines the emitter to use
  150295. * @param capacity defines the system capacity (default is 500 particles)
  150296. * @param scene defines the hosting scene
  150297. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  150298. * @returns the new Particle system
  150299. */
  150300. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  150301. /**
  150302. * This is the main static method (one-liner) of this helper to create different particle systems
  150303. * @param type This string represents the type to the particle system to create
  150304. * @param scene The scene where the particle system should live
  150305. * @param gpu If the system will use gpu
  150306. * @returns the ParticleSystemSet created
  150307. */
  150308. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  150309. /**
  150310. * Static function used to export a particle system to a ParticleSystemSet variable.
  150311. * Please note that the emitter shape is not exported
  150312. * @param systems defines the particle systems to export
  150313. * @returns the created particle system set
  150314. */
  150315. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  150316. /**
  150317. * Creates a particle system from a snippet saved in a remote file
  150318. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  150319. * @param url defines the url to load from
  150320. * @param scene defines the hosting scene
  150321. * @param gpu If the system will use gpu
  150322. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150323. * @returns a promise that will resolve to the new particle system
  150324. */
  150325. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150326. /**
  150327. * Creates a particle system from a snippet saved by the particle system editor
  150328. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  150329. * @param scene defines the hosting scene
  150330. * @param gpu If the system will use gpu
  150331. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150332. * @returns a promise that will resolve to the new particle system
  150333. */
  150334. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150335. }
  150336. }
  150337. declare module BABYLON {
  150338. interface Engine {
  150339. /**
  150340. * Create an effect to use with particle systems.
  150341. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  150342. * the particle system for which you want to create a custom effect in the last parameter
  150343. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  150344. * @param uniformsNames defines a list of attribute names
  150345. * @param samplers defines an array of string used to represent textures
  150346. * @param defines defines the string containing the defines to use to compile the shaders
  150347. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  150348. * @param onCompiled defines a function to call when the effect creation is successful
  150349. * @param onError defines a function to call when the effect creation has failed
  150350. * @param particleSystem the particle system you want to create the effect for
  150351. * @returns the new Effect
  150352. */
  150353. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  150354. }
  150355. interface Mesh {
  150356. /**
  150357. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  150358. * @returns an array of IParticleSystem
  150359. */
  150360. getEmittedParticleSystems(): IParticleSystem[];
  150361. /**
  150362. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  150363. * @returns an array of IParticleSystem
  150364. */
  150365. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  150366. }
  150367. }
  150368. declare module BABYLON {
  150369. /** Defines the 4 color options */
  150370. export enum PointColor {
  150371. /** color value */
  150372. Color = 2,
  150373. /** uv value */
  150374. UV = 1,
  150375. /** random value */
  150376. Random = 0,
  150377. /** stated value */
  150378. Stated = 3
  150379. }
  150380. /**
  150381. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  150382. * 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.
  150383. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  150384. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  150385. *
  150386. * Full documentation here : TO BE ENTERED
  150387. */
  150388. export class PointsCloudSystem implements IDisposable {
  150389. /**
  150390. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  150391. * Example : var p = SPS.particles[i];
  150392. */
  150393. particles: CloudPoint[];
  150394. /**
  150395. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  150396. */
  150397. nbParticles: number;
  150398. /**
  150399. * This a counter for your own usage. It's not set by any SPS functions.
  150400. */
  150401. counter: number;
  150402. /**
  150403. * The PCS name. This name is also given to the underlying mesh.
  150404. */
  150405. name: string;
  150406. /**
  150407. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  150408. */
  150409. mesh: Mesh;
  150410. /**
  150411. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  150412. * Please read :
  150413. */
  150414. vars: any;
  150415. /**
  150416. * @hidden
  150417. */
  150418. _size: number;
  150419. private _scene;
  150420. private _promises;
  150421. private _positions;
  150422. private _indices;
  150423. private _normals;
  150424. private _colors;
  150425. private _uvs;
  150426. private _indices32;
  150427. private _positions32;
  150428. private _colors32;
  150429. private _uvs32;
  150430. private _updatable;
  150431. private _isVisibilityBoxLocked;
  150432. private _alwaysVisible;
  150433. private _groups;
  150434. private _groupCounter;
  150435. private _computeParticleColor;
  150436. private _computeParticleTexture;
  150437. private _computeParticleRotation;
  150438. private _computeBoundingBox;
  150439. private _isReady;
  150440. /**
  150441. * Creates a PCS (Points Cloud System) object
  150442. * @param name (String) is the PCS name, this will be the underlying mesh name
  150443. * @param pointSize (number) is the size for each point
  150444. * @param scene (Scene) is the scene in which the PCS is added
  150445. * @param options defines the options of the PCS e.g.
  150446. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  150447. */
  150448. constructor(name: string, pointSize: number, scene: Scene, options?: {
  150449. updatable?: boolean;
  150450. });
  150451. /**
  150452. * Builds the PCS underlying mesh. Returns a standard Mesh.
  150453. * If no points were added to the PCS, the returned mesh is just a single point.
  150454. * @returns a promise for the created mesh
  150455. */
  150456. buildMeshAsync(): Promise<Mesh>;
  150457. /**
  150458. * @hidden
  150459. */
  150460. private _buildMesh;
  150461. private _addParticle;
  150462. private _randomUnitVector;
  150463. private _getColorIndicesForCoord;
  150464. private _setPointsColorOrUV;
  150465. private _colorFromTexture;
  150466. private _calculateDensity;
  150467. /**
  150468. * Adds points to the PCS in random positions within a unit sphere
  150469. * @param nb (positive integer) the number of particles to be created from this model
  150470. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  150471. * @returns the number of groups in the system
  150472. */
  150473. addPoints(nb: number, pointFunction?: any): number;
  150474. /**
  150475. * Adds points to the PCS from the surface of the model shape
  150476. * @param mesh is any Mesh object that will be used as a surface model for the points
  150477. * @param nb (positive integer) the number of particles to be created from this model
  150478. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  150479. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  150480. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  150481. * @returns the number of groups in the system
  150482. */
  150483. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  150484. /**
  150485. * Adds points to the PCS inside the model shape
  150486. * @param mesh is any Mesh object that will be used as a surface model for the points
  150487. * @param nb (positive integer) the number of particles to be created from this model
  150488. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  150489. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  150490. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  150491. * @returns the number of groups in the system
  150492. */
  150493. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  150494. /**
  150495. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  150496. * This method calls `updateParticle()` for each particle of the SPS.
  150497. * For an animated SPS, it is usually called within the render loop.
  150498. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  150499. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  150500. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  150501. * @returns the PCS.
  150502. */
  150503. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  150504. /**
  150505. * Disposes the PCS.
  150506. */
  150507. dispose(): void;
  150508. /**
  150509. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  150510. * doc :
  150511. * @returns the PCS.
  150512. */
  150513. refreshVisibleSize(): PointsCloudSystem;
  150514. /**
  150515. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  150516. * @param size the size (float) of the visibility box
  150517. * note : this doesn't lock the PCS mesh bounding box.
  150518. * doc :
  150519. */
  150520. setVisibilityBox(size: number): void;
  150521. /**
  150522. * Gets whether the PCS is always visible or not
  150523. * doc :
  150524. */
  150525. get isAlwaysVisible(): boolean;
  150526. /**
  150527. * Sets the PCS as always visible or not
  150528. * doc :
  150529. */
  150530. set isAlwaysVisible(val: boolean);
  150531. /**
  150532. * Tells to `setParticles()` to compute the particle rotations or not
  150533. * Default value : false. The PCS is faster when it's set to false
  150534. * Note : particle rotations are only applied to parent particles
  150535. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  150536. */
  150537. set computeParticleRotation(val: boolean);
  150538. /**
  150539. * Tells to `setParticles()` to compute the particle colors or not.
  150540. * Default value : true. The PCS is faster when it's set to false.
  150541. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  150542. */
  150543. set computeParticleColor(val: boolean);
  150544. set computeParticleTexture(val: boolean);
  150545. /**
  150546. * Gets if `setParticles()` computes the particle colors or not.
  150547. * Default value : false. The PCS is faster when it's set to false.
  150548. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  150549. */
  150550. get computeParticleColor(): boolean;
  150551. /**
  150552. * Gets if `setParticles()` computes the particle textures or not.
  150553. * Default value : false. The PCS is faster when it's set to false.
  150554. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  150555. */
  150556. get computeParticleTexture(): boolean;
  150557. /**
  150558. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  150559. */
  150560. set computeBoundingBox(val: boolean);
  150561. /**
  150562. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  150563. */
  150564. get computeBoundingBox(): boolean;
  150565. /**
  150566. * This function does nothing. It may be overwritten to set all the particle first values.
  150567. * The PCS doesn't call this function, you may have to call it by your own.
  150568. * doc :
  150569. */
  150570. initParticles(): void;
  150571. /**
  150572. * This function does nothing. It may be overwritten to recycle a particle
  150573. * The PCS doesn't call this function, you can to call it
  150574. * doc :
  150575. * @param particle The particle to recycle
  150576. * @returns the recycled particle
  150577. */
  150578. recycleParticle(particle: CloudPoint): CloudPoint;
  150579. /**
  150580. * Updates a particle : this function should be overwritten by the user.
  150581. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  150582. * doc :
  150583. * @example : just set a particle position or velocity and recycle conditions
  150584. * @param particle The particle to update
  150585. * @returns the updated particle
  150586. */
  150587. updateParticle(particle: CloudPoint): CloudPoint;
  150588. /**
  150589. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  150590. * This does nothing and may be overwritten by the user.
  150591. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  150592. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  150593. * @param update the boolean update value actually passed to setParticles()
  150594. */
  150595. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  150596. /**
  150597. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  150598. * This will be passed three parameters.
  150599. * This does nothing and may be overwritten by the user.
  150600. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  150601. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  150602. * @param update the boolean update value actually passed to setParticles()
  150603. */
  150604. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  150605. }
  150606. }
  150607. declare module BABYLON {
  150608. /**
  150609. * Represents one particle of a points cloud system.
  150610. */
  150611. export class CloudPoint {
  150612. /**
  150613. * particle global index
  150614. */
  150615. idx: number;
  150616. /**
  150617. * The color of the particle
  150618. */
  150619. color: Nullable<Color4>;
  150620. /**
  150621. * The world space position of the particle.
  150622. */
  150623. position: Vector3;
  150624. /**
  150625. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  150626. */
  150627. rotation: Vector3;
  150628. /**
  150629. * The world space rotation quaternion of the particle.
  150630. */
  150631. rotationQuaternion: Nullable<Quaternion>;
  150632. /**
  150633. * The uv of the particle.
  150634. */
  150635. uv: Nullable<Vector2>;
  150636. /**
  150637. * The current speed of the particle.
  150638. */
  150639. velocity: Vector3;
  150640. /**
  150641. * The pivot point in the particle local space.
  150642. */
  150643. pivot: Vector3;
  150644. /**
  150645. * Must the particle be translated from its pivot point in its local space ?
  150646. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  150647. * Default : false
  150648. */
  150649. translateFromPivot: boolean;
  150650. /**
  150651. * Index of this particle in the global "positions" array (Internal use)
  150652. * @hidden
  150653. */
  150654. _pos: number;
  150655. /**
  150656. * @hidden Index of this particle in the global "indices" array (Internal use)
  150657. */
  150658. _ind: number;
  150659. /**
  150660. * Group this particle belongs to
  150661. */
  150662. _group: PointsGroup;
  150663. /**
  150664. * Group id of this particle
  150665. */
  150666. groupId: number;
  150667. /**
  150668. * Index of the particle in its group id (Internal use)
  150669. */
  150670. idxInGroup: number;
  150671. /**
  150672. * @hidden Particle BoundingInfo object (Internal use)
  150673. */
  150674. _boundingInfo: BoundingInfo;
  150675. /**
  150676. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  150677. */
  150678. _pcs: PointsCloudSystem;
  150679. /**
  150680. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  150681. */
  150682. _stillInvisible: boolean;
  150683. /**
  150684. * @hidden Last computed particle rotation matrix
  150685. */
  150686. _rotationMatrix: number[];
  150687. /**
  150688. * Parent particle Id, if any.
  150689. * Default null.
  150690. */
  150691. parentId: Nullable<number>;
  150692. /**
  150693. * @hidden Internal global position in the PCS.
  150694. */
  150695. _globalPosition: Vector3;
  150696. /**
  150697. * Creates a Point Cloud object.
  150698. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  150699. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  150700. * @param group (PointsGroup) is the group the particle belongs to
  150701. * @param groupId (integer) is the group identifier in the PCS.
  150702. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  150703. * @param pcs defines the PCS it is associated to
  150704. */
  150705. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  150706. /**
  150707. * get point size
  150708. */
  150709. get size(): Vector3;
  150710. /**
  150711. * Set point size
  150712. */
  150713. set size(scale: Vector3);
  150714. /**
  150715. * Legacy support, changed quaternion to rotationQuaternion
  150716. */
  150717. get quaternion(): Nullable<Quaternion>;
  150718. /**
  150719. * Legacy support, changed quaternion to rotationQuaternion
  150720. */
  150721. set quaternion(q: Nullable<Quaternion>);
  150722. /**
  150723. * Returns a boolean. True if the particle intersects a mesh, else false
  150724. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  150725. * @param target is the object (point or mesh) what the intersection is computed against
  150726. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  150727. * @returns true if it intersects
  150728. */
  150729. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  150730. /**
  150731. * get the rotation matrix of the particle
  150732. * @hidden
  150733. */
  150734. getRotationMatrix(m: Matrix): void;
  150735. }
  150736. /**
  150737. * Represents a group of points in a points cloud system
  150738. * * PCS internal tool, don't use it manually.
  150739. */
  150740. export class PointsGroup {
  150741. /**
  150742. * The group id
  150743. * @hidden
  150744. */
  150745. groupID: number;
  150746. /**
  150747. * image data for group (internal use)
  150748. * @hidden
  150749. */
  150750. _groupImageData: Nullable<ArrayBufferView>;
  150751. /**
  150752. * Image Width (internal use)
  150753. * @hidden
  150754. */
  150755. _groupImgWidth: number;
  150756. /**
  150757. * Image Height (internal use)
  150758. * @hidden
  150759. */
  150760. _groupImgHeight: number;
  150761. /**
  150762. * Custom position function (internal use)
  150763. * @hidden
  150764. */
  150765. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  150766. /**
  150767. * density per facet for surface points
  150768. * @hidden
  150769. */
  150770. _groupDensity: number[];
  150771. /**
  150772. * Only when points are colored by texture carries pointer to texture list array
  150773. * @hidden
  150774. */
  150775. _textureNb: number;
  150776. /**
  150777. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  150778. * PCS internal tool, don't use it manually.
  150779. * @hidden
  150780. */
  150781. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  150782. }
  150783. }
  150784. declare module BABYLON {
  150785. interface Scene {
  150786. /** @hidden (Backing field) */
  150787. _physicsEngine: Nullable<IPhysicsEngine>;
  150788. /** @hidden */
  150789. _physicsTimeAccumulator: number;
  150790. /**
  150791. * Gets the current physics engine
  150792. * @returns a IPhysicsEngine or null if none attached
  150793. */
  150794. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  150795. /**
  150796. * Enables physics to the current scene
  150797. * @param gravity defines the scene's gravity for the physics engine
  150798. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  150799. * @return a boolean indicating if the physics engine was initialized
  150800. */
  150801. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  150802. /**
  150803. * Disables and disposes the physics engine associated with the scene
  150804. */
  150805. disablePhysicsEngine(): void;
  150806. /**
  150807. * Gets a boolean indicating if there is an active physics engine
  150808. * @returns a boolean indicating if there is an active physics engine
  150809. */
  150810. isPhysicsEnabled(): boolean;
  150811. /**
  150812. * Deletes a physics compound impostor
  150813. * @param compound defines the compound to delete
  150814. */
  150815. deleteCompoundImpostor(compound: any): void;
  150816. /**
  150817. * An event triggered when physic simulation is about to be run
  150818. */
  150819. onBeforePhysicsObservable: Observable<Scene>;
  150820. /**
  150821. * An event triggered when physic simulation has been done
  150822. */
  150823. onAfterPhysicsObservable: Observable<Scene>;
  150824. }
  150825. interface AbstractMesh {
  150826. /** @hidden */
  150827. _physicsImpostor: Nullable<PhysicsImpostor>;
  150828. /**
  150829. * Gets or sets impostor used for physic simulation
  150830. * @see https://doc.babylonjs.com/features/physics_engine
  150831. */
  150832. physicsImpostor: Nullable<PhysicsImpostor>;
  150833. /**
  150834. * Gets the current physics impostor
  150835. * @see https://doc.babylonjs.com/features/physics_engine
  150836. * @returns a physics impostor or null
  150837. */
  150838. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  150839. /** Apply a physic impulse to the mesh
  150840. * @param force defines the force to apply
  150841. * @param contactPoint defines where to apply the force
  150842. * @returns the current mesh
  150843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  150844. */
  150845. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  150846. /**
  150847. * Creates a physic joint between two meshes
  150848. * @param otherMesh defines the other mesh to use
  150849. * @param pivot1 defines the pivot to use on this mesh
  150850. * @param pivot2 defines the pivot to use on the other mesh
  150851. * @param options defines additional options (can be plugin dependent)
  150852. * @returns the current mesh
  150853. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  150854. */
  150855. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  150856. /** @hidden */
  150857. _disposePhysicsObserver: Nullable<Observer<Node>>;
  150858. }
  150859. /**
  150860. * Defines the physics engine scene component responsible to manage a physics engine
  150861. */
  150862. export class PhysicsEngineSceneComponent implements ISceneComponent {
  150863. /**
  150864. * The component name helpful to identify the component in the list of scene components.
  150865. */
  150866. readonly name: string;
  150867. /**
  150868. * The scene the component belongs to.
  150869. */
  150870. scene: Scene;
  150871. /**
  150872. * Creates a new instance of the component for the given scene
  150873. * @param scene Defines the scene to register the component in
  150874. */
  150875. constructor(scene: Scene);
  150876. /**
  150877. * Registers the component in a given scene
  150878. */
  150879. register(): void;
  150880. /**
  150881. * Rebuilds the elements related to this component in case of
  150882. * context lost for instance.
  150883. */
  150884. rebuild(): void;
  150885. /**
  150886. * Disposes the component and the associated ressources
  150887. */
  150888. dispose(): void;
  150889. }
  150890. }
  150891. declare module BABYLON {
  150892. /**
  150893. * A helper for physics simulations
  150894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150895. */
  150896. export class PhysicsHelper {
  150897. private _scene;
  150898. private _physicsEngine;
  150899. /**
  150900. * Initializes the Physics helper
  150901. * @param scene Babylon.js scene
  150902. */
  150903. constructor(scene: Scene);
  150904. /**
  150905. * Applies a radial explosion impulse
  150906. * @param origin the origin of the explosion
  150907. * @param radiusOrEventOptions the radius or the options of radial explosion
  150908. * @param strength the explosion strength
  150909. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150910. * @returns A physics radial explosion event, or null
  150911. */
  150912. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150913. /**
  150914. * Applies a radial explosion force
  150915. * @param origin the origin of the explosion
  150916. * @param radiusOrEventOptions the radius or the options of radial explosion
  150917. * @param strength the explosion strength
  150918. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150919. * @returns A physics radial explosion event, or null
  150920. */
  150921. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150922. /**
  150923. * Creates a gravitational field
  150924. * @param origin the origin of the explosion
  150925. * @param radiusOrEventOptions the radius or the options of radial explosion
  150926. * @param strength the explosion strength
  150927. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150928. * @returns A physics gravitational field event, or null
  150929. */
  150930. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  150931. /**
  150932. * Creates a physics updraft event
  150933. * @param origin the origin of the updraft
  150934. * @param radiusOrEventOptions the radius or the options of the updraft
  150935. * @param strength the strength of the updraft
  150936. * @param height the height of the updraft
  150937. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  150938. * @returns A physics updraft event, or null
  150939. */
  150940. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  150941. /**
  150942. * Creates a physics vortex event
  150943. * @param origin the of the vortex
  150944. * @param radiusOrEventOptions the radius or the options of the vortex
  150945. * @param strength the strength of the vortex
  150946. * @param height the height of the vortex
  150947. * @returns a Physics vortex event, or null
  150948. * A physics vortex event or null
  150949. */
  150950. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  150951. }
  150952. /**
  150953. * Represents a physics radial explosion event
  150954. */
  150955. class PhysicsRadialExplosionEvent {
  150956. private _scene;
  150957. private _options;
  150958. private _sphere;
  150959. private _dataFetched;
  150960. /**
  150961. * Initializes a radial explosioin event
  150962. * @param _scene BabylonJS scene
  150963. * @param _options The options for the vortex event
  150964. */
  150965. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  150966. /**
  150967. * Returns the data related to the radial explosion event (sphere).
  150968. * @returns The radial explosion event data
  150969. */
  150970. getData(): PhysicsRadialExplosionEventData;
  150971. /**
  150972. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  150973. * @param impostor A physics imposter
  150974. * @param origin the origin of the explosion
  150975. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  150976. */
  150977. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  150978. /**
  150979. * Triggers affecterd impostors callbacks
  150980. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  150981. */
  150982. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  150983. /**
  150984. * Disposes the sphere.
  150985. * @param force Specifies if the sphere should be disposed by force
  150986. */
  150987. dispose(force?: boolean): void;
  150988. /*** Helpers ***/
  150989. private _prepareSphere;
  150990. private _intersectsWithSphere;
  150991. }
  150992. /**
  150993. * Represents a gravitational field event
  150994. */
  150995. class PhysicsGravitationalFieldEvent {
  150996. private _physicsHelper;
  150997. private _scene;
  150998. private _origin;
  150999. private _options;
  151000. private _tickCallback;
  151001. private _sphere;
  151002. private _dataFetched;
  151003. /**
  151004. * Initializes the physics gravitational field event
  151005. * @param _physicsHelper A physics helper
  151006. * @param _scene BabylonJS scene
  151007. * @param _origin The origin position of the gravitational field event
  151008. * @param _options The options for the vortex event
  151009. */
  151010. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  151011. /**
  151012. * Returns the data related to the gravitational field event (sphere).
  151013. * @returns A gravitational field event
  151014. */
  151015. getData(): PhysicsGravitationalFieldEventData;
  151016. /**
  151017. * Enables the gravitational field.
  151018. */
  151019. enable(): void;
  151020. /**
  151021. * Disables the gravitational field.
  151022. */
  151023. disable(): void;
  151024. /**
  151025. * Disposes the sphere.
  151026. * @param force The force to dispose from the gravitational field event
  151027. */
  151028. dispose(force?: boolean): void;
  151029. private _tick;
  151030. }
  151031. /**
  151032. * Represents a physics updraft event
  151033. */
  151034. class PhysicsUpdraftEvent {
  151035. private _scene;
  151036. private _origin;
  151037. private _options;
  151038. private _physicsEngine;
  151039. private _originTop;
  151040. private _originDirection;
  151041. private _tickCallback;
  151042. private _cylinder;
  151043. private _cylinderPosition;
  151044. private _dataFetched;
  151045. /**
  151046. * Initializes the physics updraft event
  151047. * @param _scene BabylonJS scene
  151048. * @param _origin The origin position of the updraft
  151049. * @param _options The options for the updraft event
  151050. */
  151051. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  151052. /**
  151053. * Returns the data related to the updraft event (cylinder).
  151054. * @returns A physics updraft event
  151055. */
  151056. getData(): PhysicsUpdraftEventData;
  151057. /**
  151058. * Enables the updraft.
  151059. */
  151060. enable(): void;
  151061. /**
  151062. * Disables the updraft.
  151063. */
  151064. disable(): void;
  151065. /**
  151066. * Disposes the cylinder.
  151067. * @param force Specifies if the updraft should be disposed by force
  151068. */
  151069. dispose(force?: boolean): void;
  151070. private getImpostorHitData;
  151071. private _tick;
  151072. /*** Helpers ***/
  151073. private _prepareCylinder;
  151074. private _intersectsWithCylinder;
  151075. }
  151076. /**
  151077. * Represents a physics vortex event
  151078. */
  151079. class PhysicsVortexEvent {
  151080. private _scene;
  151081. private _origin;
  151082. private _options;
  151083. private _physicsEngine;
  151084. private _originTop;
  151085. private _tickCallback;
  151086. private _cylinder;
  151087. private _cylinderPosition;
  151088. private _dataFetched;
  151089. /**
  151090. * Initializes the physics vortex event
  151091. * @param _scene The BabylonJS scene
  151092. * @param _origin The origin position of the vortex
  151093. * @param _options The options for the vortex event
  151094. */
  151095. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  151096. /**
  151097. * Returns the data related to the vortex event (cylinder).
  151098. * @returns The physics vortex event data
  151099. */
  151100. getData(): PhysicsVortexEventData;
  151101. /**
  151102. * Enables the vortex.
  151103. */
  151104. enable(): void;
  151105. /**
  151106. * Disables the cortex.
  151107. */
  151108. disable(): void;
  151109. /**
  151110. * Disposes the sphere.
  151111. * @param force
  151112. */
  151113. dispose(force?: boolean): void;
  151114. private getImpostorHitData;
  151115. private _tick;
  151116. /*** Helpers ***/
  151117. private _prepareCylinder;
  151118. private _intersectsWithCylinder;
  151119. }
  151120. /**
  151121. * Options fot the radial explosion event
  151122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151123. */
  151124. export class PhysicsRadialExplosionEventOptions {
  151125. /**
  151126. * The radius of the sphere for the radial explosion.
  151127. */
  151128. radius: number;
  151129. /**
  151130. * The strenth of the explosion.
  151131. */
  151132. strength: number;
  151133. /**
  151134. * The strenght of the force in correspondence to the distance of the affected object
  151135. */
  151136. falloff: PhysicsRadialImpulseFalloff;
  151137. /**
  151138. * Sphere options for the radial explosion.
  151139. */
  151140. sphere: {
  151141. segments: number;
  151142. diameter: number;
  151143. };
  151144. /**
  151145. * Sphere options for the radial explosion.
  151146. */
  151147. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  151148. }
  151149. /**
  151150. * Options fot the updraft event
  151151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151152. */
  151153. export class PhysicsUpdraftEventOptions {
  151154. /**
  151155. * The radius of the cylinder for the vortex
  151156. */
  151157. radius: number;
  151158. /**
  151159. * The strenth of the updraft.
  151160. */
  151161. strength: number;
  151162. /**
  151163. * The height of the cylinder for the updraft.
  151164. */
  151165. height: number;
  151166. /**
  151167. * The mode for the the updraft.
  151168. */
  151169. updraftMode: PhysicsUpdraftMode;
  151170. }
  151171. /**
  151172. * Options fot the vortex event
  151173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151174. */
  151175. export class PhysicsVortexEventOptions {
  151176. /**
  151177. * The radius of the cylinder for the vortex
  151178. */
  151179. radius: number;
  151180. /**
  151181. * The strenth of the vortex.
  151182. */
  151183. strength: number;
  151184. /**
  151185. * The height of the cylinder for the vortex.
  151186. */
  151187. height: number;
  151188. /**
  151189. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  151190. */
  151191. centripetalForceThreshold: number;
  151192. /**
  151193. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  151194. */
  151195. centripetalForceMultiplier: number;
  151196. /**
  151197. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  151198. */
  151199. centrifugalForceMultiplier: number;
  151200. /**
  151201. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  151202. */
  151203. updraftForceMultiplier: number;
  151204. }
  151205. /**
  151206. * The strenght of the force in correspondence to the distance of the affected object
  151207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151208. */
  151209. export enum PhysicsRadialImpulseFalloff {
  151210. /** Defines that impulse is constant in strength across it's whole radius */
  151211. Constant = 0,
  151212. /** Defines that impulse gets weaker if it's further from the origin */
  151213. Linear = 1
  151214. }
  151215. /**
  151216. * The strength of the force in correspondence to the distance of the affected object
  151217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151218. */
  151219. export enum PhysicsUpdraftMode {
  151220. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  151221. Center = 0,
  151222. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  151223. Perpendicular = 1
  151224. }
  151225. /**
  151226. * Interface for a physics hit data
  151227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151228. */
  151229. export interface PhysicsHitData {
  151230. /**
  151231. * The force applied at the contact point
  151232. */
  151233. force: Vector3;
  151234. /**
  151235. * The contact point
  151236. */
  151237. contactPoint: Vector3;
  151238. /**
  151239. * The distance from the origin to the contact point
  151240. */
  151241. distanceFromOrigin: number;
  151242. }
  151243. /**
  151244. * Interface for radial explosion event data
  151245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151246. */
  151247. export interface PhysicsRadialExplosionEventData {
  151248. /**
  151249. * A sphere used for the radial explosion event
  151250. */
  151251. sphere: Mesh;
  151252. }
  151253. /**
  151254. * Interface for gravitational field event data
  151255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151256. */
  151257. export interface PhysicsGravitationalFieldEventData {
  151258. /**
  151259. * A sphere mesh used for the gravitational field event
  151260. */
  151261. sphere: Mesh;
  151262. }
  151263. /**
  151264. * Interface for updraft event data
  151265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151266. */
  151267. export interface PhysicsUpdraftEventData {
  151268. /**
  151269. * A cylinder used for the updraft event
  151270. */
  151271. cylinder: Mesh;
  151272. }
  151273. /**
  151274. * Interface for vortex event data
  151275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151276. */
  151277. export interface PhysicsVortexEventData {
  151278. /**
  151279. * A cylinder used for the vortex event
  151280. */
  151281. cylinder: Mesh;
  151282. }
  151283. /**
  151284. * Interface for an affected physics impostor
  151285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151286. */
  151287. export interface PhysicsAffectedImpostorWithData {
  151288. /**
  151289. * The impostor affected by the effect
  151290. */
  151291. impostor: PhysicsImpostor;
  151292. /**
  151293. * The data about the hit/horce from the explosion
  151294. */
  151295. hitData: PhysicsHitData;
  151296. }
  151297. }
  151298. declare module BABYLON {
  151299. /** @hidden */
  151300. export var blackAndWhitePixelShader: {
  151301. name: string;
  151302. shader: string;
  151303. };
  151304. }
  151305. declare module BABYLON {
  151306. /**
  151307. * Post process used to render in black and white
  151308. */
  151309. export class BlackAndWhitePostProcess extends PostProcess {
  151310. /**
  151311. * Linear about to convert he result to black and white (default: 1)
  151312. */
  151313. degree: number;
  151314. /**
  151315. * Gets a string identifying the name of the class
  151316. * @returns "BlackAndWhitePostProcess" string
  151317. */
  151318. getClassName(): string;
  151319. /**
  151320. * Creates a black and white post process
  151321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  151322. * @param name The name of the effect.
  151323. * @param options The required width/height ratio to downsize to before computing the render pass.
  151324. * @param camera The camera to apply the render pass to.
  151325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151326. * @param engine The engine which the post process will be applied. (default: current engine)
  151327. * @param reusable If the post process can be reused on the same frame. (default: false)
  151328. */
  151329. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151330. /** @hidden */
  151331. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  151332. }
  151333. }
  151334. declare module BABYLON {
  151335. /**
  151336. * This represents a set of one or more post processes in Babylon.
  151337. * A post process can be used to apply a shader to a texture after it is rendered.
  151338. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151339. */
  151340. export class PostProcessRenderEffect {
  151341. private _postProcesses;
  151342. private _getPostProcesses;
  151343. private _singleInstance;
  151344. private _cameras;
  151345. private _indicesForCamera;
  151346. /**
  151347. * Name of the effect
  151348. * @hidden
  151349. */
  151350. _name: string;
  151351. /**
  151352. * Instantiates a post process render effect.
  151353. * A post process can be used to apply a shader to a texture after it is rendered.
  151354. * @param engine The engine the effect is tied to
  151355. * @param name The name of the effect
  151356. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  151357. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  151358. */
  151359. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  151360. /**
  151361. * Checks if all the post processes in the effect are supported.
  151362. */
  151363. get isSupported(): boolean;
  151364. /**
  151365. * Updates the current state of the effect
  151366. * @hidden
  151367. */
  151368. _update(): void;
  151369. /**
  151370. * Attaches the effect on cameras
  151371. * @param cameras The camera to attach to.
  151372. * @hidden
  151373. */
  151374. _attachCameras(cameras: Camera): void;
  151375. /**
  151376. * Attaches the effect on cameras
  151377. * @param cameras The camera to attach to.
  151378. * @hidden
  151379. */
  151380. _attachCameras(cameras: Camera[]): void;
  151381. /**
  151382. * Detaches the effect on cameras
  151383. * @param cameras The camera to detatch from.
  151384. * @hidden
  151385. */
  151386. _detachCameras(cameras: Camera): void;
  151387. /**
  151388. * Detatches the effect on cameras
  151389. * @param cameras The camera to detatch from.
  151390. * @hidden
  151391. */
  151392. _detachCameras(cameras: Camera[]): void;
  151393. /**
  151394. * Enables the effect on given cameras
  151395. * @param cameras The camera to enable.
  151396. * @hidden
  151397. */
  151398. _enable(cameras: Camera): void;
  151399. /**
  151400. * Enables the effect on given cameras
  151401. * @param cameras The camera to enable.
  151402. * @hidden
  151403. */
  151404. _enable(cameras: Nullable<Camera[]>): void;
  151405. /**
  151406. * Disables the effect on the given cameras
  151407. * @param cameras The camera to disable.
  151408. * @hidden
  151409. */
  151410. _disable(cameras: Camera): void;
  151411. /**
  151412. * Disables the effect on the given cameras
  151413. * @param cameras The camera to disable.
  151414. * @hidden
  151415. */
  151416. _disable(cameras: Nullable<Camera[]>): void;
  151417. /**
  151418. * Gets a list of the post processes contained in the effect.
  151419. * @param camera The camera to get the post processes on.
  151420. * @returns The list of the post processes in the effect.
  151421. */
  151422. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  151423. }
  151424. }
  151425. declare module BABYLON {
  151426. /** @hidden */
  151427. export var extractHighlightsPixelShader: {
  151428. name: string;
  151429. shader: string;
  151430. };
  151431. }
  151432. declare module BABYLON {
  151433. /**
  151434. * 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.
  151435. */
  151436. export class ExtractHighlightsPostProcess extends PostProcess {
  151437. /**
  151438. * The luminance threshold, pixels below this value will be set to black.
  151439. */
  151440. threshold: number;
  151441. /** @hidden */
  151442. _exposure: number;
  151443. /**
  151444. * Post process which has the input texture to be used when performing highlight extraction
  151445. * @hidden
  151446. */
  151447. _inputPostProcess: Nullable<PostProcess>;
  151448. /**
  151449. * Gets a string identifying the name of the class
  151450. * @returns "ExtractHighlightsPostProcess" string
  151451. */
  151452. getClassName(): string;
  151453. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151454. }
  151455. }
  151456. declare module BABYLON {
  151457. /** @hidden */
  151458. export var bloomMergePixelShader: {
  151459. name: string;
  151460. shader: string;
  151461. };
  151462. }
  151463. declare module BABYLON {
  151464. /**
  151465. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  151466. */
  151467. export class BloomMergePostProcess extends PostProcess {
  151468. /** Weight of the bloom to be added to the original input. */
  151469. weight: number;
  151470. /**
  151471. * Gets a string identifying the name of the class
  151472. * @returns "BloomMergePostProcess" string
  151473. */
  151474. getClassName(): string;
  151475. /**
  151476. * Creates a new instance of @see BloomMergePostProcess
  151477. * @param name The name of the effect.
  151478. * @param originalFromInput Post process which's input will be used for the merge.
  151479. * @param blurred Blurred highlights post process which's output will be used.
  151480. * @param weight Weight of the bloom to be added to the original input.
  151481. * @param options The required width/height ratio to downsize to before computing the render pass.
  151482. * @param camera The camera to apply the render pass to.
  151483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151484. * @param engine The engine which the post process will be applied. (default: current engine)
  151485. * @param reusable If the post process can be reused on the same frame. (default: false)
  151486. * @param textureType Type of textures used when performing the post process. (default: 0)
  151487. * @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)
  151488. */
  151489. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  151490. /** Weight of the bloom to be added to the original input. */
  151491. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151492. }
  151493. }
  151494. declare module BABYLON {
  151495. /**
  151496. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  151497. */
  151498. export class BloomEffect extends PostProcessRenderEffect {
  151499. private bloomScale;
  151500. /**
  151501. * @hidden Internal
  151502. */
  151503. _effects: Array<PostProcess>;
  151504. /**
  151505. * @hidden Internal
  151506. */
  151507. _downscale: ExtractHighlightsPostProcess;
  151508. private _blurX;
  151509. private _blurY;
  151510. private _merge;
  151511. /**
  151512. * The luminance threshold to find bright areas of the image to bloom.
  151513. */
  151514. get threshold(): number;
  151515. set threshold(value: number);
  151516. /**
  151517. * The strength of the bloom.
  151518. */
  151519. get weight(): number;
  151520. set weight(value: number);
  151521. /**
  151522. * Specifies the size of the bloom blur kernel, relative to the final output size
  151523. */
  151524. get kernel(): number;
  151525. set kernel(value: number);
  151526. /**
  151527. * Creates a new instance of @see BloomEffect
  151528. * @param scene The scene the effect belongs to.
  151529. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  151530. * @param bloomKernel The size of the kernel to be used when applying the blur.
  151531. * @param bloomWeight The the strength of bloom.
  151532. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  151533. * @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)
  151534. */
  151535. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  151536. /**
  151537. * Disposes each of the internal effects for a given camera.
  151538. * @param camera The camera to dispose the effect on.
  151539. */
  151540. disposeEffects(camera: Camera): void;
  151541. /**
  151542. * @hidden Internal
  151543. */
  151544. _updateEffects(): void;
  151545. /**
  151546. * Internal
  151547. * @returns if all the contained post processes are ready.
  151548. * @hidden
  151549. */
  151550. _isReady(): boolean;
  151551. }
  151552. }
  151553. declare module BABYLON {
  151554. /** @hidden */
  151555. export var chromaticAberrationPixelShader: {
  151556. name: string;
  151557. shader: string;
  151558. };
  151559. }
  151560. declare module BABYLON {
  151561. /**
  151562. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  151563. */
  151564. export class ChromaticAberrationPostProcess extends PostProcess {
  151565. /**
  151566. * The amount of seperation of rgb channels (default: 30)
  151567. */
  151568. aberrationAmount: number;
  151569. /**
  151570. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  151571. */
  151572. radialIntensity: number;
  151573. /**
  151574. * 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))
  151575. */
  151576. direction: Vector2;
  151577. /**
  151578. * 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))
  151579. */
  151580. centerPosition: Vector2;
  151581. /** The width of the screen to apply the effect on */
  151582. screenWidth: number;
  151583. /** The height of the screen to apply the effect on */
  151584. screenHeight: number;
  151585. /**
  151586. * Gets a string identifying the name of the class
  151587. * @returns "ChromaticAberrationPostProcess" string
  151588. */
  151589. getClassName(): string;
  151590. /**
  151591. * Creates a new instance ChromaticAberrationPostProcess
  151592. * @param name The name of the effect.
  151593. * @param screenWidth The width of the screen to apply the effect on.
  151594. * @param screenHeight The height of the screen to apply the effect on.
  151595. * @param options The required width/height ratio to downsize to before computing the render pass.
  151596. * @param camera The camera to apply the render pass to.
  151597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151598. * @param engine The engine which the post process will be applied. (default: current engine)
  151599. * @param reusable If the post process can be reused on the same frame. (default: false)
  151600. * @param textureType Type of textures used when performing the post process. (default: 0)
  151601. * @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)
  151602. */
  151603. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151604. /** @hidden */
  151605. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  151606. }
  151607. }
  151608. declare module BABYLON {
  151609. /** @hidden */
  151610. export var circleOfConfusionPixelShader: {
  151611. name: string;
  151612. shader: string;
  151613. };
  151614. }
  151615. declare module BABYLON {
  151616. /**
  151617. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  151618. */
  151619. export class CircleOfConfusionPostProcess extends PostProcess {
  151620. /**
  151621. * 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.
  151622. */
  151623. lensSize: number;
  151624. /**
  151625. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  151626. */
  151627. fStop: number;
  151628. /**
  151629. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  151630. */
  151631. focusDistance: number;
  151632. /**
  151633. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  151634. */
  151635. focalLength: number;
  151636. /**
  151637. * Gets a string identifying the name of the class
  151638. * @returns "CircleOfConfusionPostProcess" string
  151639. */
  151640. getClassName(): string;
  151641. private _depthTexture;
  151642. /**
  151643. * Creates a new instance CircleOfConfusionPostProcess
  151644. * @param name The name of the effect.
  151645. * @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.
  151646. * @param options The required width/height ratio to downsize to before computing the render pass.
  151647. * @param camera The camera to apply the render pass to.
  151648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151649. * @param engine The engine which the post process will be applied. (default: current engine)
  151650. * @param reusable If the post process can be reused on the same frame. (default: false)
  151651. * @param textureType Type of textures used when performing the post process. (default: 0)
  151652. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  151653. */
  151654. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151655. /**
  151656. * 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.
  151657. */
  151658. set depthTexture(value: RenderTargetTexture);
  151659. }
  151660. }
  151661. declare module BABYLON {
  151662. /** @hidden */
  151663. export var colorCorrectionPixelShader: {
  151664. name: string;
  151665. shader: string;
  151666. };
  151667. }
  151668. declare module BABYLON {
  151669. /**
  151670. *
  151671. * This post-process allows the modification of rendered colors by using
  151672. * a 'look-up table' (LUT). This effect is also called Color Grading.
  151673. *
  151674. * The object needs to be provided an url to a texture containing the color
  151675. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  151676. * Use an image editing software to tweak the LUT to match your needs.
  151677. *
  151678. * For an example of a color LUT, see here:
  151679. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  151680. * For explanations on color grading, see here:
  151681. * @see http://udn.epicgames.com/Three/ColorGrading.html
  151682. *
  151683. */
  151684. export class ColorCorrectionPostProcess extends PostProcess {
  151685. private _colorTableTexture;
  151686. /**
  151687. * Gets the color table url used to create the LUT texture
  151688. */
  151689. colorTableUrl: string;
  151690. /**
  151691. * Gets a string identifying the name of the class
  151692. * @returns "ColorCorrectionPostProcess" string
  151693. */
  151694. getClassName(): string;
  151695. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151696. /** @hidden */
  151697. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  151698. }
  151699. }
  151700. declare module BABYLON {
  151701. /** @hidden */
  151702. export var convolutionPixelShader: {
  151703. name: string;
  151704. shader: string;
  151705. };
  151706. }
  151707. declare module BABYLON {
  151708. /**
  151709. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  151710. * input texture to perform effects such as edge detection or sharpening
  151711. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  151712. */
  151713. export class ConvolutionPostProcess extends PostProcess {
  151714. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  151715. kernel: number[];
  151716. /**
  151717. * Gets a string identifying the name of the class
  151718. * @returns "ConvolutionPostProcess" string
  151719. */
  151720. getClassName(): string;
  151721. /**
  151722. * Creates a new instance ConvolutionPostProcess
  151723. * @param name The name of the effect.
  151724. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  151725. * @param options The required width/height ratio to downsize to before computing the render pass.
  151726. * @param camera The camera to apply the render pass to.
  151727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151728. * @param engine The engine which the post process will be applied. (default: current engine)
  151729. * @param reusable If the post process can be reused on the same frame. (default: false)
  151730. * @param textureType Type of textures used when performing the post process. (default: 0)
  151731. */
  151732. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151733. /** @hidden */
  151734. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  151735. /**
  151736. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151737. */
  151738. static EdgeDetect0Kernel: number[];
  151739. /**
  151740. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151741. */
  151742. static EdgeDetect1Kernel: number[];
  151743. /**
  151744. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151745. */
  151746. static EdgeDetect2Kernel: number[];
  151747. /**
  151748. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151749. */
  151750. static SharpenKernel: number[];
  151751. /**
  151752. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151753. */
  151754. static EmbossKernel: number[];
  151755. /**
  151756. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151757. */
  151758. static GaussianKernel: number[];
  151759. }
  151760. }
  151761. declare module BABYLON {
  151762. /**
  151763. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  151764. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  151765. * based on samples that have a large difference in distance than the center pixel.
  151766. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  151767. */
  151768. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  151769. /**
  151770. * The direction the blur should be applied
  151771. */
  151772. direction: Vector2;
  151773. /**
  151774. * Gets a string identifying the name of the class
  151775. * @returns "DepthOfFieldBlurPostProcess" string
  151776. */
  151777. getClassName(): string;
  151778. /**
  151779. * Creates a new instance CircleOfConfusionPostProcess
  151780. * @param name The name of the effect.
  151781. * @param scene The scene the effect belongs to.
  151782. * @param direction The direction the blur should be applied.
  151783. * @param kernel The size of the kernel used to blur.
  151784. * @param options The required width/height ratio to downsize to before computing the render pass.
  151785. * @param camera The camera to apply the render pass to.
  151786. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  151787. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  151788. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151789. * @param engine The engine which the post process will be applied. (default: current engine)
  151790. * @param reusable If the post process can be reused on the same frame. (default: false)
  151791. * @param textureType Type of textures used when performing the post process. (default: 0)
  151792. * @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)
  151793. */
  151794. 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);
  151795. }
  151796. }
  151797. declare module BABYLON {
  151798. /** @hidden */
  151799. export var depthOfFieldMergePixelShader: {
  151800. name: string;
  151801. shader: string;
  151802. };
  151803. }
  151804. declare module BABYLON {
  151805. /**
  151806. * Options to be set when merging outputs from the default pipeline.
  151807. */
  151808. export class DepthOfFieldMergePostProcessOptions {
  151809. /**
  151810. * The original image to merge on top of
  151811. */
  151812. originalFromInput: PostProcess;
  151813. /**
  151814. * Parameters to perform the merge of the depth of field effect
  151815. */
  151816. depthOfField?: {
  151817. circleOfConfusion: PostProcess;
  151818. blurSteps: Array<PostProcess>;
  151819. };
  151820. /**
  151821. * Parameters to perform the merge of bloom effect
  151822. */
  151823. bloom?: {
  151824. blurred: PostProcess;
  151825. weight: number;
  151826. };
  151827. }
  151828. /**
  151829. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  151830. */
  151831. export class DepthOfFieldMergePostProcess extends PostProcess {
  151832. private blurSteps;
  151833. /**
  151834. * Gets a string identifying the name of the class
  151835. * @returns "DepthOfFieldMergePostProcess" string
  151836. */
  151837. getClassName(): string;
  151838. /**
  151839. * Creates a new instance of DepthOfFieldMergePostProcess
  151840. * @param name The name of the effect.
  151841. * @param originalFromInput Post process which's input will be used for the merge.
  151842. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  151843. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  151844. * @param options The required width/height ratio to downsize to before computing the render pass.
  151845. * @param camera The camera to apply the render pass to.
  151846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151847. * @param engine The engine which the post process will be applied. (default: current engine)
  151848. * @param reusable If the post process can be reused on the same frame. (default: false)
  151849. * @param textureType Type of textures used when performing the post process. (default: 0)
  151850. * @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)
  151851. */
  151852. 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);
  151853. /**
  151854. * Updates the effect with the current post process compile time values and recompiles the shader.
  151855. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  151856. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  151857. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  151858. * @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
  151859. * @param onCompiled Called when the shader has been compiled.
  151860. * @param onError Called if there is an error when compiling a shader.
  151861. */
  151862. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  151863. }
  151864. }
  151865. declare module BABYLON {
  151866. /**
  151867. * Specifies the level of max blur that should be applied when using the depth of field effect
  151868. */
  151869. export enum DepthOfFieldEffectBlurLevel {
  151870. /**
  151871. * Subtle blur
  151872. */
  151873. Low = 0,
  151874. /**
  151875. * Medium blur
  151876. */
  151877. Medium = 1,
  151878. /**
  151879. * Large blur
  151880. */
  151881. High = 2
  151882. }
  151883. /**
  151884. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  151885. */
  151886. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  151887. private _circleOfConfusion;
  151888. /**
  151889. * @hidden Internal, blurs from high to low
  151890. */
  151891. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  151892. private _depthOfFieldBlurY;
  151893. private _dofMerge;
  151894. /**
  151895. * @hidden Internal post processes in depth of field effect
  151896. */
  151897. _effects: Array<PostProcess>;
  151898. /**
  151899. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  151900. */
  151901. set focalLength(value: number);
  151902. get focalLength(): number;
  151903. /**
  151904. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  151905. */
  151906. set fStop(value: number);
  151907. get fStop(): number;
  151908. /**
  151909. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  151910. */
  151911. set focusDistance(value: number);
  151912. get focusDistance(): number;
  151913. /**
  151914. * 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.
  151915. */
  151916. set lensSize(value: number);
  151917. get lensSize(): number;
  151918. /**
  151919. * Creates a new instance DepthOfFieldEffect
  151920. * @param scene The scene the effect belongs to.
  151921. * @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.
  151922. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  151923. * @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)
  151924. */
  151925. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  151926. /**
  151927. * Get the current class name of the current effet
  151928. * @returns "DepthOfFieldEffect"
  151929. */
  151930. getClassName(): string;
  151931. /**
  151932. * 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.
  151933. */
  151934. set depthTexture(value: RenderTargetTexture);
  151935. /**
  151936. * Disposes each of the internal effects for a given camera.
  151937. * @param camera The camera to dispose the effect on.
  151938. */
  151939. disposeEffects(camera: Camera): void;
  151940. /**
  151941. * @hidden Internal
  151942. */
  151943. _updateEffects(): void;
  151944. /**
  151945. * Internal
  151946. * @returns if all the contained post processes are ready.
  151947. * @hidden
  151948. */
  151949. _isReady(): boolean;
  151950. }
  151951. }
  151952. declare module BABYLON {
  151953. /** @hidden */
  151954. export var displayPassPixelShader: {
  151955. name: string;
  151956. shader: string;
  151957. };
  151958. }
  151959. declare module BABYLON {
  151960. /**
  151961. * DisplayPassPostProcess which produces an output the same as it's input
  151962. */
  151963. export class DisplayPassPostProcess extends PostProcess {
  151964. /**
  151965. * Gets a string identifying the name of the class
  151966. * @returns "DisplayPassPostProcess" string
  151967. */
  151968. getClassName(): string;
  151969. /**
  151970. * Creates the DisplayPassPostProcess
  151971. * @param name The name of the effect.
  151972. * @param options The required width/height ratio to downsize to before computing the render pass.
  151973. * @param camera The camera to apply the render pass to.
  151974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151975. * @param engine The engine which the post process will be applied. (default: current engine)
  151976. * @param reusable If the post process can be reused on the same frame. (default: false)
  151977. */
  151978. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151979. /** @hidden */
  151980. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  151981. }
  151982. }
  151983. declare module BABYLON {
  151984. /** @hidden */
  151985. export var filterPixelShader: {
  151986. name: string;
  151987. shader: string;
  151988. };
  151989. }
  151990. declare module BABYLON {
  151991. /**
  151992. * Applies a kernel filter to the image
  151993. */
  151994. export class FilterPostProcess extends PostProcess {
  151995. /** The matrix to be applied to the image */
  151996. kernelMatrix: Matrix;
  151997. /**
  151998. * Gets a string identifying the name of the class
  151999. * @returns "FilterPostProcess" string
  152000. */
  152001. getClassName(): string;
  152002. /**
  152003. *
  152004. * @param name The name of the effect.
  152005. * @param kernelMatrix The matrix to be applied to the image
  152006. * @param options The required width/height ratio to downsize to before computing the render pass.
  152007. * @param camera The camera to apply the render pass to.
  152008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152009. * @param engine The engine which the post process will be applied. (default: current engine)
  152010. * @param reusable If the post process can be reused on the same frame. (default: false)
  152011. */
  152012. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152013. /** @hidden */
  152014. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  152015. }
  152016. }
  152017. declare module BABYLON {
  152018. /** @hidden */
  152019. export var fxaaPixelShader: {
  152020. name: string;
  152021. shader: string;
  152022. };
  152023. }
  152024. declare module BABYLON {
  152025. /** @hidden */
  152026. export var fxaaVertexShader: {
  152027. name: string;
  152028. shader: string;
  152029. };
  152030. }
  152031. declare module BABYLON {
  152032. /**
  152033. * Fxaa post process
  152034. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  152035. */
  152036. export class FxaaPostProcess extends PostProcess {
  152037. /**
  152038. * Gets a string identifying the name of the class
  152039. * @returns "FxaaPostProcess" string
  152040. */
  152041. getClassName(): string;
  152042. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152043. private _getDefines;
  152044. /** @hidden */
  152045. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  152046. }
  152047. }
  152048. declare module BABYLON {
  152049. /** @hidden */
  152050. export var grainPixelShader: {
  152051. name: string;
  152052. shader: string;
  152053. };
  152054. }
  152055. declare module BABYLON {
  152056. /**
  152057. * The GrainPostProcess adds noise to the image at mid luminance levels
  152058. */
  152059. export class GrainPostProcess extends PostProcess {
  152060. /**
  152061. * The intensity of the grain added (default: 30)
  152062. */
  152063. intensity: number;
  152064. /**
  152065. * If the grain should be randomized on every frame
  152066. */
  152067. animated: boolean;
  152068. /**
  152069. * Gets a string identifying the name of the class
  152070. * @returns "GrainPostProcess" string
  152071. */
  152072. getClassName(): string;
  152073. /**
  152074. * Creates a new instance of @see GrainPostProcess
  152075. * @param name The name of the effect.
  152076. * @param options The required width/height ratio to downsize to before computing the render pass.
  152077. * @param camera The camera to apply the render pass to.
  152078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152079. * @param engine The engine which the post process will be applied. (default: current engine)
  152080. * @param reusable If the post process can be reused on the same frame. (default: false)
  152081. * @param textureType Type of textures used when performing the post process. (default: 0)
  152082. * @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)
  152083. */
  152084. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152085. /** @hidden */
  152086. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  152087. }
  152088. }
  152089. declare module BABYLON {
  152090. /** @hidden */
  152091. export var highlightsPixelShader: {
  152092. name: string;
  152093. shader: string;
  152094. };
  152095. }
  152096. declare module BABYLON {
  152097. /**
  152098. * Extracts highlights from the image
  152099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152100. */
  152101. export class HighlightsPostProcess extends PostProcess {
  152102. /**
  152103. * Gets a string identifying the name of the class
  152104. * @returns "HighlightsPostProcess" string
  152105. */
  152106. getClassName(): string;
  152107. /**
  152108. * Extracts highlights from the image
  152109. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152110. * @param name The name of the effect.
  152111. * @param options The required width/height ratio to downsize to before computing the render pass.
  152112. * @param camera The camera to apply the render pass to.
  152113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152114. * @param engine The engine which the post process will be applied. (default: current engine)
  152115. * @param reusable If the post process can be reused on the same frame. (default: false)
  152116. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  152117. */
  152118. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152119. }
  152120. }
  152121. declare module BABYLON {
  152122. /**
  152123. * Contains all parameters needed for the prepass to perform
  152124. * motion blur
  152125. */
  152126. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  152127. /**
  152128. * Is motion blur enabled
  152129. */
  152130. enabled: boolean;
  152131. /**
  152132. * Name of the configuration
  152133. */
  152134. name: string;
  152135. /**
  152136. * Textures that should be present in the MRT for this effect to work
  152137. */
  152138. readonly texturesRequired: number[];
  152139. }
  152140. }
  152141. declare module BABYLON {
  152142. interface Scene {
  152143. /** @hidden (Backing field) */
  152144. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152145. /**
  152146. * Gets or Sets the current geometry buffer associated to the scene.
  152147. */
  152148. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152149. /**
  152150. * Enables a GeometryBufferRender and associates it with the scene
  152151. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  152152. * @returns the GeometryBufferRenderer
  152153. */
  152154. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  152155. /**
  152156. * Disables the GeometryBufferRender associated with the scene
  152157. */
  152158. disableGeometryBufferRenderer(): void;
  152159. }
  152160. /**
  152161. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152162. * in several rendering techniques.
  152163. */
  152164. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  152165. /**
  152166. * The component name helpful to identify the component in the list of scene components.
  152167. */
  152168. readonly name: string;
  152169. /**
  152170. * The scene the component belongs to.
  152171. */
  152172. scene: Scene;
  152173. /**
  152174. * Creates a new instance of the component for the given scene
  152175. * @param scene Defines the scene to register the component in
  152176. */
  152177. constructor(scene: Scene);
  152178. /**
  152179. * Registers the component in a given scene
  152180. */
  152181. register(): void;
  152182. /**
  152183. * Rebuilds the elements related to this component in case of
  152184. * context lost for instance.
  152185. */
  152186. rebuild(): void;
  152187. /**
  152188. * Disposes the component and the associated ressources
  152189. */
  152190. dispose(): void;
  152191. private _gatherRenderTargets;
  152192. }
  152193. }
  152194. declare module BABYLON {
  152195. /** @hidden */
  152196. export var motionBlurPixelShader: {
  152197. name: string;
  152198. shader: string;
  152199. };
  152200. }
  152201. declare module BABYLON {
  152202. /**
  152203. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  152204. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  152205. * As an example, all you have to do is to create the post-process:
  152206. * var mb = new BABYLON.MotionBlurPostProcess(
  152207. * 'mb', // The name of the effect.
  152208. * scene, // The scene containing the objects to blur according to their velocity.
  152209. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  152210. * camera // The camera to apply the render pass to.
  152211. * );
  152212. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  152213. */
  152214. export class MotionBlurPostProcess extends PostProcess {
  152215. /**
  152216. * Defines how much the image is blurred by the movement. Default value is equal to 1
  152217. */
  152218. motionStrength: number;
  152219. /**
  152220. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  152221. */
  152222. get motionBlurSamples(): number;
  152223. /**
  152224. * Sets the number of iterations to be used for motion blur quality
  152225. */
  152226. set motionBlurSamples(samples: number);
  152227. private _motionBlurSamples;
  152228. private _forceGeometryBuffer;
  152229. private _geometryBufferRenderer;
  152230. private _prePassRenderer;
  152231. /**
  152232. * Gets a string identifying the name of the class
  152233. * @returns "MotionBlurPostProcess" string
  152234. */
  152235. getClassName(): string;
  152236. /**
  152237. * Creates a new instance MotionBlurPostProcess
  152238. * @param name The name of the effect.
  152239. * @param scene The scene containing the objects to blur according to their velocity.
  152240. * @param options The required width/height ratio to downsize to before computing the render pass.
  152241. * @param camera The camera to apply the render pass to.
  152242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152243. * @param engine The engine which the post process will be applied. (default: current engine)
  152244. * @param reusable If the post process can be reused on the same frame. (default: false)
  152245. * @param textureType Type of textures used when performing the post process. (default: 0)
  152246. * @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)
  152247. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152248. */
  152249. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152250. /**
  152251. * Excludes the given skinned mesh from computing bones velocities.
  152252. * 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.
  152253. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  152254. */
  152255. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152256. /**
  152257. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  152258. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  152259. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  152260. */
  152261. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152262. /**
  152263. * Disposes the post process.
  152264. * @param camera The camera to dispose the post process on.
  152265. */
  152266. dispose(camera?: Camera): void;
  152267. /** @hidden */
  152268. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  152269. }
  152270. }
  152271. declare module BABYLON {
  152272. /** @hidden */
  152273. export var refractionPixelShader: {
  152274. name: string;
  152275. shader: string;
  152276. };
  152277. }
  152278. declare module BABYLON {
  152279. /**
  152280. * Post process which applies a refractin texture
  152281. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152282. */
  152283. export class RefractionPostProcess extends PostProcess {
  152284. private _refTexture;
  152285. private _ownRefractionTexture;
  152286. /** the base color of the refraction (used to taint the rendering) */
  152287. color: Color3;
  152288. /** simulated refraction depth */
  152289. depth: number;
  152290. /** the coefficient of the base color (0 to remove base color tainting) */
  152291. colorLevel: number;
  152292. /** Gets the url used to load the refraction texture */
  152293. refractionTextureUrl: string;
  152294. /**
  152295. * Gets or sets the refraction texture
  152296. * Please note that you are responsible for disposing the texture if you set it manually
  152297. */
  152298. get refractionTexture(): Texture;
  152299. set refractionTexture(value: Texture);
  152300. /**
  152301. * Gets a string identifying the name of the class
  152302. * @returns "RefractionPostProcess" string
  152303. */
  152304. getClassName(): string;
  152305. /**
  152306. * Initializes the RefractionPostProcess
  152307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152308. * @param name The name of the effect.
  152309. * @param refractionTextureUrl Url of the refraction texture to use
  152310. * @param color the base color of the refraction (used to taint the rendering)
  152311. * @param depth simulated refraction depth
  152312. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  152313. * @param camera The camera to apply the render pass to.
  152314. * @param options The required width/height ratio to downsize to before computing the render pass.
  152315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152316. * @param engine The engine which the post process will be applied. (default: current engine)
  152317. * @param reusable If the post process can be reused on the same frame. (default: false)
  152318. */
  152319. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152320. /**
  152321. * Disposes of the post process
  152322. * @param camera Camera to dispose post process on
  152323. */
  152324. dispose(camera: Camera): void;
  152325. /** @hidden */
  152326. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  152327. }
  152328. }
  152329. declare module BABYLON {
  152330. /** @hidden */
  152331. export var sharpenPixelShader: {
  152332. name: string;
  152333. shader: string;
  152334. };
  152335. }
  152336. declare module BABYLON {
  152337. /**
  152338. * The SharpenPostProcess applies a sharpen kernel to every pixel
  152339. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  152340. */
  152341. export class SharpenPostProcess extends PostProcess {
  152342. /**
  152343. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  152344. */
  152345. colorAmount: number;
  152346. /**
  152347. * How much sharpness should be applied (default: 0.3)
  152348. */
  152349. edgeAmount: number;
  152350. /**
  152351. * Gets a string identifying the name of the class
  152352. * @returns "SharpenPostProcess" string
  152353. */
  152354. getClassName(): string;
  152355. /**
  152356. * Creates a new instance ConvolutionPostProcess
  152357. * @param name The name of the effect.
  152358. * @param options The required width/height ratio to downsize to before computing the render pass.
  152359. * @param camera The camera to apply the render pass to.
  152360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152361. * @param engine The engine which the post process will be applied. (default: current engine)
  152362. * @param reusable If the post process can be reused on the same frame. (default: false)
  152363. * @param textureType Type of textures used when performing the post process. (default: 0)
  152364. * @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)
  152365. */
  152366. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152367. /** @hidden */
  152368. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  152369. }
  152370. }
  152371. declare module BABYLON {
  152372. /**
  152373. * PostProcessRenderPipeline
  152374. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152375. */
  152376. export class PostProcessRenderPipeline {
  152377. private engine;
  152378. private _renderEffects;
  152379. private _renderEffectsForIsolatedPass;
  152380. /**
  152381. * List of inspectable custom properties (used by the Inspector)
  152382. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  152383. */
  152384. inspectableCustomProperties: IInspectable[];
  152385. /**
  152386. * @hidden
  152387. */
  152388. protected _cameras: Camera[];
  152389. /** @hidden */
  152390. _name: string;
  152391. /**
  152392. * Gets pipeline name
  152393. */
  152394. get name(): string;
  152395. /** Gets the list of attached cameras */
  152396. get cameras(): Camera[];
  152397. /**
  152398. * Initializes a PostProcessRenderPipeline
  152399. * @param engine engine to add the pipeline to
  152400. * @param name name of the pipeline
  152401. */
  152402. constructor(engine: Engine, name: string);
  152403. /**
  152404. * Gets the class name
  152405. * @returns "PostProcessRenderPipeline"
  152406. */
  152407. getClassName(): string;
  152408. /**
  152409. * If all the render effects in the pipeline are supported
  152410. */
  152411. get isSupported(): boolean;
  152412. /**
  152413. * Adds an effect to the pipeline
  152414. * @param renderEffect the effect to add
  152415. */
  152416. addEffect(renderEffect: PostProcessRenderEffect): void;
  152417. /** @hidden */
  152418. _rebuild(): void;
  152419. /** @hidden */
  152420. _enableEffect(renderEffectName: string, cameras: Camera): void;
  152421. /** @hidden */
  152422. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  152423. /** @hidden */
  152424. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  152425. /** @hidden */
  152426. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  152427. /** @hidden */
  152428. _attachCameras(cameras: Camera, unique: boolean): void;
  152429. /** @hidden */
  152430. _attachCameras(cameras: Camera[], unique: boolean): void;
  152431. /** @hidden */
  152432. _detachCameras(cameras: Camera): void;
  152433. /** @hidden */
  152434. _detachCameras(cameras: Nullable<Camera[]>): void;
  152435. /** @hidden */
  152436. _update(): void;
  152437. /** @hidden */
  152438. _reset(): void;
  152439. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  152440. /**
  152441. * Sets the required values to the prepass renderer.
  152442. * @param prePassRenderer defines the prepass renderer to setup.
  152443. * @returns true if the pre pass is needed.
  152444. */
  152445. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  152446. /**
  152447. * Disposes of the pipeline
  152448. */
  152449. dispose(): void;
  152450. }
  152451. }
  152452. declare module BABYLON {
  152453. /**
  152454. * PostProcessRenderPipelineManager class
  152455. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152456. */
  152457. export class PostProcessRenderPipelineManager {
  152458. private _renderPipelines;
  152459. /**
  152460. * Initializes a PostProcessRenderPipelineManager
  152461. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152462. */
  152463. constructor();
  152464. /**
  152465. * Gets the list of supported render pipelines
  152466. */
  152467. get supportedPipelines(): PostProcessRenderPipeline[];
  152468. /**
  152469. * Adds a pipeline to the manager
  152470. * @param renderPipeline The pipeline to add
  152471. */
  152472. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  152473. /**
  152474. * Attaches a camera to the pipeline
  152475. * @param renderPipelineName The name of the pipeline to attach to
  152476. * @param cameras the camera to attach
  152477. * @param unique if the camera can be attached multiple times to the pipeline
  152478. */
  152479. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  152480. /**
  152481. * Detaches a camera from the pipeline
  152482. * @param renderPipelineName The name of the pipeline to detach from
  152483. * @param cameras the camera to detach
  152484. */
  152485. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  152486. /**
  152487. * Enables an effect by name on a pipeline
  152488. * @param renderPipelineName the name of the pipeline to enable the effect in
  152489. * @param renderEffectName the name of the effect to enable
  152490. * @param cameras the cameras that the effect should be enabled on
  152491. */
  152492. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  152493. /**
  152494. * Disables an effect by name on a pipeline
  152495. * @param renderPipelineName the name of the pipeline to disable the effect in
  152496. * @param renderEffectName the name of the effect to disable
  152497. * @param cameras the cameras that the effect should be disabled on
  152498. */
  152499. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  152500. /**
  152501. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  152502. */
  152503. update(): void;
  152504. /** @hidden */
  152505. _rebuild(): void;
  152506. /**
  152507. * Disposes of the manager and pipelines
  152508. */
  152509. dispose(): void;
  152510. }
  152511. }
  152512. declare module BABYLON {
  152513. interface Scene {
  152514. /** @hidden (Backing field) */
  152515. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  152516. /**
  152517. * Gets the postprocess render pipeline manager
  152518. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152519. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  152520. */
  152521. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  152522. }
  152523. /**
  152524. * Defines the Render Pipeline scene component responsible to rendering pipelines
  152525. */
  152526. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  152527. /**
  152528. * The component name helpfull to identify the component in the list of scene components.
  152529. */
  152530. readonly name: string;
  152531. /**
  152532. * The scene the component belongs to.
  152533. */
  152534. scene: Scene;
  152535. /**
  152536. * Creates a new instance of the component for the given scene
  152537. * @param scene Defines the scene to register the component in
  152538. */
  152539. constructor(scene: Scene);
  152540. /**
  152541. * Registers the component in a given scene
  152542. */
  152543. register(): void;
  152544. /**
  152545. * Rebuilds the elements related to this component in case of
  152546. * context lost for instance.
  152547. */
  152548. rebuild(): void;
  152549. /**
  152550. * Disposes the component and the associated ressources
  152551. */
  152552. dispose(): void;
  152553. private _gatherRenderTargets;
  152554. }
  152555. }
  152556. declare module BABYLON {
  152557. /**
  152558. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  152559. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  152560. */
  152561. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152562. private _scene;
  152563. private _camerasToBeAttached;
  152564. /**
  152565. * ID of the sharpen post process,
  152566. */
  152567. private readonly SharpenPostProcessId;
  152568. /**
  152569. * @ignore
  152570. * ID of the image processing post process;
  152571. */
  152572. readonly ImageProcessingPostProcessId: string;
  152573. /**
  152574. * @ignore
  152575. * ID of the Fast Approximate Anti-Aliasing post process;
  152576. */
  152577. readonly FxaaPostProcessId: string;
  152578. /**
  152579. * ID of the chromatic aberration post process,
  152580. */
  152581. private readonly ChromaticAberrationPostProcessId;
  152582. /**
  152583. * ID of the grain post process
  152584. */
  152585. private readonly GrainPostProcessId;
  152586. /**
  152587. * Sharpen post process which will apply a sharpen convolution to enhance edges
  152588. */
  152589. sharpen: SharpenPostProcess;
  152590. private _sharpenEffect;
  152591. private bloom;
  152592. /**
  152593. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  152594. */
  152595. depthOfField: DepthOfFieldEffect;
  152596. /**
  152597. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152598. */
  152599. fxaa: FxaaPostProcess;
  152600. /**
  152601. * Image post processing pass used to perform operations such as tone mapping or color grading.
  152602. */
  152603. imageProcessing: ImageProcessingPostProcess;
  152604. /**
  152605. * Chromatic aberration post process which will shift rgb colors in the image
  152606. */
  152607. chromaticAberration: ChromaticAberrationPostProcess;
  152608. private _chromaticAberrationEffect;
  152609. /**
  152610. * Grain post process which add noise to the image
  152611. */
  152612. grain: GrainPostProcess;
  152613. private _grainEffect;
  152614. /**
  152615. * Glow post process which adds a glow to emissive areas of the image
  152616. */
  152617. private _glowLayer;
  152618. /**
  152619. * Animations which can be used to tweak settings over a period of time
  152620. */
  152621. animations: Animation[];
  152622. private _imageProcessingConfigurationObserver;
  152623. private _sharpenEnabled;
  152624. private _bloomEnabled;
  152625. private _depthOfFieldEnabled;
  152626. private _depthOfFieldBlurLevel;
  152627. private _fxaaEnabled;
  152628. private _imageProcessingEnabled;
  152629. private _defaultPipelineTextureType;
  152630. private _bloomScale;
  152631. private _chromaticAberrationEnabled;
  152632. private _grainEnabled;
  152633. private _buildAllowed;
  152634. /**
  152635. * Gets active scene
  152636. */
  152637. get scene(): Scene;
  152638. /**
  152639. * Enable or disable the sharpen process from the pipeline
  152640. */
  152641. set sharpenEnabled(enabled: boolean);
  152642. get sharpenEnabled(): boolean;
  152643. private _resizeObserver;
  152644. private _hardwareScaleLevel;
  152645. private _bloomKernel;
  152646. /**
  152647. * Specifies the size of the bloom blur kernel, relative to the final output size
  152648. */
  152649. get bloomKernel(): number;
  152650. set bloomKernel(value: number);
  152651. /**
  152652. * Specifies the weight of the bloom in the final rendering
  152653. */
  152654. private _bloomWeight;
  152655. /**
  152656. * Specifies the luma threshold for the area that will be blurred by the bloom
  152657. */
  152658. private _bloomThreshold;
  152659. private _hdr;
  152660. /**
  152661. * The strength of the bloom.
  152662. */
  152663. set bloomWeight(value: number);
  152664. get bloomWeight(): number;
  152665. /**
  152666. * The strength of the bloom.
  152667. */
  152668. set bloomThreshold(value: number);
  152669. get bloomThreshold(): number;
  152670. /**
  152671. * The scale of the bloom, lower value will provide better performance.
  152672. */
  152673. set bloomScale(value: number);
  152674. get bloomScale(): number;
  152675. /**
  152676. * Enable or disable the bloom from the pipeline
  152677. */
  152678. set bloomEnabled(enabled: boolean);
  152679. get bloomEnabled(): boolean;
  152680. private _rebuildBloom;
  152681. /**
  152682. * If the depth of field is enabled.
  152683. */
  152684. get depthOfFieldEnabled(): boolean;
  152685. set depthOfFieldEnabled(enabled: boolean);
  152686. /**
  152687. * Blur level of the depth of field effect. (Higher blur will effect performance)
  152688. */
  152689. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  152690. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  152691. /**
  152692. * If the anti aliasing is enabled.
  152693. */
  152694. set fxaaEnabled(enabled: boolean);
  152695. get fxaaEnabled(): boolean;
  152696. private _samples;
  152697. /**
  152698. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152699. */
  152700. set samples(sampleCount: number);
  152701. get samples(): number;
  152702. /**
  152703. * If image processing is enabled.
  152704. */
  152705. set imageProcessingEnabled(enabled: boolean);
  152706. get imageProcessingEnabled(): boolean;
  152707. /**
  152708. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  152709. */
  152710. set glowLayerEnabled(enabled: boolean);
  152711. get glowLayerEnabled(): boolean;
  152712. /**
  152713. * Gets the glow layer (or null if not defined)
  152714. */
  152715. get glowLayer(): Nullable<GlowLayer>;
  152716. /**
  152717. * Enable or disable the chromaticAberration process from the pipeline
  152718. */
  152719. set chromaticAberrationEnabled(enabled: boolean);
  152720. get chromaticAberrationEnabled(): boolean;
  152721. /**
  152722. * Enable or disable the grain process from the pipeline
  152723. */
  152724. set grainEnabled(enabled: boolean);
  152725. get grainEnabled(): boolean;
  152726. /**
  152727. * @constructor
  152728. * @param name - The rendering pipeline name (default: "")
  152729. * @param hdr - If high dynamic range textures should be used (default: true)
  152730. * @param scene - The scene linked to this pipeline (default: the last created scene)
  152731. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  152732. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  152733. */
  152734. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  152735. /**
  152736. * Get the class name
  152737. * @returns "DefaultRenderingPipeline"
  152738. */
  152739. getClassName(): string;
  152740. /**
  152741. * Force the compilation of the entire pipeline.
  152742. */
  152743. prepare(): void;
  152744. private _hasCleared;
  152745. private _prevPostProcess;
  152746. private _prevPrevPostProcess;
  152747. private _setAutoClearAndTextureSharing;
  152748. private _depthOfFieldSceneObserver;
  152749. private _buildPipeline;
  152750. private _disposePostProcesses;
  152751. /**
  152752. * Adds a camera to the pipeline
  152753. * @param camera the camera to be added
  152754. */
  152755. addCamera(camera: Camera): void;
  152756. /**
  152757. * Removes a camera from the pipeline
  152758. * @param camera the camera to remove
  152759. */
  152760. removeCamera(camera: Camera): void;
  152761. /**
  152762. * Dispose of the pipeline and stop all post processes
  152763. */
  152764. dispose(): void;
  152765. /**
  152766. * Serialize the rendering pipeline (Used when exporting)
  152767. * @returns the serialized object
  152768. */
  152769. serialize(): any;
  152770. /**
  152771. * Parse the serialized pipeline
  152772. * @param source Source pipeline.
  152773. * @param scene The scene to load the pipeline to.
  152774. * @param rootUrl The URL of the serialized pipeline.
  152775. * @returns An instantiated pipeline from the serialized object.
  152776. */
  152777. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  152778. }
  152779. }
  152780. declare module BABYLON {
  152781. /** @hidden */
  152782. export var lensHighlightsPixelShader: {
  152783. name: string;
  152784. shader: string;
  152785. };
  152786. }
  152787. declare module BABYLON {
  152788. /** @hidden */
  152789. export var depthOfFieldPixelShader: {
  152790. name: string;
  152791. shader: string;
  152792. };
  152793. }
  152794. declare module BABYLON {
  152795. /**
  152796. * BABYLON.JS Chromatic Aberration GLSL Shader
  152797. * Author: Olivier Guyot
  152798. * Separates very slightly R, G and B colors on the edges of the screen
  152799. * Inspired by Francois Tarlier & Martins Upitis
  152800. */
  152801. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  152802. /**
  152803. * @ignore
  152804. * The chromatic aberration PostProcess id in the pipeline
  152805. */
  152806. LensChromaticAberrationEffect: string;
  152807. /**
  152808. * @ignore
  152809. * The highlights enhancing PostProcess id in the pipeline
  152810. */
  152811. HighlightsEnhancingEffect: string;
  152812. /**
  152813. * @ignore
  152814. * The depth-of-field PostProcess id in the pipeline
  152815. */
  152816. LensDepthOfFieldEffect: string;
  152817. private _scene;
  152818. private _depthTexture;
  152819. private _grainTexture;
  152820. private _chromaticAberrationPostProcess;
  152821. private _highlightsPostProcess;
  152822. private _depthOfFieldPostProcess;
  152823. private _edgeBlur;
  152824. private _grainAmount;
  152825. private _chromaticAberration;
  152826. private _distortion;
  152827. private _highlightsGain;
  152828. private _highlightsThreshold;
  152829. private _dofDistance;
  152830. private _dofAperture;
  152831. private _dofDarken;
  152832. private _dofPentagon;
  152833. private _blurNoise;
  152834. /**
  152835. * @constructor
  152836. *
  152837. * Effect parameters are as follow:
  152838. * {
  152839. * chromatic_aberration: number; // from 0 to x (1 for realism)
  152840. * edge_blur: number; // from 0 to x (1 for realism)
  152841. * distortion: number; // from 0 to x (1 for realism)
  152842. * grain_amount: number; // from 0 to 1
  152843. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  152844. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  152845. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  152846. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  152847. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  152848. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  152849. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  152850. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  152851. * }
  152852. * Note: if an effect parameter is unset, effect is disabled
  152853. *
  152854. * @param name The rendering pipeline name
  152855. * @param parameters - An object containing all parameters (see above)
  152856. * @param scene The scene linked to this pipeline
  152857. * @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)
  152858. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152859. */
  152860. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  152861. /**
  152862. * Get the class name
  152863. * @returns "LensRenderingPipeline"
  152864. */
  152865. getClassName(): string;
  152866. /**
  152867. * Gets associated scene
  152868. */
  152869. get scene(): Scene;
  152870. /**
  152871. * Gets or sets the edge blur
  152872. */
  152873. get edgeBlur(): number;
  152874. set edgeBlur(value: number);
  152875. /**
  152876. * Gets or sets the grain amount
  152877. */
  152878. get grainAmount(): number;
  152879. set grainAmount(value: number);
  152880. /**
  152881. * Gets or sets the chromatic aberration amount
  152882. */
  152883. get chromaticAberration(): number;
  152884. set chromaticAberration(value: number);
  152885. /**
  152886. * Gets or sets the depth of field aperture
  152887. */
  152888. get dofAperture(): number;
  152889. set dofAperture(value: number);
  152890. /**
  152891. * Gets or sets the edge distortion
  152892. */
  152893. get edgeDistortion(): number;
  152894. set edgeDistortion(value: number);
  152895. /**
  152896. * Gets or sets the depth of field distortion
  152897. */
  152898. get dofDistortion(): number;
  152899. set dofDistortion(value: number);
  152900. /**
  152901. * Gets or sets the darken out of focus amount
  152902. */
  152903. get darkenOutOfFocus(): number;
  152904. set darkenOutOfFocus(value: number);
  152905. /**
  152906. * Gets or sets a boolean indicating if blur noise is enabled
  152907. */
  152908. get blurNoise(): boolean;
  152909. set blurNoise(value: boolean);
  152910. /**
  152911. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  152912. */
  152913. get pentagonBokeh(): boolean;
  152914. set pentagonBokeh(value: boolean);
  152915. /**
  152916. * Gets or sets the highlight grain amount
  152917. */
  152918. get highlightsGain(): number;
  152919. set highlightsGain(value: number);
  152920. /**
  152921. * Gets or sets the highlight threshold
  152922. */
  152923. get highlightsThreshold(): number;
  152924. set highlightsThreshold(value: number);
  152925. /**
  152926. * Sets the amount of blur at the edges
  152927. * @param amount blur amount
  152928. */
  152929. setEdgeBlur(amount: number): void;
  152930. /**
  152931. * Sets edge blur to 0
  152932. */
  152933. disableEdgeBlur(): void;
  152934. /**
  152935. * Sets the amout of grain
  152936. * @param amount Amount of grain
  152937. */
  152938. setGrainAmount(amount: number): void;
  152939. /**
  152940. * Set grain amount to 0
  152941. */
  152942. disableGrain(): void;
  152943. /**
  152944. * Sets the chromatic aberration amount
  152945. * @param amount amount of chromatic aberration
  152946. */
  152947. setChromaticAberration(amount: number): void;
  152948. /**
  152949. * Sets chromatic aberration amount to 0
  152950. */
  152951. disableChromaticAberration(): void;
  152952. /**
  152953. * Sets the EdgeDistortion amount
  152954. * @param amount amount of EdgeDistortion
  152955. */
  152956. setEdgeDistortion(amount: number): void;
  152957. /**
  152958. * Sets edge distortion to 0
  152959. */
  152960. disableEdgeDistortion(): void;
  152961. /**
  152962. * Sets the FocusDistance amount
  152963. * @param amount amount of FocusDistance
  152964. */
  152965. setFocusDistance(amount: number): void;
  152966. /**
  152967. * Disables depth of field
  152968. */
  152969. disableDepthOfField(): void;
  152970. /**
  152971. * Sets the Aperture amount
  152972. * @param amount amount of Aperture
  152973. */
  152974. setAperture(amount: number): void;
  152975. /**
  152976. * Sets the DarkenOutOfFocus amount
  152977. * @param amount amount of DarkenOutOfFocus
  152978. */
  152979. setDarkenOutOfFocus(amount: number): void;
  152980. private _pentagonBokehIsEnabled;
  152981. /**
  152982. * Creates a pentagon bokeh effect
  152983. */
  152984. enablePentagonBokeh(): void;
  152985. /**
  152986. * Disables the pentagon bokeh effect
  152987. */
  152988. disablePentagonBokeh(): void;
  152989. /**
  152990. * Enables noise blur
  152991. */
  152992. enableNoiseBlur(): void;
  152993. /**
  152994. * Disables noise blur
  152995. */
  152996. disableNoiseBlur(): void;
  152997. /**
  152998. * Sets the HighlightsGain amount
  152999. * @param amount amount of HighlightsGain
  153000. */
  153001. setHighlightsGain(amount: number): void;
  153002. /**
  153003. * Sets the HighlightsThreshold amount
  153004. * @param amount amount of HighlightsThreshold
  153005. */
  153006. setHighlightsThreshold(amount: number): void;
  153007. /**
  153008. * Disables highlights
  153009. */
  153010. disableHighlights(): void;
  153011. /**
  153012. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  153013. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  153014. */
  153015. dispose(disableDepthRender?: boolean): void;
  153016. private _createChromaticAberrationPostProcess;
  153017. private _createHighlightsPostProcess;
  153018. private _createDepthOfFieldPostProcess;
  153019. private _createGrainTexture;
  153020. }
  153021. }
  153022. declare module BABYLON {
  153023. /**
  153024. * Contains all parameters needed for the prepass to perform
  153025. * screen space subsurface scattering
  153026. */
  153027. export class SSAO2Configuration implements PrePassEffectConfiguration {
  153028. /**
  153029. * Is subsurface enabled
  153030. */
  153031. enabled: boolean;
  153032. /**
  153033. * Name of the configuration
  153034. */
  153035. name: string;
  153036. /**
  153037. * Textures that should be present in the MRT for this effect to work
  153038. */
  153039. readonly texturesRequired: number[];
  153040. }
  153041. }
  153042. declare module BABYLON {
  153043. /** @hidden */
  153044. export var ssao2PixelShader: {
  153045. name: string;
  153046. shader: string;
  153047. };
  153048. }
  153049. declare module BABYLON {
  153050. /** @hidden */
  153051. export var ssaoCombinePixelShader: {
  153052. name: string;
  153053. shader: string;
  153054. };
  153055. }
  153056. declare module BABYLON {
  153057. /**
  153058. * Render pipeline to produce ssao effect
  153059. */
  153060. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  153061. /**
  153062. * @ignore
  153063. * The PassPostProcess id in the pipeline that contains the original scene color
  153064. */
  153065. SSAOOriginalSceneColorEffect: string;
  153066. /**
  153067. * @ignore
  153068. * The SSAO PostProcess id in the pipeline
  153069. */
  153070. SSAORenderEffect: string;
  153071. /**
  153072. * @ignore
  153073. * The horizontal blur PostProcess id in the pipeline
  153074. */
  153075. SSAOBlurHRenderEffect: string;
  153076. /**
  153077. * @ignore
  153078. * The vertical blur PostProcess id in the pipeline
  153079. */
  153080. SSAOBlurVRenderEffect: string;
  153081. /**
  153082. * @ignore
  153083. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153084. */
  153085. SSAOCombineRenderEffect: string;
  153086. /**
  153087. * The output strength of the SSAO post-process. Default value is 1.0.
  153088. */
  153089. totalStrength: number;
  153090. /**
  153091. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  153092. */
  153093. maxZ: number;
  153094. /**
  153095. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  153096. */
  153097. minZAspect: number;
  153098. private _samples;
  153099. /**
  153100. * Number of samples used for the SSAO calculations. Default value is 8
  153101. */
  153102. set samples(n: number);
  153103. get samples(): number;
  153104. private _textureSamples;
  153105. /**
  153106. * Number of samples to use for antialiasing
  153107. */
  153108. set textureSamples(n: number);
  153109. get textureSamples(): number;
  153110. /**
  153111. * Force rendering the geometry through geometry buffer
  153112. */
  153113. private _forceGeometryBuffer;
  153114. /**
  153115. * Ratio object used for SSAO ratio and blur ratio
  153116. */
  153117. private _ratio;
  153118. /**
  153119. * Dynamically generated sphere sampler.
  153120. */
  153121. private _sampleSphere;
  153122. /**
  153123. * Blur filter offsets
  153124. */
  153125. private _samplerOffsets;
  153126. private _expensiveBlur;
  153127. /**
  153128. * If bilateral blur should be used
  153129. */
  153130. set expensiveBlur(b: boolean);
  153131. get expensiveBlur(): boolean;
  153132. /**
  153133. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  153134. */
  153135. radius: number;
  153136. /**
  153137. * The base color of the SSAO post-process
  153138. * The final result is "base + ssao" between [0, 1]
  153139. */
  153140. base: number;
  153141. /**
  153142. * Support test.
  153143. */
  153144. static get IsSupported(): boolean;
  153145. private _scene;
  153146. private _randomTexture;
  153147. private _originalColorPostProcess;
  153148. private _ssaoPostProcess;
  153149. private _blurHPostProcess;
  153150. private _blurVPostProcess;
  153151. private _ssaoCombinePostProcess;
  153152. private _prePassRenderer;
  153153. /**
  153154. * Gets active scene
  153155. */
  153156. get scene(): Scene;
  153157. /**
  153158. * @constructor
  153159. * @param name The rendering pipeline name
  153160. * @param scene The scene linked to this pipeline
  153161. * @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 }
  153162. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153163. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  153164. */
  153165. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  153166. /**
  153167. * Get the class name
  153168. * @returns "SSAO2RenderingPipeline"
  153169. */
  153170. getClassName(): string;
  153171. /**
  153172. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153173. */
  153174. dispose(disableGeometryBufferRenderer?: boolean): void;
  153175. private _createBlurPostProcess;
  153176. /** @hidden */
  153177. _rebuild(): void;
  153178. private _bits;
  153179. private _radicalInverse_VdC;
  153180. private _hammersley;
  153181. private _hemisphereSample_uniform;
  153182. private _generateHemisphere;
  153183. private _getDefinesForSSAO;
  153184. private _createSSAOPostProcess;
  153185. private _createSSAOCombinePostProcess;
  153186. private _createRandomTexture;
  153187. /**
  153188. * Serialize the rendering pipeline (Used when exporting)
  153189. * @returns the serialized object
  153190. */
  153191. serialize(): any;
  153192. /**
  153193. * Parse the serialized pipeline
  153194. * @param source Source pipeline.
  153195. * @param scene The scene to load the pipeline to.
  153196. * @param rootUrl The URL of the serialized pipeline.
  153197. * @returns An instantiated pipeline from the serialized object.
  153198. */
  153199. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  153200. }
  153201. }
  153202. declare module BABYLON {
  153203. /** @hidden */
  153204. export var ssaoPixelShader: {
  153205. name: string;
  153206. shader: string;
  153207. };
  153208. }
  153209. declare module BABYLON {
  153210. /**
  153211. * Render pipeline to produce ssao effect
  153212. */
  153213. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  153214. /**
  153215. * @ignore
  153216. * The PassPostProcess id in the pipeline that contains the original scene color
  153217. */
  153218. SSAOOriginalSceneColorEffect: string;
  153219. /**
  153220. * @ignore
  153221. * The SSAO PostProcess id in the pipeline
  153222. */
  153223. SSAORenderEffect: string;
  153224. /**
  153225. * @ignore
  153226. * The horizontal blur PostProcess id in the pipeline
  153227. */
  153228. SSAOBlurHRenderEffect: string;
  153229. /**
  153230. * @ignore
  153231. * The vertical blur PostProcess id in the pipeline
  153232. */
  153233. SSAOBlurVRenderEffect: string;
  153234. /**
  153235. * @ignore
  153236. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153237. */
  153238. SSAOCombineRenderEffect: string;
  153239. /**
  153240. * The output strength of the SSAO post-process. Default value is 1.0.
  153241. */
  153242. totalStrength: number;
  153243. /**
  153244. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  153245. */
  153246. radius: number;
  153247. /**
  153248. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  153249. * Must not be equal to fallOff and superior to fallOff.
  153250. * Default value is 0.0075
  153251. */
  153252. area: number;
  153253. /**
  153254. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  153255. * Must not be equal to area and inferior to area.
  153256. * Default value is 0.000001
  153257. */
  153258. fallOff: number;
  153259. /**
  153260. * The base color of the SSAO post-process
  153261. * The final result is "base + ssao" between [0, 1]
  153262. */
  153263. base: number;
  153264. private _scene;
  153265. private _depthTexture;
  153266. private _randomTexture;
  153267. private _originalColorPostProcess;
  153268. private _ssaoPostProcess;
  153269. private _blurHPostProcess;
  153270. private _blurVPostProcess;
  153271. private _ssaoCombinePostProcess;
  153272. private _firstUpdate;
  153273. /**
  153274. * Gets active scene
  153275. */
  153276. get scene(): Scene;
  153277. /**
  153278. * @constructor
  153279. * @param name - The rendering pipeline name
  153280. * @param scene - The scene linked to this pipeline
  153281. * @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 }
  153282. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  153283. */
  153284. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  153285. /**
  153286. * Get the class name
  153287. * @returns "SSAORenderingPipeline"
  153288. */
  153289. getClassName(): string;
  153290. /**
  153291. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153292. */
  153293. dispose(disableDepthRender?: boolean): void;
  153294. private _createBlurPostProcess;
  153295. /** @hidden */
  153296. _rebuild(): void;
  153297. private _createSSAOPostProcess;
  153298. private _createSSAOCombinePostProcess;
  153299. private _createRandomTexture;
  153300. }
  153301. }
  153302. declare module BABYLON {
  153303. /**
  153304. * Contains all parameters needed for the prepass to perform
  153305. * screen space reflections
  153306. */
  153307. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  153308. /**
  153309. * Is ssr enabled
  153310. */
  153311. enabled: boolean;
  153312. /**
  153313. * Name of the configuration
  153314. */
  153315. name: string;
  153316. /**
  153317. * Textures that should be present in the MRT for this effect to work
  153318. */
  153319. readonly texturesRequired: number[];
  153320. }
  153321. }
  153322. declare module BABYLON {
  153323. /** @hidden */
  153324. export var screenSpaceReflectionPixelShader: {
  153325. name: string;
  153326. shader: string;
  153327. };
  153328. }
  153329. declare module BABYLON {
  153330. /**
  153331. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  153332. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  153333. */
  153334. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  153335. /**
  153336. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  153337. */
  153338. threshold: number;
  153339. /**
  153340. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  153341. */
  153342. strength: number;
  153343. /**
  153344. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  153345. */
  153346. reflectionSpecularFalloffExponent: number;
  153347. /**
  153348. * 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]
  153349. */
  153350. step: number;
  153351. /**
  153352. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  153353. */
  153354. roughnessFactor: number;
  153355. private _forceGeometryBuffer;
  153356. private _geometryBufferRenderer;
  153357. private _prePassRenderer;
  153358. private _enableSmoothReflections;
  153359. private _reflectionSamples;
  153360. private _smoothSteps;
  153361. /**
  153362. * Gets a string identifying the name of the class
  153363. * @returns "ScreenSpaceReflectionPostProcess" string
  153364. */
  153365. getClassName(): string;
  153366. /**
  153367. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  153368. * @param name The name of the effect.
  153369. * @param scene The scene containing the objects to calculate reflections.
  153370. * @param options The required width/height ratio to downsize to before computing the render pass.
  153371. * @param camera The camera to apply the render pass to.
  153372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153373. * @param engine The engine which the post process will be applied. (default: current engine)
  153374. * @param reusable If the post process can be reused on the same frame. (default: false)
  153375. * @param textureType Type of textures used when performing the post process. (default: 0)
  153376. * @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)
  153377. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  153378. */
  153379. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  153380. /**
  153381. * Gets wether or not smoothing reflections is enabled.
  153382. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153383. */
  153384. get enableSmoothReflections(): boolean;
  153385. /**
  153386. * Sets wether or not smoothing reflections is enabled.
  153387. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153388. */
  153389. set enableSmoothReflections(enabled: boolean);
  153390. /**
  153391. * Gets the number of samples taken while computing reflections. More samples count is high,
  153392. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153393. */
  153394. get reflectionSamples(): number;
  153395. /**
  153396. * Sets the number of samples taken while computing reflections. More samples count is high,
  153397. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153398. */
  153399. set reflectionSamples(samples: number);
  153400. /**
  153401. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  153402. * more the post-process will require GPU power and can generate a drop in FPS.
  153403. * Default value (5.0) work pretty well in all cases but can be adjusted.
  153404. */
  153405. get smoothSteps(): number;
  153406. set smoothSteps(steps: number);
  153407. private _updateEffectDefines;
  153408. /** @hidden */
  153409. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  153410. }
  153411. }
  153412. declare module BABYLON {
  153413. /** @hidden */
  153414. export var standardPixelShader: {
  153415. name: string;
  153416. shader: string;
  153417. };
  153418. }
  153419. declare module BABYLON {
  153420. /**
  153421. * Standard rendering pipeline
  153422. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  153423. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  153424. */
  153425. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  153426. /**
  153427. * Public members
  153428. */
  153429. /**
  153430. * Post-process which contains the original scene color before the pipeline applies all the effects
  153431. */
  153432. originalPostProcess: Nullable<PostProcess>;
  153433. /**
  153434. * Post-process used to down scale an image x4
  153435. */
  153436. downSampleX4PostProcess: Nullable<PostProcess>;
  153437. /**
  153438. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  153439. */
  153440. brightPassPostProcess: Nullable<PostProcess>;
  153441. /**
  153442. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  153443. */
  153444. blurHPostProcesses: PostProcess[];
  153445. /**
  153446. * Post-process array storing all the vertical blur post-processes used by the pipeline
  153447. */
  153448. blurVPostProcesses: PostProcess[];
  153449. /**
  153450. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  153451. */
  153452. textureAdderPostProcess: Nullable<PostProcess>;
  153453. /**
  153454. * Post-process used to create volumetric lighting effect
  153455. */
  153456. volumetricLightPostProcess: Nullable<PostProcess>;
  153457. /**
  153458. * Post-process used to smooth the previous volumetric light post-process on the X axis
  153459. */
  153460. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  153461. /**
  153462. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  153463. */
  153464. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  153465. /**
  153466. * Post-process used to merge the volumetric light effect and the real scene color
  153467. */
  153468. volumetricLightMergePostProces: Nullable<PostProcess>;
  153469. /**
  153470. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  153471. */
  153472. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  153473. /**
  153474. * Base post-process used to calculate the average luminance of the final image for HDR
  153475. */
  153476. luminancePostProcess: Nullable<PostProcess>;
  153477. /**
  153478. * Post-processes used to create down sample post-processes in order to get
  153479. * the average luminance of the final image for HDR
  153480. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  153481. */
  153482. luminanceDownSamplePostProcesses: PostProcess[];
  153483. /**
  153484. * Post-process used to create a HDR effect (light adaptation)
  153485. */
  153486. hdrPostProcess: Nullable<PostProcess>;
  153487. /**
  153488. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  153489. */
  153490. textureAdderFinalPostProcess: Nullable<PostProcess>;
  153491. /**
  153492. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  153493. */
  153494. lensFlareFinalPostProcess: Nullable<PostProcess>;
  153495. /**
  153496. * Post-process used to merge the final HDR post-process and the real scene color
  153497. */
  153498. hdrFinalPostProcess: Nullable<PostProcess>;
  153499. /**
  153500. * Post-process used to create a lens flare effect
  153501. */
  153502. lensFlarePostProcess: Nullable<PostProcess>;
  153503. /**
  153504. * Post-process that merges the result of the lens flare post-process and the real scene color
  153505. */
  153506. lensFlareComposePostProcess: Nullable<PostProcess>;
  153507. /**
  153508. * Post-process used to create a motion blur effect
  153509. */
  153510. motionBlurPostProcess: Nullable<PostProcess>;
  153511. /**
  153512. * Post-process used to create a depth of field effect
  153513. */
  153514. depthOfFieldPostProcess: Nullable<PostProcess>;
  153515. /**
  153516. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  153517. */
  153518. fxaaPostProcess: Nullable<FxaaPostProcess>;
  153519. /**
  153520. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  153521. */
  153522. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  153523. /**
  153524. * Represents the brightness threshold in order to configure the illuminated surfaces
  153525. */
  153526. brightThreshold: number;
  153527. /**
  153528. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  153529. */
  153530. blurWidth: number;
  153531. /**
  153532. * Sets if the blur for highlighted surfaces must be only horizontal
  153533. */
  153534. horizontalBlur: boolean;
  153535. /**
  153536. * Gets the overall exposure used by the pipeline
  153537. */
  153538. get exposure(): number;
  153539. /**
  153540. * Sets the overall exposure used by the pipeline
  153541. */
  153542. set exposure(value: number);
  153543. /**
  153544. * Texture used typically to simulate "dirty" on camera lens
  153545. */
  153546. lensTexture: Nullable<Texture>;
  153547. /**
  153548. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  153549. */
  153550. volumetricLightCoefficient: number;
  153551. /**
  153552. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  153553. */
  153554. volumetricLightPower: number;
  153555. /**
  153556. * Used the set the blur intensity to smooth the volumetric lights
  153557. */
  153558. volumetricLightBlurScale: number;
  153559. /**
  153560. * Light (spot or directional) used to generate the volumetric lights rays
  153561. * The source light must have a shadow generate so the pipeline can get its
  153562. * depth map
  153563. */
  153564. sourceLight: Nullable<SpotLight | DirectionalLight>;
  153565. /**
  153566. * For eye adaptation, represents the minimum luminance the eye can see
  153567. */
  153568. hdrMinimumLuminance: number;
  153569. /**
  153570. * For eye adaptation, represents the decrease luminance speed
  153571. */
  153572. hdrDecreaseRate: number;
  153573. /**
  153574. * For eye adaptation, represents the increase luminance speed
  153575. */
  153576. hdrIncreaseRate: number;
  153577. /**
  153578. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  153579. */
  153580. get hdrAutoExposure(): boolean;
  153581. /**
  153582. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  153583. */
  153584. set hdrAutoExposure(value: boolean);
  153585. /**
  153586. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  153587. */
  153588. lensColorTexture: Nullable<Texture>;
  153589. /**
  153590. * The overall strengh for the lens flare effect
  153591. */
  153592. lensFlareStrength: number;
  153593. /**
  153594. * Dispersion coefficient for lens flare ghosts
  153595. */
  153596. lensFlareGhostDispersal: number;
  153597. /**
  153598. * Main lens flare halo width
  153599. */
  153600. lensFlareHaloWidth: number;
  153601. /**
  153602. * Based on the lens distortion effect, defines how much the lens flare result
  153603. * is distorted
  153604. */
  153605. lensFlareDistortionStrength: number;
  153606. /**
  153607. * Configures the blur intensity used for for lens flare (halo)
  153608. */
  153609. lensFlareBlurWidth: number;
  153610. /**
  153611. * Lens star texture must be used to simulate rays on the flares and is available
  153612. * in the documentation
  153613. */
  153614. lensStarTexture: Nullable<Texture>;
  153615. /**
  153616. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  153617. * flare effect by taking account of the dirt texture
  153618. */
  153619. lensFlareDirtTexture: Nullable<Texture>;
  153620. /**
  153621. * Represents the focal length for the depth of field effect
  153622. */
  153623. depthOfFieldDistance: number;
  153624. /**
  153625. * Represents the blur intensity for the blurred part of the depth of field effect
  153626. */
  153627. depthOfFieldBlurWidth: number;
  153628. /**
  153629. * Gets how much the image is blurred by the movement while using the motion blur post-process
  153630. */
  153631. get motionStrength(): number;
  153632. /**
  153633. * Sets how much the image is blurred by the movement while using the motion blur post-process
  153634. */
  153635. set motionStrength(strength: number);
  153636. /**
  153637. * Gets wether or not the motion blur post-process is object based or screen based.
  153638. */
  153639. get objectBasedMotionBlur(): boolean;
  153640. /**
  153641. * Sets wether or not the motion blur post-process should be object based or screen based
  153642. */
  153643. set objectBasedMotionBlur(value: boolean);
  153644. /**
  153645. * List of animations for the pipeline (IAnimatable implementation)
  153646. */
  153647. animations: Animation[];
  153648. /**
  153649. * Private members
  153650. */
  153651. private _scene;
  153652. private _currentDepthOfFieldSource;
  153653. private _basePostProcess;
  153654. private _fixedExposure;
  153655. private _currentExposure;
  153656. private _hdrAutoExposure;
  153657. private _hdrCurrentLuminance;
  153658. private _motionStrength;
  153659. private _isObjectBasedMotionBlur;
  153660. private _floatTextureType;
  153661. private _camerasToBeAttached;
  153662. private _ratio;
  153663. private _bloomEnabled;
  153664. private _depthOfFieldEnabled;
  153665. private _vlsEnabled;
  153666. private _lensFlareEnabled;
  153667. private _hdrEnabled;
  153668. private _motionBlurEnabled;
  153669. private _fxaaEnabled;
  153670. private _screenSpaceReflectionsEnabled;
  153671. private _motionBlurSamples;
  153672. private _volumetricLightStepsCount;
  153673. private _samples;
  153674. /**
  153675. * @ignore
  153676. * Specifies if the bloom pipeline is enabled
  153677. */
  153678. get BloomEnabled(): boolean;
  153679. set BloomEnabled(enabled: boolean);
  153680. /**
  153681. * @ignore
  153682. * Specifies if the depth of field pipeline is enabed
  153683. */
  153684. get DepthOfFieldEnabled(): boolean;
  153685. set DepthOfFieldEnabled(enabled: boolean);
  153686. /**
  153687. * @ignore
  153688. * Specifies if the lens flare pipeline is enabed
  153689. */
  153690. get LensFlareEnabled(): boolean;
  153691. set LensFlareEnabled(enabled: boolean);
  153692. /**
  153693. * @ignore
  153694. * Specifies if the HDR pipeline is enabled
  153695. */
  153696. get HDREnabled(): boolean;
  153697. set HDREnabled(enabled: boolean);
  153698. /**
  153699. * @ignore
  153700. * Specifies if the volumetric lights scattering effect is enabled
  153701. */
  153702. get VLSEnabled(): boolean;
  153703. set VLSEnabled(enabled: boolean);
  153704. /**
  153705. * @ignore
  153706. * Specifies if the motion blur effect is enabled
  153707. */
  153708. get MotionBlurEnabled(): boolean;
  153709. set MotionBlurEnabled(enabled: boolean);
  153710. /**
  153711. * Specifies if anti-aliasing is enabled
  153712. */
  153713. get fxaaEnabled(): boolean;
  153714. set fxaaEnabled(enabled: boolean);
  153715. /**
  153716. * Specifies if screen space reflections are enabled.
  153717. */
  153718. get screenSpaceReflectionsEnabled(): boolean;
  153719. set screenSpaceReflectionsEnabled(enabled: boolean);
  153720. /**
  153721. * Specifies the number of steps used to calculate the volumetric lights
  153722. * Typically in interval [50, 200]
  153723. */
  153724. get volumetricLightStepsCount(): number;
  153725. set volumetricLightStepsCount(count: number);
  153726. /**
  153727. * Specifies the number of samples used for the motion blur effect
  153728. * Typically in interval [16, 64]
  153729. */
  153730. get motionBlurSamples(): number;
  153731. set motionBlurSamples(samples: number);
  153732. /**
  153733. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  153734. */
  153735. get samples(): number;
  153736. set samples(sampleCount: number);
  153737. /**
  153738. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  153739. * @constructor
  153740. * @param name The rendering pipeline name
  153741. * @param scene The scene linked to this pipeline
  153742. * @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)
  153743. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  153744. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153745. */
  153746. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  153747. private _buildPipeline;
  153748. private _createDownSampleX4PostProcess;
  153749. private _createBrightPassPostProcess;
  153750. private _createBlurPostProcesses;
  153751. private _createTextureAdderPostProcess;
  153752. private _createVolumetricLightPostProcess;
  153753. private _createLuminancePostProcesses;
  153754. private _createHdrPostProcess;
  153755. private _createLensFlarePostProcess;
  153756. private _createDepthOfFieldPostProcess;
  153757. private _createMotionBlurPostProcess;
  153758. private _getDepthTexture;
  153759. private _disposePostProcesses;
  153760. /**
  153761. * Dispose of the pipeline and stop all post processes
  153762. */
  153763. dispose(): void;
  153764. /**
  153765. * Serialize the rendering pipeline (Used when exporting)
  153766. * @returns the serialized object
  153767. */
  153768. serialize(): any;
  153769. /**
  153770. * Parse the serialized pipeline
  153771. * @param source Source pipeline.
  153772. * @param scene The scene to load the pipeline to.
  153773. * @param rootUrl The URL of the serialized pipeline.
  153774. * @returns An instantiated pipeline from the serialized object.
  153775. */
  153776. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  153777. /**
  153778. * Luminance steps
  153779. */
  153780. static LuminanceSteps: number;
  153781. }
  153782. }
  153783. declare module BABYLON {
  153784. /** @hidden */
  153785. export var stereoscopicInterlacePixelShader: {
  153786. name: string;
  153787. shader: string;
  153788. };
  153789. }
  153790. declare module BABYLON {
  153791. /**
  153792. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  153793. */
  153794. export class StereoscopicInterlacePostProcessI extends PostProcess {
  153795. private _stepSize;
  153796. private _passedProcess;
  153797. /**
  153798. * Gets a string identifying the name of the class
  153799. * @returns "StereoscopicInterlacePostProcessI" string
  153800. */
  153801. getClassName(): string;
  153802. /**
  153803. * Initializes a StereoscopicInterlacePostProcessI
  153804. * @param name The name of the effect.
  153805. * @param rigCameras The rig cameras to be appled to the post process
  153806. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  153807. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  153808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153809. * @param engine The engine which the post process will be applied. (default: current engine)
  153810. * @param reusable If the post process can be reused on the same frame. (default: false)
  153811. */
  153812. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153813. }
  153814. /**
  153815. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  153816. */
  153817. export class StereoscopicInterlacePostProcess extends PostProcess {
  153818. private _stepSize;
  153819. private _passedProcess;
  153820. /**
  153821. * Gets a string identifying the name of the class
  153822. * @returns "StereoscopicInterlacePostProcess" string
  153823. */
  153824. getClassName(): string;
  153825. /**
  153826. * Initializes a StereoscopicInterlacePostProcess
  153827. * @param name The name of the effect.
  153828. * @param rigCameras The rig cameras to be appled to the post process
  153829. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  153830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153831. * @param engine The engine which the post process will be applied. (default: current engine)
  153832. * @param reusable If the post process can be reused on the same frame. (default: false)
  153833. */
  153834. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153835. }
  153836. }
  153837. declare module BABYLON {
  153838. /** @hidden */
  153839. export var tonemapPixelShader: {
  153840. name: string;
  153841. shader: string;
  153842. };
  153843. }
  153844. declare module BABYLON {
  153845. /** Defines operator used for tonemapping */
  153846. export enum TonemappingOperator {
  153847. /** Hable */
  153848. Hable = 0,
  153849. /** Reinhard */
  153850. Reinhard = 1,
  153851. /** HejiDawson */
  153852. HejiDawson = 2,
  153853. /** Photographic */
  153854. Photographic = 3
  153855. }
  153856. /**
  153857. * Defines a post process to apply tone mapping
  153858. */
  153859. export class TonemapPostProcess extends PostProcess {
  153860. private _operator;
  153861. /** Defines the required exposure adjustement */
  153862. exposureAdjustment: number;
  153863. /**
  153864. * Gets a string identifying the name of the class
  153865. * @returns "TonemapPostProcess" string
  153866. */
  153867. getClassName(): string;
  153868. /**
  153869. * Creates a new TonemapPostProcess
  153870. * @param name defines the name of the postprocess
  153871. * @param _operator defines the operator to use
  153872. * @param exposureAdjustment defines the required exposure adjustement
  153873. * @param camera defines the camera to use (can be null)
  153874. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  153875. * @param engine defines the hosting engine (can be ignore if camera is set)
  153876. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  153877. */
  153878. constructor(name: string, _operator: TonemappingOperator,
  153879. /** Defines the required exposure adjustement */
  153880. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  153881. }
  153882. }
  153883. declare module BABYLON {
  153884. /** @hidden */
  153885. export var volumetricLightScatteringPixelShader: {
  153886. name: string;
  153887. shader: string;
  153888. };
  153889. }
  153890. declare module BABYLON {
  153891. /** @hidden */
  153892. export var volumetricLightScatteringPassVertexShader: {
  153893. name: string;
  153894. shader: string;
  153895. };
  153896. }
  153897. declare module BABYLON {
  153898. /** @hidden */
  153899. export var volumetricLightScatteringPassPixelShader: {
  153900. name: string;
  153901. shader: string;
  153902. };
  153903. }
  153904. declare module BABYLON {
  153905. /**
  153906. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  153907. */
  153908. export class VolumetricLightScatteringPostProcess extends PostProcess {
  153909. private _volumetricLightScatteringPass;
  153910. private _volumetricLightScatteringRTT;
  153911. private _viewPort;
  153912. private _screenCoordinates;
  153913. private _cachedDefines;
  153914. /**
  153915. * If not undefined, the mesh position is computed from the attached node position
  153916. */
  153917. attachedNode: {
  153918. position: Vector3;
  153919. };
  153920. /**
  153921. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  153922. */
  153923. customMeshPosition: Vector3;
  153924. /**
  153925. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  153926. */
  153927. useCustomMeshPosition: boolean;
  153928. /**
  153929. * If the post-process should inverse the light scattering direction
  153930. */
  153931. invert: boolean;
  153932. /**
  153933. * The internal mesh used by the post-process
  153934. */
  153935. mesh: Mesh;
  153936. /**
  153937. * @hidden
  153938. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  153939. */
  153940. get useDiffuseColor(): boolean;
  153941. set useDiffuseColor(useDiffuseColor: boolean);
  153942. /**
  153943. * Array containing the excluded meshes not rendered in the internal pass
  153944. */
  153945. excludedMeshes: AbstractMesh[];
  153946. /**
  153947. * Controls the overall intensity of the post-process
  153948. */
  153949. exposure: number;
  153950. /**
  153951. * Dissipates each sample's contribution in range [0, 1]
  153952. */
  153953. decay: number;
  153954. /**
  153955. * Controls the overall intensity of each sample
  153956. */
  153957. weight: number;
  153958. /**
  153959. * Controls the density of each sample
  153960. */
  153961. density: number;
  153962. /**
  153963. * @constructor
  153964. * @param name The post-process name
  153965. * @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)
  153966. * @param camera The camera that the post-process will be attached to
  153967. * @param mesh The mesh used to create the light scattering
  153968. * @param samples The post-process quality, default 100
  153969. * @param samplingModeThe post-process filtering mode
  153970. * @param engine The babylon engine
  153971. * @param reusable If the post-process is reusable
  153972. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  153973. */
  153974. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  153975. /**
  153976. * Returns the string "VolumetricLightScatteringPostProcess"
  153977. * @returns "VolumetricLightScatteringPostProcess"
  153978. */
  153979. getClassName(): string;
  153980. private _isReady;
  153981. /**
  153982. * Sets the new light position for light scattering effect
  153983. * @param position The new custom light position
  153984. */
  153985. setCustomMeshPosition(position: Vector3): void;
  153986. /**
  153987. * Returns the light position for light scattering effect
  153988. * @return Vector3 The custom light position
  153989. */
  153990. getCustomMeshPosition(): Vector3;
  153991. /**
  153992. * Disposes the internal assets and detaches the post-process from the camera
  153993. */
  153994. dispose(camera: Camera): void;
  153995. /**
  153996. * Returns the render target texture used by the post-process
  153997. * @return the render target texture used by the post-process
  153998. */
  153999. getPass(): RenderTargetTexture;
  154000. private _meshExcluded;
  154001. private _createPass;
  154002. private _updateMeshScreenCoordinates;
  154003. /**
  154004. * Creates a default mesh for the Volumeric Light Scattering post-process
  154005. * @param name The mesh name
  154006. * @param scene The scene where to create the mesh
  154007. * @return the default mesh
  154008. */
  154009. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  154010. }
  154011. }
  154012. declare module BABYLON {
  154013. /** @hidden */
  154014. export var screenSpaceCurvaturePixelShader: {
  154015. name: string;
  154016. shader: string;
  154017. };
  154018. }
  154019. declare module BABYLON {
  154020. /**
  154021. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  154022. */
  154023. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  154024. /**
  154025. * Defines how much ridge the curvature effect displays.
  154026. */
  154027. ridge: number;
  154028. /**
  154029. * Defines how much valley the curvature effect displays.
  154030. */
  154031. valley: number;
  154032. private _geometryBufferRenderer;
  154033. /**
  154034. * Gets a string identifying the name of the class
  154035. * @returns "ScreenSpaceCurvaturePostProcess" string
  154036. */
  154037. getClassName(): string;
  154038. /**
  154039. * Creates a new instance ScreenSpaceCurvaturePostProcess
  154040. * @param name The name of the effect.
  154041. * @param scene The scene containing the objects to blur according to their velocity.
  154042. * @param options The required width/height ratio to downsize to before computing the render pass.
  154043. * @param camera The camera to apply the render pass to.
  154044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154045. * @param engine The engine which the post process will be applied. (default: current engine)
  154046. * @param reusable If the post process can be reused on the same frame. (default: false)
  154047. * @param textureType Type of textures used when performing the post process. (default: 0)
  154048. * @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)
  154049. */
  154050. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  154051. /**
  154052. * Support test.
  154053. */
  154054. static get IsSupported(): boolean;
  154055. /** @hidden */
  154056. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  154057. }
  154058. }
  154059. declare module BABYLON {
  154060. interface Scene {
  154061. /** @hidden (Backing field) */
  154062. _boundingBoxRenderer: BoundingBoxRenderer;
  154063. /** @hidden (Backing field) */
  154064. _forceShowBoundingBoxes: boolean;
  154065. /**
  154066. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  154067. */
  154068. forceShowBoundingBoxes: boolean;
  154069. /**
  154070. * Gets the bounding box renderer associated with the scene
  154071. * @returns a BoundingBoxRenderer
  154072. */
  154073. getBoundingBoxRenderer(): BoundingBoxRenderer;
  154074. }
  154075. interface AbstractMesh {
  154076. /** @hidden (Backing field) */
  154077. _showBoundingBox: boolean;
  154078. /**
  154079. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  154080. */
  154081. showBoundingBox: boolean;
  154082. }
  154083. /**
  154084. * Component responsible of rendering the bounding box of the meshes in a scene.
  154085. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  154086. */
  154087. export class BoundingBoxRenderer implements ISceneComponent {
  154088. /**
  154089. * The component name helpfull to identify the component in the list of scene components.
  154090. */
  154091. readonly name: string;
  154092. /**
  154093. * The scene the component belongs to.
  154094. */
  154095. scene: Scene;
  154096. /**
  154097. * Color of the bounding box lines placed in front of an object
  154098. */
  154099. frontColor: Color3;
  154100. /**
  154101. * Color of the bounding box lines placed behind an object
  154102. */
  154103. backColor: Color3;
  154104. /**
  154105. * Defines if the renderer should show the back lines or not
  154106. */
  154107. showBackLines: boolean;
  154108. /**
  154109. * Observable raised before rendering a bounding box
  154110. */
  154111. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  154112. /**
  154113. * Observable raised after rendering a bounding box
  154114. */
  154115. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  154116. /**
  154117. * Observable raised after resources are created
  154118. */
  154119. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  154120. /**
  154121. * When false, no bounding boxes will be rendered
  154122. */
  154123. enabled: boolean;
  154124. /**
  154125. * @hidden
  154126. */
  154127. renderList: SmartArray<BoundingBox>;
  154128. private _colorShader;
  154129. private _vertexBuffers;
  154130. private _indexBuffer;
  154131. private _fillIndexBuffer;
  154132. private _fillIndexData;
  154133. /**
  154134. * Instantiates a new bounding box renderer in a scene.
  154135. * @param scene the scene the renderer renders in
  154136. */
  154137. constructor(scene: Scene);
  154138. /**
  154139. * Registers the component in a given scene
  154140. */
  154141. register(): void;
  154142. private _evaluateSubMesh;
  154143. private _preActiveMesh;
  154144. private _prepareResources;
  154145. private _createIndexBuffer;
  154146. /**
  154147. * Rebuilds the elements related to this component in case of
  154148. * context lost for instance.
  154149. */
  154150. rebuild(): void;
  154151. /**
  154152. * @hidden
  154153. */
  154154. reset(): void;
  154155. /**
  154156. * Render the bounding boxes of a specific rendering group
  154157. * @param renderingGroupId defines the rendering group to render
  154158. */
  154159. render(renderingGroupId: number): void;
  154160. /**
  154161. * In case of occlusion queries, we can render the occlusion bounding box through this method
  154162. * @param mesh Define the mesh to render the occlusion bounding box for
  154163. */
  154164. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  154165. /**
  154166. * Dispose and release the resources attached to this renderer.
  154167. */
  154168. dispose(): void;
  154169. }
  154170. }
  154171. declare module BABYLON {
  154172. interface Scene {
  154173. /** @hidden (Backing field) */
  154174. _depthRenderer: {
  154175. [id: string]: DepthRenderer;
  154176. };
  154177. /**
  154178. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  154179. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  154180. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  154181. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  154182. * @returns the created depth renderer
  154183. */
  154184. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  154185. /**
  154186. * Disables a depth renderer for a given camera
  154187. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  154188. */
  154189. disableDepthRenderer(camera?: Nullable<Camera>): void;
  154190. }
  154191. /**
  154192. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  154193. * in several rendering techniques.
  154194. */
  154195. export class DepthRendererSceneComponent implements ISceneComponent {
  154196. /**
  154197. * The component name helpfull to identify the component in the list of scene components.
  154198. */
  154199. readonly name: string;
  154200. /**
  154201. * The scene the component belongs to.
  154202. */
  154203. scene: Scene;
  154204. /**
  154205. * Creates a new instance of the component for the given scene
  154206. * @param scene Defines the scene to register the component in
  154207. */
  154208. constructor(scene: Scene);
  154209. /**
  154210. * Registers the component in a given scene
  154211. */
  154212. register(): void;
  154213. /**
  154214. * Rebuilds the elements related to this component in case of
  154215. * context lost for instance.
  154216. */
  154217. rebuild(): void;
  154218. /**
  154219. * Disposes the component and the associated ressources
  154220. */
  154221. dispose(): void;
  154222. private _gatherRenderTargets;
  154223. private _gatherActiveCameraRenderTargets;
  154224. }
  154225. }
  154226. declare module BABYLON {
  154227. interface AbstractScene {
  154228. /** @hidden (Backing field) */
  154229. _prePassRenderer: Nullable<PrePassRenderer>;
  154230. /**
  154231. * Gets or Sets the current prepass renderer associated to the scene.
  154232. */
  154233. prePassRenderer: Nullable<PrePassRenderer>;
  154234. /**
  154235. * Enables the prepass and associates it with the scene
  154236. * @returns the PrePassRenderer
  154237. */
  154238. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  154239. /**
  154240. * Disables the prepass associated with the scene
  154241. */
  154242. disablePrePassRenderer(): void;
  154243. }
  154244. /**
  154245. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  154246. * in several rendering techniques.
  154247. */
  154248. export class PrePassRendererSceneComponent implements ISceneComponent {
  154249. /**
  154250. * The component name helpful to identify the component in the list of scene components.
  154251. */
  154252. readonly name: string;
  154253. /**
  154254. * The scene the component belongs to.
  154255. */
  154256. scene: Scene;
  154257. /**
  154258. * Creates a new instance of the component for the given scene
  154259. * @param scene Defines the scene to register the component in
  154260. */
  154261. constructor(scene: Scene);
  154262. /**
  154263. * Registers the component in a given scene
  154264. */
  154265. register(): void;
  154266. private _beforeCameraDraw;
  154267. private _afterCameraDraw;
  154268. private _beforeClearStage;
  154269. /**
  154270. * Rebuilds the elements related to this component in case of
  154271. * context lost for instance.
  154272. */
  154273. rebuild(): void;
  154274. /**
  154275. * Disposes the component and the associated ressources
  154276. */
  154277. dispose(): void;
  154278. }
  154279. }
  154280. declare module BABYLON {
  154281. /** @hidden */
  154282. export var fibonacci: {
  154283. name: string;
  154284. shader: string;
  154285. };
  154286. }
  154287. declare module BABYLON {
  154288. /** @hidden */
  154289. export var diffusionProfile: {
  154290. name: string;
  154291. shader: string;
  154292. };
  154293. }
  154294. declare module BABYLON {
  154295. /** @hidden */
  154296. export var subSurfaceScatteringPixelShader: {
  154297. name: string;
  154298. shader: string;
  154299. };
  154300. }
  154301. declare module BABYLON {
  154302. /**
  154303. * Sub surface scattering post process
  154304. */
  154305. export class SubSurfaceScatteringPostProcess extends PostProcess {
  154306. /**
  154307. * Gets a string identifying the name of the class
  154308. * @returns "SubSurfaceScatteringPostProcess" string
  154309. */
  154310. getClassName(): string;
  154311. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  154312. }
  154313. }
  154314. declare module BABYLON {
  154315. /**
  154316. * Contains all parameters needed for the prepass to perform
  154317. * screen space subsurface scattering
  154318. */
  154319. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  154320. /** @hidden */
  154321. static _SceneComponentInitialization: (scene: Scene) => void;
  154322. private _ssDiffusionS;
  154323. private _ssFilterRadii;
  154324. private _ssDiffusionD;
  154325. /**
  154326. * Post process to attach for screen space subsurface scattering
  154327. */
  154328. postProcess: SubSurfaceScatteringPostProcess;
  154329. /**
  154330. * Diffusion profile color for subsurface scattering
  154331. */
  154332. get ssDiffusionS(): number[];
  154333. /**
  154334. * Diffusion profile max color channel value for subsurface scattering
  154335. */
  154336. get ssDiffusionD(): number[];
  154337. /**
  154338. * Diffusion profile filter radius for subsurface scattering
  154339. */
  154340. get ssFilterRadii(): number[];
  154341. /**
  154342. * Is subsurface enabled
  154343. */
  154344. enabled: boolean;
  154345. /**
  154346. * Name of the configuration
  154347. */
  154348. name: string;
  154349. /**
  154350. * Diffusion profile colors for subsurface scattering
  154351. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  154352. * See ...
  154353. * Note that you can only store up to 5 of them
  154354. */
  154355. ssDiffusionProfileColors: Color3[];
  154356. /**
  154357. * Defines the ratio real world => scene units.
  154358. * Used for subsurface scattering
  154359. */
  154360. metersPerUnit: number;
  154361. /**
  154362. * Textures that should be present in the MRT for this effect to work
  154363. */
  154364. readonly texturesRequired: number[];
  154365. private _scene;
  154366. /**
  154367. * Builds a subsurface configuration object
  154368. * @param scene The scene
  154369. */
  154370. constructor(scene: Scene);
  154371. /**
  154372. * Adds a new diffusion profile.
  154373. * Useful for more realistic subsurface scattering on diverse materials.
  154374. * @param color The color of the diffusion profile. Should be the average color of the material.
  154375. * @return The index of the diffusion profile for the material subsurface configuration
  154376. */
  154377. addDiffusionProfile(color: Color3): number;
  154378. /**
  154379. * Creates the sss post process
  154380. * @return The created post process
  154381. */
  154382. createPostProcess(): SubSurfaceScatteringPostProcess;
  154383. /**
  154384. * Deletes all diffusion profiles.
  154385. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  154386. */
  154387. clearAllDiffusionProfiles(): void;
  154388. /**
  154389. * Disposes this object
  154390. */
  154391. dispose(): void;
  154392. /**
  154393. * @hidden
  154394. * https://zero-radiance.github.io/post/sampling-diffusion/
  154395. *
  154396. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  154397. * ------------------------------------------------------------------------------------
  154398. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  154399. * PDF[r, phi, s] = r * R[r, phi, s]
  154400. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  154401. * ------------------------------------------------------------------------------------
  154402. * We importance sample the color channel with the widest scattering distance.
  154403. */
  154404. getDiffusionProfileParameters(color: Color3): number;
  154405. /**
  154406. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  154407. * 'u' is the random number (the value of the CDF): [0, 1).
  154408. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  154409. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  154410. */
  154411. private _sampleBurleyDiffusionProfile;
  154412. }
  154413. }
  154414. declare module BABYLON {
  154415. interface AbstractScene {
  154416. /** @hidden (Backing field) */
  154417. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  154418. /**
  154419. * Gets or Sets the current prepass renderer associated to the scene.
  154420. */
  154421. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  154422. /**
  154423. * Enables the subsurface effect for prepass
  154424. * @returns the SubSurfaceConfiguration
  154425. */
  154426. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  154427. /**
  154428. * Disables the subsurface effect for prepass
  154429. */
  154430. disableSubSurfaceForPrePass(): void;
  154431. }
  154432. /**
  154433. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  154434. * in several rendering techniques.
  154435. */
  154436. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  154437. /**
  154438. * The component name helpful to identify the component in the list of scene components.
  154439. */
  154440. readonly name: string;
  154441. /**
  154442. * The scene the component belongs to.
  154443. */
  154444. scene: Scene;
  154445. /**
  154446. * Creates a new instance of the component for the given scene
  154447. * @param scene Defines the scene to register the component in
  154448. */
  154449. constructor(scene: Scene);
  154450. /**
  154451. * Registers the component in a given scene
  154452. */
  154453. register(): void;
  154454. /**
  154455. * Serializes the component data to the specified json object
  154456. * @param serializationObject The object to serialize to
  154457. */
  154458. serialize(serializationObject: any): void;
  154459. /**
  154460. * Adds all the elements from the container to the scene
  154461. * @param container the container holding the elements
  154462. */
  154463. addFromContainer(container: AbstractScene): void;
  154464. /**
  154465. * Removes all the elements in the container from the scene
  154466. * @param container contains the elements to remove
  154467. * @param dispose if the removed element should be disposed (default: false)
  154468. */
  154469. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  154470. /**
  154471. * Rebuilds the elements related to this component in case of
  154472. * context lost for instance.
  154473. */
  154474. rebuild(): void;
  154475. /**
  154476. * Disposes the component and the associated ressources
  154477. */
  154478. dispose(): void;
  154479. }
  154480. }
  154481. declare module BABYLON {
  154482. /** @hidden */
  154483. export var outlinePixelShader: {
  154484. name: string;
  154485. shader: string;
  154486. };
  154487. }
  154488. declare module BABYLON {
  154489. /** @hidden */
  154490. export var outlineVertexShader: {
  154491. name: string;
  154492. shader: string;
  154493. };
  154494. }
  154495. declare module BABYLON {
  154496. interface Scene {
  154497. /** @hidden */
  154498. _outlineRenderer: OutlineRenderer;
  154499. /**
  154500. * Gets the outline renderer associated with the scene
  154501. * @returns a OutlineRenderer
  154502. */
  154503. getOutlineRenderer(): OutlineRenderer;
  154504. }
  154505. interface AbstractMesh {
  154506. /** @hidden (Backing field) */
  154507. _renderOutline: boolean;
  154508. /**
  154509. * Gets or sets a boolean indicating if the outline must be rendered as well
  154510. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  154511. */
  154512. renderOutline: boolean;
  154513. /** @hidden (Backing field) */
  154514. _renderOverlay: boolean;
  154515. /**
  154516. * Gets or sets a boolean indicating if the overlay must be rendered as well
  154517. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  154518. */
  154519. renderOverlay: boolean;
  154520. }
  154521. /**
  154522. * This class is responsible to draw bothe outline/overlay of meshes.
  154523. * It should not be used directly but through the available method on mesh.
  154524. */
  154525. export class OutlineRenderer implements ISceneComponent {
  154526. /**
  154527. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  154528. */
  154529. private static _StencilReference;
  154530. /**
  154531. * The name of the component. Each component must have a unique name.
  154532. */
  154533. name: string;
  154534. /**
  154535. * The scene the component belongs to.
  154536. */
  154537. scene: Scene;
  154538. /**
  154539. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  154540. */
  154541. zOffset: number;
  154542. private _engine;
  154543. private _effect;
  154544. private _cachedDefines;
  154545. private _savedDepthWrite;
  154546. /**
  154547. * Instantiates a new outline renderer. (There could be only one per scene).
  154548. * @param scene Defines the scene it belongs to
  154549. */
  154550. constructor(scene: Scene);
  154551. /**
  154552. * Register the component to one instance of a scene.
  154553. */
  154554. register(): void;
  154555. /**
  154556. * Rebuilds the elements related to this component in case of
  154557. * context lost for instance.
  154558. */
  154559. rebuild(): void;
  154560. /**
  154561. * Disposes the component and the associated ressources.
  154562. */
  154563. dispose(): void;
  154564. /**
  154565. * Renders the outline in the canvas.
  154566. * @param subMesh Defines the sumesh to render
  154567. * @param batch Defines the batch of meshes in case of instances
  154568. * @param useOverlay Defines if the rendering is for the overlay or the outline
  154569. */
  154570. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  154571. /**
  154572. * Returns whether or not the outline renderer is ready for a given submesh.
  154573. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  154574. * @param subMesh Defines the submesh to check readyness for
  154575. * @param useInstances Defines wheter wee are trying to render instances or not
  154576. * @returns true if ready otherwise false
  154577. */
  154578. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  154579. private _beforeRenderingMesh;
  154580. private _afterRenderingMesh;
  154581. }
  154582. }
  154583. declare module BABYLON {
  154584. /**
  154585. * Defines the basic options interface of a Sprite Frame Source Size.
  154586. */
  154587. export interface ISpriteJSONSpriteSourceSize {
  154588. /**
  154589. * number of the original width of the Frame
  154590. */
  154591. w: number;
  154592. /**
  154593. * number of the original height of the Frame
  154594. */
  154595. h: number;
  154596. }
  154597. /**
  154598. * Defines the basic options interface of a Sprite Frame Data.
  154599. */
  154600. export interface ISpriteJSONSpriteFrameData {
  154601. /**
  154602. * number of the x offset of the Frame
  154603. */
  154604. x: number;
  154605. /**
  154606. * number of the y offset of the Frame
  154607. */
  154608. y: number;
  154609. /**
  154610. * number of the width of the Frame
  154611. */
  154612. w: number;
  154613. /**
  154614. * number of the height of the Frame
  154615. */
  154616. h: number;
  154617. }
  154618. /**
  154619. * Defines the basic options interface of a JSON Sprite.
  154620. */
  154621. export interface ISpriteJSONSprite {
  154622. /**
  154623. * string name of the Frame
  154624. */
  154625. filename: string;
  154626. /**
  154627. * ISpriteJSONSpriteFrame basic object of the frame data
  154628. */
  154629. frame: ISpriteJSONSpriteFrameData;
  154630. /**
  154631. * boolean to flag is the frame was rotated.
  154632. */
  154633. rotated: boolean;
  154634. /**
  154635. * boolean to flag is the frame was trimmed.
  154636. */
  154637. trimmed: boolean;
  154638. /**
  154639. * ISpriteJSONSpriteFrame basic object of the source data
  154640. */
  154641. spriteSourceSize: ISpriteJSONSpriteFrameData;
  154642. /**
  154643. * ISpriteJSONSpriteFrame basic object of the source data
  154644. */
  154645. sourceSize: ISpriteJSONSpriteSourceSize;
  154646. }
  154647. /**
  154648. * Defines the basic options interface of a JSON atlas.
  154649. */
  154650. export interface ISpriteJSONAtlas {
  154651. /**
  154652. * Array of objects that contain the frame data.
  154653. */
  154654. frames: Array<ISpriteJSONSprite>;
  154655. /**
  154656. * object basic object containing the sprite meta data.
  154657. */
  154658. meta?: object;
  154659. }
  154660. }
  154661. declare module BABYLON {
  154662. /** @hidden */
  154663. export var spriteMapPixelShader: {
  154664. name: string;
  154665. shader: string;
  154666. };
  154667. }
  154668. declare module BABYLON {
  154669. /** @hidden */
  154670. export var spriteMapVertexShader: {
  154671. name: string;
  154672. shader: string;
  154673. };
  154674. }
  154675. declare module BABYLON {
  154676. /**
  154677. * Defines the basic options interface of a SpriteMap
  154678. */
  154679. export interface ISpriteMapOptions {
  154680. /**
  154681. * Vector2 of the number of cells in the grid.
  154682. */
  154683. stageSize?: Vector2;
  154684. /**
  154685. * Vector2 of the size of the output plane in World Units.
  154686. */
  154687. outputSize?: Vector2;
  154688. /**
  154689. * Vector3 of the position of the output plane in World Units.
  154690. */
  154691. outputPosition?: Vector3;
  154692. /**
  154693. * Vector3 of the rotation of the output plane.
  154694. */
  154695. outputRotation?: Vector3;
  154696. /**
  154697. * number of layers that the system will reserve in resources.
  154698. */
  154699. layerCount?: number;
  154700. /**
  154701. * number of max animation frames a single cell will reserve in resources.
  154702. */
  154703. maxAnimationFrames?: number;
  154704. /**
  154705. * number cell index of the base tile when the system compiles.
  154706. */
  154707. baseTile?: number;
  154708. /**
  154709. * boolean flip the sprite after its been repositioned by the framing data.
  154710. */
  154711. flipU?: boolean;
  154712. /**
  154713. * Vector3 scalar of the global RGB values of the SpriteMap.
  154714. */
  154715. colorMultiply?: Vector3;
  154716. }
  154717. /**
  154718. * Defines the IDisposable interface in order to be cleanable from resources.
  154719. */
  154720. export interface ISpriteMap extends IDisposable {
  154721. /**
  154722. * String name of the SpriteMap.
  154723. */
  154724. name: string;
  154725. /**
  154726. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  154727. */
  154728. atlasJSON: ISpriteJSONAtlas;
  154729. /**
  154730. * Texture of the SpriteMap.
  154731. */
  154732. spriteSheet: Texture;
  154733. /**
  154734. * The parameters to initialize the SpriteMap with.
  154735. */
  154736. options: ISpriteMapOptions;
  154737. }
  154738. /**
  154739. * Class used to manage a grid restricted sprite deployment on an Output plane.
  154740. */
  154741. export class SpriteMap implements ISpriteMap {
  154742. /** The Name of the spriteMap */
  154743. name: string;
  154744. /** The JSON file with the frame and meta data */
  154745. atlasJSON: ISpriteJSONAtlas;
  154746. /** The systems Sprite Sheet Texture */
  154747. spriteSheet: Texture;
  154748. /** Arguments passed with the Constructor */
  154749. options: ISpriteMapOptions;
  154750. /** Public Sprite Storage array, parsed from atlasJSON */
  154751. sprites: Array<ISpriteJSONSprite>;
  154752. /** Returns the Number of Sprites in the System */
  154753. get spriteCount(): number;
  154754. /** Returns the Position of Output Plane*/
  154755. get position(): Vector3;
  154756. /** Returns the Position of Output Plane*/
  154757. set position(v: Vector3);
  154758. /** Returns the Rotation of Output Plane*/
  154759. get rotation(): Vector3;
  154760. /** Returns the Rotation of Output Plane*/
  154761. set rotation(v: Vector3);
  154762. /** Sets the AnimationMap*/
  154763. get animationMap(): RawTexture;
  154764. /** Sets the AnimationMap*/
  154765. set animationMap(v: RawTexture);
  154766. /** Scene that the SpriteMap was created in */
  154767. private _scene;
  154768. /** Texture Buffer of Float32 that holds tile frame data*/
  154769. private _frameMap;
  154770. /** Texture Buffers of Float32 that holds tileMap data*/
  154771. private _tileMaps;
  154772. /** Texture Buffer of Float32 that holds Animation Data*/
  154773. private _animationMap;
  154774. /** Custom ShaderMaterial Central to the System*/
  154775. private _material;
  154776. /** Custom ShaderMaterial Central to the System*/
  154777. private _output;
  154778. /** Systems Time Ticker*/
  154779. private _time;
  154780. /**
  154781. * Creates a new SpriteMap
  154782. * @param name defines the SpriteMaps Name
  154783. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  154784. * @param spriteSheet is the Texture that the Sprites are on.
  154785. * @param options a basic deployment configuration
  154786. * @param scene The Scene that the map is deployed on
  154787. */
  154788. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  154789. /**
  154790. * Returns tileID location
  154791. * @returns Vector2 the cell position ID
  154792. */
  154793. getTileID(): Vector2;
  154794. /**
  154795. * Gets the UV location of the mouse over the SpriteMap.
  154796. * @returns Vector2 the UV position of the mouse interaction
  154797. */
  154798. getMousePosition(): Vector2;
  154799. /**
  154800. * Creates the "frame" texture Buffer
  154801. * -------------------------------------
  154802. * Structure of frames
  154803. * "filename": "Falling-Water-2.png",
  154804. * "frame": {"x":69,"y":103,"w":24,"h":32},
  154805. * "rotated": true,
  154806. * "trimmed": true,
  154807. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  154808. * "sourceSize": {"w":32,"h":32}
  154809. * @returns RawTexture of the frameMap
  154810. */
  154811. private _createFrameBuffer;
  154812. /**
  154813. * Creates the tileMap texture Buffer
  154814. * @param buffer normally and array of numbers, or a false to generate from scratch
  154815. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  154816. * @returns RawTexture of the tileMap
  154817. */
  154818. private _createTileBuffer;
  154819. /**
  154820. * Modifies the data of the tileMaps
  154821. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  154822. * @param pos is the iVector2 Coordinates of the Tile
  154823. * @param tile The SpriteIndex of the new Tile
  154824. */
  154825. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  154826. /**
  154827. * Creates the animationMap texture Buffer
  154828. * @param buffer normally and array of numbers, or a false to generate from scratch
  154829. * @returns RawTexture of the animationMap
  154830. */
  154831. private _createTileAnimationBuffer;
  154832. /**
  154833. * Modifies the data of the animationMap
  154834. * @param cellID is the Index of the Sprite
  154835. * @param _frame is the target Animation frame
  154836. * @param toCell is the Target Index of the next frame of the animation
  154837. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  154838. * @param speed is a global scalar of the time variable on the map.
  154839. */
  154840. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  154841. /**
  154842. * Exports the .tilemaps file
  154843. */
  154844. saveTileMaps(): void;
  154845. /**
  154846. * Imports the .tilemaps file
  154847. * @param url of the .tilemaps file
  154848. */
  154849. loadTileMaps(url: string): void;
  154850. /**
  154851. * Release associated resources
  154852. */
  154853. dispose(): void;
  154854. }
  154855. }
  154856. declare module BABYLON {
  154857. /**
  154858. * Class used to manage multiple sprites of different sizes on the same spritesheet
  154859. * @see https://doc.babylonjs.com/babylon101/sprites
  154860. */
  154861. export class SpritePackedManager extends SpriteManager {
  154862. /** defines the packed manager's name */
  154863. name: string;
  154864. /**
  154865. * Creates a new sprite manager from a packed sprite sheet
  154866. * @param name defines the manager's name
  154867. * @param imgUrl defines the sprite sheet url
  154868. * @param capacity defines the maximum allowed number of sprites
  154869. * @param scene defines the hosting scene
  154870. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  154871. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  154872. * @param samplingMode defines the smapling mode to use with spritesheet
  154873. * @param fromPacked set to true; do not alter
  154874. */
  154875. constructor(
  154876. /** defines the packed manager's name */
  154877. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  154878. }
  154879. }
  154880. declare module BABYLON {
  154881. /**
  154882. * Defines the list of states available for a task inside a AssetsManager
  154883. */
  154884. export enum AssetTaskState {
  154885. /**
  154886. * Initialization
  154887. */
  154888. INIT = 0,
  154889. /**
  154890. * Running
  154891. */
  154892. RUNNING = 1,
  154893. /**
  154894. * Done
  154895. */
  154896. DONE = 2,
  154897. /**
  154898. * Error
  154899. */
  154900. ERROR = 3
  154901. }
  154902. /**
  154903. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  154904. */
  154905. export abstract class AbstractAssetTask {
  154906. /**
  154907. * Task name
  154908. */ name: string;
  154909. /**
  154910. * Callback called when the task is successful
  154911. */
  154912. onSuccess: (task: any) => void;
  154913. /**
  154914. * Callback called when the task is not successful
  154915. */
  154916. onError: (task: any, message?: string, exception?: any) => void;
  154917. /**
  154918. * Creates a new AssetsManager
  154919. * @param name defines the name of the task
  154920. */
  154921. constructor(
  154922. /**
  154923. * Task name
  154924. */ name: string);
  154925. private _isCompleted;
  154926. private _taskState;
  154927. private _errorObject;
  154928. /**
  154929. * Get if the task is completed
  154930. */
  154931. get isCompleted(): boolean;
  154932. /**
  154933. * Gets the current state of the task
  154934. */
  154935. get taskState(): AssetTaskState;
  154936. /**
  154937. * Gets the current error object (if task is in error)
  154938. */
  154939. get errorObject(): {
  154940. message?: string;
  154941. exception?: any;
  154942. };
  154943. /**
  154944. * Internal only
  154945. * @hidden
  154946. */
  154947. _setErrorObject(message?: string, exception?: any): void;
  154948. /**
  154949. * Execute the current task
  154950. * @param scene defines the scene where you want your assets to be loaded
  154951. * @param onSuccess is a callback called when the task is successfully executed
  154952. * @param onError is a callback called if an error occurs
  154953. */
  154954. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154955. /**
  154956. * Execute the current task
  154957. * @param scene defines the scene where you want your assets to be loaded
  154958. * @param onSuccess is a callback called when the task is successfully executed
  154959. * @param onError is a callback called if an error occurs
  154960. */
  154961. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154962. /**
  154963. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  154964. * This can be used with failed tasks that have the reason for failure fixed.
  154965. */
  154966. reset(): void;
  154967. private onErrorCallback;
  154968. private onDoneCallback;
  154969. }
  154970. /**
  154971. * Define the interface used by progress events raised during assets loading
  154972. */
  154973. export interface IAssetsProgressEvent {
  154974. /**
  154975. * Defines the number of remaining tasks to process
  154976. */
  154977. remainingCount: number;
  154978. /**
  154979. * Defines the total number of tasks
  154980. */
  154981. totalCount: number;
  154982. /**
  154983. * Defines the task that was just processed
  154984. */
  154985. task: AbstractAssetTask;
  154986. }
  154987. /**
  154988. * Class used to share progress information about assets loading
  154989. */
  154990. export class AssetsProgressEvent implements IAssetsProgressEvent {
  154991. /**
  154992. * Defines the number of remaining tasks to process
  154993. */
  154994. remainingCount: number;
  154995. /**
  154996. * Defines the total number of tasks
  154997. */
  154998. totalCount: number;
  154999. /**
  155000. * Defines the task that was just processed
  155001. */
  155002. task: AbstractAssetTask;
  155003. /**
  155004. * Creates a AssetsProgressEvent
  155005. * @param remainingCount defines the number of remaining tasks to process
  155006. * @param totalCount defines the total number of tasks
  155007. * @param task defines the task that was just processed
  155008. */
  155009. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  155010. }
  155011. /**
  155012. * Define a task used by AssetsManager to load assets into a container
  155013. */
  155014. export class ContainerAssetTask extends AbstractAssetTask {
  155015. /**
  155016. * Defines the name of the task
  155017. */
  155018. name: string;
  155019. /**
  155020. * Defines the list of mesh's names you want to load
  155021. */
  155022. meshesNames: any;
  155023. /**
  155024. * Defines the root url to use as a base to load your meshes and associated resources
  155025. */
  155026. rootUrl: string;
  155027. /**
  155028. * Defines the filename or File of the scene to load from
  155029. */
  155030. sceneFilename: string | File;
  155031. /**
  155032. * Get the loaded asset container
  155033. */
  155034. loadedContainer: AssetContainer;
  155035. /**
  155036. * Gets the list of loaded meshes
  155037. */
  155038. loadedMeshes: Array<AbstractMesh>;
  155039. /**
  155040. * Gets the list of loaded particle systems
  155041. */
  155042. loadedParticleSystems: Array<IParticleSystem>;
  155043. /**
  155044. * Gets the list of loaded skeletons
  155045. */
  155046. loadedSkeletons: Array<Skeleton>;
  155047. /**
  155048. * Gets the list of loaded animation groups
  155049. */
  155050. loadedAnimationGroups: Array<AnimationGroup>;
  155051. /**
  155052. * Callback called when the task is successful
  155053. */
  155054. onSuccess: (task: ContainerAssetTask) => void;
  155055. /**
  155056. * Callback called when the task is successful
  155057. */
  155058. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  155059. /**
  155060. * Creates a new ContainerAssetTask
  155061. * @param name defines the name of the task
  155062. * @param meshesNames defines the list of mesh's names you want to load
  155063. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155064. * @param sceneFilename defines the filename or File of the scene to load from
  155065. */
  155066. constructor(
  155067. /**
  155068. * Defines the name of the task
  155069. */
  155070. name: string,
  155071. /**
  155072. * Defines the list of mesh's names you want to load
  155073. */
  155074. meshesNames: any,
  155075. /**
  155076. * Defines the root url to use as a base to load your meshes and associated resources
  155077. */
  155078. rootUrl: string,
  155079. /**
  155080. * Defines the filename or File of the scene to load from
  155081. */
  155082. sceneFilename: string | File);
  155083. /**
  155084. * Execute the current task
  155085. * @param scene defines the scene where you want your assets to be loaded
  155086. * @param onSuccess is a callback called when the task is successfully executed
  155087. * @param onError is a callback called if an error occurs
  155088. */
  155089. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155090. }
  155091. /**
  155092. * Define a task used by AssetsManager to load meshes
  155093. */
  155094. export class MeshAssetTask extends AbstractAssetTask {
  155095. /**
  155096. * Defines the name of the task
  155097. */
  155098. name: string;
  155099. /**
  155100. * Defines the list of mesh's names you want to load
  155101. */
  155102. meshesNames: any;
  155103. /**
  155104. * Defines the root url to use as a base to load your meshes and associated resources
  155105. */
  155106. rootUrl: string;
  155107. /**
  155108. * Defines the filename or File of the scene to load from
  155109. */
  155110. sceneFilename: string | File;
  155111. /**
  155112. * Gets the list of loaded meshes
  155113. */
  155114. loadedMeshes: Array<AbstractMesh>;
  155115. /**
  155116. * Gets the list of loaded particle systems
  155117. */
  155118. loadedParticleSystems: Array<IParticleSystem>;
  155119. /**
  155120. * Gets the list of loaded skeletons
  155121. */
  155122. loadedSkeletons: Array<Skeleton>;
  155123. /**
  155124. * Gets the list of loaded animation groups
  155125. */
  155126. loadedAnimationGroups: Array<AnimationGroup>;
  155127. /**
  155128. * Callback called when the task is successful
  155129. */
  155130. onSuccess: (task: MeshAssetTask) => void;
  155131. /**
  155132. * Callback called when the task is successful
  155133. */
  155134. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  155135. /**
  155136. * Creates a new MeshAssetTask
  155137. * @param name defines the name of the task
  155138. * @param meshesNames defines the list of mesh's names you want to load
  155139. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155140. * @param sceneFilename defines the filename or File of the scene to load from
  155141. */
  155142. constructor(
  155143. /**
  155144. * Defines the name of the task
  155145. */
  155146. name: string,
  155147. /**
  155148. * Defines the list of mesh's names you want to load
  155149. */
  155150. meshesNames: any,
  155151. /**
  155152. * Defines the root url to use as a base to load your meshes and associated resources
  155153. */
  155154. rootUrl: string,
  155155. /**
  155156. * Defines the filename or File of the scene to load from
  155157. */
  155158. sceneFilename: string | File);
  155159. /**
  155160. * Execute the current task
  155161. * @param scene defines the scene where you want your assets to be loaded
  155162. * @param onSuccess is a callback called when the task is successfully executed
  155163. * @param onError is a callback called if an error occurs
  155164. */
  155165. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155166. }
  155167. /**
  155168. * Define a task used by AssetsManager to load text content
  155169. */
  155170. export class TextFileAssetTask extends AbstractAssetTask {
  155171. /**
  155172. * Defines the name of the task
  155173. */
  155174. name: string;
  155175. /**
  155176. * Defines the location of the file to load
  155177. */
  155178. url: string;
  155179. /**
  155180. * Gets the loaded text string
  155181. */
  155182. text: string;
  155183. /**
  155184. * Callback called when the task is successful
  155185. */
  155186. onSuccess: (task: TextFileAssetTask) => void;
  155187. /**
  155188. * Callback called when the task is successful
  155189. */
  155190. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  155191. /**
  155192. * Creates a new TextFileAssetTask object
  155193. * @param name defines the name of the task
  155194. * @param url defines the location of the file to load
  155195. */
  155196. constructor(
  155197. /**
  155198. * Defines the name of the task
  155199. */
  155200. name: string,
  155201. /**
  155202. * Defines the location of the file to load
  155203. */
  155204. url: string);
  155205. /**
  155206. * Execute the current task
  155207. * @param scene defines the scene where you want your assets to be loaded
  155208. * @param onSuccess is a callback called when the task is successfully executed
  155209. * @param onError is a callback called if an error occurs
  155210. */
  155211. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155212. }
  155213. /**
  155214. * Define a task used by AssetsManager to load binary data
  155215. */
  155216. export class BinaryFileAssetTask extends AbstractAssetTask {
  155217. /**
  155218. * Defines the name of the task
  155219. */
  155220. name: string;
  155221. /**
  155222. * Defines the location of the file to load
  155223. */
  155224. url: string;
  155225. /**
  155226. * Gets the lodaded data (as an array buffer)
  155227. */
  155228. data: ArrayBuffer;
  155229. /**
  155230. * Callback called when the task is successful
  155231. */
  155232. onSuccess: (task: BinaryFileAssetTask) => void;
  155233. /**
  155234. * Callback called when the task is successful
  155235. */
  155236. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  155237. /**
  155238. * Creates a new BinaryFileAssetTask object
  155239. * @param name defines the name of the new task
  155240. * @param url defines the location of the file to load
  155241. */
  155242. constructor(
  155243. /**
  155244. * Defines the name of the task
  155245. */
  155246. name: string,
  155247. /**
  155248. * Defines the location of the file to load
  155249. */
  155250. url: string);
  155251. /**
  155252. * Execute the current task
  155253. * @param scene defines the scene where you want your assets to be loaded
  155254. * @param onSuccess is a callback called when the task is successfully executed
  155255. * @param onError is a callback called if an error occurs
  155256. */
  155257. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155258. }
  155259. /**
  155260. * Define a task used by AssetsManager to load images
  155261. */
  155262. export class ImageAssetTask extends AbstractAssetTask {
  155263. /**
  155264. * Defines the name of the task
  155265. */
  155266. name: string;
  155267. /**
  155268. * Defines the location of the image to load
  155269. */
  155270. url: string;
  155271. /**
  155272. * Gets the loaded images
  155273. */
  155274. image: HTMLImageElement;
  155275. /**
  155276. * Callback called when the task is successful
  155277. */
  155278. onSuccess: (task: ImageAssetTask) => void;
  155279. /**
  155280. * Callback called when the task is successful
  155281. */
  155282. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  155283. /**
  155284. * Creates a new ImageAssetTask
  155285. * @param name defines the name of the task
  155286. * @param url defines the location of the image to load
  155287. */
  155288. constructor(
  155289. /**
  155290. * Defines the name of the task
  155291. */
  155292. name: string,
  155293. /**
  155294. * Defines the location of the image to load
  155295. */
  155296. url: string);
  155297. /**
  155298. * Execute the current task
  155299. * @param scene defines the scene where you want your assets to be loaded
  155300. * @param onSuccess is a callback called when the task is successfully executed
  155301. * @param onError is a callback called if an error occurs
  155302. */
  155303. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155304. }
  155305. /**
  155306. * Defines the interface used by texture loading tasks
  155307. */
  155308. export interface ITextureAssetTask<TEX extends BaseTexture> {
  155309. /**
  155310. * Gets the loaded texture
  155311. */
  155312. texture: TEX;
  155313. }
  155314. /**
  155315. * Define a task used by AssetsManager to load 2D textures
  155316. */
  155317. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  155318. /**
  155319. * Defines the name of the task
  155320. */
  155321. name: string;
  155322. /**
  155323. * Defines the location of the file to load
  155324. */
  155325. url: string;
  155326. /**
  155327. * Defines if mipmap should not be generated (default is false)
  155328. */
  155329. noMipmap?: boolean | undefined;
  155330. /**
  155331. * Defines if texture must be inverted on Y axis (default is true)
  155332. */
  155333. invertY: boolean;
  155334. /**
  155335. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155336. */
  155337. samplingMode: number;
  155338. /**
  155339. * Gets the loaded texture
  155340. */
  155341. texture: Texture;
  155342. /**
  155343. * Callback called when the task is successful
  155344. */
  155345. onSuccess: (task: TextureAssetTask) => void;
  155346. /**
  155347. * Callback called when the task is successful
  155348. */
  155349. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  155350. /**
  155351. * Creates a new TextureAssetTask object
  155352. * @param name defines the name of the task
  155353. * @param url defines the location of the file to load
  155354. * @param noMipmap defines if mipmap should not be generated (default is false)
  155355. * @param invertY defines if texture must be inverted on Y axis (default is true)
  155356. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155357. */
  155358. constructor(
  155359. /**
  155360. * Defines the name of the task
  155361. */
  155362. name: string,
  155363. /**
  155364. * Defines the location of the file to load
  155365. */
  155366. url: string,
  155367. /**
  155368. * Defines if mipmap should not be generated (default is false)
  155369. */
  155370. noMipmap?: boolean | undefined,
  155371. /**
  155372. * Defines if texture must be inverted on Y axis (default is true)
  155373. */
  155374. invertY?: boolean,
  155375. /**
  155376. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155377. */
  155378. samplingMode?: number);
  155379. /**
  155380. * Execute the current task
  155381. * @param scene defines the scene where you want your assets to be loaded
  155382. * @param onSuccess is a callback called when the task is successfully executed
  155383. * @param onError is a callback called if an error occurs
  155384. */
  155385. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155386. }
  155387. /**
  155388. * Define a task used by AssetsManager to load cube textures
  155389. */
  155390. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  155391. /**
  155392. * Defines the name of the task
  155393. */
  155394. name: string;
  155395. /**
  155396. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155397. */
  155398. url: string;
  155399. /**
  155400. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155401. */
  155402. extensions?: string[] | undefined;
  155403. /**
  155404. * Defines if mipmaps should not be generated (default is false)
  155405. */
  155406. noMipmap?: boolean | undefined;
  155407. /**
  155408. * Defines the explicit list of files (undefined by default)
  155409. */
  155410. files?: string[] | undefined;
  155411. /**
  155412. * Gets the loaded texture
  155413. */
  155414. texture: CubeTexture;
  155415. /**
  155416. * Callback called when the task is successful
  155417. */
  155418. onSuccess: (task: CubeTextureAssetTask) => void;
  155419. /**
  155420. * Callback called when the task is successful
  155421. */
  155422. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  155423. /**
  155424. * Creates a new CubeTextureAssetTask
  155425. * @param name defines the name of the task
  155426. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155427. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155428. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155429. * @param files defines the explicit list of files (undefined by default)
  155430. */
  155431. constructor(
  155432. /**
  155433. * Defines the name of the task
  155434. */
  155435. name: string,
  155436. /**
  155437. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155438. */
  155439. url: string,
  155440. /**
  155441. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155442. */
  155443. extensions?: string[] | undefined,
  155444. /**
  155445. * Defines if mipmaps should not be generated (default is false)
  155446. */
  155447. noMipmap?: boolean | undefined,
  155448. /**
  155449. * Defines the explicit list of files (undefined by default)
  155450. */
  155451. files?: string[] | undefined);
  155452. /**
  155453. * Execute the current task
  155454. * @param scene defines the scene where you want your assets to be loaded
  155455. * @param onSuccess is a callback called when the task is successfully executed
  155456. * @param onError is a callback called if an error occurs
  155457. */
  155458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155459. }
  155460. /**
  155461. * Define a task used by AssetsManager to load HDR cube textures
  155462. */
  155463. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  155464. /**
  155465. * Defines the name of the task
  155466. */
  155467. name: string;
  155468. /**
  155469. * Defines the location of the file to load
  155470. */
  155471. url: string;
  155472. /**
  155473. * Defines the desired size (the more it increases the longer the generation will be)
  155474. */
  155475. size: number;
  155476. /**
  155477. * Defines if mipmaps should not be generated (default is false)
  155478. */
  155479. noMipmap: boolean;
  155480. /**
  155481. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155482. */
  155483. generateHarmonics: boolean;
  155484. /**
  155485. * 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)
  155486. */
  155487. gammaSpace: boolean;
  155488. /**
  155489. * Internal Use Only
  155490. */
  155491. reserved: boolean;
  155492. /**
  155493. * Gets the loaded texture
  155494. */
  155495. texture: HDRCubeTexture;
  155496. /**
  155497. * Callback called when the task is successful
  155498. */
  155499. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  155500. /**
  155501. * Callback called when the task is successful
  155502. */
  155503. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  155504. /**
  155505. * Creates a new HDRCubeTextureAssetTask object
  155506. * @param name defines the name of the task
  155507. * @param url defines the location of the file to load
  155508. * @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.
  155509. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155510. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155511. * @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)
  155512. * @param reserved Internal use only
  155513. */
  155514. constructor(
  155515. /**
  155516. * Defines the name of the task
  155517. */
  155518. name: string,
  155519. /**
  155520. * Defines the location of the file to load
  155521. */
  155522. url: string,
  155523. /**
  155524. * Defines the desired size (the more it increases the longer the generation will be)
  155525. */
  155526. size: number,
  155527. /**
  155528. * Defines if mipmaps should not be generated (default is false)
  155529. */
  155530. noMipmap?: boolean,
  155531. /**
  155532. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155533. */
  155534. generateHarmonics?: boolean,
  155535. /**
  155536. * 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)
  155537. */
  155538. gammaSpace?: boolean,
  155539. /**
  155540. * Internal Use Only
  155541. */
  155542. reserved?: boolean);
  155543. /**
  155544. * Execute the current task
  155545. * @param scene defines the scene where you want your assets to be loaded
  155546. * @param onSuccess is a callback called when the task is successfully executed
  155547. * @param onError is a callback called if an error occurs
  155548. */
  155549. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155550. }
  155551. /**
  155552. * Define a task used by AssetsManager to load Equirectangular cube textures
  155553. */
  155554. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  155555. /**
  155556. * Defines the name of the task
  155557. */
  155558. name: string;
  155559. /**
  155560. * Defines the location of the file to load
  155561. */
  155562. url: string;
  155563. /**
  155564. * Defines the desired size (the more it increases the longer the generation will be)
  155565. */
  155566. size: number;
  155567. /**
  155568. * Defines if mipmaps should not be generated (default is false)
  155569. */
  155570. noMipmap: boolean;
  155571. /**
  155572. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  155573. * but the standard material would require them in Gamma space) (default is true)
  155574. */
  155575. gammaSpace: boolean;
  155576. /**
  155577. * Gets the loaded texture
  155578. */
  155579. texture: EquiRectangularCubeTexture;
  155580. /**
  155581. * Callback called when the task is successful
  155582. */
  155583. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  155584. /**
  155585. * Callback called when the task is successful
  155586. */
  155587. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  155588. /**
  155589. * Creates a new EquiRectangularCubeTextureAssetTask object
  155590. * @param name defines the name of the task
  155591. * @param url defines the location of the file to load
  155592. * @param size defines the desired size (the more it increases the longer the generation will be)
  155593. * If the size is omitted this implies you are using a preprocessed cubemap.
  155594. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155595. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  155596. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  155597. * (default is true)
  155598. */
  155599. constructor(
  155600. /**
  155601. * Defines the name of the task
  155602. */
  155603. name: string,
  155604. /**
  155605. * Defines the location of the file to load
  155606. */
  155607. url: string,
  155608. /**
  155609. * Defines the desired size (the more it increases the longer the generation will be)
  155610. */
  155611. size: number,
  155612. /**
  155613. * Defines if mipmaps should not be generated (default is false)
  155614. */
  155615. noMipmap?: boolean,
  155616. /**
  155617. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  155618. * but the standard material would require them in Gamma space) (default is true)
  155619. */
  155620. gammaSpace?: boolean);
  155621. /**
  155622. * Execute the current task
  155623. * @param scene defines the scene where you want your assets to be loaded
  155624. * @param onSuccess is a callback called when the task is successfully executed
  155625. * @param onError is a callback called if an error occurs
  155626. */
  155627. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155628. }
  155629. /**
  155630. * This class can be used to easily import assets into a scene
  155631. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  155632. */
  155633. export class AssetsManager {
  155634. private _scene;
  155635. private _isLoading;
  155636. protected _tasks: AbstractAssetTask[];
  155637. protected _waitingTasksCount: number;
  155638. protected _totalTasksCount: number;
  155639. /**
  155640. * Callback called when all tasks are processed
  155641. */
  155642. onFinish: (tasks: AbstractAssetTask[]) => void;
  155643. /**
  155644. * Callback called when a task is successful
  155645. */
  155646. onTaskSuccess: (task: AbstractAssetTask) => void;
  155647. /**
  155648. * Callback called when a task had an error
  155649. */
  155650. onTaskError: (task: AbstractAssetTask) => void;
  155651. /**
  155652. * Callback called when a task is done (whatever the result is)
  155653. */
  155654. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  155655. /**
  155656. * Observable called when all tasks are processed
  155657. */
  155658. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  155659. /**
  155660. * Observable called when a task had an error
  155661. */
  155662. onTaskErrorObservable: Observable<AbstractAssetTask>;
  155663. /**
  155664. * Observable called when all tasks were executed
  155665. */
  155666. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  155667. /**
  155668. * Observable called when a task is done (whatever the result is)
  155669. */
  155670. onProgressObservable: Observable<IAssetsProgressEvent>;
  155671. /**
  155672. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  155673. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  155674. */
  155675. useDefaultLoadingScreen: boolean;
  155676. /**
  155677. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  155678. * when all assets have been downloaded.
  155679. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  155680. */
  155681. autoHideLoadingUI: boolean;
  155682. /**
  155683. * Creates a new AssetsManager
  155684. * @param scene defines the scene to work on
  155685. */
  155686. constructor(scene: Scene);
  155687. /**
  155688. * Add a ContainerAssetTask to the list of active tasks
  155689. * @param taskName defines the name of the new task
  155690. * @param meshesNames defines the name of meshes to load
  155691. * @param rootUrl defines the root url to use to locate files
  155692. * @param sceneFilename defines the filename of the scene file
  155693. * @returns a new ContainerAssetTask object
  155694. */
  155695. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  155696. /**
  155697. * Add a MeshAssetTask to the list of active tasks
  155698. * @param taskName defines the name of the new task
  155699. * @param meshesNames defines the name of meshes to load
  155700. * @param rootUrl defines the root url to use to locate files
  155701. * @param sceneFilename defines the filename of the scene file
  155702. * @returns a new MeshAssetTask object
  155703. */
  155704. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  155705. /**
  155706. * Add a TextFileAssetTask to the list of active tasks
  155707. * @param taskName defines the name of the new task
  155708. * @param url defines the url of the file to load
  155709. * @returns a new TextFileAssetTask object
  155710. */
  155711. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  155712. /**
  155713. * Add a BinaryFileAssetTask to the list of active tasks
  155714. * @param taskName defines the name of the new task
  155715. * @param url defines the url of the file to load
  155716. * @returns a new BinaryFileAssetTask object
  155717. */
  155718. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  155719. /**
  155720. * Add a ImageAssetTask to the list of active tasks
  155721. * @param taskName defines the name of the new task
  155722. * @param url defines the url of the file to load
  155723. * @returns a new ImageAssetTask object
  155724. */
  155725. addImageTask(taskName: string, url: string): ImageAssetTask;
  155726. /**
  155727. * Add a TextureAssetTask to the list of active tasks
  155728. * @param taskName defines the name of the new task
  155729. * @param url defines the url of the file to load
  155730. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155731. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  155732. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  155733. * @returns a new TextureAssetTask object
  155734. */
  155735. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  155736. /**
  155737. * Add a CubeTextureAssetTask to the list of active tasks
  155738. * @param taskName defines the name of the new task
  155739. * @param url defines the url of the file to load
  155740. * @param extensions defines the extension to use to load the cube map (can be null)
  155741. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155742. * @param files defines the list of files to load (can be null)
  155743. * @returns a new CubeTextureAssetTask object
  155744. */
  155745. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  155746. /**
  155747. *
  155748. * Add a HDRCubeTextureAssetTask to the list of active tasks
  155749. * @param taskName defines the name of the new task
  155750. * @param url defines the url of the file to load
  155751. * @param size defines the size you want for the cubemap (can be null)
  155752. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155753. * @param generateHarmonics defines if you want to automatically generate (true by default)
  155754. * @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)
  155755. * @param reserved Internal use only
  155756. * @returns a new HDRCubeTextureAssetTask object
  155757. */
  155758. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  155759. /**
  155760. *
  155761. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  155762. * @param taskName defines the name of the new task
  155763. * @param url defines the url of the file to load
  155764. * @param size defines the size you want for the cubemap (can be null)
  155765. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155766. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  155767. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  155768. * @returns a new EquiRectangularCubeTextureAssetTask object
  155769. */
  155770. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  155771. /**
  155772. * Remove a task from the assets manager.
  155773. * @param task the task to remove
  155774. */
  155775. removeTask(task: AbstractAssetTask): void;
  155776. private _decreaseWaitingTasksCount;
  155777. private _runTask;
  155778. /**
  155779. * Reset the AssetsManager and remove all tasks
  155780. * @return the current instance of the AssetsManager
  155781. */
  155782. reset(): AssetsManager;
  155783. /**
  155784. * Start the loading process
  155785. * @return the current instance of the AssetsManager
  155786. */
  155787. load(): AssetsManager;
  155788. /**
  155789. * Start the loading process as an async operation
  155790. * @return a promise returning the list of failed tasks
  155791. */
  155792. loadAsync(): Promise<void>;
  155793. }
  155794. }
  155795. declare module BABYLON {
  155796. /**
  155797. * Wrapper class for promise with external resolve and reject.
  155798. */
  155799. export class Deferred<T> {
  155800. /**
  155801. * The promise associated with this deferred object.
  155802. */
  155803. readonly promise: Promise<T>;
  155804. private _resolve;
  155805. private _reject;
  155806. /**
  155807. * The resolve method of the promise associated with this deferred object.
  155808. */
  155809. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  155810. /**
  155811. * The reject method of the promise associated with this deferred object.
  155812. */
  155813. get reject(): (reason?: any) => void;
  155814. /**
  155815. * Constructor for this deferred object.
  155816. */
  155817. constructor();
  155818. }
  155819. }
  155820. declare module BABYLON {
  155821. /**
  155822. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  155823. */
  155824. export class MeshExploder {
  155825. private _centerMesh;
  155826. private _meshes;
  155827. private _meshesOrigins;
  155828. private _toCenterVectors;
  155829. private _scaledDirection;
  155830. private _newPosition;
  155831. private _centerPosition;
  155832. /**
  155833. * Explodes meshes from a center mesh.
  155834. * @param meshes The meshes to explode.
  155835. * @param centerMesh The mesh to be center of explosion.
  155836. */
  155837. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  155838. private _setCenterMesh;
  155839. /**
  155840. * Get class name
  155841. * @returns "MeshExploder"
  155842. */
  155843. getClassName(): string;
  155844. /**
  155845. * "Exploded meshes"
  155846. * @returns Array of meshes with the centerMesh at index 0.
  155847. */
  155848. getMeshes(): Array<Mesh>;
  155849. /**
  155850. * Explodes meshes giving a specific direction
  155851. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  155852. */
  155853. explode(direction?: number): void;
  155854. }
  155855. }
  155856. declare module BABYLON {
  155857. /**
  155858. * Class used to help managing file picking and drag'n'drop
  155859. */
  155860. export class FilesInput {
  155861. /**
  155862. * List of files ready to be loaded
  155863. */
  155864. static get FilesToLoad(): {
  155865. [key: string]: File;
  155866. };
  155867. /**
  155868. * Callback called when a file is processed
  155869. */
  155870. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  155871. private _engine;
  155872. private _currentScene;
  155873. private _sceneLoadedCallback;
  155874. private _progressCallback;
  155875. private _additionalRenderLoopLogicCallback;
  155876. private _textureLoadingCallback;
  155877. private _startingProcessingFilesCallback;
  155878. private _onReloadCallback;
  155879. private _errorCallback;
  155880. private _elementToMonitor;
  155881. private _sceneFileToLoad;
  155882. private _filesToLoad;
  155883. /**
  155884. * Creates a new FilesInput
  155885. * @param engine defines the rendering engine
  155886. * @param scene defines the hosting scene
  155887. * @param sceneLoadedCallback callback called when scene is loaded
  155888. * @param progressCallback callback called to track progress
  155889. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  155890. * @param textureLoadingCallback callback called when a texture is loading
  155891. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  155892. * @param onReloadCallback callback called when a reload is requested
  155893. * @param errorCallback callback call if an error occurs
  155894. */
  155895. 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>);
  155896. private _dragEnterHandler;
  155897. private _dragOverHandler;
  155898. private _dropHandler;
  155899. /**
  155900. * Calls this function to listen to drag'n'drop events on a specific DOM element
  155901. * @param elementToMonitor defines the DOM element to track
  155902. */
  155903. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  155904. /** Gets the current list of files to load */
  155905. get filesToLoad(): File[];
  155906. /**
  155907. * Release all associated resources
  155908. */
  155909. dispose(): void;
  155910. private renderFunction;
  155911. private drag;
  155912. private drop;
  155913. private _traverseFolder;
  155914. private _processFiles;
  155915. /**
  155916. * Load files from a drop event
  155917. * @param event defines the drop event to use as source
  155918. */
  155919. loadFiles(event: any): void;
  155920. private _processReload;
  155921. /**
  155922. * Reload the current scene from the loaded files
  155923. */
  155924. reload(): void;
  155925. }
  155926. }
  155927. declare module BABYLON {
  155928. /**
  155929. * Defines the root class used to create scene optimization to use with SceneOptimizer
  155930. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155931. */
  155932. export class SceneOptimization {
  155933. /**
  155934. * Defines the priority of this optimization (0 by default which means first in the list)
  155935. */
  155936. priority: number;
  155937. /**
  155938. * Gets a string describing the action executed by the current optimization
  155939. * @returns description string
  155940. */
  155941. getDescription(): string;
  155942. /**
  155943. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155944. * @param scene defines the current scene where to apply this optimization
  155945. * @param optimizer defines the current optimizer
  155946. * @returns true if everything that can be done was applied
  155947. */
  155948. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155949. /**
  155950. * Creates the SceneOptimization object
  155951. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155952. * @param desc defines the description associated with the optimization
  155953. */
  155954. constructor(
  155955. /**
  155956. * Defines the priority of this optimization (0 by default which means first in the list)
  155957. */
  155958. priority?: number);
  155959. }
  155960. /**
  155961. * Defines an optimization used to reduce the size of render target textures
  155962. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155963. */
  155964. export class TextureOptimization extends SceneOptimization {
  155965. /**
  155966. * Defines the priority of this optimization (0 by default which means first in the list)
  155967. */
  155968. priority: number;
  155969. /**
  155970. * 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
  155971. */
  155972. maximumSize: number;
  155973. /**
  155974. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155975. */
  155976. step: number;
  155977. /**
  155978. * Gets a string describing the action executed by the current optimization
  155979. * @returns description string
  155980. */
  155981. getDescription(): string;
  155982. /**
  155983. * Creates the TextureOptimization object
  155984. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155985. * @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
  155986. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155987. */
  155988. constructor(
  155989. /**
  155990. * Defines the priority of this optimization (0 by default which means first in the list)
  155991. */
  155992. priority?: number,
  155993. /**
  155994. * 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
  155995. */
  155996. maximumSize?: number,
  155997. /**
  155998. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155999. */
  156000. step?: number);
  156001. /**
  156002. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156003. * @param scene defines the current scene where to apply this optimization
  156004. * @param optimizer defines the current optimizer
  156005. * @returns true if everything that can be done was applied
  156006. */
  156007. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156008. }
  156009. /**
  156010. * Defines an optimization used to increase or decrease the rendering resolution
  156011. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156012. */
  156013. export class HardwareScalingOptimization extends SceneOptimization {
  156014. /**
  156015. * Defines the priority of this optimization (0 by default which means first in the list)
  156016. */
  156017. priority: number;
  156018. /**
  156019. * Defines the maximum scale to use (2 by default)
  156020. */
  156021. maximumScale: number;
  156022. /**
  156023. * Defines the step to use between two passes (0.5 by default)
  156024. */
  156025. step: number;
  156026. private _currentScale;
  156027. private _directionOffset;
  156028. /**
  156029. * Gets a string describing the action executed by the current optimization
  156030. * @return description string
  156031. */
  156032. getDescription(): string;
  156033. /**
  156034. * Creates the HardwareScalingOptimization object
  156035. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156036. * @param maximumScale defines the maximum scale to use (2 by default)
  156037. * @param step defines the step to use between two passes (0.5 by default)
  156038. */
  156039. constructor(
  156040. /**
  156041. * Defines the priority of this optimization (0 by default which means first in the list)
  156042. */
  156043. priority?: number,
  156044. /**
  156045. * Defines the maximum scale to use (2 by default)
  156046. */
  156047. maximumScale?: number,
  156048. /**
  156049. * Defines the step to use between two passes (0.5 by default)
  156050. */
  156051. step?: number);
  156052. /**
  156053. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156054. * @param scene defines the current scene where to apply this optimization
  156055. * @param optimizer defines the current optimizer
  156056. * @returns true if everything that can be done was applied
  156057. */
  156058. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156059. }
  156060. /**
  156061. * Defines an optimization used to remove shadows
  156062. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156063. */
  156064. export class ShadowsOptimization extends SceneOptimization {
  156065. /**
  156066. * Gets a string describing the action executed by the current optimization
  156067. * @return description string
  156068. */
  156069. getDescription(): string;
  156070. /**
  156071. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156072. * @param scene defines the current scene where to apply this optimization
  156073. * @param optimizer defines the current optimizer
  156074. * @returns true if everything that can be done was applied
  156075. */
  156076. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156077. }
  156078. /**
  156079. * Defines an optimization used to turn post-processes off
  156080. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156081. */
  156082. export class PostProcessesOptimization extends SceneOptimization {
  156083. /**
  156084. * Gets a string describing the action executed by the current optimization
  156085. * @return description string
  156086. */
  156087. getDescription(): string;
  156088. /**
  156089. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156090. * @param scene defines the current scene where to apply this optimization
  156091. * @param optimizer defines the current optimizer
  156092. * @returns true if everything that can be done was applied
  156093. */
  156094. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156095. }
  156096. /**
  156097. * Defines an optimization used to turn lens flares off
  156098. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156099. */
  156100. export class LensFlaresOptimization extends SceneOptimization {
  156101. /**
  156102. * Gets a string describing the action executed by the current optimization
  156103. * @return description string
  156104. */
  156105. getDescription(): string;
  156106. /**
  156107. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156108. * @param scene defines the current scene where to apply this optimization
  156109. * @param optimizer defines the current optimizer
  156110. * @returns true if everything that can be done was applied
  156111. */
  156112. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156113. }
  156114. /**
  156115. * Defines an optimization based on user defined callback.
  156116. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156117. */
  156118. export class CustomOptimization extends SceneOptimization {
  156119. /**
  156120. * Callback called to apply the custom optimization.
  156121. */
  156122. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  156123. /**
  156124. * Callback called to get custom description
  156125. */
  156126. onGetDescription: () => string;
  156127. /**
  156128. * Gets a string describing the action executed by the current optimization
  156129. * @returns description string
  156130. */
  156131. getDescription(): string;
  156132. /**
  156133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156134. * @param scene defines the current scene where to apply this optimization
  156135. * @param optimizer defines the current optimizer
  156136. * @returns true if everything that can be done was applied
  156137. */
  156138. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156139. }
  156140. /**
  156141. * Defines an optimization used to turn particles off
  156142. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156143. */
  156144. export class ParticlesOptimization extends SceneOptimization {
  156145. /**
  156146. * Gets a string describing the action executed by the current optimization
  156147. * @return description string
  156148. */
  156149. getDescription(): string;
  156150. /**
  156151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156152. * @param scene defines the current scene where to apply this optimization
  156153. * @param optimizer defines the current optimizer
  156154. * @returns true if everything that can be done was applied
  156155. */
  156156. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156157. }
  156158. /**
  156159. * Defines an optimization used to turn render targets off
  156160. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156161. */
  156162. export class RenderTargetsOptimization extends SceneOptimization {
  156163. /**
  156164. * Gets a string describing the action executed by the current optimization
  156165. * @return description string
  156166. */
  156167. getDescription(): string;
  156168. /**
  156169. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156170. * @param scene defines the current scene where to apply this optimization
  156171. * @param optimizer defines the current optimizer
  156172. * @returns true if everything that can be done was applied
  156173. */
  156174. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156175. }
  156176. /**
  156177. * Defines an optimization used to merge meshes with compatible materials
  156178. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156179. */
  156180. export class MergeMeshesOptimization extends SceneOptimization {
  156181. private static _UpdateSelectionTree;
  156182. /**
  156183. * Gets or sets a boolean which defines if optimization octree has to be updated
  156184. */
  156185. static get UpdateSelectionTree(): boolean;
  156186. /**
  156187. * Gets or sets a boolean which defines if optimization octree has to be updated
  156188. */
  156189. static set UpdateSelectionTree(value: boolean);
  156190. /**
  156191. * Gets a string describing the action executed by the current optimization
  156192. * @return description string
  156193. */
  156194. getDescription(): string;
  156195. private _canBeMerged;
  156196. /**
  156197. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156198. * @param scene defines the current scene where to apply this optimization
  156199. * @param optimizer defines the current optimizer
  156200. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  156201. * @returns true if everything that can be done was applied
  156202. */
  156203. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  156204. }
  156205. /**
  156206. * Defines a list of options used by SceneOptimizer
  156207. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156208. */
  156209. export class SceneOptimizerOptions {
  156210. /**
  156211. * Defines the target frame rate to reach (60 by default)
  156212. */
  156213. targetFrameRate: number;
  156214. /**
  156215. * Defines the interval between two checkes (2000ms by default)
  156216. */
  156217. trackerDuration: number;
  156218. /**
  156219. * Gets the list of optimizations to apply
  156220. */
  156221. optimizations: SceneOptimization[];
  156222. /**
  156223. * Creates a new list of options used by SceneOptimizer
  156224. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  156225. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  156226. */
  156227. constructor(
  156228. /**
  156229. * Defines the target frame rate to reach (60 by default)
  156230. */
  156231. targetFrameRate?: number,
  156232. /**
  156233. * Defines the interval between two checkes (2000ms by default)
  156234. */
  156235. trackerDuration?: number);
  156236. /**
  156237. * Add a new optimization
  156238. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  156239. * @returns the current SceneOptimizerOptions
  156240. */
  156241. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  156242. /**
  156243. * Add a new custom optimization
  156244. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  156245. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  156246. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156247. * @returns the current SceneOptimizerOptions
  156248. */
  156249. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  156250. /**
  156251. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  156252. * @param targetFrameRate defines the target frame rate (60 by default)
  156253. * @returns a SceneOptimizerOptions object
  156254. */
  156255. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156256. /**
  156257. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  156258. * @param targetFrameRate defines the target frame rate (60 by default)
  156259. * @returns a SceneOptimizerOptions object
  156260. */
  156261. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156262. /**
  156263. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  156264. * @param targetFrameRate defines the target frame rate (60 by default)
  156265. * @returns a SceneOptimizerOptions object
  156266. */
  156267. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156268. }
  156269. /**
  156270. * Class used to run optimizations in order to reach a target frame rate
  156271. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156272. */
  156273. export class SceneOptimizer implements IDisposable {
  156274. private _isRunning;
  156275. private _options;
  156276. private _scene;
  156277. private _currentPriorityLevel;
  156278. private _targetFrameRate;
  156279. private _trackerDuration;
  156280. private _currentFrameRate;
  156281. private _sceneDisposeObserver;
  156282. private _improvementMode;
  156283. /**
  156284. * Defines an observable called when the optimizer reaches the target frame rate
  156285. */
  156286. onSuccessObservable: Observable<SceneOptimizer>;
  156287. /**
  156288. * Defines an observable called when the optimizer enables an optimization
  156289. */
  156290. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  156291. /**
  156292. * Defines an observable called when the optimizer is not able to reach the target frame rate
  156293. */
  156294. onFailureObservable: Observable<SceneOptimizer>;
  156295. /**
  156296. * Gets a boolean indicating if the optimizer is in improvement mode
  156297. */
  156298. get isInImprovementMode(): boolean;
  156299. /**
  156300. * Gets the current priority level (0 at start)
  156301. */
  156302. get currentPriorityLevel(): number;
  156303. /**
  156304. * Gets the current frame rate checked by the SceneOptimizer
  156305. */
  156306. get currentFrameRate(): number;
  156307. /**
  156308. * Gets or sets the current target frame rate (60 by default)
  156309. */
  156310. get targetFrameRate(): number;
  156311. /**
  156312. * Gets or sets the current target frame rate (60 by default)
  156313. */
  156314. set targetFrameRate(value: number);
  156315. /**
  156316. * Gets or sets the current interval between two checks (every 2000ms by default)
  156317. */
  156318. get trackerDuration(): number;
  156319. /**
  156320. * Gets or sets the current interval between two checks (every 2000ms by default)
  156321. */
  156322. set trackerDuration(value: number);
  156323. /**
  156324. * Gets the list of active optimizations
  156325. */
  156326. get optimizations(): SceneOptimization[];
  156327. /**
  156328. * Creates a new SceneOptimizer
  156329. * @param scene defines the scene to work on
  156330. * @param options defines the options to use with the SceneOptimizer
  156331. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  156332. * @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)
  156333. */
  156334. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  156335. /**
  156336. * Stops the current optimizer
  156337. */
  156338. stop(): void;
  156339. /**
  156340. * Reset the optimizer to initial step (current priority level = 0)
  156341. */
  156342. reset(): void;
  156343. /**
  156344. * Start the optimizer. By default it will try to reach a specific framerate
  156345. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  156346. */
  156347. start(): void;
  156348. private _checkCurrentState;
  156349. /**
  156350. * Release all resources
  156351. */
  156352. dispose(): void;
  156353. /**
  156354. * Helper function to create a SceneOptimizer with one single line of code
  156355. * @param scene defines the scene to work on
  156356. * @param options defines the options to use with the SceneOptimizer
  156357. * @param onSuccess defines a callback to call on success
  156358. * @param onFailure defines a callback to call on failure
  156359. * @returns the new SceneOptimizer object
  156360. */
  156361. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  156362. }
  156363. }
  156364. declare module BABYLON {
  156365. /**
  156366. * Class used to serialize a scene into a string
  156367. */
  156368. export class SceneSerializer {
  156369. /**
  156370. * Clear cache used by a previous serialization
  156371. */
  156372. static ClearCache(): void;
  156373. /**
  156374. * Serialize a scene into a JSON compatible object
  156375. * @param scene defines the scene to serialize
  156376. * @returns a JSON compatible object
  156377. */
  156378. static Serialize(scene: Scene): any;
  156379. /**
  156380. * Serialize a mesh into a JSON compatible object
  156381. * @param toSerialize defines the mesh to serialize
  156382. * @param withParents defines if parents must be serialized as well
  156383. * @param withChildren defines if children must be serialized as well
  156384. * @returns a JSON compatible object
  156385. */
  156386. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  156387. }
  156388. }
  156389. declare module BABYLON {
  156390. /**
  156391. * Class used to host texture specific utilities
  156392. */
  156393. export class TextureTools {
  156394. /**
  156395. * Uses the GPU to create a copy texture rescaled at a given size
  156396. * @param texture Texture to copy from
  156397. * @param width defines the desired width
  156398. * @param height defines the desired height
  156399. * @param useBilinearMode defines if bilinear mode has to be used
  156400. * @return the generated texture
  156401. */
  156402. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  156403. }
  156404. }
  156405. declare module BABYLON {
  156406. /**
  156407. * This represents the different options available for the video capture.
  156408. */
  156409. export interface VideoRecorderOptions {
  156410. /** Defines the mime type of the video. */
  156411. mimeType: string;
  156412. /** Defines the FPS the video should be recorded at. */
  156413. fps: number;
  156414. /** Defines the chunk size for the recording data. */
  156415. recordChunckSize: number;
  156416. /** The audio tracks to attach to the recording. */
  156417. audioTracks?: MediaStreamTrack[];
  156418. }
  156419. /**
  156420. * This can help with recording videos from BabylonJS.
  156421. * This is based on the available WebRTC functionalities of the browser.
  156422. *
  156423. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  156424. */
  156425. export class VideoRecorder {
  156426. private static readonly _defaultOptions;
  156427. /**
  156428. * Returns whether or not the VideoRecorder is available in your browser.
  156429. * @param engine Defines the Babylon Engine.
  156430. * @returns true if supported otherwise false.
  156431. */
  156432. static IsSupported(engine: Engine): boolean;
  156433. private readonly _options;
  156434. private _canvas;
  156435. private _mediaRecorder;
  156436. private _recordedChunks;
  156437. private _fileName;
  156438. private _resolve;
  156439. private _reject;
  156440. /**
  156441. * True when a recording is already in progress.
  156442. */
  156443. get isRecording(): boolean;
  156444. /**
  156445. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  156446. * @param engine Defines the BabylonJS Engine you wish to record.
  156447. * @param options Defines options that can be used to customize the capture.
  156448. */
  156449. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  156450. /**
  156451. * Stops the current recording before the default capture timeout passed in the startRecording function.
  156452. */
  156453. stopRecording(): void;
  156454. /**
  156455. * Starts recording the canvas for a max duration specified in parameters.
  156456. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  156457. * If null no automatic download will start and you can rely on the promise to get the data back.
  156458. * @param maxDuration Defines the maximum recording time in seconds.
  156459. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  156460. * @return A promise callback at the end of the recording with the video data in Blob.
  156461. */
  156462. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  156463. /**
  156464. * Releases internal resources used during the recording.
  156465. */
  156466. dispose(): void;
  156467. private _handleDataAvailable;
  156468. private _handleError;
  156469. private _handleStop;
  156470. }
  156471. }
  156472. declare module BABYLON {
  156473. /**
  156474. * Class containing a set of static utilities functions for screenshots
  156475. */
  156476. export class ScreenshotTools {
  156477. /**
  156478. * Captures a screenshot of the current rendering
  156479. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156480. * @param engine defines the rendering engine
  156481. * @param camera defines the source camera
  156482. * @param size This parameter can be set to a single number or to an object with the
  156483. * following (optional) properties: precision, width, height. If a single number is passed,
  156484. * it will be used for both width and height. If an object is passed, the screenshot size
  156485. * will be derived from the parameters. The precision property is a multiplier allowing
  156486. * rendering at a higher or lower resolution
  156487. * @param successCallback defines the callback receives a single parameter which contains the
  156488. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  156489. * src parameter of an <img> to display it
  156490. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  156491. * Check your browser for supported MIME types
  156492. */
  156493. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  156494. /**
  156495. * Captures a screenshot of the current rendering
  156496. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156497. * @param engine defines the rendering engine
  156498. * @param camera defines the source camera
  156499. * @param size This parameter can be set to a single number or to an object with the
  156500. * following (optional) properties: precision, width, height. If a single number is passed,
  156501. * it will be used for both width and height. If an object is passed, the screenshot size
  156502. * will be derived from the parameters. The precision property is a multiplier allowing
  156503. * rendering at a higher or lower resolution
  156504. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  156505. * Check your browser for supported MIME types
  156506. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  156507. * to the src parameter of an <img> to display it
  156508. */
  156509. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  156510. /**
  156511. * Generates an image screenshot from the specified camera.
  156512. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156513. * @param engine The engine to use for rendering
  156514. * @param camera The camera to use for rendering
  156515. * @param size This parameter can be set to a single number or to an object with the
  156516. * following (optional) properties: precision, width, height. If a single number is passed,
  156517. * it will be used for both width and height. If an object is passed, the screenshot size
  156518. * will be derived from the parameters. The precision property is a multiplier allowing
  156519. * rendering at a higher or lower resolution
  156520. * @param successCallback The callback receives a single parameter which contains the
  156521. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  156522. * src parameter of an <img> to display it
  156523. * @param mimeType The MIME type of the screenshot image (default: image/png).
  156524. * Check your browser for supported MIME types
  156525. * @param samples Texture samples (default: 1)
  156526. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  156527. * @param fileName A name for for the downloaded file.
  156528. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  156529. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  156530. */
  156531. 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;
  156532. /**
  156533. * Generates an image screenshot from the specified camera.
  156534. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156535. * @param engine The engine to use for rendering
  156536. * @param camera The camera to use for rendering
  156537. * @param size This parameter can be set to a single number or to an object with the
  156538. * following (optional) properties: precision, width, height. If a single number is passed,
  156539. * it will be used for both width and height. If an object is passed, the screenshot size
  156540. * will be derived from the parameters. The precision property is a multiplier allowing
  156541. * rendering at a higher or lower resolution
  156542. * @param mimeType The MIME type of the screenshot image (default: image/png).
  156543. * Check your browser for supported MIME types
  156544. * @param samples Texture samples (default: 1)
  156545. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  156546. * @param fileName A name for for the downloaded file.
  156547. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  156548. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  156549. * to the src parameter of an <img> to display it
  156550. */
  156551. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  156552. /**
  156553. * Gets height and width for screenshot size
  156554. * @private
  156555. */
  156556. private static _getScreenshotSize;
  156557. }
  156558. }
  156559. declare module BABYLON {
  156560. /**
  156561. * Interface for a data buffer
  156562. */
  156563. export interface IDataBuffer {
  156564. /**
  156565. * Reads bytes from the data buffer.
  156566. * @param byteOffset The byte offset to read
  156567. * @param byteLength The byte length to read
  156568. * @returns A promise that resolves when the bytes are read
  156569. */
  156570. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  156571. /**
  156572. * The byte length of the buffer.
  156573. */
  156574. readonly byteLength: number;
  156575. }
  156576. /**
  156577. * Utility class for reading from a data buffer
  156578. */
  156579. export class DataReader {
  156580. /**
  156581. * The data buffer associated with this data reader.
  156582. */
  156583. readonly buffer: IDataBuffer;
  156584. /**
  156585. * The current byte offset from the beginning of the data buffer.
  156586. */
  156587. byteOffset: number;
  156588. private _dataView;
  156589. private _dataByteOffset;
  156590. /**
  156591. * Constructor
  156592. * @param buffer The buffer to read
  156593. */
  156594. constructor(buffer: IDataBuffer);
  156595. /**
  156596. * Loads the given byte length.
  156597. * @param byteLength The byte length to load
  156598. * @returns A promise that resolves when the load is complete
  156599. */
  156600. loadAsync(byteLength: number): Promise<void>;
  156601. /**
  156602. * Read a unsigned 32-bit integer from the currently loaded data range.
  156603. * @returns The 32-bit integer read
  156604. */
  156605. readUint32(): number;
  156606. /**
  156607. * Read a byte array from the currently loaded data range.
  156608. * @param byteLength The byte length to read
  156609. * @returns The byte array read
  156610. */
  156611. readUint8Array(byteLength: number): Uint8Array;
  156612. /**
  156613. * Read a string from the currently loaded data range.
  156614. * @param byteLength The byte length to read
  156615. * @returns The string read
  156616. */
  156617. readString(byteLength: number): string;
  156618. /**
  156619. * Skips the given byte length the currently loaded data range.
  156620. * @param byteLength The byte length to skip
  156621. */
  156622. skipBytes(byteLength: number): void;
  156623. }
  156624. }
  156625. declare module BABYLON {
  156626. /**
  156627. * Class for storing data to local storage if available or in-memory storage otherwise
  156628. */
  156629. export class DataStorage {
  156630. private static _Storage;
  156631. private static _GetStorage;
  156632. /**
  156633. * Reads a string from the data storage
  156634. * @param key The key to read
  156635. * @param defaultValue The value if the key doesn't exist
  156636. * @returns The string value
  156637. */
  156638. static ReadString(key: string, defaultValue: string): string;
  156639. /**
  156640. * Writes a string to the data storage
  156641. * @param key The key to write
  156642. * @param value The value to write
  156643. */
  156644. static WriteString(key: string, value: string): void;
  156645. /**
  156646. * Reads a boolean from the data storage
  156647. * @param key The key to read
  156648. * @param defaultValue The value if the key doesn't exist
  156649. * @returns The boolean value
  156650. */
  156651. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  156652. /**
  156653. * Writes a boolean to the data storage
  156654. * @param key The key to write
  156655. * @param value The value to write
  156656. */
  156657. static WriteBoolean(key: string, value: boolean): void;
  156658. /**
  156659. * Reads a number from the data storage
  156660. * @param key The key to read
  156661. * @param defaultValue The value if the key doesn't exist
  156662. * @returns The number value
  156663. */
  156664. static ReadNumber(key: string, defaultValue: number): number;
  156665. /**
  156666. * Writes a number to the data storage
  156667. * @param key The key to write
  156668. * @param value The value to write
  156669. */
  156670. static WriteNumber(key: string, value: number): void;
  156671. }
  156672. }
  156673. declare module BABYLON {
  156674. /**
  156675. * Class used to record delta files between 2 scene states
  156676. */
  156677. export class SceneRecorder {
  156678. private _trackedScene;
  156679. private _savedJSON;
  156680. /**
  156681. * Track a given scene. This means the current scene state will be considered the original state
  156682. * @param scene defines the scene to track
  156683. */
  156684. track(scene: Scene): void;
  156685. /**
  156686. * Get the delta between current state and original state
  156687. * @returns a string containing the delta
  156688. */
  156689. getDelta(): any;
  156690. private _compareArray;
  156691. private _compareObjects;
  156692. private _compareCollections;
  156693. private static GetShadowGeneratorById;
  156694. /**
  156695. * Apply a given delta to a given scene
  156696. * @param deltaJSON defines the JSON containing the delta
  156697. * @param scene defines the scene to apply the delta to
  156698. */
  156699. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  156700. private static _ApplyPropertiesToEntity;
  156701. private static _ApplyDeltaForEntity;
  156702. }
  156703. }
  156704. declare module BABYLON {
  156705. /**
  156706. * A 3D trajectory consisting of an order list of vectors describing a
  156707. * path of motion through 3D space.
  156708. */
  156709. export class Trajectory {
  156710. private _points;
  156711. private readonly _segmentLength;
  156712. /**
  156713. * Serialize to JSON.
  156714. * @returns serialized JSON string
  156715. */
  156716. serialize(): string;
  156717. /**
  156718. * Deserialize from JSON.
  156719. * @param json serialized JSON string
  156720. * @returns deserialized Trajectory
  156721. */
  156722. static Deserialize(json: string): Trajectory;
  156723. /**
  156724. * Create a new empty Trajectory.
  156725. * @param segmentLength radius of discretization for Trajectory points
  156726. */
  156727. constructor(segmentLength?: number);
  156728. /**
  156729. * Get the length of the Trajectory.
  156730. * @returns length of the Trajectory
  156731. */
  156732. getLength(): number;
  156733. /**
  156734. * Append a new point to the Trajectory.
  156735. * NOTE: This implementation has many allocations.
  156736. * @param point point to append to the Trajectory
  156737. */
  156738. add(point: DeepImmutable<Vector3>): void;
  156739. /**
  156740. * Create a new Trajectory with a segment length chosen to make it
  156741. * probable that the new Trajectory will have a specified number of
  156742. * segments. This operation is imprecise.
  156743. * @param targetResolution number of segments desired
  156744. * @returns new Trajectory with approximately the requested number of segments
  156745. */
  156746. resampleAtTargetResolution(targetResolution: number): Trajectory;
  156747. /**
  156748. * Convert Trajectory segments into tokenized representation. This
  156749. * representation is an array of numbers where each nth number is the
  156750. * index of the token which is most similar to the nth segment of the
  156751. * Trajectory.
  156752. * @param tokens list of vectors which serve as discrete tokens
  156753. * @returns list of indices of most similar token per segment
  156754. */
  156755. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  156756. private static _forwardDir;
  156757. private static _inverseFromVec;
  156758. private static _upDir;
  156759. private static _fromToVec;
  156760. private static _lookMatrix;
  156761. /**
  156762. * Transform the rotation (i.e., direction) of a segment to isolate
  156763. * the relative transformation represented by the segment. This operation
  156764. * may or may not succeed due to singularities in the equations that define
  156765. * motion relativity in this context.
  156766. * @param priorVec the origin of the prior segment
  156767. * @param fromVec the origin of the current segment
  156768. * @param toVec the destination of the current segment
  156769. * @param result reference to output variable
  156770. * @returns whether or not transformation was successful
  156771. */
  156772. private static _transformSegmentDirToRef;
  156773. private static _bestMatch;
  156774. private static _score;
  156775. private static _bestScore;
  156776. /**
  156777. * Determine which token vector is most similar to the
  156778. * segment vector.
  156779. * @param segment segment vector
  156780. * @param tokens token vector list
  156781. * @returns index of the most similar token to the segment
  156782. */
  156783. private static _tokenizeSegment;
  156784. }
  156785. /**
  156786. * Class representing a set of known, named trajectories to which Trajectories can be
  156787. * added and using which Trajectories can be recognized.
  156788. */
  156789. export class TrajectoryClassifier {
  156790. private _maximumAllowableMatchCost;
  156791. private _vector3Alphabet;
  156792. private _levenshteinAlphabet;
  156793. private _nameToDescribedTrajectory;
  156794. /**
  156795. * Serialize to JSON.
  156796. * @returns JSON serialization
  156797. */
  156798. serialize(): string;
  156799. /**
  156800. * Deserialize from JSON.
  156801. * @param json JSON serialization
  156802. * @returns deserialized TrajectorySet
  156803. */
  156804. static Deserialize(json: string): TrajectoryClassifier;
  156805. /**
  156806. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  156807. * VERY naive, need to be generating these things from known
  156808. * sets. Better version later, probably eliminating this one.
  156809. * @returns auto-generated TrajectorySet
  156810. */
  156811. static Generate(): TrajectoryClassifier;
  156812. private constructor();
  156813. /**
  156814. * Add a new Trajectory to the set with a given name.
  156815. * @param trajectory new Trajectory to be added
  156816. * @param classification name to which to add the Trajectory
  156817. */
  156818. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  156819. /**
  156820. * Remove a known named trajectory and all Trajectories associated with it.
  156821. * @param classification name to remove
  156822. * @returns whether anything was removed
  156823. */
  156824. deleteClassification(classification: string): boolean;
  156825. /**
  156826. * Attempt to recognize a Trajectory from among all the classifications
  156827. * already known to the classifier.
  156828. * @param trajectory Trajectory to be recognized
  156829. * @returns classification of Trajectory if recognized, null otherwise
  156830. */
  156831. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  156832. }
  156833. }
  156834. declare module BABYLON {
  156835. /**
  156836. * An interface for all Hit test features
  156837. */
  156838. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  156839. /**
  156840. * Triggered when new babylon (transformed) hit test results are available
  156841. */
  156842. onHitTestResultObservable: Observable<T[]>;
  156843. }
  156844. /**
  156845. * Options used for hit testing
  156846. */
  156847. export interface IWebXRLegacyHitTestOptions {
  156848. /**
  156849. * Only test when user interacted with the scene. Default - hit test every frame
  156850. */
  156851. testOnPointerDownOnly?: boolean;
  156852. /**
  156853. * The node to use to transform the local results to world coordinates
  156854. */
  156855. worldParentNode?: TransformNode;
  156856. }
  156857. /**
  156858. * Interface defining the babylon result of raycasting/hit-test
  156859. */
  156860. export interface IWebXRLegacyHitResult {
  156861. /**
  156862. * Transformation matrix that can be applied to a node that will put it in the hit point location
  156863. */
  156864. transformationMatrix: Matrix;
  156865. /**
  156866. * The native hit test result
  156867. */
  156868. xrHitResult: XRHitResult | XRHitTestResult;
  156869. }
  156870. /**
  156871. * The currently-working hit-test module.
  156872. * Hit test (or Ray-casting) is used to interact with the real world.
  156873. * For further information read here - https://github.com/immersive-web/hit-test
  156874. */
  156875. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  156876. /**
  156877. * options to use when constructing this feature
  156878. */
  156879. readonly options: IWebXRLegacyHitTestOptions;
  156880. private _direction;
  156881. private _mat;
  156882. private _onSelectEnabled;
  156883. private _origin;
  156884. /**
  156885. * The module's name
  156886. */
  156887. static readonly Name: string;
  156888. /**
  156889. * The (Babylon) version of this module.
  156890. * This is an integer representing the implementation version.
  156891. * This number does not correspond to the WebXR specs version
  156892. */
  156893. static readonly Version: number;
  156894. /**
  156895. * Populated with the last native XR Hit Results
  156896. */
  156897. lastNativeXRHitResults: XRHitResult[];
  156898. /**
  156899. * Triggered when new babylon (transformed) hit test results are available
  156900. */
  156901. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  156902. /**
  156903. * Creates a new instance of the (legacy version) hit test feature
  156904. * @param _xrSessionManager an instance of WebXRSessionManager
  156905. * @param options options to use when constructing this feature
  156906. */
  156907. constructor(_xrSessionManager: WebXRSessionManager,
  156908. /**
  156909. * options to use when constructing this feature
  156910. */
  156911. options?: IWebXRLegacyHitTestOptions);
  156912. /**
  156913. * execute a hit test with an XR Ray
  156914. *
  156915. * @param xrSession a native xrSession that will execute this hit test
  156916. * @param xrRay the ray (position and direction) to use for ray-casting
  156917. * @param referenceSpace native XR reference space to use for the hit-test
  156918. * @param filter filter function that will filter the results
  156919. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156920. */
  156921. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  156922. /**
  156923. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  156924. * @param event the (select) event to use to select with
  156925. * @param referenceSpace the reference space to use for this hit test
  156926. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156927. */
  156928. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156929. /**
  156930. * attach this feature
  156931. * Will usually be called by the features manager
  156932. *
  156933. * @returns true if successful.
  156934. */
  156935. attach(): boolean;
  156936. /**
  156937. * detach this feature.
  156938. * Will usually be called by the features manager
  156939. *
  156940. * @returns true if successful.
  156941. */
  156942. detach(): boolean;
  156943. /**
  156944. * Dispose this feature and all of the resources attached
  156945. */
  156946. dispose(): void;
  156947. protected _onXRFrame(frame: XRFrame): void;
  156948. private _onHitTestResults;
  156949. private _onSelect;
  156950. }
  156951. }
  156952. declare module BABYLON {
  156953. /**
  156954. * Options used for hit testing (version 2)
  156955. */
  156956. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  156957. /**
  156958. * Do not create a permanent hit test. Will usually be used when only
  156959. * transient inputs are needed.
  156960. */
  156961. disablePermanentHitTest?: boolean;
  156962. /**
  156963. * Enable transient (for example touch-based) hit test inspections
  156964. */
  156965. enableTransientHitTest?: boolean;
  156966. /**
  156967. * Offset ray for the permanent hit test
  156968. */
  156969. offsetRay?: Vector3;
  156970. /**
  156971. * Offset ray for the transient hit test
  156972. */
  156973. transientOffsetRay?: Vector3;
  156974. /**
  156975. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  156976. */
  156977. useReferenceSpace?: boolean;
  156978. /**
  156979. * Override the default entity type(s) of the hit-test result
  156980. */
  156981. entityTypes?: XRHitTestTrackableType[];
  156982. }
  156983. /**
  156984. * Interface defining the babylon result of hit-test
  156985. */
  156986. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  156987. /**
  156988. * The input source that generated this hit test (if transient)
  156989. */
  156990. inputSource?: XRInputSource;
  156991. /**
  156992. * Is this a transient hit test
  156993. */
  156994. isTransient?: boolean;
  156995. /**
  156996. * Position of the hit test result
  156997. */
  156998. position: Vector3;
  156999. /**
  157000. * Rotation of the hit test result
  157001. */
  157002. rotationQuaternion: Quaternion;
  157003. /**
  157004. * The native hit test result
  157005. */
  157006. xrHitResult: XRHitTestResult;
  157007. }
  157008. /**
  157009. * The currently-working hit-test module.
  157010. * Hit test (or Ray-casting) is used to interact with the real world.
  157011. * For further information read here - https://github.com/immersive-web/hit-test
  157012. *
  157013. * Tested on chrome (mobile) 80.
  157014. */
  157015. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  157016. /**
  157017. * options to use when constructing this feature
  157018. */
  157019. readonly options: IWebXRHitTestOptions;
  157020. private _tmpMat;
  157021. private _tmpPos;
  157022. private _tmpQuat;
  157023. private _transientXrHitTestSource;
  157024. private _xrHitTestSource;
  157025. private initHitTestSource;
  157026. /**
  157027. * The module's name
  157028. */
  157029. static readonly Name: string;
  157030. /**
  157031. * The (Babylon) version of this module.
  157032. * This is an integer representing the implementation version.
  157033. * This number does not correspond to the WebXR specs version
  157034. */
  157035. static readonly Version: number;
  157036. /**
  157037. * When set to true, each hit test will have its own position/rotation objects
  157038. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  157039. * the developers will clone them or copy them as they see fit.
  157040. */
  157041. autoCloneTransformation: boolean;
  157042. /**
  157043. * Triggered when new babylon (transformed) hit test results are available
  157044. * Note - this will be called when results come back from the device. It can be an empty array!!
  157045. */
  157046. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  157047. /**
  157048. * Use this to temporarily pause hit test checks.
  157049. */
  157050. paused: boolean;
  157051. /**
  157052. * Creates a new instance of the hit test feature
  157053. * @param _xrSessionManager an instance of WebXRSessionManager
  157054. * @param options options to use when constructing this feature
  157055. */
  157056. constructor(_xrSessionManager: WebXRSessionManager,
  157057. /**
  157058. * options to use when constructing this feature
  157059. */
  157060. options?: IWebXRHitTestOptions);
  157061. /**
  157062. * attach this feature
  157063. * Will usually be called by the features manager
  157064. *
  157065. * @returns true if successful.
  157066. */
  157067. attach(): boolean;
  157068. /**
  157069. * detach this feature.
  157070. * Will usually be called by the features manager
  157071. *
  157072. * @returns true if successful.
  157073. */
  157074. detach(): boolean;
  157075. /**
  157076. * Dispose this feature and all of the resources attached
  157077. */
  157078. dispose(): void;
  157079. protected _onXRFrame(frame: XRFrame): void;
  157080. private _processWebXRHitTestResult;
  157081. }
  157082. }
  157083. declare module BABYLON {
  157084. /**
  157085. * Configuration options of the anchor system
  157086. */
  157087. export interface IWebXRAnchorSystemOptions {
  157088. /**
  157089. * a node that will be used to convert local to world coordinates
  157090. */
  157091. worldParentNode?: TransformNode;
  157092. /**
  157093. * If set to true a reference of the created anchors will be kept until the next session starts
  157094. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  157095. */
  157096. doNotRemoveAnchorsOnSessionEnded?: boolean;
  157097. }
  157098. /**
  157099. * A babylon container for an XR Anchor
  157100. */
  157101. export interface IWebXRAnchor {
  157102. /**
  157103. * A babylon-assigned ID for this anchor
  157104. */
  157105. id: number;
  157106. /**
  157107. * Transformation matrix to apply to an object attached to this anchor
  157108. */
  157109. transformationMatrix: Matrix;
  157110. /**
  157111. * The native anchor object
  157112. */
  157113. xrAnchor: XRAnchor;
  157114. /**
  157115. * if defined, this object will be constantly updated by the anchor's position and rotation
  157116. */
  157117. attachedNode?: TransformNode;
  157118. }
  157119. /**
  157120. * An implementation of the anchor system for WebXR.
  157121. * For further information see https://github.com/immersive-web/anchors/
  157122. */
  157123. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  157124. private _options;
  157125. private _lastFrameDetected;
  157126. private _trackedAnchors;
  157127. private _referenceSpaceForFrameAnchors;
  157128. private _futureAnchors;
  157129. /**
  157130. * The module's name
  157131. */
  157132. static readonly Name: string;
  157133. /**
  157134. * The (Babylon) version of this module.
  157135. * This is an integer representing the implementation version.
  157136. * This number does not correspond to the WebXR specs version
  157137. */
  157138. static readonly Version: number;
  157139. /**
  157140. * Observers registered here will be executed when a new anchor was added to the session
  157141. */
  157142. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  157143. /**
  157144. * Observers registered here will be executed when an anchor was removed from the session
  157145. */
  157146. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  157147. /**
  157148. * Observers registered here will be executed when an existing anchor updates
  157149. * This can execute N times every frame
  157150. */
  157151. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  157152. /**
  157153. * Set the reference space to use for anchor creation, when not using a hit test.
  157154. * Will default to the session's reference space if not defined
  157155. */
  157156. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  157157. /**
  157158. * constructs a new anchor system
  157159. * @param _xrSessionManager an instance of WebXRSessionManager
  157160. * @param _options configuration object for this feature
  157161. */
  157162. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  157163. private _tmpVector;
  157164. private _tmpQuaternion;
  157165. private _populateTmpTransformation;
  157166. /**
  157167. * Create a new anchor point using a hit test result at a specific point in the scene
  157168. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157169. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157170. *
  157171. * @param hitTestResult The hit test result to use for this anchor creation
  157172. * @param position an optional position offset for this anchor
  157173. * @param rotationQuaternion an optional rotation offset for this anchor
  157174. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  157175. */
  157176. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  157177. /**
  157178. * Add a new anchor at a specific position and rotation
  157179. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  157180. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  157181. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157182. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157183. *
  157184. * @param position the position in which to add an anchor
  157185. * @param rotationQuaternion an optional rotation for the anchor transformation
  157186. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  157187. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  157188. */
  157189. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  157190. /**
  157191. * detach this feature.
  157192. * Will usually be called by the features manager
  157193. *
  157194. * @returns true if successful.
  157195. */
  157196. detach(): boolean;
  157197. /**
  157198. * Dispose this feature and all of the resources attached
  157199. */
  157200. dispose(): void;
  157201. protected _onXRFrame(frame: XRFrame): void;
  157202. /**
  157203. * avoiding using Array.find for global support.
  157204. * @param xrAnchor the plane to find in the array
  157205. */
  157206. private _findIndexInAnchorArray;
  157207. private _updateAnchorWithXRFrame;
  157208. private _createAnchorAtTransformation;
  157209. }
  157210. }
  157211. declare module BABYLON {
  157212. /**
  157213. * Options used in the plane detector module
  157214. */
  157215. export interface IWebXRPlaneDetectorOptions {
  157216. /**
  157217. * The node to use to transform the local results to world coordinates
  157218. */
  157219. worldParentNode?: TransformNode;
  157220. /**
  157221. * If set to true a reference of the created planes will be kept until the next session starts
  157222. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  157223. */
  157224. doNotRemovePlanesOnSessionEnded?: boolean;
  157225. }
  157226. /**
  157227. * A babylon interface for a WebXR plane.
  157228. * A Plane is actually a polygon, built from N points in space
  157229. *
  157230. * Supported in chrome 79, not supported in canary 81 ATM
  157231. */
  157232. export interface IWebXRPlane {
  157233. /**
  157234. * a babylon-assigned ID for this polygon
  157235. */
  157236. id: number;
  157237. /**
  157238. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  157239. */
  157240. polygonDefinition: Array<Vector3>;
  157241. /**
  157242. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  157243. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  157244. */
  157245. transformationMatrix: Matrix;
  157246. /**
  157247. * the native xr-plane object
  157248. */
  157249. xrPlane: XRPlane;
  157250. }
  157251. /**
  157252. * The plane detector is used to detect planes in the real world when in AR
  157253. * For more information see https://github.com/immersive-web/real-world-geometry/
  157254. */
  157255. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  157256. private _options;
  157257. private _detectedPlanes;
  157258. private _enabled;
  157259. private _lastFrameDetected;
  157260. /**
  157261. * The module's name
  157262. */
  157263. static readonly Name: string;
  157264. /**
  157265. * The (Babylon) version of this module.
  157266. * This is an integer representing the implementation version.
  157267. * This number does not correspond to the WebXR specs version
  157268. */
  157269. static readonly Version: number;
  157270. /**
  157271. * Observers registered here will be executed when a new plane was added to the session
  157272. */
  157273. onPlaneAddedObservable: Observable<IWebXRPlane>;
  157274. /**
  157275. * Observers registered here will be executed when a plane is no longer detected in the session
  157276. */
  157277. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  157278. /**
  157279. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  157280. * This can execute N times every frame
  157281. */
  157282. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  157283. /**
  157284. * construct a new Plane Detector
  157285. * @param _xrSessionManager an instance of xr Session manager
  157286. * @param _options configuration to use when constructing this feature
  157287. */
  157288. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  157289. /**
  157290. * detach this feature.
  157291. * Will usually be called by the features manager
  157292. *
  157293. * @returns true if successful.
  157294. */
  157295. detach(): boolean;
  157296. /**
  157297. * Dispose this feature and all of the resources attached
  157298. */
  157299. dispose(): void;
  157300. /**
  157301. * Check if the needed objects are defined.
  157302. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  157303. */
  157304. isCompatible(): boolean;
  157305. protected _onXRFrame(frame: XRFrame): void;
  157306. private _init;
  157307. private _updatePlaneWithXRPlane;
  157308. /**
  157309. * avoiding using Array.find for global support.
  157310. * @param xrPlane the plane to find in the array
  157311. */
  157312. private findIndexInPlaneArray;
  157313. }
  157314. }
  157315. declare module BABYLON {
  157316. /**
  157317. * Options interface for the background remover plugin
  157318. */
  157319. export interface IWebXRBackgroundRemoverOptions {
  157320. /**
  157321. * Further background meshes to disable when entering AR
  157322. */
  157323. backgroundMeshes?: AbstractMesh[];
  157324. /**
  157325. * flags to configure the removal of the environment helper.
  157326. * If not set, the entire background will be removed. If set, flags should be set as well.
  157327. */
  157328. environmentHelperRemovalFlags?: {
  157329. /**
  157330. * Should the skybox be removed (default false)
  157331. */
  157332. skyBox?: boolean;
  157333. /**
  157334. * Should the ground be removed (default false)
  157335. */
  157336. ground?: boolean;
  157337. };
  157338. /**
  157339. * don't disable the environment helper
  157340. */
  157341. ignoreEnvironmentHelper?: boolean;
  157342. }
  157343. /**
  157344. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  157345. */
  157346. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  157347. /**
  157348. * read-only options to be used in this module
  157349. */
  157350. readonly options: IWebXRBackgroundRemoverOptions;
  157351. /**
  157352. * The module's name
  157353. */
  157354. static readonly Name: string;
  157355. /**
  157356. * The (Babylon) version of this module.
  157357. * This is an integer representing the implementation version.
  157358. * This number does not correspond to the WebXR specs version
  157359. */
  157360. static readonly Version: number;
  157361. /**
  157362. * registered observers will be triggered when the background state changes
  157363. */
  157364. onBackgroundStateChangedObservable: Observable<boolean>;
  157365. /**
  157366. * constructs a new background remover module
  157367. * @param _xrSessionManager the session manager for this module
  157368. * @param options read-only options to be used in this module
  157369. */
  157370. constructor(_xrSessionManager: WebXRSessionManager,
  157371. /**
  157372. * read-only options to be used in this module
  157373. */
  157374. options?: IWebXRBackgroundRemoverOptions);
  157375. /**
  157376. * attach this feature
  157377. * Will usually be called by the features manager
  157378. *
  157379. * @returns true if successful.
  157380. */
  157381. attach(): boolean;
  157382. /**
  157383. * detach this feature.
  157384. * Will usually be called by the features manager
  157385. *
  157386. * @returns true if successful.
  157387. */
  157388. detach(): boolean;
  157389. /**
  157390. * Dispose this feature and all of the resources attached
  157391. */
  157392. dispose(): void;
  157393. protected _onXRFrame(_xrFrame: XRFrame): void;
  157394. private _setBackgroundState;
  157395. }
  157396. }
  157397. declare module BABYLON {
  157398. /**
  157399. * Options for the controller physics feature
  157400. */
  157401. export class IWebXRControllerPhysicsOptions {
  157402. /**
  157403. * Should the headset get its own impostor
  157404. */
  157405. enableHeadsetImpostor?: boolean;
  157406. /**
  157407. * Optional parameters for the headset impostor
  157408. */
  157409. headsetImpostorParams?: {
  157410. /**
  157411. * The type of impostor to create. Default is sphere
  157412. */
  157413. impostorType: number;
  157414. /**
  157415. * the size of the impostor. Defaults to 10cm
  157416. */
  157417. impostorSize?: number | {
  157418. width: number;
  157419. height: number;
  157420. depth: number;
  157421. };
  157422. /**
  157423. * Friction definitions
  157424. */
  157425. friction?: number;
  157426. /**
  157427. * Restitution
  157428. */
  157429. restitution?: number;
  157430. };
  157431. /**
  157432. * The physics properties of the future impostors
  157433. */
  157434. physicsProperties?: {
  157435. /**
  157436. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  157437. * Note that this requires a physics engine that supports mesh impostors!
  157438. */
  157439. useControllerMesh?: boolean;
  157440. /**
  157441. * The type of impostor to create. Default is sphere
  157442. */
  157443. impostorType?: number;
  157444. /**
  157445. * the size of the impostor. Defaults to 10cm
  157446. */
  157447. impostorSize?: number | {
  157448. width: number;
  157449. height: number;
  157450. depth: number;
  157451. };
  157452. /**
  157453. * Friction definitions
  157454. */
  157455. friction?: number;
  157456. /**
  157457. * Restitution
  157458. */
  157459. restitution?: number;
  157460. };
  157461. /**
  157462. * the xr input to use with this pointer selection
  157463. */
  157464. xrInput: WebXRInput;
  157465. }
  157466. /**
  157467. * Add physics impostor to your webxr controllers,
  157468. * including naive calculation of their linear and angular velocity
  157469. */
  157470. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  157471. private readonly _options;
  157472. private _attachController;
  157473. private _controllers;
  157474. private _debugMode;
  157475. private _delta;
  157476. private _headsetImpostor?;
  157477. private _headsetMesh?;
  157478. private _lastTimestamp;
  157479. private _tmpQuaternion;
  157480. private _tmpVector;
  157481. /**
  157482. * The module's name
  157483. */
  157484. static readonly Name: string;
  157485. /**
  157486. * The (Babylon) version of this module.
  157487. * This is an integer representing the implementation version.
  157488. * This number does not correspond to the webxr specs version
  157489. */
  157490. static readonly Version: number;
  157491. /**
  157492. * Construct a new Controller Physics Feature
  157493. * @param _xrSessionManager the corresponding xr session manager
  157494. * @param _options options to create this feature with
  157495. */
  157496. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  157497. /**
  157498. * @hidden
  157499. * enable debugging - will show console outputs and the impostor mesh
  157500. */
  157501. _enablePhysicsDebug(): void;
  157502. /**
  157503. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  157504. * @param xrController the controller to add
  157505. */
  157506. addController(xrController: WebXRInputSource): void;
  157507. /**
  157508. * attach this feature
  157509. * Will usually be called by the features manager
  157510. *
  157511. * @returns true if successful.
  157512. */
  157513. attach(): boolean;
  157514. /**
  157515. * detach this feature.
  157516. * Will usually be called by the features manager
  157517. *
  157518. * @returns true if successful.
  157519. */
  157520. detach(): boolean;
  157521. /**
  157522. * Get the headset impostor, if enabled
  157523. * @returns the impostor
  157524. */
  157525. getHeadsetImpostor(): PhysicsImpostor | undefined;
  157526. /**
  157527. * Get the physics impostor of a specific controller.
  157528. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  157529. * @param controller the controller or the controller id of which to get the impostor
  157530. * @returns the impostor or null
  157531. */
  157532. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  157533. /**
  157534. * Update the physics properties provided in the constructor
  157535. * @param newProperties the new properties object
  157536. */
  157537. setPhysicsProperties(newProperties: {
  157538. impostorType?: number;
  157539. impostorSize?: number | {
  157540. width: number;
  157541. height: number;
  157542. depth: number;
  157543. };
  157544. friction?: number;
  157545. restitution?: number;
  157546. }): void;
  157547. protected _onXRFrame(_xrFrame: any): void;
  157548. private _detachController;
  157549. }
  157550. }
  157551. declare module BABYLON {
  157552. /**
  157553. * A babylon interface for a "WebXR" feature point.
  157554. * Represents the position and confidence value of a given feature point.
  157555. */
  157556. export interface IWebXRFeaturePoint {
  157557. /**
  157558. * Represents the position of the feature point in world space.
  157559. */
  157560. position: Vector3;
  157561. /**
  157562. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  157563. */
  157564. confidenceValue: number;
  157565. }
  157566. /**
  157567. * The feature point system is used to detect feature points from real world geometry.
  157568. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  157569. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  157570. */
  157571. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  157572. private _enabled;
  157573. private _featurePointCloud;
  157574. /**
  157575. * The module's name
  157576. */
  157577. static readonly Name: string;
  157578. /**
  157579. * The (Babylon) version of this module.
  157580. * This is an integer representing the implementation version.
  157581. * This number does not correspond to the WebXR specs version
  157582. */
  157583. static readonly Version: number;
  157584. /**
  157585. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  157586. * Will notify the observers about which feature points have been added.
  157587. */
  157588. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  157589. /**
  157590. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  157591. * Will notify the observers about which feature points have been updated.
  157592. */
  157593. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  157594. /**
  157595. * The current feature point cloud maintained across frames.
  157596. */
  157597. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  157598. /**
  157599. * construct the feature point system
  157600. * @param _xrSessionManager an instance of xr Session manager
  157601. */
  157602. constructor(_xrSessionManager: WebXRSessionManager);
  157603. /**
  157604. * Detach this feature.
  157605. * Will usually be called by the features manager
  157606. *
  157607. * @returns true if successful.
  157608. */
  157609. detach(): boolean;
  157610. /**
  157611. * Dispose this feature and all of the resources attached
  157612. */
  157613. dispose(): void;
  157614. /**
  157615. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  157616. */
  157617. protected _onXRFrame(frame: XRFrame): void;
  157618. /**
  157619. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  157620. */
  157621. private _init;
  157622. }
  157623. }
  157624. declare module BABYLON {
  157625. /**
  157626. * Configuration interface for the hand tracking feature
  157627. */
  157628. export interface IWebXRHandTrackingOptions {
  157629. /**
  157630. * The xrInput that will be used as source for new hands
  157631. */
  157632. xrInput: WebXRInput;
  157633. /**
  157634. * Configuration object for the joint meshes
  157635. */
  157636. jointMeshes?: {
  157637. /**
  157638. * Should the meshes created be invisible (defaults to false)
  157639. */
  157640. invisible?: boolean;
  157641. /**
  157642. * A source mesh to be used to create instances. Defaults to a sphere.
  157643. * This mesh will be the source for all other (25) meshes.
  157644. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  157645. */
  157646. sourceMesh?: Mesh;
  157647. /**
  157648. * This function will be called after a mesh was created for a specific joint.
  157649. * Using this function you can either manipulate the instance or return a new mesh.
  157650. * When returning a new mesh the instance created before will be disposed
  157651. */
  157652. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  157653. /**
  157654. * Should the source mesh stay visible. Defaults to false
  157655. */
  157656. keepOriginalVisible?: boolean;
  157657. /**
  157658. * Scale factor for all instances (defaults to 2)
  157659. */
  157660. scaleFactor?: number;
  157661. /**
  157662. * Should each instance have its own physics impostor
  157663. */
  157664. enablePhysics?: boolean;
  157665. /**
  157666. * If enabled, override default physics properties
  157667. */
  157668. physicsProps?: {
  157669. friction?: number;
  157670. restitution?: number;
  157671. impostorType?: number;
  157672. };
  157673. /**
  157674. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  157675. */
  157676. handMesh?: AbstractMesh;
  157677. };
  157678. }
  157679. /**
  157680. * Parts of the hands divided to writs and finger names
  157681. */
  157682. export const enum HandPart {
  157683. /**
  157684. * HandPart - Wrist
  157685. */
  157686. WRIST = "wrist",
  157687. /**
  157688. * HandPart - The THumb
  157689. */
  157690. THUMB = "thumb",
  157691. /**
  157692. * HandPart - Index finger
  157693. */
  157694. INDEX = "index",
  157695. /**
  157696. * HandPart - Middle finger
  157697. */
  157698. MIDDLE = "middle",
  157699. /**
  157700. * HandPart - Ring finger
  157701. */
  157702. RING = "ring",
  157703. /**
  157704. * HandPart - Little finger
  157705. */
  157706. LITTLE = "little"
  157707. }
  157708. /**
  157709. * Representing a single hand (with its corresponding native XRHand object)
  157710. */
  157711. export class WebXRHand implements IDisposable {
  157712. /** the controller to which the hand correlates */
  157713. readonly xrController: WebXRInputSource;
  157714. /** the meshes to be used to track the hand joints */
  157715. readonly trackedMeshes: AbstractMesh[];
  157716. /**
  157717. * Hand-parts definition (key is HandPart)
  157718. */
  157719. handPartsDefinition: {
  157720. [key: string]: number[];
  157721. };
  157722. /**
  157723. * Populate the HandPartsDefinition object.
  157724. * This is called as a side effect since certain browsers don't have XRHand defined.
  157725. */
  157726. private generateHandPartsDefinition;
  157727. /**
  157728. * Construct a new hand object
  157729. * @param xrController the controller to which the hand correlates
  157730. * @param trackedMeshes the meshes to be used to track the hand joints
  157731. */
  157732. constructor(
  157733. /** the controller to which the hand correlates */
  157734. xrController: WebXRInputSource,
  157735. /** the meshes to be used to track the hand joints */
  157736. trackedMeshes: AbstractMesh[]);
  157737. /**
  157738. * Update this hand from the latest xr frame
  157739. * @param xrFrame xrFrame to update from
  157740. * @param referenceSpace The current viewer reference space
  157741. * @param scaleFactor optional scale factor for the meshes
  157742. */
  157743. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  157744. /**
  157745. * Get meshes of part of the hand
  157746. * @param part the part of hand to get
  157747. * @returns An array of meshes that correlate to the hand part requested
  157748. */
  157749. getHandPartMeshes(part: HandPart): AbstractMesh[];
  157750. /**
  157751. * Dispose this Hand object
  157752. */
  157753. dispose(): void;
  157754. }
  157755. /**
  157756. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  157757. */
  157758. export class WebXRHandTracking extends WebXRAbstractFeature {
  157759. /**
  157760. * options to use when constructing this feature
  157761. */
  157762. readonly options: IWebXRHandTrackingOptions;
  157763. private static _idCounter;
  157764. /**
  157765. * The module's name
  157766. */
  157767. static readonly Name: string;
  157768. /**
  157769. * The (Babylon) version of this module.
  157770. * This is an integer representing the implementation version.
  157771. * This number does not correspond to the WebXR specs version
  157772. */
  157773. static readonly Version: number;
  157774. /**
  157775. * This observable will notify registered observers when a new hand object was added and initialized
  157776. */
  157777. onHandAddedObservable: Observable<WebXRHand>;
  157778. /**
  157779. * This observable will notify its observers right before the hand object is disposed
  157780. */
  157781. onHandRemovedObservable: Observable<WebXRHand>;
  157782. private _hands;
  157783. /**
  157784. * Creates a new instance of the hit test feature
  157785. * @param _xrSessionManager an instance of WebXRSessionManager
  157786. * @param options options to use when constructing this feature
  157787. */
  157788. constructor(_xrSessionManager: WebXRSessionManager,
  157789. /**
  157790. * options to use when constructing this feature
  157791. */
  157792. options: IWebXRHandTrackingOptions);
  157793. /**
  157794. * Check if the needed objects are defined.
  157795. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  157796. */
  157797. isCompatible(): boolean;
  157798. /**
  157799. * attach this feature
  157800. * Will usually be called by the features manager
  157801. *
  157802. * @returns true if successful.
  157803. */
  157804. attach(): boolean;
  157805. /**
  157806. * detach this feature.
  157807. * Will usually be called by the features manager
  157808. *
  157809. * @returns true if successful.
  157810. */
  157811. detach(): boolean;
  157812. /**
  157813. * Dispose this feature and all of the resources attached
  157814. */
  157815. dispose(): void;
  157816. /**
  157817. * Get the hand object according to the controller id
  157818. * @param controllerId the controller id to which we want to get the hand
  157819. * @returns null if not found or the WebXRHand object if found
  157820. */
  157821. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  157822. /**
  157823. * Get a hand object according to the requested handedness
  157824. * @param handedness the handedness to request
  157825. * @returns null if not found or the WebXRHand object if found
  157826. */
  157827. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  157828. protected _onXRFrame(_xrFrame: XRFrame): void;
  157829. private _attachHand;
  157830. private _detachHand;
  157831. }
  157832. }
  157833. declare module BABYLON {
  157834. /**
  157835. * The motion controller class for all microsoft mixed reality controllers
  157836. */
  157837. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  157838. protected readonly _mapping: {
  157839. defaultButton: {
  157840. valueNodeName: string;
  157841. unpressedNodeName: string;
  157842. pressedNodeName: string;
  157843. };
  157844. defaultAxis: {
  157845. valueNodeName: string;
  157846. minNodeName: string;
  157847. maxNodeName: string;
  157848. };
  157849. buttons: {
  157850. "xr-standard-trigger": {
  157851. rootNodeName: string;
  157852. componentProperty: string;
  157853. states: string[];
  157854. };
  157855. "xr-standard-squeeze": {
  157856. rootNodeName: string;
  157857. componentProperty: string;
  157858. states: string[];
  157859. };
  157860. "xr-standard-touchpad": {
  157861. rootNodeName: string;
  157862. labelAnchorNodeName: string;
  157863. touchPointNodeName: string;
  157864. };
  157865. "xr-standard-thumbstick": {
  157866. rootNodeName: string;
  157867. componentProperty: string;
  157868. states: string[];
  157869. };
  157870. };
  157871. axes: {
  157872. "xr-standard-touchpad": {
  157873. "x-axis": {
  157874. rootNodeName: string;
  157875. };
  157876. "y-axis": {
  157877. rootNodeName: string;
  157878. };
  157879. };
  157880. "xr-standard-thumbstick": {
  157881. "x-axis": {
  157882. rootNodeName: string;
  157883. };
  157884. "y-axis": {
  157885. rootNodeName: string;
  157886. };
  157887. };
  157888. };
  157889. };
  157890. /**
  157891. * The base url used to load the left and right controller models
  157892. */
  157893. static MODEL_BASE_URL: string;
  157894. /**
  157895. * The name of the left controller model file
  157896. */
  157897. static MODEL_LEFT_FILENAME: string;
  157898. /**
  157899. * The name of the right controller model file
  157900. */
  157901. static MODEL_RIGHT_FILENAME: string;
  157902. profileId: string;
  157903. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157904. protected _getFilenameAndPath(): {
  157905. filename: string;
  157906. path: string;
  157907. };
  157908. protected _getModelLoadingConstraints(): boolean;
  157909. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157910. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157911. protected _updateModel(): void;
  157912. }
  157913. }
  157914. declare module BABYLON {
  157915. /**
  157916. * The motion controller class for oculus touch (quest, rift).
  157917. * This class supports legacy mapping as well the standard xr mapping
  157918. */
  157919. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  157920. private _forceLegacyControllers;
  157921. private _modelRootNode;
  157922. /**
  157923. * The base url used to load the left and right controller models
  157924. */
  157925. static MODEL_BASE_URL: string;
  157926. /**
  157927. * The name of the left controller model file
  157928. */
  157929. static MODEL_LEFT_FILENAME: string;
  157930. /**
  157931. * The name of the right controller model file
  157932. */
  157933. static MODEL_RIGHT_FILENAME: string;
  157934. /**
  157935. * Base Url for the Quest controller model.
  157936. */
  157937. static QUEST_MODEL_BASE_URL: string;
  157938. profileId: string;
  157939. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  157940. protected _getFilenameAndPath(): {
  157941. filename: string;
  157942. path: string;
  157943. };
  157944. protected _getModelLoadingConstraints(): boolean;
  157945. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157946. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157947. protected _updateModel(): void;
  157948. /**
  157949. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  157950. * between the touch and touch 2.
  157951. */
  157952. private _isQuest;
  157953. }
  157954. }
  157955. declare module BABYLON {
  157956. /**
  157957. * The motion controller class for the standard HTC-Vive controllers
  157958. */
  157959. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  157960. private _modelRootNode;
  157961. /**
  157962. * The base url used to load the left and right controller models
  157963. */
  157964. static MODEL_BASE_URL: string;
  157965. /**
  157966. * File name for the controller model.
  157967. */
  157968. static MODEL_FILENAME: string;
  157969. profileId: string;
  157970. /**
  157971. * Create a new Vive motion controller object
  157972. * @param scene the scene to use to create this controller
  157973. * @param gamepadObject the corresponding gamepad object
  157974. * @param handedness the handedness of the controller
  157975. */
  157976. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157977. protected _getFilenameAndPath(): {
  157978. filename: string;
  157979. path: string;
  157980. };
  157981. protected _getModelLoadingConstraints(): boolean;
  157982. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157983. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157984. protected _updateModel(): void;
  157985. }
  157986. }
  157987. declare module BABYLON {
  157988. /**
  157989. * A cursor which tracks a point on a path
  157990. */
  157991. export class PathCursor {
  157992. private path;
  157993. /**
  157994. * Stores path cursor callbacks for when an onchange event is triggered
  157995. */
  157996. private _onchange;
  157997. /**
  157998. * The value of the path cursor
  157999. */
  158000. value: number;
  158001. /**
  158002. * The animation array of the path cursor
  158003. */
  158004. animations: Animation[];
  158005. /**
  158006. * Initializes the path cursor
  158007. * @param path The path to track
  158008. */
  158009. constructor(path: Path2);
  158010. /**
  158011. * Gets the cursor point on the path
  158012. * @returns A point on the path cursor at the cursor location
  158013. */
  158014. getPoint(): Vector3;
  158015. /**
  158016. * Moves the cursor ahead by the step amount
  158017. * @param step The amount to move the cursor forward
  158018. * @returns This path cursor
  158019. */
  158020. moveAhead(step?: number): PathCursor;
  158021. /**
  158022. * Moves the cursor behind by the step amount
  158023. * @param step The amount to move the cursor back
  158024. * @returns This path cursor
  158025. */
  158026. moveBack(step?: number): PathCursor;
  158027. /**
  158028. * Moves the cursor by the step amount
  158029. * If the step amount is greater than one, an exception is thrown
  158030. * @param step The amount to move the cursor
  158031. * @returns This path cursor
  158032. */
  158033. move(step: number): PathCursor;
  158034. /**
  158035. * Ensures that the value is limited between zero and one
  158036. * @returns This path cursor
  158037. */
  158038. private ensureLimits;
  158039. /**
  158040. * Runs onchange callbacks on change (used by the animation engine)
  158041. * @returns This path cursor
  158042. */
  158043. private raiseOnChange;
  158044. /**
  158045. * Executes a function on change
  158046. * @param f A path cursor onchange callback
  158047. * @returns This path cursor
  158048. */
  158049. onchange(f: (cursor: PathCursor) => void): PathCursor;
  158050. }
  158051. }
  158052. declare module BABYLON {
  158053. /** @hidden */
  158054. export var blurPixelShader: {
  158055. name: string;
  158056. shader: string;
  158057. };
  158058. }
  158059. declare module BABYLON {
  158060. /** @hidden */
  158061. export var pointCloudVertexDeclaration: {
  158062. name: string;
  158063. shader: string;
  158064. };
  158065. }
  158066. // Mixins
  158067. interface Window {
  158068. mozIndexedDB: IDBFactory;
  158069. webkitIndexedDB: IDBFactory;
  158070. msIndexedDB: IDBFactory;
  158071. webkitURL: typeof URL;
  158072. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  158073. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  158074. WebGLRenderingContext: WebGLRenderingContext;
  158075. MSGesture: MSGesture;
  158076. CANNON: any;
  158077. AudioContext: AudioContext;
  158078. webkitAudioContext: AudioContext;
  158079. PointerEvent: any;
  158080. Math: Math;
  158081. Uint8Array: Uint8ArrayConstructor;
  158082. Float32Array: Float32ArrayConstructor;
  158083. mozURL: typeof URL;
  158084. msURL: typeof URL;
  158085. VRFrameData: any; // WebVR, from specs 1.1
  158086. DracoDecoderModule: any;
  158087. setImmediate(handler: (...args: any[]) => void): number;
  158088. }
  158089. interface HTMLCanvasElement {
  158090. requestPointerLock(): void;
  158091. msRequestPointerLock?(): void;
  158092. mozRequestPointerLock?(): void;
  158093. webkitRequestPointerLock?(): void;
  158094. /** Track wether a record is in progress */
  158095. isRecording: boolean;
  158096. /** Capture Stream method defined by some browsers */
  158097. captureStream(fps?: number): MediaStream;
  158098. }
  158099. interface CanvasRenderingContext2D {
  158100. msImageSmoothingEnabled: boolean;
  158101. }
  158102. interface MouseEvent {
  158103. mozMovementX: number;
  158104. mozMovementY: number;
  158105. webkitMovementX: number;
  158106. webkitMovementY: number;
  158107. msMovementX: number;
  158108. msMovementY: number;
  158109. }
  158110. interface Navigator {
  158111. mozGetVRDevices: (any: any) => any;
  158112. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158113. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158114. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158115. webkitGetGamepads(): Gamepad[];
  158116. msGetGamepads(): Gamepad[];
  158117. webkitGamepads(): Gamepad[];
  158118. }
  158119. interface HTMLVideoElement {
  158120. mozSrcObject: any;
  158121. }
  158122. interface Math {
  158123. fround(x: number): number;
  158124. imul(a: number, b: number): number;
  158125. }
  158126. interface WebGLRenderingContext {
  158127. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  158128. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  158129. vertexAttribDivisor(index: number, divisor: number): void;
  158130. createVertexArray(): any;
  158131. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  158132. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  158133. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  158134. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  158135. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  158136. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  158137. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  158138. // Queries
  158139. createQuery(): WebGLQuery;
  158140. deleteQuery(query: WebGLQuery): void;
  158141. beginQuery(target: number, query: WebGLQuery): void;
  158142. endQuery(target: number): void;
  158143. getQueryParameter(query: WebGLQuery, pname: number): any;
  158144. getQuery(target: number, pname: number): any;
  158145. MAX_SAMPLES: number;
  158146. RGBA8: number;
  158147. READ_FRAMEBUFFER: number;
  158148. DRAW_FRAMEBUFFER: number;
  158149. UNIFORM_BUFFER: number;
  158150. HALF_FLOAT_OES: number;
  158151. RGBA16F: number;
  158152. RGBA32F: number;
  158153. R32F: number;
  158154. RG32F: number;
  158155. RGB32F: number;
  158156. R16F: number;
  158157. RG16F: number;
  158158. RGB16F: number;
  158159. RED: number;
  158160. RG: number;
  158161. R8: number;
  158162. RG8: number;
  158163. UNSIGNED_INT_24_8: number;
  158164. DEPTH24_STENCIL8: number;
  158165. MIN: number;
  158166. MAX: number;
  158167. /* Multiple Render Targets */
  158168. drawBuffers(buffers: number[]): void;
  158169. readBuffer(src: number): void;
  158170. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  158171. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  158172. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  158173. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  158174. // Occlusion Query
  158175. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  158176. ANY_SAMPLES_PASSED: number;
  158177. QUERY_RESULT_AVAILABLE: number;
  158178. QUERY_RESULT: number;
  158179. }
  158180. interface WebGLProgram {
  158181. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  158182. }
  158183. interface EXT_disjoint_timer_query {
  158184. QUERY_COUNTER_BITS_EXT: number;
  158185. TIME_ELAPSED_EXT: number;
  158186. TIMESTAMP_EXT: number;
  158187. GPU_DISJOINT_EXT: number;
  158188. QUERY_RESULT_EXT: number;
  158189. QUERY_RESULT_AVAILABLE_EXT: number;
  158190. queryCounterEXT(query: WebGLQuery, target: number): void;
  158191. createQueryEXT(): WebGLQuery;
  158192. beginQueryEXT(target: number, query: WebGLQuery): void;
  158193. endQueryEXT(target: number): void;
  158194. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  158195. deleteQueryEXT(query: WebGLQuery): void;
  158196. }
  158197. interface WebGLUniformLocation {
  158198. _currentState: any;
  158199. }
  158200. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  158201. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  158202. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  158203. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158204. interface WebGLRenderingContext {
  158205. readonly RASTERIZER_DISCARD: number;
  158206. readonly DEPTH_COMPONENT24: number;
  158207. readonly TEXTURE_3D: number;
  158208. readonly TEXTURE_2D_ARRAY: number;
  158209. readonly TEXTURE_COMPARE_FUNC: number;
  158210. readonly TEXTURE_COMPARE_MODE: number;
  158211. readonly COMPARE_REF_TO_TEXTURE: number;
  158212. readonly TEXTURE_WRAP_R: number;
  158213. readonly HALF_FLOAT: number;
  158214. readonly RGB8: number;
  158215. readonly RED_INTEGER: number;
  158216. readonly RG_INTEGER: number;
  158217. readonly RGB_INTEGER: number;
  158218. readonly RGBA_INTEGER: number;
  158219. readonly R8_SNORM: number;
  158220. readonly RG8_SNORM: number;
  158221. readonly RGB8_SNORM: number;
  158222. readonly RGBA8_SNORM: number;
  158223. readonly R8I: number;
  158224. readonly RG8I: number;
  158225. readonly RGB8I: number;
  158226. readonly RGBA8I: number;
  158227. readonly R8UI: number;
  158228. readonly RG8UI: number;
  158229. readonly RGB8UI: number;
  158230. readonly RGBA8UI: number;
  158231. readonly R16I: number;
  158232. readonly RG16I: number;
  158233. readonly RGB16I: number;
  158234. readonly RGBA16I: number;
  158235. readonly R16UI: number;
  158236. readonly RG16UI: number;
  158237. readonly RGB16UI: number;
  158238. readonly RGBA16UI: number;
  158239. readonly R32I: number;
  158240. readonly RG32I: number;
  158241. readonly RGB32I: number;
  158242. readonly RGBA32I: number;
  158243. readonly R32UI: number;
  158244. readonly RG32UI: number;
  158245. readonly RGB32UI: number;
  158246. readonly RGBA32UI: number;
  158247. readonly RGB10_A2UI: number;
  158248. readonly R11F_G11F_B10F: number;
  158249. readonly RGB9_E5: number;
  158250. readonly RGB10_A2: number;
  158251. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  158252. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  158253. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  158254. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  158255. readonly DEPTH_COMPONENT32F: number;
  158256. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  158257. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  158258. 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;
  158259. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  158260. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  158261. readonly TRANSFORM_FEEDBACK: number;
  158262. readonly INTERLEAVED_ATTRIBS: number;
  158263. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  158264. createTransformFeedback(): WebGLTransformFeedback;
  158265. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  158266. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  158267. beginTransformFeedback(primitiveMode: number): void;
  158268. endTransformFeedback(): void;
  158269. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  158270. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158271. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158272. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158273. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  158274. }
  158275. interface ImageBitmap {
  158276. readonly width: number;
  158277. readonly height: number;
  158278. close(): void;
  158279. }
  158280. interface WebGLQuery extends WebGLObject {
  158281. }
  158282. declare var WebGLQuery: {
  158283. prototype: WebGLQuery;
  158284. new(): WebGLQuery;
  158285. };
  158286. interface WebGLSampler extends WebGLObject {
  158287. }
  158288. declare var WebGLSampler: {
  158289. prototype: WebGLSampler;
  158290. new(): WebGLSampler;
  158291. };
  158292. interface WebGLSync extends WebGLObject {
  158293. }
  158294. declare var WebGLSync: {
  158295. prototype: WebGLSync;
  158296. new(): WebGLSync;
  158297. };
  158298. interface WebGLTransformFeedback extends WebGLObject {
  158299. }
  158300. declare var WebGLTransformFeedback: {
  158301. prototype: WebGLTransformFeedback;
  158302. new(): WebGLTransformFeedback;
  158303. };
  158304. interface WebGLVertexArrayObject extends WebGLObject {
  158305. }
  158306. declare var WebGLVertexArrayObject: {
  158307. prototype: WebGLVertexArrayObject;
  158308. new(): WebGLVertexArrayObject;
  158309. };
  158310. // Type definitions for WebVR API
  158311. // Project: https://w3c.github.io/webvr/
  158312. // Definitions by: six a <https://github.com/lostfictions>
  158313. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158314. interface VRDisplay extends EventTarget {
  158315. /**
  158316. * Dictionary of capabilities describing the VRDisplay.
  158317. */
  158318. readonly capabilities: VRDisplayCapabilities;
  158319. /**
  158320. * z-depth defining the far plane of the eye view frustum
  158321. * enables mapping of values in the render target depth
  158322. * attachment to scene coordinates. Initially set to 10000.0.
  158323. */
  158324. depthFar: number;
  158325. /**
  158326. * z-depth defining the near plane of the eye view frustum
  158327. * enables mapping of values in the render target depth
  158328. * attachment to scene coordinates. Initially set to 0.01.
  158329. */
  158330. depthNear: number;
  158331. /**
  158332. * An identifier for this distinct VRDisplay. Used as an
  158333. * association point in the Gamepad API.
  158334. */
  158335. readonly displayId: number;
  158336. /**
  158337. * A display name, a user-readable name identifying it.
  158338. */
  158339. readonly displayName: string;
  158340. readonly isConnected: boolean;
  158341. readonly isPresenting: boolean;
  158342. /**
  158343. * If this VRDisplay supports room-scale experiences, the optional
  158344. * stage attribute contains details on the room-scale parameters.
  158345. */
  158346. readonly stageParameters: VRStageParameters | null;
  158347. /**
  158348. * Passing the value returned by `requestAnimationFrame` to
  158349. * `cancelAnimationFrame` will unregister the callback.
  158350. * @param handle Define the hanle of the request to cancel
  158351. */
  158352. cancelAnimationFrame(handle: number): void;
  158353. /**
  158354. * Stops presenting to the VRDisplay.
  158355. * @returns a promise to know when it stopped
  158356. */
  158357. exitPresent(): Promise<void>;
  158358. /**
  158359. * Return the current VREyeParameters for the given eye.
  158360. * @param whichEye Define the eye we want the parameter for
  158361. * @returns the eye parameters
  158362. */
  158363. getEyeParameters(whichEye: string): VREyeParameters;
  158364. /**
  158365. * Populates the passed VRFrameData with the information required to render
  158366. * the current frame.
  158367. * @param frameData Define the data structure to populate
  158368. * @returns true if ok otherwise false
  158369. */
  158370. getFrameData(frameData: VRFrameData): boolean;
  158371. /**
  158372. * Get the layers currently being presented.
  158373. * @returns the list of VR layers
  158374. */
  158375. getLayers(): VRLayer[];
  158376. /**
  158377. * Return a VRPose containing the future predicted pose of the VRDisplay
  158378. * when the current frame will be presented. The value returned will not
  158379. * change until JavaScript has returned control to the browser.
  158380. *
  158381. * The VRPose will contain the position, orientation, velocity,
  158382. * and acceleration of each of these properties.
  158383. * @returns the pose object
  158384. */
  158385. getPose(): VRPose;
  158386. /**
  158387. * Return the current instantaneous pose of the VRDisplay, with no
  158388. * prediction applied.
  158389. * @returns the current instantaneous pose
  158390. */
  158391. getImmediatePose(): VRPose;
  158392. /**
  158393. * The callback passed to `requestAnimationFrame` will be called
  158394. * any time a new frame should be rendered. When the VRDisplay is
  158395. * presenting the callback will be called at the native refresh
  158396. * rate of the HMD. When not presenting this function acts
  158397. * identically to how window.requestAnimationFrame acts. Content should
  158398. * make no assumptions of frame rate or vsync behavior as the HMD runs
  158399. * asynchronously from other displays and at differing refresh rates.
  158400. * @param callback Define the eaction to run next frame
  158401. * @returns the request handle it
  158402. */
  158403. requestAnimationFrame(callback: FrameRequestCallback): number;
  158404. /**
  158405. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  158406. * Repeat calls while already presenting will update the VRLayers being displayed.
  158407. * @param layers Define the list of layer to present
  158408. * @returns a promise to know when the request has been fulfilled
  158409. */
  158410. requestPresent(layers: VRLayer[]): Promise<void>;
  158411. /**
  158412. * Reset the pose for this display, treating its current position and
  158413. * orientation as the "origin/zero" values. VRPose.position,
  158414. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  158415. * updated when calling resetPose(). This should be called in only
  158416. * sitting-space experiences.
  158417. */
  158418. resetPose(): void;
  158419. /**
  158420. * The VRLayer provided to the VRDisplay will be captured and presented
  158421. * in the HMD. Calling this function has the same effect on the source
  158422. * canvas as any other operation that uses its source image, and canvases
  158423. * created without preserveDrawingBuffer set to true will be cleared.
  158424. * @param pose Define the pose to submit
  158425. */
  158426. submitFrame(pose?: VRPose): void;
  158427. }
  158428. declare var VRDisplay: {
  158429. prototype: VRDisplay;
  158430. new(): VRDisplay;
  158431. };
  158432. interface VRLayer {
  158433. leftBounds?: number[] | Float32Array | null;
  158434. rightBounds?: number[] | Float32Array | null;
  158435. source?: HTMLCanvasElement | null;
  158436. }
  158437. interface VRDisplayCapabilities {
  158438. readonly canPresent: boolean;
  158439. readonly hasExternalDisplay: boolean;
  158440. readonly hasOrientation: boolean;
  158441. readonly hasPosition: boolean;
  158442. readonly maxLayers: number;
  158443. }
  158444. interface VREyeParameters {
  158445. /** @deprecated */
  158446. readonly fieldOfView: VRFieldOfView;
  158447. readonly offset: Float32Array;
  158448. readonly renderHeight: number;
  158449. readonly renderWidth: number;
  158450. }
  158451. interface VRFieldOfView {
  158452. readonly downDegrees: number;
  158453. readonly leftDegrees: number;
  158454. readonly rightDegrees: number;
  158455. readonly upDegrees: number;
  158456. }
  158457. interface VRFrameData {
  158458. readonly leftProjectionMatrix: Float32Array;
  158459. readonly leftViewMatrix: Float32Array;
  158460. readonly pose: VRPose;
  158461. readonly rightProjectionMatrix: Float32Array;
  158462. readonly rightViewMatrix: Float32Array;
  158463. readonly timestamp: number;
  158464. }
  158465. interface VRPose {
  158466. readonly angularAcceleration: Float32Array | null;
  158467. readonly angularVelocity: Float32Array | null;
  158468. readonly linearAcceleration: Float32Array | null;
  158469. readonly linearVelocity: Float32Array | null;
  158470. readonly orientation: Float32Array | null;
  158471. readonly position: Float32Array | null;
  158472. readonly timestamp: number;
  158473. }
  158474. interface VRStageParameters {
  158475. sittingToStandingTransform?: Float32Array;
  158476. sizeX?: number;
  158477. sizeY?: number;
  158478. }
  158479. interface Navigator {
  158480. getVRDisplays(): Promise<VRDisplay[]>;
  158481. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  158482. }
  158483. interface Window {
  158484. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  158485. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  158486. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  158487. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  158488. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  158489. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  158490. }
  158491. interface Gamepad {
  158492. readonly displayId: number;
  158493. }
  158494. /**
  158495. * Available session modes
  158496. */
  158497. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  158498. /**
  158499. * Reference space types
  158500. */
  158501. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  158502. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  158503. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  158504. /**
  158505. * Handedness types
  158506. */
  158507. type XRHandedness = "none" | "left" | "right";
  158508. /**
  158509. * InputSource target ray modes
  158510. */
  158511. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  158512. /**
  158513. * Eye types
  158514. */
  158515. type XREye = "none" | "left" | "right";
  158516. /**
  158517. * Type of XR events available
  158518. */
  158519. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  158520. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  158521. type XRPlaneSet = Set<XRPlane>;
  158522. type XRAnchorSet = Set<XRAnchor>;
  158523. type XREventHandler = (callback: any) => void;
  158524. interface XRLayer extends EventTarget {}
  158525. interface XRSessionInit {
  158526. optionalFeatures?: string[];
  158527. requiredFeatures?: string[];
  158528. }
  158529. interface XRSessionEvent extends Event {
  158530. readonly session: XRSession;
  158531. }
  158532. interface XRSystem {
  158533. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  158534. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  158535. }
  158536. interface XRViewport {
  158537. readonly x: number;
  158538. readonly y: number;
  158539. readonly width: number;
  158540. readonly height: number;
  158541. }
  158542. interface XRWebGLLayerInit {
  158543. antialias?: boolean;
  158544. depth?: boolean;
  158545. stencil?: boolean;
  158546. alpha?: boolean;
  158547. multiview?: boolean;
  158548. framebufferScaleFactor?: number;
  158549. }
  158550. declare class XRWebGLLayer {
  158551. static getNativeFramebufferScaleFactor(session: XRSession): number;
  158552. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  158553. readonly antialias: boolean;
  158554. readonly framebuffer: WebGLFramebuffer;
  158555. readonly framebufferWidth: number;
  158556. readonly framebufferHeight: number;
  158557. readonly ignoreDepthValues: boolean;
  158558. getViewport: (view: XRView) => XRViewport;
  158559. }
  158560. // tslint:disable-next-line no-empty-interface
  158561. interface XRSpace extends EventTarget {}
  158562. interface XRRenderState {
  158563. readonly baseLayer?: XRWebGLLayer;
  158564. readonly depthFar: number;
  158565. readonly depthNear: number;
  158566. readonly inlineVerticalFieldOfView?: number;
  158567. }
  158568. interface XRRenderStateInit extends XRRenderState {
  158569. baseLayer: XRWebGLLayer;
  158570. depthFar: number;
  158571. depthNear: number;
  158572. inlineVerticalFieldOfView?: number;
  158573. layers?: XRLayer[];
  158574. }
  158575. interface XRReferenceSpace extends XRSpace {
  158576. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  158577. onreset: XREventHandler;
  158578. }
  158579. interface XRBoundedReferenceSpace extends XRSpace {
  158580. readonly boundsGeometry: DOMPointReadOnly[];
  158581. }
  158582. interface XRInputSource {
  158583. readonly handedness: XRHandedness;
  158584. readonly targetRayMode: XRTargetRayMode;
  158585. readonly targetRaySpace: XRSpace;
  158586. readonly gripSpace?: XRSpace;
  158587. readonly gamepad?: Gamepad;
  158588. readonly profiles: Array<string>;
  158589. readonly hand?: XRHand;
  158590. }
  158591. interface XRPose {
  158592. readonly transform: XRRigidTransform;
  158593. readonly emulatedPosition: boolean;
  158594. }
  158595. interface XRFrame {
  158596. readonly session: XRSession;
  158597. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  158598. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  158599. // AR
  158600. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  158601. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  158602. // Anchors
  158603. trackedAnchors?: XRAnchorSet;
  158604. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  158605. // Planes
  158606. worldInformation?: {
  158607. detectedPlanes?: XRPlaneSet;
  158608. };
  158609. // Hand tracking
  158610. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  158611. }
  158612. interface XRInputSourceEvent extends Event {
  158613. readonly frame: XRFrame;
  158614. readonly inputSource: XRInputSource;
  158615. }
  158616. type XRInputSourceArray = XRInputSource[];
  158617. interface XRSession {
  158618. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  158619. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  158620. /**
  158621. * Returns a list of this session's XRInputSources, each representing an input device
  158622. * used to control the camera and/or scene.
  158623. */
  158624. readonly inputSources: Array<XRInputSource>;
  158625. /**
  158626. * object which contains options affecting how the imagery is rendered.
  158627. * This includes things such as the near and far clipping planes
  158628. */
  158629. readonly renderState: XRRenderState;
  158630. readonly visibilityState: XRVisibilityState;
  158631. /**
  158632. * Removes a callback from the animation frame painting callback from
  158633. * XRSession's set of animation frame rendering callbacks, given the
  158634. * identifying handle returned by a previous call to requestAnimationFrame().
  158635. */
  158636. cancelAnimationFrame: (handle: number) => void;
  158637. /**
  158638. * Ends the WebXR session. Returns a promise which resolves when the
  158639. * session has been shut down.
  158640. */
  158641. end(): Promise<void>;
  158642. /**
  158643. * Schedules the specified method to be called the next time the user agent
  158644. * is working on rendering an animation frame for the WebXR device. Returns an
  158645. * integer value which can be used to identify the request for the purposes of
  158646. * canceling the callback using cancelAnimationFrame(). This method is comparable
  158647. * to the Window.requestAnimationFrame() method.
  158648. */
  158649. requestAnimationFrame: XRFrameRequestCallback;
  158650. /**
  158651. * Requests that a new XRReferenceSpace of the specified type be created.
  158652. * Returns a promise which resolves with the XRReferenceSpace or
  158653. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  158654. * the requested space type isn't supported by the device.
  158655. */
  158656. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  158657. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  158658. onend: XREventHandler;
  158659. oninputsourceschange: XREventHandler;
  158660. onselect: XREventHandler;
  158661. onselectstart: XREventHandler;
  158662. onselectend: XREventHandler;
  158663. onsqueeze: XREventHandler;
  158664. onsqueezestart: XREventHandler;
  158665. onsqueezeend: XREventHandler;
  158666. onvisibilitychange: XREventHandler;
  158667. // hit test
  158668. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  158669. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  158670. // legacy AR hit test
  158671. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  158672. // legacy plane detection
  158673. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  158674. }
  158675. interface XRViewerPose extends XRPose {
  158676. readonly views: Array<XRView>;
  158677. }
  158678. declare class XRRigidTransform {
  158679. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  158680. position: DOMPointReadOnly;
  158681. orientation: DOMPointReadOnly;
  158682. matrix: Float32Array;
  158683. inverse: XRRigidTransform;
  158684. }
  158685. interface XRView {
  158686. readonly eye: XREye;
  158687. readonly projectionMatrix: Float32Array;
  158688. readonly transform: XRRigidTransform;
  158689. readonly recommendedViewportScale?: number;
  158690. requestViewportScale(scale: number): void;
  158691. }
  158692. interface XRInputSourceChangeEvent extends Event {
  158693. session: XRSession;
  158694. removed: Array<XRInputSource>;
  158695. added: Array<XRInputSource>;
  158696. }
  158697. // Experimental/Draft features
  158698. declare class XRRay {
  158699. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  158700. origin: DOMPointReadOnly;
  158701. direction: DOMPointReadOnly;
  158702. matrix: Float32Array;
  158703. }
  158704. declare enum XRHitTestTrackableType {
  158705. "point",
  158706. "plane",
  158707. "mesh",
  158708. }
  158709. interface XRHitResult {
  158710. hitMatrix: Float32Array;
  158711. }
  158712. interface XRTransientInputHitTestResult {
  158713. readonly inputSource: XRInputSource;
  158714. readonly results: Array<XRHitTestResult>;
  158715. }
  158716. interface XRHitTestResult {
  158717. getPose(baseSpace: XRSpace): XRPose | undefined;
  158718. // When anchor system is enabled
  158719. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  158720. }
  158721. interface XRHitTestSource {
  158722. cancel(): void;
  158723. }
  158724. interface XRTransientInputHitTestSource {
  158725. cancel(): void;
  158726. }
  158727. interface XRHitTestOptionsInit {
  158728. space: XRSpace;
  158729. entityTypes?: Array<XRHitTestTrackableType>;
  158730. offsetRay?: XRRay;
  158731. }
  158732. interface XRTransientInputHitTestOptionsInit {
  158733. profile: string;
  158734. entityTypes?: Array<XRHitTestTrackableType>;
  158735. offsetRay?: XRRay;
  158736. }
  158737. interface XRAnchor {
  158738. anchorSpace: XRSpace;
  158739. delete(): void;
  158740. }
  158741. interface XRPlane {
  158742. orientation: "Horizontal" | "Vertical";
  158743. planeSpace: XRSpace;
  158744. polygon: Array<DOMPointReadOnly>;
  158745. lastChangedTime: number;
  158746. }
  158747. interface XRJointSpace extends XRSpace {}
  158748. interface XRJointPose extends XRPose {
  158749. radius: number | undefined;
  158750. }
  158751. interface XRHand extends Iterable<XRJointSpace> {
  158752. readonly length: number;
  158753. [index: number]: XRJointSpace;
  158754. readonly WRIST: number;
  158755. readonly THUMB_METACARPAL: number;
  158756. readonly THUMB_PHALANX_PROXIMAL: number;
  158757. readonly THUMB_PHALANX_DISTAL: number;
  158758. readonly THUMB_PHALANX_TIP: number;
  158759. readonly INDEX_METACARPAL: number;
  158760. readonly INDEX_PHALANX_PROXIMAL: number;
  158761. readonly INDEX_PHALANX_INTERMEDIATE: number;
  158762. readonly INDEX_PHALANX_DISTAL: number;
  158763. readonly INDEX_PHALANX_TIP: number;
  158764. readonly MIDDLE_METACARPAL: number;
  158765. readonly MIDDLE_PHALANX_PROXIMAL: number;
  158766. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  158767. readonly MIDDLE_PHALANX_DISTAL: number;
  158768. readonly MIDDLE_PHALANX_TIP: number;
  158769. readonly RING_METACARPAL: number;
  158770. readonly RING_PHALANX_PROXIMAL: number;
  158771. readonly RING_PHALANX_INTERMEDIATE: number;
  158772. readonly RING_PHALANX_DISTAL: number;
  158773. readonly RING_PHALANX_TIP: number;
  158774. readonly LITTLE_METACARPAL: number;
  158775. readonly LITTLE_PHALANX_PROXIMAL: number;
  158776. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  158777. readonly LITTLE_PHALANX_DISTAL: number;
  158778. readonly LITTLE_PHALANX_TIP: number;
  158779. }
  158780. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  158781. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  158782. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  158783. interface XRSession {
  158784. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  158785. }
  158786. interface XRFrame {
  158787. featurePointCloud? : Array<number>;
  158788. }